[java-identity-provider] branch master updated: IDP-1418 Throw a BreanCreation error if useStartTLS is specified but trustFile isn't

Rod Widdowson rdw at steadingsoftware.com
Wed Mar 20 12:30:55 EDT 2019


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=717d4ba036f5d28495731fb9fc4d1de52acba01a

The following commit(s) were added to refs/heads/master by this push:
       new  717d4ba   IDP-1418 Throw a BreanCreation error if useStartTLS is specified but trustFile isn't
717d4ba is described below

commit 717d4ba036f5d28495731fb9fc4d1de52acba01a
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Mar 20 16:16:07 2019 +0000

    IDP-1418 Throw a BreanCreation error if useStartTLS is specified but trustFile isn't
    
    https://issues.shibboleth.net/jira/browse/IDP-1418
---
 .../dc/ldap/impl/CredentialConfigFactoryBean.java  | 27 ++++++++++++++++++++++
 .../dc/ldap/impl/LDAPDataConnectorParser.java      | 14 ++++++++---
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/ldap/impl/CredentialConfigFactoryBean.java b/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/ldap/impl/CredentialConfigFactoryBean.java
index 27f4542..32065a6 100644
--- a/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/ldap/impl/CredentialConfigFactoryBean.java
+++ b/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/ldap/impl/CredentialConfigFactoryBean.java
@@ -24,6 +24,8 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import net.shibboleth.ext.spring.factory.AbstractComponentAwareFactoryBean;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport.ObjectType;
 
 import org.ldaptive.ssl.CredentialConfig;
 import org.ldaptive.ssl.CredentialConfigFactory;
@@ -47,6 +49,9 @@ public class CredentialConfigFactoryBean extends AbstractComponentAwareFactoryBe
     /** Our authentication credential for the LDAP connection. */
     @Nullable private Credential authCredential;
 
+    /** Did the user specify useStartTLS? */
+    private boolean useStartTLS;
+
     /** {@inheritDoc} */
     @Override public Class<?> getObjectType() {
         return CredentialConfig.class;
@@ -56,6 +61,10 @@ public class CredentialConfigFactoryBean extends AbstractComponentAwareFactoryBe
     @Override protected CredentialConfig doCreateInstance() throws Exception {
         X509Certificate[] trustCerts = null;
 
+        if (getUseStartTLS() && trustCredential == null) {
+            throw new BeanCreationException("setting useStartTLS=\"true\" requires 'trustFile' bet set to a value");
+        }
+
         if (trustCredential != null) {
             if (trustCredential instanceof X509Credential) {
                 final X509Credential cred = (X509Credential) trustCredential;
@@ -86,6 +95,24 @@ public class CredentialConfigFactoryBean extends AbstractComponentAwareFactoryBe
     }
 
     /**
+     * Get the useStartTLS setting the Data Connector.
+     *
+     * @return the specified value
+     */
+    @Nullable public boolean  getUseStartTLS() {
+        return useStartTLS;
+    }
+
+    /**
+     * Set the useStartTLS setting the Data Connector.
+     *
+     * @param value the Value specified
+     */
+    public void setUseStartTLS(@Nullable final boolean value) {
+        useStartTLS = value;
+    }
+
+    /**
      * Get the authentication credential for the LDAP connection.
      * 
      * @return Returns the authnCredential.
diff --git a/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/ldap/impl/LDAPDataConnectorParser.java b/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/ldap/impl/LDAPDataConnectorParser.java
index 7ef898c..1c40a39 100644
--- a/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/ldap/impl/LDAPDataConnectorParser.java
+++ b/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/ldap/impl/LDAPDataConnectorParser.java
@@ -300,7 +300,7 @@ public class LDAPDataConnectorParser extends AbstractDataConnectorParser {
                 connectionConfig.addPropertyValue("responseTimeout", 3000);
             }
             final BeanDefinitionBuilder sslConfig = BeanDefinitionBuilder.genericBeanDefinition(SslConfig.class);
-            sslConfig.addPropertyValue("credentialConfig", createCredentialConfig(parserContext));
+            sslConfig.addPropertyValue("credentialConfig", createCredentialConfig(parserContext, useStartTLS));
             connectionConfig.addPropertyValue("sslConfig", sslConfig.getBeanDefinition());
             final BeanDefinitionBuilder connectionInitializer =
                     BeanDefinitionBuilder.genericBeanDefinition(BindConnectionInitializer.class);
@@ -331,12 +331,19 @@ public class LDAPDataConnectorParser extends AbstractDataConnectorParser {
          * Read StartTLS trust and authentication credentials.
          * 
          * @param parserContext bean definition parsing context
+         * @param useStartTLS the value of useStartTls (if specified)
          * @return credential config
          */
-        @Nonnull protected BeanDefinition createCredentialConfig(@Nonnull final ParserContext parserContext) {
+        // CheckStyle: CyclomaticComplexity|MethodLength OFF
+        @Nonnull protected BeanDefinition createCredentialConfig(@Nonnull final ParserContext parserContext,
+                @Nullable final String useStartTLS) {
             final BeanDefinitionBuilder result =
                     BeanDefinitionBuilder.genericBeanDefinition(CredentialConfigFactoryBean.class);
 
+            if (useStartTLS != null) {
+                result.addPropertyValue("useStartTLS", useStartTLS);
+            }
+
             final List<Element> trustElements =
                     ElementSupport.getChildElementsByTagNameNS(configElement,
                             AttributeResolverNamespaceHandler.NAMESPACE,
@@ -398,7 +405,8 @@ public class LDAPDataConnectorParser extends AbstractDataConnectorParser {
 
             return result.getBeanDefinition();
         }
-        
+        // CheckStyle: CyclomaticComplexity|MethodLength ON
+
         /**
          * Get the textual content of the <FilterTemplate>.
          * 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list