if (certs != null) {
returnCert[0] = certs[0];
return certs[0].getSubjectDN();
} else if(ut != null){
WSUsernameTokenPrincipal principal = new WSUsernameTokenPrincipal(
ut.getName(), ut.isHashed());
principal.setNonce(ut.getNonce());
principal.setPassword(ut.getPassword());
principal.setCreatedTime(ut.getCreated());
return principal;
} else if (dkt != null) {
WSDerivedKeyTokenPrincipal principal = new WSDerivedKeyTokenPrincipal(dkt.getID());
principal.setNonce(dkt.getNonce());
principal.setLabel(dkt.getLabel());
principal.setLength(dkt.getLength());
principal.setOffset(dkt.getOffset());
String basetokenId = dkt.getSecuityTokenReference().getReference().getURI().substring(1);
principal.setBasetokenId(basetokenId);
return principal;
} else if(samlKi != null) {
final SAMLAssertion assertion = samlKi.getAssertion();
CustomTokenPrincipal principal = new CustomTokenPrincipal(assertion.getId());
principal.setTokenObject(assertion);
return principal;
} else if(secretKey != null) {
//This is the custom key scenario
CustomTokenPrincipal principal = new CustomTokenPrincipal(customTokenId);
return principal;