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