Changed the way Saml attributes are created. Now every attribute must implement...
authordousti <dousti@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Mon, 17 Jun 2002 18:45:29 +0000 (18:45 +0000)
committerdousti <dousti@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Mon, 17 Jun 2002 18:45:29 +0000 (18:45 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@136 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/AAResponder.java
src/edu/internet2/middleware/shibboleth/aaLocal/attributes/eduPersonAffiliation.java
src/edu/internet2/middleware/shibboleth/aaLocal/attributes/eduPersonPrincipalName.java

index 0acf1ee..cfde486 100755 (executable)
@@ -229,21 +229,15 @@ public class AAResponder{
        while(ne.hasMore())
            vals.add(ne.next());
 
-
-       String[] scopes = new String[vals.size()];
-       scopes[0] = this.domain;
-       Object[] args = new Object[2];
-       args[0] = scopes;
-       args[1] = vals.toArray();
-
        try{
            Class attrClass = Class.forName(id);
-           Constructor[] cons = attrClass.getConstructors();
+           //      Constructor[] cons = attrClass.getConstructors();
            System.out.println("Got constructors for "+attrClass);
-           System.out.println("number of constructors "+cons.length);
-           System.out.println("first constructor is "+cons[0]);
-           System.out.println("Make a SAML attribute with: "+scopes[0]+", "+vals.get(0));
-           return (SAMLAttribute)cons[0].newInstance(args);
+           //      System.out.println("number of constructors "+cons.length);
+           //      System.out.println("first constructor is "+cons[0]);
+           //      System.out.println("Make a Shib attribute with: "+scopes[0]+", "+vals.get(0));
+           ShibAttribute sa = (ShibAttribute)attrClass.newInstance();
+           return sa.toSamlAttribute(this.domain, vals.toArray());
        }catch(Exception e){
            throw new AAException("Failed to read the class for attribute "+id+" :"+e);
        }
index 9a9c735..f22cee0 100644 (file)
@@ -1,36 +1,38 @@
 import edu.internet2.middleware.eduPerson.*;
 import edu.internet2.middleware.shibboleth.common.Constants; 
+import edu.internet2.middleware.shibboleth.aa.ShibAttribute;
 import org.opensaml.*;
 
-public class eduPersonAffiliation extends ScopedAttribute{
+public class eduPersonAffiliation implements ShibAttribute{
     
 
-    public eduPersonAffiliation(String[] scopes, Object[] values)
+    public SAMLAttribute toSamlAttribute(String defaultScope, Object[] values)
        throws SAMLException{
 
-       super("urn:mace:eduPerson:1.0:eduPersonAffiliation",
+       String[] scopes = new String[values.length];
+
+       for(int i=0; i<values.length; i++){
+           String val = (String)values[i];
+           if(val.equalsIgnoreCase("faculty") ||
+              val.equalsIgnoreCase("student") ||
+              val.equalsIgnoreCase("staff") ||
+              val.equalsIgnoreCase("alum") ||
+              val.equalsIgnoreCase("member") ||
+              val.equalsIgnoreCase("affiliate") ||
+              val.equalsIgnoreCase("employee") )
+               values[i] = val.toLowerCase();
+           else
+               values[i] = "member";
+       }
+
+       return new ScopedAttribute("urn:mace:eduPerson:1.0:eduPersonAffiliation",
                   Constants.SHIB_ATTRIBUTE_NAMESPACE_URI, 
                   new QName("urn:mace:eduPerson:1.0",
                             "eduPersonAffiliationType"),
                   10*60,
                   values,
-                  scopes[0],
+                  defaultScope,
                   scopes);
-
-     for(int i=0; i<values.length; i++){
-       String val = (String)values[i];
-       if(val.equalsIgnoreCase("faculty") ||
-          val.equalsIgnoreCase("student") ||
-          val.equalsIgnoreCase("staff") ||
-          val.equalsIgnoreCase("alum") ||
-          val.equalsIgnoreCase("member") ||
-          val.equalsIgnoreCase("affiliate") ||
-          val.equalsIgnoreCase("employee") )
-           values[i] = val.toLowerCase();
-       else
-           values[i] = "member";
-     }
-
     }
 }
 
index 263be47..0b1ea79 100644 (file)
@@ -1,24 +1,32 @@
 import edu.internet2.middleware.eduPerson.*;
 import edu.internet2.middleware.shibboleth.common.Constants; 
+import edu.internet2.middleware.shibboleth.aa.ShibAttribute;
 import org.opensaml.*;
 
-public class eduPersonPrincipalName extends ScopedAttribute{
+public class eduPersonPrincipalName implements ShibAttribute{
     
 
-    public eduPersonPrincipalName(String[] scopes, Object[] values)
+    public SAMLAttribute toSamlAttribute(String defaultScope, Object[] values)
        throws SAMLException{
 
-       super("urn:mace:eduPerson:1.0:eduPersonPrincipalName",
-                  Constants.SHIB_ATTRIBUTE_NAMESPACE_URI, 
-                  new QName("urn:mace:eduPerson:1.0",
-                            "eduPersonPrincipalNameType"),
-                  10*60,
-                  values,
-                  scopes[0],
-                  scopes);
+       String scopes[] = new String[1];
+
+       int x = ((String)values[0]).indexOf("@") ;
+       int len = ((String)values[0]).length();
+       if(x > 0){
+           values[0] = ((String)values[0]).substring(0,x-1);
+           scopes[0] = ((String)values[0]).substring(x+1, len);
+       }       
+       return new ScopedAttribute("urn:mace:eduPerson:1.0:eduPersonPrincipalName",
+                                Constants.SHIB_ATTRIBUTE_NAMESPACE_URI, 
+                                new QName("urn:mace:eduPerson:1.0",
+                                          "eduPersonPrincipalNameType"),
+                                10*60,
+                                values,
+                                defaultScope,
+                                scopes);
 
-       if(((String)values[0]).indexOf("@") < 0)
-           values[0] = (String)values[0]+"@"+scopes[0];
     }
+
 }