Added using HandleServer code
authordousti <dousti@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Mon, 17 Jun 2002 14:21:57 +0000 (14:21 +0000)
committerdousti <dousti@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Mon, 17 Jun 2002 14:21:57 +0000 (14:21 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@134 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/AAResponder.java
src/edu/internet2/middleware/shibboleth/aa/AAServlet.java

index fc1c9b3..0acf1ee 100755 (executable)
@@ -1,6 +1,5 @@
 package edu.internet2.middleware.shibboleth.aa;
 
-//import aa.*;
 import java.io.*;
 import java.util.*;
 import java.lang.reflect.*;
@@ -9,22 +8,23 @@ import javax.servlet.http.*;
 import javax.naming.*;
 import javax.naming.directory.*;
 import edu.internet2.middleware.shibboleth.*;
+import edu.internet2.middleware.shibboleth.hs.*;
 import edu.internet2.middleware.eduPerson.*;
 import org.w3c.dom.*;
 import org.opensaml.*;
 
 public class AAResponder{
 
-    //HandleRepositoryFactory hrf;
+    HandleRepositoryFactory hrf;
     ArpFactory arpFactory;
     Arp adminArp;
     DirContext ctx;
     String domain;
 
-    public AAResponder(/*HandleRepositoryFactory*/String hrf, ArpFactory arpFactory, DirContext ctx, String domain)
+    public AAResponder(HandleRepositoryFactory hrf, ArpFactory arpFactory, DirContext ctx, String domain)
        throws AAException{
 
-       //this.hrf = hrf;
+       this.hrf = hrf;
        this.arpFactory = arpFactory;
        adminArp = arpFactory.getInstance("admin", true);
        if(adminArp.isNew())
@@ -35,17 +35,24 @@ public class AAResponder{
 
 
     public SAMLAttribute[] getReleaseAttributes(String uidSyntax, String handle, String sharName, String url)
-       throws AAException/*,HandleException*/ {
+       throws AAException,HandleException {
 
        DirContext userCtx = null;
-       //HandleEntry he = hrf.getHandleEntry(handle);
-       // temp for testing
        String userName = null;
-       if(handle.equalsIgnoreCase("foo"))
-          userName = "dousti"; //he.getUsername();
+
+       if(hrf == null){
+           if(handle.equalsIgnoreCase("foo"))
+               userName = "dousti"; 
+           if(userName == null)
+               throw new AAException("No HandleRepository found!");
+       }else{
+           HandleEntry he = hrf.getHandleEntry(handle);
+           userName = he.getUsername();
+           if(userName == null)
+               throw new AAException("HandleServer returns null for user name!");
+       }
            
-       if(userName == null)
-           throw new AAException("user name is null");
+
 
        try{
            if(uidSyntax == null)
@@ -223,7 +230,8 @@ public class AAResponder{
            vals.add(ne.next());
 
 
-       String[] scopes = { this.domain };
+       String[] scopes = new String[vals.size()];
+       scopes[0] = this.domain;
        Object[] args = new Object[2];
        args[0] = scopes;
        args[1] = vals.toArray();
index 8fe72d8..356e021 100755 (executable)
@@ -9,6 +9,7 @@ import javax.naming.directory.*;
 import org.opensaml.*;
 import org.w3c.dom.*;
 import edu.internet2.middleware.shibboleth.*;
+import edu.internet2.middleware.shibboleth.hs.*;
 import edu.internet2.middleware.eduPerson.*;
 
 
@@ -23,7 +24,7 @@ public class AAServlet extends HttpServlet {
     String arpFactoryData;
     String ctxFactory;
     AAResponder responder;
-    //HandleRepositoryFactory hrf;
+    HandleRepositoryFactory hrf;
     ArpFactory arpFactory;
     
     
@@ -42,7 +43,10 @@ public class AAServlet extends HttpServlet {
            arpFactoryMethod = getInitParameter("arpFactoryMethod");
            arpFactoryData = getInitParameter("arpFactoryData");
 
-           //hrf = HandleRepositoryFactory.getInstance(Constants.POLICY_CLUBSHIB, this);
+           ServletConfig sc = getServletConfig();
+           ServletContext sctx = sc.getServletContext(); 
+           hrf = (HandleRepositoryFactory)sctx.getAttribute("HandleRepository");
+      
            arpFactory = ArpRepository.getInstance(arpFactoryMethod, arpFactoryData);
 
            Hashtable env = new Hashtable(11);
@@ -51,9 +55,8 @@ public class AAServlet extends HttpServlet {
            env.put(Context.PROVIDER_URL, dirUrl);
            DirContext ctx = new InitialDirContext(env);
            
-           responder = new AAResponder(/*hrf*/ null, arpFactory, ctx, myName);
-           //  }catch(HandleException he){
-           //      throw new ServletException("Init failed: "+he);
+           responder = new AAResponder(hrf, arpFactory, ctx, myName);
+
        }catch(NamingException ne){
            throw new ServletException("Init failed: "+ne);
        }catch(AAException ae){