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

noreply at shibboleth.net noreply at shibboleth.net
Wed Nov 12 01:13:18 EST 2014


Author: dfisher
Date: Wed Nov 12 01:13:17 2014
New Revision: 6883

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=6883&view=rev
Log:
Update InMemoryDirectory with startTLS keystore.

Added:
    trunk/idp-conf/src/test/resources/test/test-ldap.keystore   (with props)
Modified:
    trunk/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java
    trunk/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java

Modified: trunk/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java?rev=6883&r1=6882&r2=6883&view=diff
==============================================================================
--- trunk/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java (original)
+++ trunk/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java Wed Nov 12 01:13:17 2014
@@ -18,6 +18,7 @@
 package net.shibboleth.idp.test;
 
 import java.io.IOException;
+import java.security.GeneralSecurityException;
 
 import javax.annotation.Nonnull;
 
@@ -30,6 +31,8 @@
 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;
 
 /**
  * Manages an instance of the in-memory directory server.
@@ -43,14 +46,24 @@
      * Default constructor.
      * 
      * @param ldif the LDIF resource to be imported
+     * @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) throws LDAPException, IOException {
+    public InMemoryDirectory(@Nonnull final Resource ldif, @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");
-        config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", 10389));
+        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()));
+        } catch (GeneralSecurityException e) {
+            throw new IOException("Error reading keystore", e);
+        }
         config.addAdditionalBindCredentials("cn=Directory Manager", "password");
         directoryServer = new InMemoryDirectoryServer(config);
         directoryServer.importFromLDIF(true, new LDIFReader(ldif.getInputStream()));

Modified: trunk/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java?rev=6883&r1=6882&r2=6883&view=diff
==============================================================================
--- trunk/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java (original)
+++ trunk/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java Wed Nov 12 01:13:17 2014
@@ -101,6 +101,9 @@
     /** Path to LDIF file to be imported into directory server. */
     @Nonnull public final static String LDIF_FILE = "/test/test-ldap.ldif";
 
+    /** Path to keystore file to be used by the directory server. */
+    @Nonnull public final static String KEYSTORE_FILE = "/test/test-ldap.keystore";
+
     /** The IDP entity ID. */
     @Nonnull public final static String IDP_ENTITY_ID = "https://idp.example.org";
 
@@ -235,7 +238,7 @@
      * @throws IOException if the LDIF resource cannot be imported
      */
     @BeforeTest public void setupDirectoryServer() throws LDAPException, IOException {
-        directoryServer = new InMemoryDirectory(new ClassPathResource(LDIF_FILE));
+        directoryServer = new InMemoryDirectory(new ClassPathResource(LDIF_FILE), new ClassPathResource(KEYSTORE_FILE));
         directoryServer.start();
     }
 



More information about the commits mailing list