Fixed a small bug where value handler was being set repeatedly.
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / aa / attrresolv / provider / SimpleAttributeDefinition.java
index bc18e0a..60c6aa5 100644 (file)
@@ -93,7 +93,15 @@ public class SimpleAttributeDefinition extends BaseAttributeDefinition implement
 
                String sourceName = e.getAttribute("sourceName");
                if (sourceName == null || sourceName.equals("")) {
-                       connectorMapping = getId().substring(getId().lastIndexOf(":") + 1);
+                       int index = getId().lastIndexOf("#");
+                       if (index < 0) {
+                               index = getId().lastIndexOf(":");
+                               int slashIndex = getId().lastIndexOf("/");
+                               if (slashIndex > index) {
+                                       index = slashIndex;
+                               }
+                       }
+                       connectorMapping = getId().substring(index + 1);
                } else {
                        connectorMapping = sourceName;
                }
@@ -167,14 +175,15 @@ public class SimpleAttributeDefinition extends BaseAttributeDefinition implement
                        attribute.setLifetime(lifeTime);
                }
 
+               if (smartScope != null) {
+                       attribute.registerValueHandler(new ScopedStringValueHandler(smartScope));
+               }
+               if (smartScope == null && valueHandler != null) {
+                       attribute.registerValueHandler(valueHandler);
+               }
+               
                Iterator resultsIt = results.iterator();
                while (resultsIt.hasNext()) {
-                       if (smartScope != null) {
-                               attribute.registerValueHandler(new ScopedStringValueHandler(smartScope));
-                       }
-                       if (smartScope == null && valueHandler != null) {
-                               attribute.registerValueHandler(valueHandler);
-                       }
                        attribute.addValue(resultsIt.next());
                }
                attribute.setResolved();