in plugins/core/src/main/java/org/apache/cxf/fediz/core/saml/SAMLTokenValidator.java [315:373]
protected List<Claim> parseClaimsInAssertion(
org.opensaml.saml.saml1.core.Assertion assertion) {
List<org.opensaml.saml.saml1.core.AttributeStatement> attributeStatements = assertion
.getAttributeStatements();
if (attributeStatements == null || attributeStatements.isEmpty()) {
LOG.debug("No attribute statements found");
return Collections.emptyList();
}
List<Claim> collection = new ArrayList<>();
Map<String, Claim> claimsMap = new HashMap<>();
for (org.opensaml.saml.saml1.core.AttributeStatement statement : attributeStatements) {
LOG.debug("parsing statement: {}", statement.getElementQName());
List<org.opensaml.saml.saml1.core.Attribute> attributes = statement
.getAttributes();
for (org.opensaml.saml.saml1.core.Attribute attribute : attributes) {
LOG.debug("parsing attribute: {}", attribute.getAttributeName());
Claim c = new Claim();
c.setIssuer(assertion.getIssuer());
if (attribute.getAttributeNamespace() != null) {
URI attrName = parseAttributeName(attribute.getAttributeName());
if (attrName.isAbsolute()) {
// Workaround for CXF-4484
c.setClaimType(attrName);
if (attribute.getAttributeName().startsWith(attribute.getAttributeNamespace())) {
LOG.info("AttributeName fully qualified '" + attribute.getAttributeName()
+ "' but does match with AttributeNamespace '"
+ attribute.getAttributeNamespace() + "'");
} else {
LOG.warn("AttributeName fully qualified '" + attribute.getAttributeName()
+ "' but does NOT match with AttributeNamespace (ignored) '"
+ attribute.getAttributeNamespace() + "'");
}
} else {
if (attribute.getAttributeNamespace().endsWith("/")) {
c.setClaimType(URI.create(attribute.getAttributeNamespace()
+ attrName.toString()));
} else {
c.setClaimType(URI.create(attribute.getAttributeNamespace()
+ "/" + attrName.toString()));
}
}
} else {
c.setClaimType(parseAttributeName(attribute.getAttributeName()));
}
List<String> valueList = new ArrayList<>();
for (XMLObject attributeValue : attribute.getAttributeValues()) {
Element attributeValueElement = attributeValue.getDOM();
String value = attributeValueElement.getTextContent();
LOG.debug(" [{}]", value);
valueList.add(value);
}
mergeClaimToMap(claimsMap, c, valueList);
}
}
collection.addAll(claimsMap.values());
return collection;
}