Initial Version
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / aaLocal / EchoDirContext.java
1 import java.util.*;
2 import javax.naming.*;
3 import javax.naming.directory.*;
4
5 public class EchoDirContext extends InitialDirContext{
6
7     String uid = "unknown";
8     
9
10     public EchoDirContext(Hashtable env)
11         throws NamingException{
12     }
13
14     
15     public Object lookup(String s) throws NamingException{
16         int i = s.indexOf("=");
17         if(i >= 0)
18             uid = s.substring(i+1);
19         else
20             uid = s;
21
22         return this;
23     }
24     
25     public Attributes getAttributes(String name, String[] ids)
26         throws NamingException{
27
28         BasicAttributes attrs = new BasicAttributes();
29
30         for(int i=0; i<ids.length; i++){
31             if(ids[i].equalsIgnoreCase("eduPersonAffiliation")){
32                 // return member as value;
33                 attrs.put(new BasicAttribute("eduPersonAffiliation", "member"));
34             }
35             if(ids[i].equalsIgnoreCase("eduPersonPrincipalName")){
36                 // return uid
37                 attrs.put(new BasicAttribute("eduPersonPrincipalName", uid));
38             }
39         }
40         return attrs;
41     }
42 }