diff --git a/saml-core/src/main/java/org/keycloak/saml/common/DefaultPicketLinkLogger.java b/saml-core/src/main/java/org/keycloak/saml/common/DefaultPicketLinkLogger.java index 17c59445c3..0d781c66f3 100755 --- a/saml-core/src/main/java/org/keycloak/saml/common/DefaultPicketLinkLogger.java +++ b/saml-core/src/main/java/org/keycloak/saml/common/DefaultPicketLinkLogger.java @@ -441,14 +441,10 @@ public class DefaultPicketLinkLogger implements PicketLinkLogger { return new RuntimeException(expectedXsi); } - /* - *(non-Javadoc) - * - *@see org.picketlink.identity.federation.PicketLinkLogger#parserExpectedTag(java.lang.String, java.lang.String) - */ @Override - public RuntimeException parserExpectedTag(String tag, String foundElementTag) { - return new RuntimeException(ErrorCodes.EXPECTED_TAG + tag + ". Found <" + foundElementTag + ">"); + public RuntimeException parserExpectedTag(String tag, String foundElementTag, Integer line, Integer column) { + return new RuntimeException(ErrorCodes.EXPECTED_TAG + " " + tag + ". Found " + foundElementTag + + " at line " + line.toString() + ", column " + column); } @Override @@ -2386,7 +2382,7 @@ public class DefaultPicketLinkLogger implements PicketLinkLogger { @Override public ProcessingException samlExtensionUnknownChild(Class clazz) { - return new ProcessingException("Unknown child type specified for extension: " + return new ProcessingException("Unknown child type specified for extension: " + (clazz == null ? "" : clazz.getSimpleName()) + "."); } diff --git a/saml-core/src/main/java/org/keycloak/saml/common/PicketLinkLogger.java b/saml-core/src/main/java/org/keycloak/saml/common/PicketLinkLogger.java index c36b620083..1f7353a897 100755 --- a/saml-core/src/main/java/org/keycloak/saml/common/PicketLinkLogger.java +++ b/saml-core/src/main/java/org/keycloak/saml/common/PicketLinkLogger.java @@ -291,10 +291,12 @@ public interface PicketLinkLogger { /** * @param tag * @param foundElementTag + * @param line + * @param column * * @return */ - RuntimeException parserExpectedTag(String tag, String foundElementTag); + RuntimeException parserExpectedTag(String tag, String foundElementTag, Integer line, Integer column); /** * @param ns @@ -1229,4 +1231,4 @@ public interface PicketLinkLogger { ProcessingException samlAssertionWrongAudience(String serviceURL); ProcessingException samlExtensionUnknownChild(Class clazz); -} \ No newline at end of file +} diff --git a/saml-core/src/main/java/org/keycloak/saml/common/util/StaxParserUtil.java b/saml-core/src/main/java/org/keycloak/saml/common/util/StaxParserUtil.java index 32ee397913..2eda10dd23 100755 --- a/saml-core/src/main/java/org/keycloak/saml/common/util/StaxParserUtil.java +++ b/saml-core/src/main/java/org/keycloak/saml/common/util/StaxParserUtil.java @@ -880,8 +880,10 @@ public class StaxParserUtil { @Deprecated public static void validate(StartElement startElement, String tag) { String foundElementTag = StaxParserUtil.getElementName(startElement); - if (!tag.equals(foundElementTag)) - throw logger.parserExpectedTag(tag, foundElementTag); + if (!tag.equals(foundElementTag)) { + Location location = startElement.getLocation(); + throw logger.parserExpectedTag(tag, foundElementTag, location.getLineNumber(), location.getColumnNumber()); + } } /** @@ -894,8 +896,10 @@ public class StaxParserUtil { */ public static void validate(StartElement startElement, QName tag) { if (! Objects.equals(startElement.getName(), tag)) { - String foundElementTag = StaxParserUtil.getElementName(startElement); - throw logger.parserExpectedTag(tag.getLocalPart(), foundElementTag); + Location location = startElement.getLocation(); + throw logger.parserExpectedTag( + tag.toString(), startElement.getName().toString(), + location.getLineNumber(), location.getColumnNumber()); } } @@ -943,4 +947,4 @@ public class StaxParserUtil { } } } -} \ No newline at end of file +}