mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-8037: Fix attribute detection, tested to work with onelogin.com
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 23de431f96)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
b528047fb6
commit
1a7f76ac77
|
|
@ -240,22 +240,27 @@ public class SAML2LoginAPIAuthenticatorCmd extends BaseCmd implements APIAuthent
|
|||
}
|
||||
}
|
||||
|
||||
AttributeStatement attributeStatement = assertion.getAttributeStatements().get(0);
|
||||
List<Attribute> attributes = attributeStatement.getAttributes();
|
||||
|
||||
// Try capturing standard LDAP attributes
|
||||
for (Attribute attribute: attributes) {
|
||||
String attributeName = attribute.getName();
|
||||
String attributeValue = attribute.getAttributeValues().get(0).getDOM().getTextContent();
|
||||
if (attributeName.equalsIgnoreCase("uid") && uniqueUserId == null) {
|
||||
username = attributeValue;
|
||||
uniqueUserId = SAMLUtils.createSAMLId(username);
|
||||
} else if (attributeName.equalsIgnoreCase("givenName")) {
|
||||
firstName = attributeValue;
|
||||
} else if (attributeName.equalsIgnoreCase(("sn"))) {
|
||||
lastName = attributeValue;
|
||||
} else if (attributeName.equalsIgnoreCase("mail")) {
|
||||
email = attributeValue;
|
||||
List<AttributeStatement> attributeStatements = assertion.getAttributeStatements();
|
||||
if (attributeStatements != null && attributeStatements.size() > 0) {
|
||||
for (AttributeStatement attributeStatement: attributeStatements) {
|
||||
if (attributeStatement == null) {
|
||||
continue;
|
||||
}
|
||||
// Try capturing standard LDAP attributes
|
||||
for (Attribute attribute: attributeStatement.getAttributes()) {
|
||||
String attributeName = attribute.getName();
|
||||
String attributeValue = attribute.getAttributeValues().get(0).getDOM().getTextContent();
|
||||
if (attributeName.equalsIgnoreCase("uid") && uniqueUserId == null) {
|
||||
username = attributeValue;
|
||||
uniqueUserId = SAMLUtils.createSAMLId(username);
|
||||
} else if (attributeName.equalsIgnoreCase("givenName")) {
|
||||
firstName = attributeValue;
|
||||
} else if (attributeName.equalsIgnoreCase(("sn"))) {
|
||||
lastName = attributeValue;
|
||||
} else if (attributeName.equalsIgnoreCase("mail")) {
|
||||
email = attributeValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue