public void validateToken(WSTrustRequestContext context) throws WSTrustException
{
// get the SAML assertion that must be validated.
ValidateTargetType validateTarget = context.getRequestSecurityToken().getValidateTarget();
if(validateTarget == null)
throw new WSTrustException("Invalid validate message: missing required ValidateTarget");
String code = WSTrustConstants.STATUS_CODE_VALID;
String reason = "SAMLV2.0 Assertion successfuly validated";
AssertionType assertion = null;
Object assertionObj = validateTarget.getAny();
if(assertionObj instanceof JAXBElement)
{
JAXBElement<AssertionType> assertionType = (JAXBElement<AssertionType>) validateTarget.getAny();
assertion = assertionType.getValue();
}
else if(assertionObj instanceof Element)
{
Element assertionElement = (Element) assertionObj;
if(!this.isAssertion(assertionElement))
{
code = WSTrustConstants.STATUS_CODE_INVALID;
reason = "Validation failure: supplied token is not a SAMLV2.0 Assertion";
}
else
{
try
{
assertion = SAMLUtil.fromElement((Element) assertionObj);
}
catch (JAXBException e)
{
throw new WSTrustException("Unmarshalling error:",e);
}
}
}
// check the assertion lifetime.