System.err -> log4j
[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
16 import org.apache.log4j.Logger;
17 import org.opensaml.*;
18
19 public class eduPersonPrincipalName implements ShibAttribute{
20         
21         private static Logger log = Logger.getLogger(SAMLResponse.class.getName());
22     
23
24     public SAMLAttribute toSamlAttribute(String defaultScope, Object[] values)
25         throws SAMLException{
26
27         String scopes[] = new String[1];
28         String vals[] = new String[1];
29         String eppn = (String)values[0];
30
31         int x = eppn.indexOf("@") ;
32         log.debug("EPPN: "+eppn+"    @ at "+x);
33         if(x > 0){
34             vals[0] = eppn.substring(0,x);
35             scopes[0] = eppn.substring(x+1);
36         }else{
37             vals[0] = eppn;
38             scopes[0] = defaultScope;
39         }
40
41         System.out.println("AA debug: sending value="+vals[0]+"  scope="+scopes[0]);
42                 
43         return new ScopedAttribute("urn:mace:eduPerson:1.0:eduPersonPrincipalName",
44                                  Constants.SHIB_ATTRIBUTE_NAMESPACE_URI, 
45                                  new QName("urn:mace:eduPerson:1.0",
46                                            "eduPersonPrincipalNameType"),
47                                  10*60,
48                                  vals,
49                                  defaultScope,
50                                  scopes);
51
52     }
53
54 }
55