if(!isValid)
throw new GeneralSecurityException("Validation check failed");
String issuer = null;
IssuerInfoHolder idpIssuer = new IssuerInfoHolder(this.identityURL);
ProtocolContext protocolContext = new HTTPContext(request,response, context);
//Create the request/response
SAML2HandlerRequest saml2HandlerRequest =
new DefaultSAML2HandlerRequest(protocolContext,
idpIssuer.getIssuer(), samlObject,
HANDLER_TYPE.IDP);
saml2HandlerRequest.setRelayState(relayState);
Map<String, Object> requestOptions = new HashMap<String, Object>();
requestOptions.put("ROLE_GENERATOR", rg);
saml2HandlerRequest.setOptions(requestOptions);
SAML2HandlerResponse saml2HandlerResponse = new DefaultSAML2HandlerResponse();
Set<SAML2Handler> handlers = chain.handlers();
if(samlObject instanceof StatusResponseType)
{
statusResponseType = (StatusResponseType) samlObject;
issuer = statusResponseType.getIssuer().getValue();
webRequestUtil.isTrusted(issuer);
if(handlers != null)
{
for(SAML2Handler handler: handlers)
{
handler.handleStatusResponseType(saml2HandlerRequest, saml2HandlerResponse);
}
}
}
else
throw new RuntimeException("Unknown type:" + samlObject.getClass().getName());
samlResponse = saml2HandlerResponse.getResultingDocument();
relayState = saml2HandlerResponse.getRelayState();
destination = saml2HandlerResponse.getDestination();
}
catch(Exception e)
{
throw new RuntimeException(e);
}
}
else
//Send valid saml response after processing the request
if(samlRequestMessage != null)
{
//Get the SAML Request Message
RequestAbstractType requestAbstractType = null;
StatusResponseType statusResponseType = null;
try
{
samlObject = webRequestUtil.getSAMLObject(samlRequestMessage);
boolean isPost = webRequestUtil.hasSAMLRequestInPostProfile();
boolean isValid = validate(request.getRemoteAddr(),
request.getQueryString(),
new SessionHolder(samlRequestMessage, null), isPost);
if(!isValid)
throw new GeneralSecurityException("Validation check failed");
String issuer = null;
IssuerInfoHolder idpIssuer = new IssuerInfoHolder(this.identityURL);
ProtocolContext protocolContext = new HTTPContext(request,response, context);
//Create the request/response
SAML2HandlerRequest saml2HandlerRequest =
new DefaultSAML2HandlerRequest(protocolContext,
idpIssuer.getIssuer(), samlObject,
HANDLER_TYPE.IDP);
saml2HandlerRequest.setRelayState(relayState);
Map<String, Object> requestOptions = new HashMap<String, Object>();
requestOptions.put(GeneralConstants.ROLE_GENERATOR, rg);