[java-identity-provider COMMIT] /trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolve...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Oct 16 10:54:15 EDT 2014
Author: scantor
Date: Thu Oct 16 10:54:15 2014
New Revision: 6722
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=6722&view=rev
Log:
IDP-491 - TemplateAttributeDefinition throws when no source data is supplied
Modified:
trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeDefinition.java
Modified: trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeDefinition.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeDefinition.java?rev=6722&r1=6721&r2=6722&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeDefinition.java (original)
+++ trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/TemplateAttributeDefinition.java Thu Oct 16 10:54:15 2014
@@ -17,7 +17,6 @@
package net.shibboleth.idp.attribute.resolver.ad.impl;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -27,7 +26,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import javax.annotation.concurrent.NotThreadSafe;
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.IdPAttributeValue;
@@ -41,11 +39,13 @@
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.ThreadSafeAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.collection.CollectionSupport;
import net.shibboleth.utilities.java.support.collection.LazyMap;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
+import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import net.shibboleth.utilities.java.support.velocity.Template;
@@ -56,18 +56,19 @@
import org.slf4j.LoggerFactory;
import com.google.common.base.Predicates;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
/**
* An attribute definition that constructs its values based on the values of its dependencies using the Velocity
- * Template Language. Dependencies may have multiple values, however multiples dependencies must have the same number of
+ * Template Language. Dependencies may have multiple values, however multiple dependencies must have the same number of
* values. In the case of multi-valued dependencies, the template will be evaluated multiples times, iterating over each
- * dependency. <br/>
- * The template is inserted into the engine with a unique name derived from this class and from the id supplied for this
- * attribute. <br/>
- * This is marked not thread safe since the constructor cannot do a safe check & insert of the template into the
- * repository.
+ * dependency.
+ *
+ * <p>The template is inserted into the engine with a unique name derived from this class and from the id supplied for
+ * this attribute.</p>
*/
- at NotThreadSafe
+ at ThreadSafeAfterInit
public class TemplateAttributeDefinition extends AbstractAttributeDefinition {
/** Class logger. */
@@ -83,7 +84,12 @@
@NonnullAfterInit private VelocityEngine engine;
/** The names of the attributes we need. */
- @Nonnull private List<String> sourceAttributes = Collections.emptyList();
+ @Nonnull @NonnullElements private List<String> sourceAttributes;
+
+ /** Constructor. */
+ public TemplateAttributeDefinition() {
+ sourceAttributes = Collections.emptyList();
+ }
/**
* Get the source attribute IDs.
@@ -102,14 +108,14 @@
public void setSourceAttributes(@Nonnull @NullableElements final List<String> newSourceAttributes) {
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
-
- final ArrayList<String> checkedSourceAttrs = new ArrayList<String>(newSourceAttributes.size());
- CollectionSupport.addIf(checkedSourceAttrs, newSourceAttributes, Predicates.notNull());
- sourceAttributes = Collections.unmodifiableList(checkedSourceAttrs);
- }
-
- /**
- * Gets the template text to be evaluated.
+ Constraint.isNotNull(newSourceAttributes, "Source attribute list cannot be null");
+
+ sourceAttributes = Lists.newArrayListWithExpectedSize(newSourceAttributes.size());
[... 236 lines stripped ...]
More information about the commits
mailing list