| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.InetAddress; |
| | | import java.net.Socket; |
| | | import java.net.UnknownHostException; |
| | |
| | | import java.util.Arrays; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the LDAP authentication handler. |
| | | */ |
| | |
| | | public void testDoSimpleBindWithValidDNAndPWNoControls() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password"), requestControls, |
| | | responseControls); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), ByteString.valueOfUtf8("password"), |
| | | requestControls, responseControls); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSimpleBindWithNullDNAndPWNoControls() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSimpleBind(3, null, null, requestControls, responseControls); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSimpleBind(3, null, null, requestControls, responseControls); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSimpleBindWithEmptyDNAndPWNoControls() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSimpleBind(3, ByteString.empty(), ByteString.empty(), |
| | | requestControls, responseControls); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSimpleBind(3, ByteString.empty(), ByteString.empty(), requestControls, responseControls); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSimpleBindWithDNButNoPassword() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.empty(), requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSimpleBindWithDNButInvalidPassword() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("wrongPassword"), |
| | | requestControls, responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSimpleBindWithPasswordPolicyControl() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | requestControls.add(new PasswordPolicyRequestControl()); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password"), |
| | | requestControls, responseControls); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), ByteString.valueOfUtf8("password"), |
| | | requestControls, responseControls); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindNullMechanism() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSASLBind(null, null, null, saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindEmptyMechanism() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSASLBind(null, null, "", saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindInvalidMechanism() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSASLBind(null, null, "invalid", saslProperties, |
| | | requestControls, responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindAnonymousDisabled() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("testDoSASLBindAnonymousDisabled"); |
| | | saslProperties.put("trace", propList); |
| | | saslProperties.put("trace", newArrayList("testDoSASLBindAnonymousDisabled")); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = newSocket()) |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "ANONYMOUS", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | anonymous(authHandler, saslProperties); |
| | | } |
| | | } |
| | | |
| | |
| | | AnonymousSASLMechanismHandler handler = new AnonymousSASLMechanismHandler(); |
| | | handler.initializeSASLMechanismHandler(null); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("testDoSASLBindAnonymous"); |
| | | saslProperties.put("trace", propList); |
| | | saslProperties.put("trace", newArrayList("testDoSASLBindAnonymous")); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | anonymous(authHandler, saslProperties); |
| | | } |
| | | |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "ANONYMOUS", saslProperties, requestControls, |
| | | responseControls); |
| | | s.close(); |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>doSASLBind</CODE> method for the case in which ANONYMOUS |
| | | * authentication is enabled in the server and there is no trace information. |
| | |
| | | AnonymousSASLMechanismHandler handler = new AnonymousSASLMechanismHandler(); |
| | | handler.initializeSASLMechanismHandler(null); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "ANONYMOUS", saslProperties, requestControls, |
| | | responseControls); |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | anonymous(authHandler, saslProperties); |
| | | } |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | |
| | |
| | | AnonymousSASLMechanismHandler handler = new AnonymousSASLMechanismHandler(); |
| | | handler.initializeSASLMechanismHandler(null); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("testDoSASLBindAnonymousMultivaluedTrace"); |
| | | propList.add("aSecondTraceStringWhichIsInvalid"); |
| | | saslProperties.put("trace", propList); |
| | | saslProperties.put("trace", |
| | | newArrayList("testDoSASLBindAnonymousMultivaluedTrace", "aSecondTraceStringWhichIsInvalid")); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = newSocket()) |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "ANONYMOUS", saslProperties, requestControls, |
| | | responseControls); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | anonymous(authHandler, saslProperties); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | } |
| | |
| | | AnonymousSASLMechanismHandler handler = new AnonymousSASLMechanismHandler(); |
| | | handler.initializeSASLMechanismHandler(null); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("testDoSASLBindAnonymousInvalidProperty"); |
| | | saslProperties.put("invalid", propList); |
| | | saslProperties.put("invalid", newArrayList("testDoSASLBindAnonymousInvalidProperty")); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = newSocket()) |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "ANONYMOUS", saslProperties, requestControls, |
| | | responseControls); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | anonymous(authHandler, saslProperties); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | } |
| | |
| | | AnonymousSASLMechanismHandler handler = new AnonymousSASLMechanismHandler(); |
| | | handler.initializeSASLMechanismHandler(null); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | requestControls.add(new PasswordPolicyRequestControl()); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("testDoSASLBindAnonymous"); |
| | | saslProperties.put("trace", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "ANONYMOUS", saslProperties, requestControls, |
| | | responseControls); |
| | | s.close(); |
| | | saslProperties.put("trace", newArrayList("testDoSASLBindAnonymous")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), "ANONYMOUS", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | |
| | |
| | | DirectoryServer.deregisterSASLMechanismHandler("CRAM-MD5"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | cramMd5SaslBind(saslProperties); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | DirectoryServer.registerSASLMechanismHandler("CRAM-MD5", cramMD5Handler); |
| | | } |
| | | } |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | s.close(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | cramMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | cramMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add(""); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("")); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | cramMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = newSocket()) |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("invalidPassword"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | doSASLBind("CRAM-MD5", "invalidPassword", authHandler, saslProperties); |
| | | } |
| | | } |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | cramMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindCRAMMD5NullProperties() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | LinkedHashMap<String,List<String>> saslProperties = null; |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | cramMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>doSASLBind</CODE> method using CRAM-MD5 for the case in |
| | | * which the provided SASL properties were empty. |
| | |
| | | public void testDoSASLBindCRAMMD5EmptyProperties() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | cramMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | propList.add("u:test.user"); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test", "u:test.user")); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | cramMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>doSASLBind</CODE> method using CRAM-MD5 for the case in |
| | | * which an invalid SASL property was provided. |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | saslProperties.put("invalid", newArrayList("foo")); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("foo"); |
| | | saslProperties.put("invalid", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | cramMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | requestControls.add(new PasswordPolicyRequestControl()); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | s.close(); |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.valueOfUtf8("password"), "CRAM-MD5", saslProperties, |
| | | requestControls, responseControls); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | DirectoryServer.deregisterSASLMechanismHandler("DIGEST-MD5"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | saslProperties.put("realm", newArrayList("o=test")); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("o=test"); |
| | | saslProperties.put("realm", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = newSocket()) |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | digestMD5(authHandler, saslProperties); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | DirectoryServer.registerSASLMechanismHandler("DIGEST-MD5", |
| | | digestMD5Handler); |
| | | DirectoryServer.registerSASLMechanismHandler("DIGEST-MD5", digestMD5Handler); |
| | | } |
| | | } |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | |
| | | propList = new ArrayList<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, this.hostname, messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, hostname); |
| | | digestMD5(authHandler, saslProperties); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | |
| | | propList = new ArrayList<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, this.hostname, messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, hostname); |
| | | digestMD5(authHandler, saslProperties); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindDigestMD5NullProperties() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | LinkedHashMap<String,List<String>> saslProperties = null; |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindDigestMD5EmptyProperties() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindDigestMD5InvalidProperty() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("invalid", newArrayList("foo")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("foo"); |
| | | saslProperties.put("invalid", propList); |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindDigestMD5MultipleAuthIDs() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | ArrayList<String> propList = newArrayList("dn:uid=test.user,o=test"); |
| | | propList.add("u:test.user"); |
| | | saslProperties.put("authid", propList); |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindDigestMD5MEmptyAuthID() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add(""); |
| | | saslProperties.put("authid", propList); |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindDigestMD5MultipleRealms() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | saslProperties.put("realm", newArrayList("o=test", "dc=example,dc=com")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("o=test"); |
| | | propList.add("dc=example,dc=com"); |
| | | saslProperties.put("realm", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | saslProperties.put("qop", newArrayList("auth")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("auth"); |
| | | saslProperties.put("qop", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, this.hostname, messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, hostname); |
| | | digestMD5(authHandler, saslProperties); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>doSASLBind</CODE> method for the case in which the |
| | | * DIGEST-MD5 SASL properties contain the unsupported integrity quality of |
| | |
| | | public void testDoSASLBindDigestMD5UnsupportedQoPAuthInt() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | saslProperties.put("realm", newArrayList("o=test")); |
| | | saslProperties.put("qop", newArrayList("auth-int")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("o=test"); |
| | | saslProperties.put("realm", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("auth-int"); |
| | | saslProperties.put("qop", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindDigestMD5UnsupportedQoPAuthConf() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | saslProperties.put("realm", newArrayList("o=test")); |
| | | saslProperties.put("qop", newArrayList("auth-conf")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("o=test"); |
| | | saslProperties.put("realm", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("auth-conf"); |
| | | saslProperties.put("qop", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindDigestMD5InvalidQoP() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | saslProperties.put("realm", newArrayList("o=test")); |
| | | saslProperties.put("qop", newArrayList("invalid")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("o=test"); |
| | | saslProperties.put("realm", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("invalid"); |
| | | saslProperties.put("qop", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>doSASLBind</CODE> method for the case in which the |
| | | * DIGEST-MD5 SASL properties contain multiple quality of protection values. |
| | |
| | | public void testDoSASLBindDigestMD5MultipleQoPs() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | saslProperties.put("realm", newArrayList("o=test")); |
| | | saslProperties.put("qop", newArrayList("auth", "auth-int", "auth-conf")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("o=test"); |
| | | saslProperties.put("realm", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("auth"); |
| | | propList.add("auth-int"); |
| | | propList.add("auth-conf"); |
| | | saslProperties.put("qop", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindDigestMD5MultipleDigestURIs() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | saslProperties.put("realm", newArrayList("o=test")); |
| | | saslProperties.put("digest-uri", newArrayList("ldap/value1", "ldap/value2")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("o=test"); |
| | | saslProperties.put("realm", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("ldap/value1"); |
| | | propList.add("ldap/value2"); |
| | | saslProperties.put("digest-uri", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>doSASLBind</CODE> method for the case in which the |
| | | * DIGEST-MD5 SASL properties contain multiple authorization IDs. |
| | |
| | | public void testDoSASLBindDigestMD5MultipleAuthzIDs() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | saslProperties.put("realm", newArrayList("o=test")); |
| | | saslProperties.put("authzid", newArrayList("dn:uid=test.user,o=test", "u:test.user")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("o=test"); |
| | | saslProperties.put("realm", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | propList.add("u:test.user"); |
| | | saslProperties.put("authzid", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindDigestMD5InvalidAuthDN() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:invalid")); |
| | | saslProperties.put("realm", newArrayList("o=test")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:invalid"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("o=test"); |
| | | saslProperties.put("realm", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("u:nosuchuser")); |
| | | saslProperties.put("realm", newArrayList("o=test")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("u:nosuchuser"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("o=test"); |
| | | saslProperties.put("realm", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("u:nosuchuser")); |
| | | saslProperties.put("realm", newArrayList("o=test")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("u:nosuchuser"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("o=test"); |
| | | saslProperties.put("realm", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = newSocket()) |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("wrongPassword"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | doSASLBind("DIGEST-MD5", "wrongPassword", authHandler, saslProperties); |
| | | } |
| | | } |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("u:nosuchuser")); |
| | | saslProperties.put("realm", newArrayList("o=test")); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("u:nosuchuser"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | propList = new ArrayList<>(); |
| | | propList.add("o=test"); |
| | | saslProperties.put("realm", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | digestMd5SaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | requestControls.add(new PasswordPolicyRequestControl()); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | |
| | | propList = new ArrayList<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, this.hostname, messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, hostname); |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.valueOfUtf8("password"), "DIGEST-MD5", saslProperties, |
| | | requestControls, responseControls); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | trustStorePath, "password"); |
| | | |
| | | |
| | | Socket s = factory.createSocket("127.0.0.1", |
| | | TestCaseUtils.getServerLdapsPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = factory.createSocket("127.0.0.1", TestCaseUtils.getServerLdapsPort())) |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), null, "EXTERNAL", |
| | | saslProperties, requestControls, responseControls); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | doSASLBind("EXTERNAL", null, authHandler, saslProperties); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | DirectoryServer.registerSASLMechanismHandler("EXTERNAL", externalHandler); |
| | | } |
| | | } |
| | |
| | | "password"); |
| | | |
| | | |
| | | Socket s = factory.createSocket("127.0.0.1", |
| | | TestCaseUtils.getServerLdapsPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), null, "EXTERNAL", |
| | | saslProperties, requestControls, responseControls); |
| | | |
| | | s.close(); |
| | | try (Socket s = factory.createSocket("127.0.0.1", TestCaseUtils.getServerLdapsPort())) |
| | | { |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | doSASLBind("EXTERNAL", null, authHandler, saslProperties); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | "password"); |
| | | |
| | | |
| | | Socket s = factory.createSocket("127.0.0.1", |
| | | TestCaseUtils.getServerLdapsPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("foo"); |
| | | saslProperties.put("invalid", valueList); |
| | | saslProperties.put("invalid", newArrayList("foo")); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = factory.createSocket("127.0.0.1", TestCaseUtils.getServerLdapsPort());) |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), null, "EXTERNAL", |
| | | saslProperties, requestControls, responseControls); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | doSASLBind("EXTERNAL", null, authHandler, saslProperties); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | DirectoryServer.registerSASLMechanismHandler("EXTERNAL", externalHandler); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>doSASLBind</CODE> method for the case in which EXTERNAL |
| | | * authentication is enabled in the server and the password policy request |
| | |
| | | "password"); |
| | | |
| | | |
| | | Socket s = factory.createSocket("127.0.0.1", |
| | | TestCaseUtils.getServerLdapsPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | requestControls.add(new PasswordPolicyRequestControl()); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), null, "EXTERNAL", |
| | | saslProperties, requestControls, responseControls); |
| | | |
| | | s.close(); |
| | | try (Socket s = factory.createSocket("127.0.0.1", TestCaseUtils.getServerLdapsPort())) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | doSASLBind("EXTERNAL", null, authHandler, saslProperties); |
| | | authHandler.doSASLBind(ByteString.empty(), null, "EXTERNAL", saslProperties, requestControls, responseControls); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindGSSAPINullProperties() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | LinkedHashMap<String,List<String>> saslProperties = null; |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindGSSAPIEmptyProperties() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | try |
| | | private Socket newSocket() throws UnknownHostException, IOException |
| | | { |
| | | return new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | } |
| | | |
| | | private LDAPAuthenticationHandler newLDAPAuthenticationHandler(Socket s, String hostName2) throws IOException |
| | | { |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | return new LDAPAuthenticationHandler(r, w, hostName2, messageID); |
| | | } |
| | | |
| | | private void anonymous(LDAPAuthenticationHandler authHandler, Map<String, List<String>> saslProperties) |
| | | throws ClientException, LDAPException |
| | | { |
| | | doSASLBind("ANONYMOUS", "", authHandler, saslProperties); |
| | | } |
| | | |
| | | private void gssapi(LDAPAuthenticationHandler authHandler, Map<String, List<String>> saslProperties) |
| | | throws ClientException, LDAPException |
| | | { |
| | | doSASLBind("GSSAPI", "", authHandler, saslProperties); |
| | | } |
| | | |
| | | private void cramMD5(LDAPAuthenticationHandler authHandler, Map<String, List<String>> saslProperties) |
| | | throws ClientException, LDAPException |
| | | { |
| | | doSASLBind("CRAM-MD5", "password", authHandler, saslProperties); |
| | | } |
| | | |
| | | private void plain(LDAPAuthenticationHandler authHandler, Map<String, List<String>> saslProperties) |
| | | throws ClientException, LDAPException |
| | | { |
| | | doSASLBind("PLAIN", "password", authHandler, saslProperties); |
| | | } |
| | | |
| | | private void digestMD5(LDAPAuthenticationHandler authHandler, Map<String, List<String>> saslProperties) |
| | | throws ClientException, LDAPException |
| | | { |
| | | doSASLBind("DIGEST-MD5", "password", authHandler, saslProperties); |
| | | } |
| | | |
| | | private void doSASLBind(String mechanism, String bindPassword, LDAPAuthenticationHandler authHandler, |
| | | Map<String, List<String>> saslProperties) throws ClientException, LDAPException |
| | | { |
| | | ByteString bindPwd = bindPassword != null ? ByteString.valueOfUtf8(bindPassword) : null; |
| | | authHandler.doSASLBind(ByteString.empty(), bindPwd, mechanism, saslProperties, |
| | | new ArrayList<Control>(), new ArrayList<Control>()); |
| | | } |
| | | |
| | | private void plainSaslBind(Map<String, List<String>> saslProperties) throws Exception |
| | | { |
| | | try (Socket s = newSocket()) |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | plain(newLDAPAuthenticationHandler(s, "localhost"), saslProperties); |
| | | } |
| | | } |
| | | |
| | | private void cramMd5SaslBind(LinkedHashMap<String, List<String>> saslProperties) throws Exception |
| | | { |
| | | try (Socket s = newSocket()) |
| | | { |
| | | cramMD5(newLDAPAuthenticationHandler(s, "localhost"), saslProperties); |
| | | } |
| | | } |
| | | |
| | | private void digestMd5SaslBind(LinkedHashMap<String, List<String>> saslProperties) throws Exception |
| | | { |
| | | try (Socket s = newSocket()) |
| | | { |
| | | digestMD5(newLDAPAuthenticationHandler(s, "localhost"), saslProperties); |
| | | } |
| | | } |
| | | |
| | | private void gssapiSaslBind(LinkedHashMap<String, List<String>> saslProperties) throws Exception |
| | | { |
| | | try (Socket s = newSocket()) |
| | | { |
| | | gssapi(newLDAPAuthenticationHandler(s, "localhost"), saslProperties); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Tests the <CODE>doSASLBind</CODE> method for GSSAPI authentication when the |
| | |
| | | public void testDoSASLBindGSSAPIEmptyAuthID() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add(""); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindGSSAPIMultipleAuthIDs() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("u:test.user", "dn:uid=test.user,o=test")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("u:test.user"); |
| | | valueList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindGSSAPIMultipleAuthzIDs() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("u:test.user")); |
| | | saslProperties.put("authzid", newArrayList("u:test.user", "dn:uid=test.user,o=test")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("u:test.user"); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | valueList = new ArrayList<>(); |
| | | valueList.add("u:test.user"); |
| | | valueList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authzid", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindGSSAPIMultipleKDCs() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("u:test.user")); |
| | | saslProperties.put("kdc", newArrayList("kdc1", "kdc2")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("u:test.user"); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | valueList = new ArrayList<>(); |
| | | valueList.add("kdc1"); |
| | | valueList.add("kdc2"); |
| | | saslProperties.put("kdc", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindGSSAPIMultipleQoPs() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("u:test.user")); |
| | | saslProperties.put("qop", newArrayList("auth", "auth-int", "auth-conf")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("u:test.user"); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | valueList = new ArrayList<>(); |
| | | valueList.add("auth"); |
| | | valueList.add("auth-int"); |
| | | valueList.add("auth-conf"); |
| | | saslProperties.put("qop", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindGSSAPIUnsupportedQoPAuthInt() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("u:test.user")); |
| | | saslProperties.put("qop", newArrayList("auth-int")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("u:test.user"); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | valueList = new ArrayList<>(); |
| | | valueList.add("auth-int"); |
| | | saslProperties.put("qop", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindGSSAPIUnsupportedQoPAuthConf() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("u:test.user")); |
| | | saslProperties.put("qop", newArrayList("auth-conf")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("u:test.user"); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | valueList = new ArrayList<>(); |
| | | valueList.add("auth-conf"); |
| | | saslProperties.put("qop", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindGSSAPIInvalidQoP() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("u:test.user")); |
| | | saslProperties.put("qop", newArrayList("invalid")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("u:test.user"); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | valueList = new ArrayList<>(); |
| | | valueList.add("invalid"); |
| | | saslProperties.put("qop", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindGSSAPIMultipleRealms() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("u:test.user")); |
| | | saslProperties.put("realm", newArrayList("realm1", "realm2")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("u:test.user"); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | valueList = new ArrayList<>(); |
| | | valueList.add("realm1"); |
| | | valueList.add("realm2"); |
| | | saslProperties.put("realm", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindGSSAPIInvalidProperty() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("u:test.user")); |
| | | saslProperties.put("invalid", newArrayList("foo")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("u:test.user"); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | valueList = new ArrayList<>(); |
| | | valueList.add("foo"); |
| | | saslProperties.put("invalid", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>doSASLBind</CODE> method for GSSAPI authentication when the |
| | | * provided properties isn't empty but doesn't contain an auth ID. |
| | |
| | | public void testDoSASLBindGSSAPINoAuthID() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("qop", newArrayList("auth")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("auth"); |
| | | saslProperties.put("qop", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "GSSAPI", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | gssapiSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | DirectoryServer.deregisterSASLMechanismHandler("PLAIN"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | try (Socket s = newSocket()) |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | plain(authHandler, saslProperties); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | DirectoryServer.registerSASLMechanismHandler("PLAIN", |
| | | plainHandler); |
| | | DirectoryServer.registerSASLMechanismHandler("PLAIN", plainHandler); |
| | | } |
| | | } |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | |
| | | s.close(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | plain(authHandler, saslProperties); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindPlainNullProperties() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | LinkedHashMap<String,List<String>> saslProperties = null; |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | plainSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindPlainEmptyProperties() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | plainSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindPlainMultipleAuthIDs() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test", "u:test.user")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("dn:uid=test.user,o=test"); |
| | | valueList.add("u:test.user"); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | plainSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>doSASLBind</CODE> method for the case in which the PLAIN |
| | | * SASL properties have multiple auth ID values. |
| | |
| | | public void testDoSASLBindPlainZeroLengthAuthID() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add(""); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | plainSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindPlainMultipleAuthzIDs() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | saslProperties.put("authzid", newArrayList("dn:uid=test.user,o=test", "u:test.user")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | valueList = new ArrayList<>(); |
| | | valueList.add("dn:uid=test.user,o=test"); |
| | | valueList.add("u:test.user"); |
| | | saslProperties.put("authzid", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | plainSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindPlainInvalidProperty() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | saslProperties.put("invalid", newArrayList("foo")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", valueList); |
| | | |
| | | valueList = new ArrayList<>(); |
| | | valueList.add("foo"); |
| | | saslProperties.put("invalid", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | plainSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | public void testDoSASLBindPlainNoAuthID() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authzid", newArrayList("dn:uid=test.user,o=test")); |
| | | |
| | | ArrayList<String> valueList = new ArrayList<>(); |
| | | valueList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authzid", valueList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | plainSaslBind(saslProperties); |
| | | } |
| | | |
| | | |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=does.not.exist,o=test")); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=does.not.exist,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | |
| | | s.close(); |
| | | plain(newLDAPAuthenticationHandler(s, "localhost"), saslProperties); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>doSASLBind</CODE> method for PLAIN authentication in which |
| | | * the wrong password has been provided for the target user. |
| | | * Tests the <CODE>doSASLBind</CODE> method for PLAIN authentication in which the wrong password |
| | | * has been provided for the target user. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | * @throws Exception |
| | | * If an unexpected problem occurs. |
| | | */ |
| | | @Test(expectedExceptions = { LDAPException.class }) |
| | | public void testDoSASLBindPlainWrongPassword() |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=does.not.exist,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("wrongPassword"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | |
| | | s.close(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=does.not.exist,o=test")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | doSASLBind("PLAIN", "wrongPassword", authHandler, saslProperties); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | requestControls.add(new PasswordPolicyRequestControl()); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | |
| | | s.close(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.valueOfUtf8("password"), "PLAIN", saslProperties, |
| | | requestControls, responseControls); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testRequestAuthorizationIdentityUnauthenticated() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | assertNull(authHandler.requestAuthorizationIdentity()); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | assertNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | public void testRequestAuthorizationIdentitySimpleAnonymous() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSimpleBind(3, ByteString.empty(), ByteString.empty(), |
| | | requestControls, responseControls); |
| | | assertNull(authHandler.requestAuthorizationIdentity()); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSimpleBind(3, ByteString.empty(), ByteString.empty(), requestControls, responseControls); |
| | | assertNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>requestAuthorizationIdentity</CODE> method for a a client |
| | | * connection after a simple bind as a root user. |
| | |
| | | public void testRequestAuthorizationIdentitySimpleRootUser() |
| | | throws Exception |
| | | { |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password"), requestControls, |
| | | responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), ByteString.valueOfUtf8("password"), |
| | | requestControls, responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("uid=test.user,o=test"), |
| | | ByteString.valueOfUtf8("password"), requestControls, |
| | | responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("uid=test.user,o=test"), ByteString.valueOfUtf8("password"), |
| | | requestControls, responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | AnonymousSASLMechanismHandler handler = new AnonymousSASLMechanismHandler(); |
| | | handler.initializeSASLMechanismHandler(null); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("testDoSASLBindAnonymous"); |
| | | saslProperties.put("trace", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), |
| | | "ANONYMOUS", saslProperties, requestControls, |
| | | responseControls); |
| | | assertNull(authHandler.requestAuthorizationIdentity()); |
| | | |
| | | s.close(); |
| | | saslProperties.put("trace", newArrayList("testDoSASLBindAnonymous")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | anonymous(authHandler, saslProperties); |
| | | assertNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | |
| | | s.close(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | cramMD5(authHandler, saslProperties); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | |
| | | propList = new ArrayList<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, this.hostname, messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | |
| | | s.close(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, hostname); |
| | | digestMD5(authHandler, saslProperties); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | "password"); |
| | | |
| | | |
| | | Socket s = factory.createSocket("127.0.0.1", |
| | | TestCaseUtils.getServerLdapsPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), null, "EXTERNAL", |
| | | saslProperties, requestControls, responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | |
| | | s.close(); |
| | | try (Socket s = factory.createSocket("127.0.0.1", TestCaseUtils.getServerLdapsPort())) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | doSASLBind("EXTERNAL", null, authHandler, saslProperties); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | LDAPReader r = new LDAPReader(s); |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | AtomicInteger messageID = new AtomicInteger(1); |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ArrayList<Control> responseControls = new ArrayList<>(); |
| | | LinkedHashMap<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | ArrayList<String> propList = new ArrayList<>(); |
| | | propList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authid", propList); |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | |
| | | s.close(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | plain(authHandler, saslProperties); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | | } |
| | | |
| | | private void getFQDN() { |
| | |
| | | this.hostname = "localhost"; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |