Fixed the bug that dropped the last char.
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / aaLocal / attributes / eduPersonPrincipalName.java
index 263be47..23cb65c 100644 (file)
@@ -1,24 +1,40 @@
 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);
-
-       if(((String)values[0]).indexOf("@") < 0)
-           values[0] = (String)values[0]+"@"+scopes[0];
+       String scopes[] = new String[1];
+       String vals[] = new String[1];
+       String eppn = (String)values[0];
+
+       int x = eppn.indexOf("@") ;
+       System.out.println("EPPN: "+eppn+"    @ at "+x);
+       if(x > 0){
+           vals[0] = eppn.substring(0,x);
+           scopes[0] = eppn.substring(x+1);
+       }else{
+           vals[0] = eppn;
+           scopes[0] = defaultScope;
+       }
+
+       System.out.println("AA debug: sending value="+vals[0]+"  scope="+scopes[0]);
+               
+       return new ScopedAttribute("urn:mace:eduPerson:1.0:eduPersonPrincipalName",
+                                Constants.SHIB_ATTRIBUTE_NAMESPACE_URI, 
+                                new QName("urn:mace:eduPerson:1.0",
+                                          "eduPersonPrincipalNameType"),
+                                10*60,
+                                vals,
+                                defaultScope,
+                                scopes);
+
     }
+
 }