/** * Sends a HTML form redirect. Builds an HTML fragment as content containing a form * which sends itself after loading. Usefull for URLs * with a long parameter list. All URL parameters are encoded as POST body * parameters. */ public static void sendFormPostRedirect(String redirectUrl, HttpServletResponse response) { sendFormPostRedirect(redirectUrl, response, URLUtils.parseQueryStringFromUrl(redirectUrl)); }
/** * Initiates redirect based on the length of the redirection URL. * Chooses between location header redirect or form POST redirect. */ public static void sendRedirect(String redirectUrl, HttpServletResponse response) { // max length of url in ie is 2.083 if (redirectUrl.length() > 2083) { sendFormPostRedirect(redirectUrl, response); return; } sendLocationHeaderRedirect(redirectUrl, response); }
public ActionForward execute(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception { LicenseBrokerClientResponseForm lbcrForm = (LicenseBrokerClientResponseForm) form; HTTPClientFactory clientFactory = getHttpClientFactory(); try { if (lbcrForm.isInitialCall()) { PreconditionContext precCtx = getPreconditionContext(request); IdentifyPrecondition idPrec = lookupIdentifyPrecondition(request); String wasUrl = getWasUrl(idPrec); SAMLResponse samlResponse = new WAS1_1Adapter(wasUrl, clientFactory).getSAMLResponse("", PasswordAuthenticationMethod.URN, idPrec.getCredential()); URL wssUrl = getFacadeProperties(request).getSecurityClient().getURL(); LicensePrecondition licPrec = (LicensePrecondition) getPreconditionHandler(request.getSession()).currentPrecondition(); String returnUrlParamValue = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/LicRefPreconditionAction.do"; returnUrlParamValue += ";jsessionid=" + request.getSession().getId(); Map<String, Iterable<String>> params = new HashMap<String, Iterable<String>>(); params.put("ticket", Arrays.asList(samlResponse.getTicket())); params.put("WSS", Arrays.asList(wssUrl.toExternalForm())); params.put("returnURL", Arrays.asList(returnUrlParamValue)); ServletUtils.sendFormPostRedirect(licPrec.getRedirectUrl(), response, params); return null; } IteratingPreconditionHandler precHandler = getPreconditionHandler(request.getSession()); return handleLicensePrecondition(mapping, lbcrForm, (LicensePrecondition) precHandler.currentPrecondition()); } catch (Exception e) { ActionMessages lErrors = new ActionMessages(); lErrors.add("licRef.failed", new ActionMessage("failure.text.licRefFailed")); saveErrors(request, lErrors); return mapping.findForward(FacadeAction.FAILURE_FORWARD); } }