Add a configuration option to the Simple Attribute Definition PlugIn that allows...
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 19 Nov 2004 21:47:18 +0000 (21:47 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 19 Nov 2004 21:47:18 +0000 (21:47 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@1195 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/attrresolv/provider/SimpleAttributeDefinition.java
src/schemas/shibboleth-resolver-1.0.xsd

index b3d852d..868f765 100644 (file)
@@ -80,6 +80,7 @@ public class SimpleAttributeDefinition extends BaseAttributeDefinition implement
        private String connectorMapping;
        private String smartScope;
        private ValueHandler valueHandler;
        private String connectorMapping;
        private String smartScope;
        private ValueHandler valueHandler;
+       private boolean allowEmpty = false;
 
        /**
         * Constructor for SimpleAttributeDefinition.  Creates a PlugIn based on configuration
 
        /**
         * Constructor for SimpleAttributeDefinition.  Creates a PlugIn based on configuration
@@ -89,6 +90,7 @@ public class SimpleAttributeDefinition extends BaseAttributeDefinition implement
 
                super(e);
 
 
                super(e);
 
+               //Parse source name
                String sourceName = e.getAttribute("sourceName");
                if (sourceName == null || sourceName.equals("")) {
                        int index = getId().lastIndexOf("#");
                String sourceName = e.getAttribute("sourceName");
                if (sourceName == null || sourceName.equals("")) {
                        int index = getId().lastIndexOf("#");
@@ -106,6 +108,7 @@ public class SimpleAttributeDefinition extends BaseAttributeDefinition implement
 
                log.debug("Mapping attribute to name (" + connectorMapping + ") in connector.");
 
 
                log.debug("Mapping attribute to name (" + connectorMapping + ") in connector.");
 
+               //Configure smart scoping
                String smartScopingSpec = e.getAttribute("smartScope");
                if (smartScopingSpec != null && !smartScopingSpec.equals("")) {
                        smartScope = smartScopingSpec;
                String smartScopingSpec = e.getAttribute("smartScope");
                if (smartScopingSpec != null && !smartScopingSpec.equals("")) {
                        smartScope = smartScopingSpec;
@@ -116,6 +119,7 @@ public class SimpleAttributeDefinition extends BaseAttributeDefinition implement
                        log.debug("Smart Scoping disabled for attribute (" + getId() + ").");
                }
 
                        log.debug("Smart Scoping disabled for attribute (" + getId() + ").");
                }
 
+               //Load a value handler
                String valueHandlerSpec = e.getAttribute("valueHandler");
 
                if (valueHandlerSpec != null && !valueHandlerSpec.equals("")) {
                String valueHandlerSpec = e.getAttribute("valueHandler");
 
                if (valueHandlerSpec != null && !valueHandlerSpec.equals("")) {
@@ -151,7 +155,16 @@ public class SimpleAttributeDefinition extends BaseAttributeDefinition implement
                if (valueHandler != null) {
                        log.debug("Custom Value Handler enabled for attribute (" + getId() + ").");
                }
                if (valueHandler != null) {
                        log.debug("Custom Value Handler enabled for attribute (" + getId() + ").");
                }
-
+               
+               //Decide whethere or not to allow empty string values
+               String rawAllowEmpty = e.getAttribute("allowEmpty");
+               if (rawAllowEmpty != null) {
+                       if (rawAllowEmpty.equalsIgnoreCase("TRUE")) {
+                               allowEmpty = true;
+                       }
+               }
+               log.debug("Allowal of empty string values is set to (" + allowEmpty + ") for attribute (" + getId() + ").");
+       
        }
 
        /**
        }
 
        /**
@@ -182,7 +195,12 @@ public class SimpleAttributeDefinition extends BaseAttributeDefinition implement
                
                Iterator resultsIt = results.iterator();
                while (resultsIt.hasNext()) {
                
                Iterator resultsIt = results.iterator();
                while (resultsIt.hasNext()) {
-                       attribute.addValue(resultsIt.next());
+                       Object value = resultsIt.next();
+                       if (!allowEmpty && value.equals("")) {
+                               log.debug("Skipping empty string value.");
+                               continue;
+                       }
+                       attribute.addValue(value);
                }
                attribute.setResolved();
        }
                }
                attribute.setResolved();
        }
index 8fe95d3..0f8156a 100644 (file)
@@ -10,6 +10,7 @@
                                                                <xs:attribute name="sourceName" type="xs:string" use="optional"/>
                                                                <xs:attribute name="smartScope" type="xs:string" use="optional"/>
                                                                <xs:attribute name="valueHandler" type="xs:string" use="optional"/>
                                                                <xs:attribute name="sourceName" type="xs:string" use="optional"/>
                                                                <xs:attribute name="smartScope" type="xs:string" use="optional"/>
                                                                <xs:attribute name="valueHandler" type="xs:string" use="optional"/>
+                                                               <xs:attribute name="allowEmpty" type="xs:boolean" use="optional"/>
                                                        </xs:extension>
                                                </xs:complexContent>
                                        </xs:complexType>
                                                        </xs:extension>
                                                </xs:complexContent>
                                        </xs:complexType>