Add information to SAML parser exceptions
Include namespaces and location of expected/found elements Closes #29698 Signed-off-by: esagalara <erik.sagalara@gmail.com>
This commit is contained in:
parent
cdfd46f191
commit
42eec96f61
3 changed files with 17 additions and 15 deletions
|
@ -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 ? "<null>" : clazz.getSimpleName())
|
||||
+ ".");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue