private Map<String, Object> getUserAttributes(ResponseImpl samlResponse) { Map<String, Object> userAttributes = new HashMap<>(); // Add 'Subject' Assertion assertion = samlResponse.getAssertions().get(0); userAttributes.put( SAMLConstants.SAML2_ASSERTION_SUBJECT, assertion.getSubject().getNameID().getValue()); // Add other user attributes. List<AttributeStatement> attributeStatements = assertion.getAttributeStatements(); if (attributeStatements != null) { for (AttributeStatement attributeStatement : attributeStatements) { List<Attribute> attributes = attributeStatement.getAttributes(); for (Attribute attribute : attributes) { userAttributes.put( attribute.getName(), attribute.getAttributeValues().get(0).getDOM().getTextContent()); } } } return userAttributes; }