use of org.opensaml.core.xml.XMLObject in project ddf by codice.
the class AssertionConsumerService method extractSamlResponse.
private org.opensaml.saml.saml2.core.Response extractSamlResponse(String samlResponse) {
org.opensaml.saml.saml2.core.Response response = null;
try {
Document responseDoc = StaxUtils.read(new ByteArrayInputStream(samlResponse.getBytes(StandardCharsets.UTF_8)));
XMLObject responseXmlObject = OpenSAMLUtil.fromDom(responseDoc.getDocumentElement());
if (responseXmlObject instanceof org.opensaml.saml.saml2.core.Response) {
response = (org.opensaml.saml.saml2.core.Response) responseXmlObject;
}
} catch (XMLStreamException | WSSecurityException e) {
LOGGER.debug("Failed to convert AuthN response string to object.", e);
}
return response;
}
use of org.opensaml.core.xml.XMLObject in project midpoint by Evolveum.
the class MidpointAssertingPartyMetadataConverter method entityDescriptor.
private EntityDescriptor entityDescriptor(InputStream inputStream) {
Document document = document(inputStream);
Element element = document.getDocumentElement();
Unmarshaller unmarshaller = this.registry.getUnmarshallerFactory().getUnmarshaller(element);
if (unmarshaller == null) {
throw new Saml2Exception("Unsupported element of type " + element.getTagName());
}
try {
XMLObject object = unmarshaller.unmarshall(element);
if (object instanceof EntitiesDescriptor) {
return ((EntitiesDescriptor) object).getEntityDescriptors().get(0);
}
if (object instanceof EntityDescriptor) {
return (EntityDescriptor) object;
}
} catch (Exception ex) {
throw new Saml2Exception(ex);
}
throw new Saml2Exception("Unsupported element of type " + element.getTagName());
}
use of org.opensaml.core.xml.XMLObject in project spring-security by spring-projects.
the class OpenSaml4AuthenticationProvider method getAssertionAttributes.
private static Map<String, List<Object>> getAssertionAttributes(Assertion assertion) {
Map<String, List<Object>> attributeMap = new LinkedHashMap<>();
for (AttributeStatement attributeStatement : assertion.getAttributeStatements()) {
for (Attribute attribute : attributeStatement.getAttributes()) {
List<Object> attributeValues = new ArrayList<>();
for (XMLObject xmlObject : attribute.getAttributeValues()) {
Object attributeValue = getXmlObjectValue(xmlObject);
if (attributeValue != null) {
attributeValues.add(attributeValue);
}
}
attributeMap.put(attribute.getName(), attributeValues);
}
}
return attributeMap;
}
Aggregations