Moved the processing of the Handle to Servlet from AAResponder.
authordousti <dousti@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 18 Jun 2002 15:00:11 +0000 (15:00 +0000)
committerdousti <dousti@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 18 Jun 2002 15:00:11 +0000 (15:00 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@142 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

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

index cfde486..e25f217 100755 (executable)
@@ -15,16 +15,14 @@ import org.opensaml.*;
 
 public class AAResponder{
 
-    HandleRepositoryFactory hrf;
     ArpFactory arpFactory;
     Arp adminArp;
     DirContext ctx;
     String domain;
 
-    public AAResponder(HandleRepositoryFactory hrf, ArpFactory arpFactory, DirContext ctx, String domain)
+    public AAResponder(ArpFactory arpFactory, DirContext ctx, String domain)
        throws AAException{
 
-       this.hrf = hrf;
        this.arpFactory = arpFactory;
        adminArp = arpFactory.getInstance("admin", true);
        if(adminArp.isNew())
@@ -34,25 +32,10 @@ public class AAResponder{
     }
 
 
-    public SAMLAttribute[] getReleaseAttributes(String uidSyntax, String handle, String sharName, String url)
-       throws AAException,HandleException {
+    public SAMLAttribute[] getReleaseAttributes(String userName, String uidSyntax, String handle, String sharName, String url)
+       throws AAException{
 
        DirContext userCtx = null;
-       String userName = null;
-
-       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!");
-       }
-           
-
 
        try{
            if(uidSyntax == null)
index 356e021..41e911c 100755 (executable)
@@ -43,9 +43,7 @@ public class AAServlet extends HttpServlet {
            arpFactoryMethod = getInitParameter("arpFactoryMethod");
            arpFactoryData = getInitParameter("arpFactoryData");
 
-           ServletConfig sc = getServletConfig();
-           ServletContext sctx = sc.getServletContext(); 
-           hrf = (HandleRepositoryFactory)sctx.getAttribute("HandleRepository");
+
       
            arpFactory = ArpRepository.getInstance(arpFactoryMethod, arpFactoryData);
 
@@ -55,7 +53,7 @@ public class AAServlet extends HttpServlet {
            env.put(Context.PROVIDER_URL, dirUrl);
            DirContext ctx = new InitialDirContext(env);
            
-           responder = new AAResponder(hrf, arpFactory, ctx, myName);
+           responder = new AAResponder(arpFactory, ctx, myName);
 
        }catch(NamingException ne){
            throw new ServletException("Init failed: "+ne);
@@ -92,7 +90,28 @@ public class AAServlet extends HttpServlet {
            System.err.println("AA debug: issuer:"+issuedBy);
            System.err.println("AA debug: shar:"+shar);
 
-           attrs = responder.getReleaseAttributes(uidSyntax, handle, shar, resource);
+           // get HS and convert handle to userName
+           ServletConfig sc = getServletConfig();
+           ServletContext sctx = sc.getServletContext(); 
+           hrf = (HandleRepositoryFactory)sctx.getAttribute("HandleRepository");
+           System.out.println("Debug: Context aTTR: "+sctx.getAttribute("HandleRepository"));
+
+           String userName = null;
+
+           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!");
+           }
+           
+
+           attrs = responder.getReleaseAttributes(userName, uidSyntax, handle, shar, resource);
            System.err.println("AA debug: got attributes");
            saml.respond(resp, attrs, null);
 
@@ -102,8 +121,12 @@ public class AAServlet extends HttpServlet {
            }catch(Exception ee){
                throw new ServletException("AA failed to even make a SAML Failure message because "+ee+"  Origianl problem: "+se);
            }
-           //  }catch (HandleException he) {
-           //      ourSE = new org.opensaml.SAMLException(org.opensaml.SAMLException.RESPONDER,"Bad Handle or Handle Service Problem: "+he);
+       }catch (HandleException he) {
+           try{
+               saml.fail(resp, new SAMLException(null, "AA got a HandleException: "+he));
+           }catch(Exception ee){
+               throw new ServletException("AA failed to even make a SAML Failure message because "+ee+"  Origianl problem: "+he);
+           }
        }catch (Exception e) {
            try{
                saml.fail(resp, new SAMLException(null, "AA got an Exception: "+e));