[java-identity-provider] branch master updated: IDP-1327 Do full deprecation of sourceAttributeId for ComputedIds

Rod Widdowson rdw at steadingsoftware.com
Tue Sep 11 10:29:11 EDT 2018


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=62d22def82e29960049ce7e50c299c0335b3e0d8

The following commit(s) were added to refs/heads/master by this push:
       new  62d22de   IDP-1327 Do full deprecation of sourceAttributeId for ComputedIds
62d22de is described below

commit 62d22def82e29960049ce7e50c299c0335b3e0d8
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Sep 11 14:50:03 2018 +0100

    IDP-1327 Do full deprecation of sourceAttributeId for ComputedIds
    
    https://issues.shibboleth.net/jira/browse/IDP-1327
---
 .../dc/impl/BaseComputedIDDataConnectorParser.java |  22 +++--
 .../dc/ComputedIDDataConnectorParserTest.java      |  46 ++++++++-
 .../resolver/spring/dc/computedProperty.xml        |  16 ---
 .../resolver/spring/dc/resolver/computed.xml       |   3 +-
 .../{computed.xml => computedDataConnector.xml}    |   5 +-
 .../{computed.xml => computedNoSource.xml}         |   5 +-
 .../{computed.xml => computedNoSource1.xml}        |   7 +-
 .../spring/dc/resolver/computedProperty.xml        |   7 ++
 .../impl/AbstractPersistentIdDataConnector.java    | 107 +++++++++++++++++----
 .../schema/shibboleth-attribute-resolver.xsd       |   3 +-
 10 files changed, 160 insertions(+), 61 deletions(-)

diff --git a/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/BaseComputedIDDataConnectorParser.java b/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/BaseComputedIDDataConnectorParser.java
index 9747201..22a5d5f 100644
--- a/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/BaseComputedIDDataConnectorParser.java
+++ b/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/BaseComputedIDDataConnectorParser.java
@@ -26,6 +26,8 @@ import javax.xml.namespace.QName;
 import net.shibboleth.idp.attribute.resolver.spring.BaseResolverPluginParser;
 import net.shibboleth.idp.attribute.resolver.spring.dc.AbstractDataConnectorParser;
 import net.shibboleth.idp.attribute.resolver.spring.impl.AttributeResolverNamespaceHandler;
+import net.shibboleth.idp.attribute.resolver.spring.impl.InputAttributeDefinitionParser;
+import net.shibboleth.idp.attribute.resolver.spring.impl.InputDataConnectorParser;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.primitive.DeprecationSupport;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
@@ -59,6 +61,7 @@ public abstract class BaseComputedIDDataConnectorParser extends BaseResolverPlug
      * @param builder Spring's bean builder.
      * @param generatedIdDefaultName the name to give the generated Attribute if none was provided.
      */
+    // Checkstyle: CyclomaticComplexity|MethodLength OFF
     protected void doParse(@Nonnull final Element config, @Nonnull final ParserContext parserContext,
             @Nonnull final BeanDefinitionBuilder builder, @Nullable final String generatedIdDefaultName) {
         super.doParse(config, parserContext, builder);
@@ -97,7 +100,14 @@ public abstract class BaseComputedIDDataConnectorParser extends BaseResolverPlug
             builder.addPropertyValue("encoding", config.getAttributeNS(null, "encoding"));
         }
 
-        final String sourceAttribute = StringSupport.trimOrNull(config.getAttributeNS(null, "sourceAttributeID"));
+        if (config.hasAttributeNS(null, "sourceAttributeID")) {
+            final String sourceAttribute = StringSupport.trimOrNull(config.getAttributeNS(null, "sourceAttributeID"));
+            builder.addPropertyValue("sourceAttributeId", sourceAttribute);
+            DeprecationSupport.warnOnce(ObjectType.ATTRIBUTE, "sourceAttributeID",
+                    parserContext.getReaderContext().getResource().getDescription(),
+                    InputAttributeDefinitionParser.ELEMENT_NAME.getLocalPart() + " or "
+                            + InputDataConnectorParser.ELEMENT_NAME.getLocalPart());
+        }
 
         final String salt;
         if (AttributeSupport.hasAttribute(config, new QName("salt"))) {
@@ -107,18 +117,18 @@ public abstract class BaseComputedIDDataConnectorParser extends BaseResolverPlug
         }
         
         if (null == salt) {
-            log.debug("{} Generated Attribute: '{}', sourceAttribute = '{}', no salt provided", 
-                    getLogPrefix(), generatedAttribute, sourceAttribute);
+            log.debug("{} Generated Attribute: '{}', no salt provided", getLogPrefix(), generatedAttribute);
         } else {
-            log.debug("{} Generated Attribute: '{}', sourceAttribute = '{}', see TRACE log for its value", 
-                    getLogPrefix(), generatedAttribute, sourceAttribute);
+            log.debug("{} Generated Attribute: '{}', see TRACE log for the salt value", 
+                    getLogPrefix(), generatedAttribute);
             log.trace("{} salt: '{}'", getLogPrefix(), salt);
         }
 
         builder.addPropertyValue("generatedAttributeId", generatedAttribute);
-        builder.addPropertyValue("sourceAttributeId", sourceAttribute);
         builder.addPropertyValue("salt", salt);
     }
+    // Checkstyle: CyclomaticComplexity|MethodLength ON
+
     /**
      * return a string which is to be prepended to all log messages.
      * 
diff --git a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/ComputedIDDataConnectorParserTest.java b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/ComputedIDDataConnectorParserTest.java
index 4603584..99e5326 100644
--- a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/ComputedIDDataConnectorParserTest.java
+++ b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/ComputedIDDataConnectorParserTest.java
@@ -25,6 +25,7 @@ import net.shibboleth.idp.saml.attribute.resolver.impl.ComputedIDDataConnector;
 import net.shibboleth.idp.saml.nameid.impl.ComputedPersistentIdGenerationStrategy.Encoding;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 
+import org.springframework.beans.factory.BeanCreationException;
 import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
 import org.springframework.core.env.MutablePropertySources;
@@ -36,6 +37,7 @@ import org.testng.annotations.Test;
 /**
  * test for {@link ComputedIDDataConnectorParser}
  */
+ at SuppressWarnings("deprecation")
 public class ComputedIDDataConnectorParserTest extends BaseAttributeDefinitionParserTest {
     
     @Test public void withSalt() throws ComponentInitializationException {
@@ -43,25 +45,58 @@ public class ComputedIDDataConnectorParserTest extends BaseAttributeDefinitionPa
         
         Assert.assertEquals(connector.getId(), "computed");
         Assert.assertEquals(connector.getSourceAttributeId(), "theSourceRemainsTheSame");
+        Assert.assertEquals(connector.getSourceAttributeInformation(), "theSourceRemainsTheSame");
         Assert.assertEquals(connector.getGeneratedAttributeId(), "jenny");
         Assert.assertEquals(connector.getSalt(), "abcdefghijklmnopqrst ".getBytes());
         Assert.assertEquals(connector.getAlgorithm(), "SHA");
         Assert.assertEquals(connector.getEncoding(), Encoding.BASE64);
 
-        connector.initialize();
+        Assert.assertTrue(connector.isInitialized());
     }
     
-    @Test public void resolver() throws ComponentInitializationException {
+    @Test public void resolverAttribute() throws ComponentInitializationException {
         final ComputedIDDataConnector connector = getDataConnector("resolver/computed.xml", ComputedIDDataConnector.class);
         
         Assert.assertEquals(connector.getId(), "computed");
-        Assert.assertEquals(connector.getSourceAttributeId(), "theSourceRemainsTheSame");
+        Assert.assertNull(connector.getSourceAttributeId());
         Assert.assertEquals(connector.getGeneratedAttributeId(), "jenny");
         Assert.assertEquals(connector.getSalt(), "abcdefghijklmnopqrst ".getBytes());
+        Assert.assertEquals(connector.getSourceAttributeInformation(), "theSourceRemainsTheSame");
         Assert.assertEquals(connector.getAlgorithm(), "SHA256");
         Assert.assertEquals(connector.getEncoding(), Encoding.BASE32);
 
-        connector.initialize();
+        Assert.assertTrue(connector.isInitialized());
+    }
+
+    @Test public void resolverDataConnector() throws ComponentInitializationException {
+        final ComputedIDDataConnector connector = getDataConnector("resolver/computedDataConnector.xml", ComputedIDDataConnector.class);
+
+        Assert.assertEquals(connector.getId(), "computed");
+        Assert.assertNull(connector.getSourceAttributeId());
+        Assert.assertEquals(connector.getGeneratedAttributeId(), "jenny");
+        Assert.assertEquals(connector.getSalt(), "abcdefghijklmnopqrst ".getBytes());
+        Assert.assertEquals(connector.getSourceAttributeInformation(), "DC/theSourceRemainsTheSame");
+
+        Assert.assertTrue(connector.isInitialized());
+}
+
+    @Test public void resolverNoSourceAttr() {
+        try {
+            getDataConnector("resolver/computedNoSource.xml", ComputedIDDataConnector.class);
+            Assert.fail("Expected initialize to fail");
+        } catch (final BeanCreationException ex) {
+            Assert.assertEquals(ex.getCause().getClass(), ComponentInitializationException.class);
+        }
+    }
+
+    @Test public void resolverNoSourceDependency() {
+        final ComputedIDDataConnector connector = getDataConnector("resolver/computedNoSource1.xml", ComputedIDDataConnector.class);
+        Assert.assertEquals(connector.getId(), "computed");
+        Assert.assertEquals(connector.getSourceAttributeId(), "theSourceRemainsTheSame");
+        Assert.assertEquals(connector.getGeneratedAttributeId(), "jenny");
+        Assert.assertEquals(connector.getSalt(), "abcdefghijklmnopqrst ".getBytes());
+        Assert.assertEquals(connector.getSourceAttributeInformation(), "theSourceRemainsTheSame");
+
     }
 
     @Test public void propertySalt()  {
@@ -87,7 +122,7 @@ public class ComputedIDDataConnectorParserTest extends BaseAttributeDefinitionPa
         final SchemaTypeAwareXMLBeanDefinitionReader beanDefinitionReader =
                 new SchemaTypeAwareXMLBeanDefinitionReader(context);
 
-        beanDefinitionReader.loadBeanDefinitions(DATACONNECTOR_FILE_PATH + "computedProperty.xml");
+        beanDefinitionReader.loadBeanDefinitions(DATACONNECTOR_FILE_PATH + "resolver/computedProperty.xml");
 
         
         beanDefinitionReader.setValidating(true);
@@ -97,6 +132,7 @@ public class ComputedIDDataConnectorParserTest extends BaseAttributeDefinitionPa
         final ComputedIDDataConnector connector =  context.getBean(ComputedIDDataConnector.class);
         
         Assert.assertEquals(connector.getSalt(), salt.getBytes());
+        Assert.assertTrue(connector.isInitialized());
     }
 
 }
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/computedProperty.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/computedProperty.xml
deleted file mode 100644
index 98e2a12..0000000
--- a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/computedProperty.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resolver:DataConnector id="computed"
-	xsi:type="dc:ComputedId" xmlns:resolver="urn:mace:shibboleth:2.0:resolver"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pc="urn:mace:shibboleth:2.0:resolver:pc"
-	xmlns:ad="urn:mace:shibboleth:2.0:resolver:ad" xmlns:dc="urn:mace:shibboleth:2.0:resolver:dc"
-	xmlns:enc="urn:mace:shibboleth:2.0:attribute:encoder" xmlns:sec="urn:mace:shibboleth:2.0:security"
-	
-	sourceAttributeID="theSourceRemainsTheSame"
-	generatedAttributeID="jenny"
-	salt="%{the.ComputedIDDataConnector.salt}"
-	xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd
-                        urn:mace:shibboleth:2.0:resolver:pc http://shibboleth.net/schema/idp/shibboleth-attribute-resolver-pc.xsd
-                        urn:mace:shibboleth:2.0:resolver:ad http://shibboleth.net/schema/idp/shibboleth-attribute-resolver-ad.xsd
-                        urn:mace:shibboleth:2.0:resolver:dc http://shibboleth.net/schema/idp/shibboleth-attribute-resolver-dc.xsd
-                        urn:mace:shibboleth:2.0:attribute:encoder http://shibboleth.net/schema/idp/shibboleth-attribute-encoder.xsd
-                        urn:mace:shibboleth:2.0:security http://shibboleth.net/schema/idp/shibboleth-security.xsd" />
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml
index add8e3b..01945a0 100644
--- a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml
@@ -2,12 +2,11 @@
 <DataConnector id="computed"
 	xsi:type="ComputedId" xmlns="urn:mace:shibboleth:2.0:resolver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	
-	sourceAttributeID="theSourceRemainsTheSame"
 	generatedAttributeID="jenny"
 	salt="abcdefghijklmnopqrst "
 	algorithm="SHA256"
 	encoding="BASE32"
 	xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd">
     <FailoverDataConnector ref="2123"/>
-    <Dependency ref="321"/>
+    <InputAttributeDefinition ref="theSourceRemainsTheSame" />
 </DataConnector>
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computedDataConnector.xml
similarity index 79%
copy from idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml
copy to idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computedDataConnector.xml
index add8e3b..7cbc1d0 100644
--- a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computedDataConnector.xml
@@ -2,12 +2,9 @@
 <DataConnector id="computed"
 	xsi:type="ComputedId" xmlns="urn:mace:shibboleth:2.0:resolver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	
-	sourceAttributeID="theSourceRemainsTheSame"
 	generatedAttributeID="jenny"
 	salt="abcdefghijklmnopqrst "
-	algorithm="SHA256"
-	encoding="BASE32"
 	xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd">
     <FailoverDataConnector ref="2123"/>
-    <Dependency ref="321"/>
+    <InputDataConnector ref="DC" attributeNames="theSourceRemainsTheSame" />
 </DataConnector>
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computedNoSource.xml
similarity index 79%
copy from idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml
copy to idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computedNoSource.xml
index add8e3b..b177efd 100644
--- a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computedNoSource.xml
@@ -2,12 +2,9 @@
 <DataConnector id="computed"
 	xsi:type="ComputedId" xmlns="urn:mace:shibboleth:2.0:resolver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	
-	sourceAttributeID="theSourceRemainsTheSame"
 	generatedAttributeID="jenny"
 	salt="abcdefghijklmnopqrst "
-	algorithm="SHA256"
-	encoding="BASE32"
 	xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd">
     <FailoverDataConnector ref="2123"/>
-    <Dependency ref="321"/>
+    <Dependency ref="abc"/>
 </DataConnector>
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computedNoSource1.xml
similarity index 78%
copy from idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml
copy to idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computedNoSource1.xml
index add8e3b..985b391 100644
--- a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computed.xml
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computedNoSource1.xml
@@ -1,13 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <DataConnector id="computed"
 	xsi:type="ComputedId" xmlns="urn:mace:shibboleth:2.0:resolver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	
-	sourceAttributeID="theSourceRemainsTheSame"
+
+	sourceAttributeID="theSourceRemainsTheSame"	
 	generatedAttributeID="jenny"
 	salt="abcdefghijklmnopqrst "
-	algorithm="SHA256"
-	encoding="BASE32"
 	xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd">
     <FailoverDataConnector ref="2123"/>
-    <Dependency ref="321"/>
 </DataConnector>
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computedProperty.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computedProperty.xml
new file mode 100644
index 0000000..c401dd5
--- /dev/null
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/computedProperty.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<DataConnector id="computed" xsi:type="ComputedId" xmlns="urn:mace:shibboleth:2.0:resolver"	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	
+	sourceAttributeID="theSourceRemainsTheSame"
+	generatedAttributeID="jenny"
+	salt="%{the.ComputedIDDataConnector.salt}"
+	xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd"/>
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/AbstractPersistentIdDataConnector.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/AbstractPersistentIdDataConnector.java
index 0301459..2e1f30a 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/AbstractPersistentIdDataConnector.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/AbstractPersistentIdDataConnector.java
@@ -30,6 +30,8 @@ import net.shibboleth.idp.attribute.IdPAttributeValue;
 import net.shibboleth.idp.attribute.StringAttributeValue;
 import net.shibboleth.idp.attribute.resolver.AbstractDataConnector;
 import net.shibboleth.idp.attribute.resolver.PluginDependencySupport;
+import net.shibboleth.idp.attribute.resolver.ResolverAttributeDefinitionDependency;
+import net.shibboleth.idp.attribute.resolver.ResolverDataConnectorDependency;
 import net.shibboleth.idp.attribute.resolver.ResolverPluginDependency;
 import net.shibboleth.idp.attribute.resolver.context.AttributeResolverWorkContext;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
@@ -55,14 +57,29 @@ public abstract class AbstractPersistentIdDataConnector extends AbstractDataConn
     /** ID of the attribute whose first value is used when generating the computed ID. */
     @NonnullAfterInit private String sourceAttribute;
 
+    /** Information about the dependency. */
+    @NonnullAfterInit private String sourceInformation;
+
     /**
      * Get the ID of the attribute whose first value is used when generating the computed ID.
      * 
      * @return ID of the attribute whose first value is used when generating the computed ID
      */
-    @NonnullAfterInit public String getSourceAttributeId() {
+    @Nullable @Deprecated public String getSourceAttributeId() {
         return sourceAttribute;
     }
+    
+    /**
+     * Get Information about the attribute whose first value is used when generating the computed ID.
+     * This is derived from the sourceID (if present) and/or the dependencies.  
+     * Public purely as an aid to testing.
+     *
+     * @return log-friend information.
+     */
+    @Nullable @NonnullAfterInit public String getSourceAttributeInformation() {
+        ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
+        return sourceInformation;
+    }
 
     /**
      * Set the ID of the attribute whose first value is used when generating the computed ID.
@@ -92,20 +109,74 @@ public abstract class AbstractPersistentIdDataConnector extends AbstractDataConn
         ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
         generatedAttribute = newAttributeId;
     }
-
-    /** {@inheritDoc} */
-    @Override protected void doInitialize() throws ComponentInitializationException {
-
-        if (null == getSourceAttributeId()) {
-            throw new ComponentInitializationException(getLogPrefix() + " No source attribute present.");
-        }
-
-        // We have an input id, so that gets added to the dependencies.
-        if (null != getSourceAttributeId()) {
-            for (final ResolverPluginDependency depends : getDependencies()) {
+    
+    /**
+     * Do the dance with dependencies.
+     * 
+     * Old style ones get the sourceId added (failing if it isn't there).
+     * New style ones get their names added to the information string.
+     *
+     * @throws ComponentInitializationException if the dependencies are not aligned correctly
+     */
+ // Checkstyle: CyclomaticComplexity|MethodLength OFF
+    private void doDependencyInformation() throws ComponentInitializationException {
+        final StringBuilder dependencyInformation = new StringBuilder();
+        boolean seenAttribute = false;
+        for (final ResolverPluginDependency depends : getDependencies()) {
+            if (seenAttribute) {
+                dependencyInformation.append(", ");
+            }
+            if (depends instanceof ResolverAttributeDefinitionDependency) {
+                dependencyInformation.append(depends.getDependencyPluginId());
+                // No other work needed.  The name is the reference
+            } else if (depends instanceof ResolverDataConnectorDependency) {
+                final ResolverDataConnectorDependency dataConnectorDependency =
+                        (ResolverDataConnectorDependency) depends;
+                if (dataConnectorDependency.isAllAttributes()) {
+                    dependencyInformation.append(depends.getDependencyPluginId()).append("/*");
+                } else if (dataConnectorDependency.getAttributeNames().isEmpty()) {
+                    throw new ComponentInitializationException(getLogPrefix() + " No source attribute present.");
+                } else if (dataConnectorDependency.getAttributeNames().size() == 1) {
+                    dependencyInformation.append(dataConnectorDependency.getDependencyPluginId()).
+                                          append('/').
+                                          append(dataConnectorDependency.getAttributeNames().iterator().next());
+                } else {
+                    dependencyInformation.append(dataConnectorDependency.getDependencyPluginId()).
+                                          append('/').
+                                          append(dataConnectorDependency.getAttributeNames().toString());
+                }
+                // No work needed.  The names are stored elsewhere
+            } else {
+                if (null == getSourceAttributeId()) {
+                    throw new ComponentInitializationException(getLogPrefix() + " No source attribute present.");
+                }
+                dependencyInformation.append(depends.getDependencyPluginId()).
+                                      append('/').
+                                      append(getSourceAttributeId());
                 depends.setDependencyAttributeId(getSourceAttributeId());
             }
+            seenAttribute = true;
+        }
+        if (!seenAttribute) {
+            if (null == getSourceAttributeId()) {
+                throw new ComponentInitializationException(getLogPrefix() + " No source attribute present.");
+            } else {
+                log.warn("{} source Attribute {} present, but not declared as a dependency", getLogPrefix(), 
+                        getSourceAttributeId());
+                dependencyInformation.append(getSourceAttributeId());
+            }
         }
+        sourceInformation = dependencyInformation.toString();
+        log.debug("{} Source for definition: {}", getLogPrefix(), sourceInformation);
+    }
+ // Checkstyle: CyclomaticComplexity|MethodLength ON
+
+    /** {@inheritDoc} */
+    @Override protected void doInitialize() throws ComponentInitializationException { 
+
+        // Set up the dependencies first. Then the initialize in the parent
+        // will correctly rehash the dependencies.
+        doDependencyInformation();
         super.doInitialize();
 
         if (null == generatedAttribute) {
@@ -130,13 +201,13 @@ public abstract class AbstractPersistentIdDataConnector extends AbstractDataConn
                 PluginDependencySupport.getMergedAttributeValues(workContext, getDependencies(), getId());
         if (attributeValues == null || attributeValues.isEmpty()) {
             log.debug("{} Source attribute {} for connector {} provide no values", getLogPrefix(),
-                    getSourceAttributeId(), getId());
+                    getSourceAttributeInformation(), getId());
             return null;
         }
 
         if (attributeValues.size() > 1) {
             log.warn("{} Source attribute {} for connector {} has more than one value, only one value is used",
-                    getLogPrefix(), getSourceAttributeId(), getId());
+                    getLogPrefix(), getSourceAttributeInformation(), getId());
         }
 
         final IdPAttributeValue attributeValue = attributeValues.iterator().next();
@@ -146,24 +217,24 @@ public abstract class AbstractPersistentIdDataConnector extends AbstractDataConn
         if (attributeValue instanceof StringAttributeValue) {
             if (StringSupport.trimOrNull((String) attributeValue.getValue()) == null) {
                 log.warn("{} Source attribute {} for connector {} was all-whitespace", getLogPrefix(),
-                        getSourceAttributeId(), getId());
+                        getSourceAttributeInformation(), getId());
                 return null;
             }
             val = (String) attributeValue.getValue();
         } else if (attributeValue instanceof EmptyAttributeValue) {
             final EmptyAttributeValue emptyVal = (EmptyAttributeValue) attributeValue;
             log.warn("{} Source attribute {} value for connector {} was an empty value of type {}", getLogPrefix(),
-                    getSourceAttributeId(), getId(), emptyVal.getDisplayValue());
+                    getSourceAttributeInformation(), getId(), emptyVal.getDisplayValue());
             return null;
         } else {
             log.warn("{} Source attribute {} for connector {} was of an unsupported type: {}", getLogPrefix(),
-                    getSourceAttributeId(), getId(), attributeValue.getClass().getName());
+                    getSourceAttributeInformation(), getId(), attributeValue.getClass().getName());
             return null;
         }
 
         if (val == null) {
             log.warn("{} Attribute value {} for connector {} resolved as empty or null", getLogPrefix(),
-                    getSourceAttributeId(), getId());
+                    getSourceAttributeInformation(), getId());
         }
         return val;
     }
diff --git a/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd b/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd
index d8ff6f5..f221785 100644
--- a/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd
+++ b/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd
@@ -880,10 +880,11 @@
                         </documentation>
                     </annotation>
                 </attribute>
-                <attribute name="sourceAttributeID" type="string" use="required">
+                <attribute name="sourceAttributeID" type="string" >
                     <annotation>
                         <documentation>
                             The name of the attribute which should be used to as input to the computed ID.
+                            Legacy only.  Use InputAttributeDefinition or InputDataConnector
                         </documentation>
                     </annotation>
                 </attribute>

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


More information about the commits mailing list