{
principal = (GenericPrincipal) process(request,response);
if(principal == null)
{
AuthnRequestType authnRequest = spUtil.createSAMLRequest(serviceURL, identityURL);
sendRequestToIDP(authnRequest, relayState, response);
return false;
}
String username = principal.getName();
String password = ServiceProviderSAMLContext.EMPTY_PASSWORD;
//Map to JBoss specific principal
if(spConfiguration.getServerEnvironment().equalsIgnoreCase("JBOSS"))
{
GenericPrincipal gp = (GenericPrincipal) principal;
//Push a context
ServiceProviderSAMLContext.push(username, Arrays.asList(gp.getRoles()));
principal = context.getRealm().authenticate(username, password);
ServiceProviderSAMLContext.clear();
}
session.setNote(Constants.SESS_USERNAME_NOTE, username);
session.setNote(Constants.SESS_PASSWORD_NOTE, password);
request.setUserPrincipal(principal);
register(request, response, principal, Constants.FORM_METHOD, username, password);
return true;
}
catch(AssertionExpiredException aie)
{
log.debug("Assertion has expired. Issuing a new saml2 request to the IDP");
try
{
AuthnRequestType authnRequest = spUtil.createSAMLRequest(serviceURL, identityURL);
sendRequestToIDP(authnRequest, relayState, response);
}
catch (Exception e)
{
log.trace("Exception:",e);