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