fixed a bug.
[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
14         int x = ((String)values[0]).indexOf("@") ;
15         int len = ((String)values[0]).length();
16         if(x > 0){
17             values[0] = ((String)values[0]).substring(0,x-1);
18             scopes[0] = ((String)values[0]).substring(x+1);
19         }       
20         return new ScopedAttribute("urn:mace:eduPerson:1.0:eduPersonPrincipalName",
21                                  Constants.SHIB_ATTRIBUTE_NAMESPACE_URI, 
22                                  new QName("urn:mace:eduPerson:1.0",
23                                            "eduPersonPrincipalNameType"),
24                                  10*60,
25                                  values,
26                                  defaultScope,
27                                  scopes);
28
29     }
30
31 }
32