public static void handleException(Throwable t, HttpServletRequest request, HttpServletResponse response, String page) throws IOException, ServletException { request.setAttribute("exception", t); fwd(request, response, page); } }
public void handleError(PresentableState state, Throwable t) throws IOException, ServletException { state.getResponse().setHeader("X-Frame-Options", "DENY"); JSPUtil.handleException(t, state.getRequest(), state.getResponse(), ERROR_PAGE); }
JSPUtil.handleException(new RuntimeException("Please specify a gateway name."), request, response, configurationReader.getErrorUrl()); return; JSPUtil.handleException(new RuntimeException("Please specify a portal user name."), request, response, configurationReader.getErrorUrl()); return; JSPUtil.handleException(new RuntimeException("Please specify a contact email address for community" + " user account."), request, response, configurationReader.getErrorUrl()); return; JSPUtil.handleException(t, request, response, configurationReader.getErrorUrl()); return; request.setAttribute("action", ACTION_REDIRECT_VALUE); log.info("1.b. Showing redirect page."); JSPUtil.fwd(request, response, configurationReader.getPortalRedirectUrl());
public void handleError(PresentableState state, Throwable t) throws IOException, ServletException { AuthorizedState aState = (AuthorizedState) state; state.getResponse().setHeader("X-Frame-Options", "DENY"); state.getRequest().setAttribute("client", aState.getTransaction().getClient()); JSPUtil.handleException(t, state.getRequest(), state.getResponse(), ERROR_PAGE); }
@Override protected void doIt(HttpServletRequest request, HttpServletResponse response) throws Throwable { String cause = request.getParameter(CAUSE); String identifier = request.getParameter(IDENTIFIER); request.setAttribute(CAUSE, cause); request.setAttribute(IDENTIFIER, identifier); request.setAttribute(MESSAGE, URLDecoder.decode(request.getParameter(MESSAGE), "UTF-8")); String stackTrace = request.getParameter(STACK_TRACE); if (stackTrace == null || stackTrace.length() == 0) { stackTrace = "(none)"; } else { try { stackTrace = new String(Base64.decodeBase64(stackTrace)); } catch (Throwable x) { info("Could not decode stack trace for cause " + x.getClass().getName() + " msg=\"" + x.getMessage() + "\", trace:" + stackTrace); stackTrace = "(none)"; } } request.setAttribute(STACK_TRACE, stackTrace); if (cause.equals(UnknownClientException.class.getSimpleName())) { JSPUtil.fwd(request, response, "/noClientErrorPage.jsp"); return; } Client client = getClient(BasicIdentifier.newID(identifier)); request.setAttribute("client", client); JSPUtil.fwd(request, response, "/errorPage2.jsp"); } }
@Override public void handleException(Throwable t, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { t.printStackTrace(); if (t.getCause() == null) { clientServlet.warn("2.a. Exception from the server: (no other cause)"); request.setAttribute("cause", "(none)"); request.setAttribute("stackTrace", "(none)"); } else { clientServlet.warn("2.a. Exception from the server: " + t.getCause().getMessage()); request.setAttribute("cause", t.getCause().getMessage()); request.setAttribute("stackTrace", t.getCause()); } clientServlet.error("Exception while trying to get cert. message:" + t.getMessage()); if (t instanceof RuntimeException) { String path = clientServlet.getServletContext().getContextPath(); if(!path.endsWith("/")){ // normalize it path = path + "/"; } request.setAttribute("action", path); request.setAttribute("message", t.getMessage()); JSPUtil.fwd(request, response, clientServlet.getCE().getErrorPagePath()); return; } throw new ServletException("Error", t); } }
public void present(PresentableState state) throws Throwable { postprocess(new TransactionState(state.getRequest(), state.getResponse(), null, null)); switch (state.getState()) { case INITIAL_STATE: JSPUtil.fwd(state.getRequest(), state.getResponse(), INIT_PAGE); break; case REQUEST_STATE: if (state instanceof ClientState) { ClientState cState = (ClientState) state; state.getRequest().setAttribute("client", cState.getClient()); JSPUtil.fwd(state.getRequest(), state.getResponse(), OK_PAGE); } else { throw new IllegalStateException("Error: An instance of ClientState was expected, but got an instance of \"" + state.getClass().getName() + "\""); } break; case ERROR_STATE: default: } }
@Override protected void doIt(HttpServletRequest request, HttpServletResponse response) throws Throwable { info("1.a. Starting transaction"); OA4MPResponse gtwResp = null; // Drumroll please: here is the work for this call. Identifier id = AssetStoreUtil.createID(); gtwResp = getOA4MPService().requestCert(id); // if there is a store, store something in it. Cookie cookie = new Cookie(OA4MP_CLIENT_REQUEST_ID, id.getUri().toString()); cookie.setMaxAge(15 * 60); // 15 minutes cookie.setSecure(true); debug("id = " + id.getUri()); response.addCookie(cookie); info("1.b. Got response. Creating page with redirect for " + gtwResp.getRedirect().getHost()); if (getCE().isShowRedirectPage()) { request.setAttribute(REDIR, REDIR); request.setAttribute("redirectUrl", gtwResp.getRedirect().toString()); request.setAttribute(ACTION_KEY, ACTION_KEY); request.setAttribute("action", ACTION_REDIRECT_VALUE); // Normally, we'd just do a redirect, but we will put up a page and show the redirect to the user. // The client response contains the generated private key as well // In a real application, the private key would be stored. This, however, exceeds the scope of this // sample application -- all we need to do to complete the process is send along the redirect url. info("1.b. Showing redirect page."); JSPUtil.fwd(request, response, getCE().getRedirectPagePath()); return; } response.sendRedirect(gtwResp.getRedirect().toString()); }
JSPUtil.fwd(request, response, getCE().getRedirectPagePath());
JSPUtil.fwd(request, response, clientServlet.getCE().getErrorPagePath());
GeneralException ge = new GeneralException("Error: The token presented by portal is null."); request.setAttribute("exception", ge); JSPUtil.fwd(request, response, configurationReader.getErrorUrl()); return; "Error: This servlet requires parameters for the token and verifier. It cannot be called directly."); request.setAttribute("exception", ge); JSPUtil.fwd(request, response, configurationReader.getErrorUrl()); return; error("Exception while trying to get cert. message:" + t.getMessage()); request.setAttribute("exception", t); JSPUtil.fwd(request, response, configurationReader.getErrorUrl()); return; JSPUtil.fwd(request, response, configurationReader.getSuccessUrl()); } else {
"The server is configured for a limit of " + getServiceEnvironment().getMaxAllowedNewClientRequests() + " and" + " there are " + getServiceEnvironment().getClientApprovalStore().getPendingCount() + " pending approvals in the store.",null); JSPUtil.fwd(request, response, "/tooManyClientRequests.jsp"); JSPUtil.fwd(request, response, INIT_PAGE); } catch (Throwable t) { if(ServletDebugUtil.isEnabled()){
GeneralException ge = new GeneralException("Error: This servlet requires parameters for the token and possibly verifier."); request.setAttribute("exception", ge); JSPUtil.fwd(request, response, getCE().getErrorPagePath()); return; JSPUtil.fwd(request, response, getCE().getSuccessPagePath()); return;
GeneralException ge = new GeneralException("Error: This servlet requires parameters for the token and possibly verifier."); request.setAttribute("exception", ge); JSPUtil.fwd(request, response, getCE().getErrorPagePath()); return; JSPUtil.fwd(request, response, getCE().getSuccessPagePath()); return;