[java-identity-provider COMMIT] in /trunk/idp-attribute-resolver-impl/src: main/java/net/shibboleth/idp/attribute/res...
noreply at shibboleth.net
noreply at shibboleth.net
Wed Apr 17 10:48:24 EDT 2013
Author: rdw
Date: Wed Apr 17 10:48:23 2013
New Revision: 4407
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4407&view=rev
Log:
IDP-205 Template definition takes its input attributes as an Array<String> rather than trying to infer them from the dependendencies. Makes constructing the bean tractable and understandable.
Modified:
trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/TemplateAttributeDefinition.java
trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/TemplateAttributeTest.java
Modified: trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/TemplateAttributeDefinition.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/TemplateAttributeDefinition.java?rev=4407&r1=4406&r2=4407&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/TemplateAttributeDefinition.java (original)
+++ trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/TemplateAttributeDefinition.java Wed Apr 17 10:48:23 2013
@@ -17,10 +17,11 @@
package net.shibboleth.idp.attribute.resolver.impl.ad;
-import java.util.HashSet;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
import javax.annotation.Nonnull;
@@ -32,9 +33,12 @@
import net.shibboleth.idp.attribute.StringAttributeValue;
import net.shibboleth.idp.attribute.UnsupportedAttributeTypeException;
import net.shibboleth.idp.attribute.resolver.AttributeResolutionContext;
-import net.shibboleth.idp.attribute.resolver.ResolutionException;
import net.shibboleth.idp.attribute.resolver.BaseAttributeDefinition;
import net.shibboleth.idp.attribute.resolver.PluginDependencySupport;
+import net.shibboleth.idp.attribute.resolver.ResolutionException;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+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;
@@ -47,6 +51,7 @@
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
+import com.google.common.base.Predicates;
/**
* An attribute definition that constructs its values based on the values of its dependencies using the Velocity
@@ -69,6 +74,32 @@
/** Template to be evaluated. */
private Template template;
+ /** The names of the attributes we need. */
+ private List<String> sourceAttributes = Collections.EMPTY_LIST;
+
+ /**
+ * Get the source attribute IDs.
+ *
+ * @return the source attribute IDs
+ */
+ @Nonnull @Unmodifiable @NonnullElements public List<String> getSourceAttributes() {
+ return Collections.unmodifiableList(sourceAttributes);
+ }
+
+ /**
+ * Set the source attribute IDs.
+ *
+ * @param newSourceAttributes the source attribute IDs
+ */
+ public void setSourceAttributes(List<String> newSourceAttributes) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+
+ ArrayList<String> checkedSourceAttrs = new ArrayList<String>(newSourceAttributes.size());
+ CollectionSupport.addIf(checkedSourceAttrs, newSourceAttributes, Predicates.notNull());
+ sourceAttributes = Collections.unmodifiableList(checkedSourceAttrs);
+ }
+
/**
* Gets the template to be evaluated.
*
@@ -97,7 +128,7 @@
final Attribute resultantAttribute = new Attribute(getId());
final Map<String, Iterator<AttributeValue>> sourceValues = new LazyMap<String, Iterator<AttributeValue>>();
- final int valueCount = countAndSetupSourceValues(resolutionContext, sourceValues);
+ final int valueCount = setupSourceValues(resolutionContext, sourceValues);
// build velocity context
VelocityContext velocityContext;
@@ -109,6 +140,13 @@
for (String attributeId : sourceValues.keySet()) {
final AttributeValue value = sourceValues.get(attributeId).next();
+ if (!(value instanceof StringAttributeValue)) {
+ throw new ResolutionException(new UnsupportedAttributeTypeException(
+ "This attribute definition only supports attribute value types of "
+ + StringAttributeValue.class.getName() + " not values of type "
[... 260 lines stripped ...]
More information about the commits
mailing list