String role = null;
try{
Assertion assertion = AssertionUtil.fromElement(assertionEle);
Subject subject = null;
NameID nameID = null;
// SAML 2.0
try {
subject = assertion.getSubject();
} catch (Exception ex){
subject = null;
}
if (subject != null){
nameID = subject.getNameId();
}
List<Object> statements = assertion.getStatements();
for (Object s : statements){
if (s instanceof AttributeStatement){
List<Attribute> samlAttrs = ((AttributeStatement)s).getAttributes();
for (Attribute samlAttr : samlAttrs){
String attrName = samlAttr.getName();
String attrValue = ((Element)samlAttr.getAttributes().iterator().next()).getFirstChild().getNodeValue();
if (attrName.equals("ActAs")){
actAs = attrValue;
} else if (attrName.equals("Role")){
role = attrValue;
}
}
// for SAML 1.0, 1.1
if (subject == null){
subject = ((AttributeStatement)s).getSubject();
}
} else if (s instanceof AuthenticationStatement){
subject = ((AuthenticationStatement)s).getSubject();
}
}
// Get the user identifier in the Subject:
if (nameID != null){
//SAML 2.0 case
name = nameID.getValue();
}else{
// SAML 1.0, 1.1. case
NameIdentifier nameIdentifier = subject.getNameIdentifier();
if (nameIdentifier != null){
name = nameIdentifier.getValue();
}
}
}catch (Exception ex){