AbstractToken abstractToken) throws WSSPolicyException {
if (!(tokenSecurityEvent instanceof IssuedTokenSecurityEvent)) {
throw new WSSPolicyException("Expected a IssuedTokenSecurityEvent but got " + tokenSecurityEvent.getClass().getName());
}
IssuedToken issuedToken = (IssuedToken) abstractToken;
IssuedTokenSecurityEvent<? extends SecurityToken> issuedTokenSecurityEvent
= (IssuedTokenSecurityEvent<? extends SecurityToken>) tokenSecurityEvent;
try {
if (issuedToken.getIssuerName() != null &&
!issuedToken.getIssuerName().equals(issuedTokenSecurityEvent.getIssuerName())) {
setErrorMessage("IssuerName in Policy (" + issuedToken.getIssuerName() +
") didn't match with the one in the IssuedToken (" + issuedTokenSecurityEvent.getIssuerName() + ")");
return false;
}
if (issuedToken.getRequestSecurityTokenTemplate() != null) {
if (issuedTokenSecurityEvent instanceof SamlTokenSecurityEvent) {
SamlTokenSecurityEvent samlTokenSecurityEvent = (SamlTokenSecurityEvent) issuedTokenSecurityEvent;
String errorMsg = checkIssuedTokenTemplate(issuedToken.getRequestSecurityTokenTemplate(), samlTokenSecurityEvent);
if (errorMsg != null) {
setErrorMessage(errorMsg);
return false;
}
} else if (issuedTokenSecurityEvent instanceof KerberosTokenSecurityEvent) {
KerberosTokenSecurityEvent kerberosTokenSecurityEvent = (KerberosTokenSecurityEvent) issuedTokenSecurityEvent;
String errorMsg = checkIssuedTokenTemplate(issuedToken.getRequestSecurityTokenTemplate(), kerberosTokenSecurityEvent);
if (errorMsg != null) {
setErrorMessage(errorMsg);
return false;
}
}
}
Element claims = issuedToken.getClaims();
if (claims != null && issuedTokenSecurityEvent instanceof SamlTokenSecurityEvent) {
String errorMsg =
validateClaims((Element) claims, (SamlTokenSecurityEvent)issuedTokenSecurityEvent);
if (errorMsg != null) {
setErrorMessage(errorMsg);