[java-identity-provider COMMIT] in /branches/3.3/idp-conf/src/test/java/net/shibboleth/idp/test: InMemoryDirectory.ja...

noreply at shibboleth.net noreply at shibboleth.net
Fri Mar 3 19:49:37 EST 2017


Author: scantor
Date: Fri Mar  3 19:49:37 2017
New Revision: 8644

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=8644&view=rev
Log:
Port mock LDAP changes from trunk.

Modified:
    branches/3.3/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java
    branches/3.3/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java

Modified: branches/3.3/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java
URL: http://svn.shibboleth.net/view/java-identity-provider/branches/3.3/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java?rev=8644&r1=8643&r2=8644&view=diff
==============================================================================
--- branches/3.3/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java	(original)
+++ branches/3.3/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java	Fri Mar  3 19:49:37 2017
@@ -19,8 +19,13 @@
 
 import java.io.IOException;
 import java.security.GeneralSecurityException;
+import java.security.KeyStore;
 
 import javax.annotation.Nonnull;
+
+import org.ldaptive.ssl.CredentialConfigFactory;
+import org.ldaptive.ssl.SslConfig;
+import org.ldaptive.ssl.TLSSocketFactory;
 
 import org.springframework.core.io.Resource;
 
@@ -29,8 +34,6 @@
 import com.unboundid.ldap.listener.InMemoryListenerConfig;
 import com.unboundid.ldap.sdk.LDAPException;
 import com.unboundid.ldif.LDIFReader;
-import com.unboundid.util.ssl.KeyStoreKeyManager;
-import com.unboundid.util.ssl.SSLUtil;
 
 import net.shibboleth.utilities.java.support.annotation.constraint.Positive;
 import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -44,54 +47,30 @@
     @Nonnull private final InMemoryDirectoryServer directoryServer;
 
     /**
-     * Constructor without STARTTLS support. Listens on port 10389.
-     * 
-     * @param ldif the LDIF resource to be imported
-     * 
-     * @throws LDAPException if the in-memory directory server cannot be created
-     * @throws IOException if the LDIF resource cannot be imported
-     */
-    public InMemoryDirectory(@Nonnull final Resource ldif) throws LDAPException, IOException {
-       this(ldif, 10389);
-    }
-    
-    /**
-     * Constructor without STARTTLS support.
-     *
-     * @param ldif the LDIF resource to be imported
-     * @param port port to listen on
-     * @throws LDAPException if the in-memory directory server cannot be created
-     * @throws IOException if the LDIF resource cannot be imported
-     */
-    public InMemoryDirectory(@Nonnull final Resource ldif, @Positive final int port) throws LDAPException, IOException {
-        Constraint.isNotNull(ldif, "LDIF resource cannot be null");
-        Constraint.isGreaterThan(-1, port, "Port must be greater than -1");
-        final InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=example,dc=org", "ou=system");
-        config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", port));
-        config.addAdditionalBindCredentials("cn=Directory Manager", "password");
-        directoryServer = new InMemoryDirectoryServer(config);
-        directoryServer.importFromLDIF(true, new LDIFReader(ldif.getInputStream()));
-    }
-    
-    /**
      * Constructor with STARTTLS support.
      * 
      * @param ldif the LDIF resource to be imported
+     * @param port port to listen on
      * @param keystore to use for startTLS
      * 
      * @throws LDAPException if the in-memory directory server cannot be created
      * @throws IOException if the LDIF resource cannot be imported
      */
-    public InMemoryDirectory(@Nonnull final Resource ldif, @Nonnull final Resource keystore) throws LDAPException,
+    public InMemoryDirectory(@Nonnull final Resource ldif, @Positive final int port, @Nonnull final Resource keystore) throws LDAPException,
             IOException {
         Constraint.isNotNull(ldif, "LDIF resource cannot be null");
         final InMemoryDirectoryServerConfig config =
                 new InMemoryDirectoryServerConfig("dc=example,dc=org", "ou=system");
         try {
-            final SSLUtil sslUtil =
-                    new SSLUtil(new KeyStoreKeyManager(keystore.getFile(), "changeit".toCharArray()), null);
-            config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", null, 10389,
-                    sslUtil.createSSLSocketFactory()));
+            final KeyStore ks = KeyStore.getInstance("JKS");
+            final String ksPass = "changeit";
+            ks.load(keystore.getInputStream(), ksPass.toCharArray());
+            final TLSSocketFactory socketFactory = new TLSSocketFactory();
+            socketFactory.setSslConfig(new SslConfig(CredentialConfigFactory.createKeyStoreCredentialConfig(ks, ksPass)));
+            socketFactory.initialize();
+            
+            config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", null, port,
+                    socketFactory));
         } catch (GeneralSecurityException e) {

[... 19 lines stripped ...]


More information about the commits mailing list