* @param assertion an {@code Element} representing the SAMLV2.0 assertion to be validated.
* @return the constructed {@code WSTrustRequestContext} instance.
* @throws Exception if an error occurs while creating the validating context.
*/
private WSTrustRequestContext createValidatingContext(Element assertion) throws Exception {
RequestSecurityToken request = new RequestSecurityToken();
request.setRequestType(URI.create(WSTrustConstants.VALIDATE_REQUEST));
request.setTokenType(URI.create(WSTrustConstants.STATUS_TYPE));
ValidateTargetType validateTarget = new ValidateTargetType();
validateTarget.add(assertion);
request.setValidateTarget(validateTarget);
// we need to set the request document in the request object for the test.
DOMSource requestSource = (DOMSource) this.createSourceFromRequest(request);
request.setRSTDocument((Document) requestSource.getNode());
WSTrustRequestContext context = new WSTrustRequestContext(request, new TestPrincipal("sguilhen"));
return context;
}