Yet fixing no-attr
authordousti <dousti@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 14 Jun 2002 18:11:41 +0000 (18:11 +0000)
committerdousti <dousti@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 14 Jun 2002 18:11:41 +0000 (18:11 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@120 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/AASaml.java

index c33ead1..6207509 100755 (executable)
@@ -68,19 +68,28 @@ public class AASaml {
        
        try{
 
-           SAMLSubject rSubject = new SAMLSubject(sub.getName(),
-                                              sub.getNameQualifier(),
-                                              sub.getFormat(),
-                                              sub.getConfirmationMethods(),
-                                              sub.getConfirmationData());
+           if(attrs == null || attrs.length == 0){
+               sResp = new SAMLResponse(reqID,
+                                        /* recipient URL*/ null,
+                                        /* sig */ null,
+                                        /* no attrs -> no assersion*/ null,
+                                        exception);            
+           }else{
+               Date now = new Date();
+               Date  then = null;
+
+               SAMLSubject rSubject = new SAMLSubject(sub.getName(),
+                                                      sub.getNameQualifier(),
+                                                      sub.getFormat(),
+                                                      sub.getConfirmationMethods(),
+                                                      sub.getConfirmationData());
             
-           SAMLStatement[] statements = new SAMLStatement[1];
-           statements[0] = new SAMLAttributeStatement(rSubject, attrs);
-           
+               SAMLCondition[] conditions = new SAMLCondition[1];
+               conditions[0] = new SAMLAudienceRestrictionCondition(policies);
 
-           Date now = new Date();
-           Date  then = null;
-           if(attrs != null && attrs.length > 0){
+               SAMLStatement[] statements = new SAMLStatement[1];
+               statements[0] = new SAMLAttributeStatement(rSubject, attrs);
+           
                long min = attrs[0].getLifetime();
                for(int i = 1; i < attrs.length; i++){
                    long t = attrs[i].getLifetime();
@@ -89,27 +98,22 @@ public class AASaml {
                }
                if(min > 0)
                    then = new Date(now.getTime() + min);
-           }
-           SAMLCondition[] conditions = new SAMLCondition[1];
-           conditions[0] = new SAMLAudienceRestrictionCondition(policies);
 
-           SAMLAssertion[] assertions= null;
-           if(attrs != null && attrs.length > 0){
                SAMLAssertion sAssertion = new SAMLAssertion(myName,
                                             now,
                                             then,
                                             conditions,
                                             statements,
                                             /* sig */ null);
-               assertions= new SAMLAssertion[1];
+               SAMLAssertion[] assertions= new SAMLAssertion[1];
                assertions[0] = sAssertion;
-           }
 
-           sResp = new SAMLResponse(reqID,
-                                    /* recipient URL*/ null,
-                                    /* sig */ null,
-                                    assertions,
-                                    exception);
+               sResp = new SAMLResponse(reqID,
+                                        /* recipient URL*/ null,
+                                        /* sig */ null,
+                                        assertions,
+                                        exception);
+           }
        }catch (SAMLException se) {
            ourSE = se;
        }finally{