Now we follow SAML semantics for returning no attributes
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / aa / AASaml.java
index 61a8b32..30dd93a 100755 (executable)
@@ -24,11 +24,17 @@ public class AASaml {
     SAMLBinding binding;
     
 
-    public AASaml(HttpServletRequest req, String myName)
-       throws SAMLException{
+    public AASaml(String myName){
+       
+       Init.init();
 
        binding = SAMLBindingFactory.getInstance(protocol, policies);
        this.myName = myName;
+    }
+
+    public void receive(HttpServletRequest req)
+       throws SAMLException{
+
        sharName=new StringBuffer();
        SAMLRequest sReq = binding.receive(req, sharName);
        SAMLAttributeQuery q = (SAMLAttributeQuery)sReq.getQuery();
@@ -36,7 +42,7 @@ public class AASaml {
        reqID = sReq.getRequestId();
        sub = q.getSubject();
     }
-       
+
     public String getHandle(){
        return sub.getName();
     }
@@ -68,9 +74,12 @@ public class AASaml {
                                               sub.getConfirmationMethods(),
                                               sub.getConfirmationData());
             
-           SAMLStatement sStatement = new SAMLAttributeStatement(rSubject, attrs);
-           SAMLStatement[] statements = new SAMLStatement[1];
-           statements[0] = sStatement;
+           SAMLStatement[] statements = null;
+           if(attrs != null && attrs.length > 0){
+               statements = new SAMLStatement[1];
+               statements[0] = new SAMLAttributeStatement(rSubject, attrs);
+           }
+
            Date now = new Date();
            Date  then = null;
            if(attrs != null && attrs.length > 0){
@@ -106,4 +115,9 @@ public class AASaml {
        }
     }
 
+    public void fail(HttpServletResponse resp, SAMLException exception)
+       throws IOException{
+
+       binding.respond(resp, null, exception);
+    }
 }