String claimLocalName = claimType.getLocalName();
String claimNS = claimType.getNamespaceURI();
if ("ClaimType".equals(claimLocalName)) {
String claimTypeUri = claimType.getAttribute("Uri");
String claimTypeOptional = claimType.getAttribute("Optional");
RequestClaim requestClaim = new RequestClaim();
try {
requestClaim.setClaimType(new URI(claimTypeUri));
} catch (URISyntaxException e) {
LOG.log(
Level.WARNING,
"Cannot create URI from the given ClaimType attribute value " + claimTypeUri,
e
);
}
requestClaim.setOptional(Boolean.parseBoolean(claimTypeOptional));
return requestClaim;
} else if ("ClaimValue".equals(claimLocalName)) {
String claimTypeUri = claimType.getAttribute("Uri");
String claimTypeOptional = claimType.getAttribute("Optional");
RequestClaim requestClaim = new RequestClaim();
try {
requestClaim.setClaimType(new URI(claimTypeUri));
} catch (URISyntaxException e) {
LOG.log(
Level.WARNING,
"Cannot create URI from the given ClaimTye attribute value " + claimTypeUri,
e
);
}
Node valueNode = claimType.getFirstChild();
if (valueNode != null) {
if ("Value".equals(valueNode.getLocalName())) {
requestClaim.setClaimValue(valueNode.getTextContent().trim());
} else {
LOG.warning("Unsupported child element of ClaimValue element "
+ valueNode.getLocalName());
return null;
}
} else {
LOG.warning("No child element of ClaimValue element available");
return null;
}
requestClaim.setOptional(Boolean.parseBoolean(claimTypeOptional));
return requestClaim;
}
LOG.fine("Found unknown element: " + claimLocalName + " " + claimNS);