}
try {
Element tokenElement = (Element) tokenObject;
AssertionType assertion = SAMLUtil.fromElement(tokenElement);
SubjectType subject = assertion.getSubject();
if (subject != null) {
BaseIDAbstractType baseID = subject.getSubType().getBaseID();
if (baseID != null && baseID instanceof NameIDType) {
NameIDType nameID = (NameIDType) baseID;
Principal mappedPrincipal = new SimplePrincipal(nameID.getValue());
result.setMappedObject(mappedPrincipal);
logger.trace("Mapped principal = " + mappedPrincipal);