@@ -184,7 +184,7 @@ public boolean isValid(String requestId) {
184184 if (requestId != null && !ObjectUtils .equals (responseInResponseTo , requestId )) {
185185 throw new Exception ("The InResponseTo of the Response: " + responseInResponseTo
186186 + ", does not match the ID of the AuthNRequest sent by the SP: " + requestId );
187- }
187+ }
188188
189189 if (!this .encrypted && settings .getWantAssertionsEncrypted ()) {
190190 throw new Exception ("The assertion of the Response is not encrypted and the SP requires it" );
@@ -286,68 +286,68 @@ public boolean isValid(String requestId) {
286286 }
287287 }
288288
289- // Check SubjectConfirmation, at least one SubjectConfirmation must be valid
289+ // Check SubjectConfirmation, at least one SubjectConfirmation must be valid
290290 private void validateSubjectConfirmation (String responseInResponseTo ) throws Exception {
291291 final List <SubjectConfirmationIssue > validationIssues = new ArrayList <>();
292- boolean validSubjectConfirmation = false ;
293- NodeList subjectConfirmationNodes = this .queryAssertion ("/saml:Subject/saml:SubjectConfirmation" );
294- for (int i = 0 ; i < subjectConfirmationNodes .getLength (); i ++) {
295- Node scn = subjectConfirmationNodes .item (i );
296-
297- Node method = scn .getAttributes ().getNamedItem ("Method" );
298- if (method != null && !method .getNodeValue ().equals (Constants .CM_BEARER )) {
299- continue ;
300- }
292+ boolean validSubjectConfirmation = false ;
293+ NodeList subjectConfirmationNodes = this .queryAssertion ("/saml:Subject/saml:SubjectConfirmation" );
294+ for (int i = 0 ; i < subjectConfirmationNodes .getLength (); i ++) {
295+ Node scn = subjectConfirmationNodes .item (i );
296+
297+ Node method = scn .getAttributes ().getNamedItem ("Method" );
298+ if (method != null && !method .getNodeValue ().equals (Constants .CM_BEARER )) {
299+ continue ;
300+ }
301301
302- NodeList subjectConfirmationDataNodes = scn .getChildNodes ();
303- for (int c = 0 ; c < subjectConfirmationDataNodes .getLength (); c ++) {
304- if (subjectConfirmationDataNodes .item (c ).getLocalName () != null && subjectConfirmationDataNodes .item (c ).getLocalName ().equals ("SubjectConfirmationData" )) {
302+ NodeList subjectConfirmationDataNodes = scn .getChildNodes ();
303+ for (int c = 0 ; c < subjectConfirmationDataNodes .getLength (); c ++) {
304+ if (subjectConfirmationDataNodes .item (c ).getLocalName () != null && subjectConfirmationDataNodes .item (c ).getLocalName ().equals ("SubjectConfirmationData" )) {
305305
306- Node recipient = subjectConfirmationDataNodes .item (c ).getAttributes ().getNamedItem ("Recipient" );
306+ Node recipient = subjectConfirmationDataNodes .item (c ).getAttributes ().getNamedItem ("Recipient" );
307307 if (recipient == null ) {
308308 validationIssues .add (new SubjectConfirmationIssue (i , "SubjectConfirmationData doesn't contain a Recipient" ));
309309 continue ;
310310 }
311311
312312 if (!recipient .getNodeValue ().equals (currentUrl )) {
313313 validationIssues .add (new SubjectConfirmationIssue (i , "SubjectConfirmationData doesn't match a valid Recipient" ));
314- continue ;
315- }
314+ continue ;
315+ }
316316
317- Node inResponseTo = subjectConfirmationDataNodes .item (c ).getAttributes ().getNamedItem ("InResponseTo" );
317+ Node inResponseTo = subjectConfirmationDataNodes .item (c ).getAttributes ().getNamedItem ("InResponseTo" );
318318 if (inResponseTo == null && responseInResponseTo != null ||
319319 inResponseTo != null && !inResponseTo .getNodeValue ().equals (responseInResponseTo )) {
320320 validationIssues .add (new SubjectConfirmationIssue (i , "SubjectConfirmationData has an invalid InResponseTo value" ));;
321- continue ;
322- }
321+ continue ;
322+ }
323323
324-
325- Node notOnOrAfter = subjectConfirmationDataNodes .item (c ).getAttributes ().getNamedItem ("NotOnOrAfter" );
324+
325+ Node notOnOrAfter = subjectConfirmationDataNodes .item (c ).getAttributes ().getNamedItem ("NotOnOrAfter" );
326326 if (notOnOrAfter == null ) {
327327 validationIssues .add (new SubjectConfirmationIssue (i , "SubjectConfirmationData doesn't contain a NotOnOrAfter attribute" ));
328328 continue ;
329329 }
330330
331- DateTime noa = Util .parseDateTime (notOnOrAfter .getNodeValue ());
332- if (noa .isEqualNow () || noa .isBeforeNow ()) {
331+ DateTime noa = Util .parseDateTime (notOnOrAfter .getNodeValue ());
332+ if (noa .isEqualNow () || noa .isBeforeNow ()) {
333333 validationIssues .add (new SubjectConfirmationIssue (i , "SubjectConfirmationData is no longer valid" ));
334- continue ;
335- }
334+ continue ;
335+ }
336336
337- Node notBefore = subjectConfirmationDataNodes .item (c ).getAttributes ().getNamedItem ("NotBefore" );
338- if (notBefore != null ) {
339- DateTime nb = Util .parseDateTime (notBefore .getNodeValue ());
340- if (nb .isAfterNow ()) {
337+ Node notBefore = subjectConfirmationDataNodes .item (c ).getAttributes ().getNamedItem ("NotBefore" );
338+ if (notBefore != null ) {
339+ DateTime nb = Util .parseDateTime (notBefore .getNodeValue ());
340+ if (nb .isAfterNow ()) {
341341 validationIssues .add (new SubjectConfirmationIssue (i , "SubjectConfirmationData is not yet valid" ));
342- continue ;
343- }
344- }
345- validSubjectConfirmation = true ;
342+ continue ;
346343 }
347344 }
345+ validSubjectConfirmation = true ;
348346 }
347+ }
348+ }
349349
350- if (!validSubjectConfirmation ) {
350+ if (!validSubjectConfirmation ) {
351351 throw new Exception (SubjectConfirmationIssue .prettyPrintIssues (validationIssues ));
352352 }
353353 }
0 commit comments