[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 Feb 1 14:52:22 GMT 2012


Author: lajoie
Date: Wed Feb  1 14:52:22 2012
New Revision: 4110

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4110&view=rev
Log:
make TempaltedAttributeDefinition compile
do fix some easy compilation errors in unit tests

Modified:
    trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/TemplateAttributeDefinition.java
    trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ScriptedAttributeTest.java
    trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/SimpleAttributeTest.java

Modified: trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/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/impl/TemplateAttributeDefinition.java?rev=4110&r1=4109&r2=4110&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/TemplateAttributeDefinition.java (original)
+++ trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/TemplateAttributeDefinition.java Wed Feb  1 14:52:22 2012
@@ -18,18 +18,20 @@
 package net.shibboleth.idp.attribute.resolver.impl;
 
 import java.io.StringWriter;
-import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 import net.jcip.annotations.NotThreadSafe;
 import net.shibboleth.idp.attribute.Attribute;
+import net.shibboleth.idp.attribute.AttributeValue;
+import net.shibboleth.idp.attribute.StringAttributeValue;
 import net.shibboleth.idp.attribute.resolver.AttributeResolutionContext;
 import net.shibboleth.idp.attribute.resolver.AttributeResolutionException;
 import net.shibboleth.idp.attribute.resolver.BaseAttributeDefinition;
-import net.shibboleth.idp.attribute.resolver.ResolverPluginDependency;
+import net.shibboleth.idp.attribute.resolver.PluginDependencySupport;
 import net.shibboleth.utilities.java.support.collection.LazyMap;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
@@ -127,6 +129,8 @@
     protected void doInitialize() throws ComponentInitializationException {
         super.doInitialize();
 
+        // TODO check have dependencies
+
         templateName = "shibboleth.resolver.ad." + this.getClass().getName() + getId();
 
         if (null == templateSource) {
@@ -152,7 +156,7 @@
             throws AttributeResolutionException {
 
         final Attribute resultantAttribute = new Attribute(getId());
-        final Map<String, Iterator> sourceValues = new LazyMap<String, Iterator>();
+        final Map<String, Iterator<AttributeValue>> sourceValues = new LazyMap<String, Iterator<AttributeValue>>();
         final int valueCount = countAndSetupSourceValues(resolutionContext, sourceValues);
 
         if (null == getDependencies()) {
@@ -179,12 +183,11 @@
                 Template template;
                 template = velocity.getTemplate(templateName);
                 template.merge(vCtx, output);
-                resultantAttribute.addValue(output.toString());
+                resultantAttribute.getValues().add(new StringAttributeValue(output.toString()));
 
             } catch (Exception e) {
-                //
-                // Yup, Velocity throws Exception....
-                //
+                // TODO(lajoie) catch something other than exception
+
                 log.error("Unable to populate " + templateName + " template", e);
                 throw new AttributeResolutionException("Unable to evaluate template", e);
             }
@@ -192,7 +195,7 @@
 
         return Optional.of(resultantAttribute);
     }
-    
+
     /**
      * Set up a map which can be used to populate the template. The key is the attribute name and the value is the
      * iterator to give all the names. We also return how deep the iteration will be and throw an exception if there is
@@ -207,36 +210,25 @@
      * @throws AttributeResolutionException if there is a mismatched count of attributes
      */
     private int countAndSetupSourceValues(final AttributeResolutionContext resolutionContext,
-            Map<String, Iterator> sourceValues) throws AttributeResolutionException {
-        int valueCount = -1;
-        final Set<ResolverPluginDependency> depends = getDependencies();
-        final Set<String> unresolvedAttributes = new HashSet<String>(sourceAttributes);
-
-        for (ResolverPluginDependency dep : depends) {
-            final Attribute dependentAttribute = dep.getDependentAttribute(resolutionContext);
-            if (null == dependentAttribute) {
-                log.warn("Dependency of TemplateAttribute " + getId() + " returned null dependent attribute");
-                continue;
-            }

[... 218 lines stripped ...]


More information about the commits mailing list