23cb65c8d7fd4d3251178c412c6e2ab5fc476f33
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / aaLocal / attributes / eduPersonPrincipalName.java
1 import edu.internet2.middleware.eduPerson.*;
2 import edu.internet2.middleware.shibboleth.common.Constants; 
3 import edu.internet2.middleware.shibboleth.aa.ShibAttribute;
4 import org.opensaml.*;
5
6 public class eduPersonPrincipalName implements ShibAttribute{
7     
8
9     public SAMLAttribute toSamlAttribute(String defaultScope, Object[] values)
10         throws SAMLException{
11
12         String scopes[] = new String[1];
13         String vals[] = new String[1];
14         String eppn = (String)values[0];
15
16         int x = eppn.indexOf("@") ;
17         System.out.println("EPPN: "+eppn+"    @ at "+x);
18         if(x > 0){
19             vals[0] = eppn.substring(0,x);
20             scopes[0] = eppn.substring(x+1);
21         }else{
22             vals[0] = eppn;
23             scopes[0] = defaultScope;
24         }
25
26         System.out.println("AA debug: sending value="+vals[0]+"  scope="+scopes[0]);
27                 
28         return new ScopedAttribute("urn:mace:eduPerson:1.0:eduPersonPrincipalName",
29                                  Constants.SHIB_ATTRIBUTE_NAMESPACE_URI, 
30                                  new QName("urn:mace:eduPerson:1.0",
31                                            "eduPersonPrincipalNameType"),
32                                  10*60,
33                                  vals,
34                                  defaultScope,
35                                  scopes);
36
37     }
38
39 }
40