Skip to content

Commit 25fab2e

Browse files
committed
Avoid looping over assertions (there will always be just one there)
1 parent 56def43 commit 25fab2e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

core/src/main/java/com/onelogin/saml2/authn/SamlResponse.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,9 @@ public boolean isValid(String requestId) {
243243

244244
// Check SAML version on the assertion
245245
NodeList assertions = queryAssertion("");
246-
for(int i = 0; i < assertions.getLength(); i++) {
247-
Node versionAttribute = assertions.item(i).getAttributes().getNamedItem("Version");
248-
if (versionAttribute == null || !"2.0".equals(versionAttribute.getNodeValue())) {
249-
throw new ValidationError("Unsupported SAML Version on Assertion.", ValidationError.UNSUPPORTED_SAML_VERSION);
250-
}
246+
Node versionAttribute = assertions.item(0).getAttributes().getNamedItem("Version");
247+
if (versionAttribute == null || !"2.0".equals(versionAttribute.getNodeValue())) {
248+
throw new ValidationError("Unsupported SAML Version on Assertion.", ValidationError.UNSUPPORTED_SAML_VERSION);
251249
}
252250

253251
if (!this.encrypted && settings.getWantAssertionsEncrypted()) {

0 commit comments

Comments
 (0)