LOG.debug("Request body too big to save during authentication");
response.sendError(HttpServletResponse.SC_FORBIDDEN,
sm.getString("authenticator.requestBodyTooBig"));
return false;
}
FederationProcessor wfProc = new FederationProcessorImpl();
redirectToIssuer(request, response, wfProc);
return false;
}
}
return true;
}
// Is this the re-submit of the original request URI after successful
// authentication? If so, forward the *original* request instead.
if (matchRequest(request)) {
session = request.getSessionInternal(true);
if (LOG.isDebugEnabled()) {
LOG.debug("Restore request from session '"
+ session.getIdInternal() + "'");
}
principal = (Principal)session.getNote(Constants.FORM_PRINCIPAL_NOTE);
register(request, response, principal,
FederationConstants.WSFED_METHOD, null, null);
if (restoreRequest(request, session)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Proceed to restored request");
}
return true;
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Restore of original request failed");
}
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return false;
}
}
// Acquire references to objects we will need to evaluate
/*
* MessageBytes uriMB = MessageBytes.newInstance(); CharChunk uriCC =
* uriMB.getCharChunk(); uriCC.setLimit(-1);
*/
// String contextPath = request.getContextPath();
String requestURI = request.getDecodedRequestURI();
String wa = request.getParameter("wa");
// Unauthenticated -> redirect
if (wa == null) {
session = request.getSessionInternal(true);
if (LOG.isDebugEnabled()) {
LOG.debug("Save request in session '" + session.getIdInternal() + "'");
}
try {
saveRequest(request, session);
} catch (IOException ioe) {
LOG.debug("Request body too big to save during authentication");
response.sendError(HttpServletResponse.SC_FORBIDDEN,
sm.getString("authenticator.requestBodyTooBig"));
return false;
}
FederationProcessor wfProc = new FederationProcessorImpl();
redirectToIssuer(request, response, wfProc);
return false;
}
// Check whether it is the signin request, validate the token.
// If failed, redirect to the error page if they are not correct
String wresult = request.getParameter("wresult");
FederationResponse wfRes = null;
if (wa.equals(FederationConstants.ACTION_SIGNIN)) {
if (LOG.isDebugEnabled()) {
LOG.debug("SignIn request found");
LOG.debug("SignIn action...");
}
if (wresult == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("SignIn request must contain wresult");
}
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return false;
} else {
request.getResponse().sendAcknowledgement();
// processSignInRequest
if (LOG.isDebugEnabled()) {
LOG.debug("Process SignIn request");
LOG.debug("wresult=\n" + wresult);
}
FederationRequest wfReq = new FederationRequest();
wfReq.setWa(wa);
wfReq.setWresult(wresult);
X509Certificate certs[] =
(X509Certificate[])request.getAttribute("javax.servlet.request.X509Certificate");
wfReq.setCerts(certs);
String contextName = request.getServletContext().getContextPath();
if (contextName == null || contextName.isEmpty()) {
contextName = "/";
}
FederationContext fedConfig = getContextConfiguration(contextName);
FederationProcessor wfProc = new FederationProcessorImpl();
try {
wfRes = wfProc.processRequest(wfReq, fedConfig);
} catch (ProcessingException ex) {
LOG.error("Federation processing failed: " + ex.getMessage());
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return false;
}