Updated EchoContext to match new attribute name.
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / aaLocal / EchoDirContext.java
1 package edu.internet2.middleware.shibboleth.aaLocal;
2
3 /**
4  *  Attribute Authority & Release Policy
5  *  Simple implementation of a trivial directory layer
6  *  mostly for demo and testing
7  *
8  * @author     Parviz Dousti (dousti@cmu.edu)
9  * @created    June, 2002
10  */
11
12
13 import java.util.*;
14 import javax.naming.*;
15 import javax.naming.directory.*;
16
17 public class EchoDirContext extends InitialDirContext{
18
19     String uid = "unknown";
20     
21
22     public EchoDirContext(Hashtable env)
23         throws NamingException{
24     }
25
26     
27     public Object lookup(String s) throws NamingException{
28         int i = s.indexOf("=");
29         if(i >= 0)
30             uid = s.substring(i+1);
31         else
32             uid = s;
33
34         return this;
35     }
36     
37     public Attributes getAttributes(String name, String[] ids)
38         throws NamingException{
39
40         BasicAttributes attrs = new BasicAttributes();
41
42         for(int i=0; i<ids.length; i++){
43             if(ids[i].equalsIgnoreCase("eduPersonScopedAffiliation")){
44                 // return member as value;
45                 attrs.put(new BasicAttribute("eduPersonScopedAffiliation", "member"));
46             }
47             if(ids[i].equalsIgnoreCase("eduPersonPrincipalName")){
48                 // return uid
49                 attrs.put(new BasicAttribute("eduPersonPrincipalName", uid));
50             }
51         }
52         return attrs;
53     }
54 }