Search in sources :

Example 16 with CompleteRequestException

use of com.iplanet.jato.CompleteRequestException in project OpenAM by OpenRock.

the class AuthenticationServletBase method onRequestHandlerNotSpecified.

/**
     * Forwards to login view bean, in case of no handler specified
     *
     * @param requestContext - request context
     * @throws ServletException
     */
protected void onRequestHandlerNotSpecified(RequestContext requestContext) throws ServletException {
    ViewBeanManager viewBeanManager = requestContext.getViewBeanManager();
    AuthExceptionViewBean vb = (AuthExceptionViewBean) viewBeanManager.getViewBean(com.sun.identity.authentication.UI.AuthExceptionViewBean.class);
    vb.forwardTo(requestContext);
    throw new CompleteRequestException();
}
Also used : CompleteRequestException(com.iplanet.jato.CompleteRequestException) ViewBeanManager(com.iplanet.jato.ViewBeanManager)

Example 17 with CompleteRequestException

use of com.iplanet.jato.CompleteRequestException in project OpenAM by OpenRock.

the class LoginServlet method initializeRequestContext.

/**
     *
     *
     */
protected void initializeRequestContext(RequestContext requestContext) {
    super.initializeRequestContext(requestContext);
    // Set a view bean manager in the request context.  This must be
    // done at the module level because the view bean manager is
    // module specifc.
    ViewBeanManager viewBeanManager = new ViewBeanManager(requestContext, PACKAGE_NAME);
    ((RequestContextImpl) requestContext).setViewBeanManager(viewBeanManager);
    HttpServletRequest request = requestContext.getRequest();
    HttpServletResponse response = requestContext.getResponse();
    // by redirecting the response with dummy cookie.
    if (checkForCookiesInBrowser(request, response, debug)) {
        throw new CompleteRequestException();
    }
    // Check content length
    try {
        RequestUtils.checkContentLength(request);
    } catch (L10NMessageImpl e) {
        if (debug.messageEnabled()) {
            ISLocaleContext localeContext = new ISLocaleContext();
            localeContext.setLocale(request);
            java.util.Locale locale = localeContext.getLocale();
            debug.message("LoginServlet: " + e.getL10NMessage(locale));
        }
        AuthExceptionViewBean vb = (AuthExceptionViewBean) viewBeanManager.getViewBean(com.sun.identity.authentication.UI.AuthExceptionViewBean.class);
        vb.forwardTo(requestContext);
        throw new CompleteRequestException();
    }
    // Check if the hostname in the URL is an FQDN else
    // redirect to the fqdn
    String client_type = AuthUtils.getClientType(request);
    if (debug.messageEnabled()) {
        debug.message("Client Type = " + client_type);
    }
    String hostName = AuthUtils.getHostName(request);
    if (!AuthUtils.isValidFQDNRequest(hostName)) {
        try {
            String newHN = AuthUtils.getValidFQDNResource(hostName, request);
            if (debug.messageEnabled()) {
                debug.message("FQDN = " + newHN);
            }
            if (AuthUtils.isGenericHTMLClient(client_type)) {
                debug.message("This is HTML");
                response.sendRedirect(newHN);
            } else {
                String fileName = AuthUtils.getDefaultFileName(request, REDIRECT_JSP);
                if (debug.messageEnabled()) {
                    debug.message("Forward to : " + fileName);
                }
                RequestDispatcher dispatcher = request.getRequestDispatcher(fileName);
                dispatcher.forward(request, response);
            }
        } catch (Exception e) {
        // came here continue
        }
        throw new CompleteRequestException();
    }
    final boolean isLoginRequest = LOGIN_PAGE_NAME.equals(getPageName(request));
    String cookieURL = AuthUtils.getCookieURLForSessionUpgrade(request);
    if (cookieURL != null && isLoginRequest) {
        rerouteRequest(request, response, cookieURL);
        return;
    }
    // Check whether this is the correct server to accept the client
    // response.
    String authCookieValue = AuthUtils.getAuthCookieValue(request);
    if ((authCookieValue != null) && (authCookieValue.length() != 0) && (!authCookieValue.equalsIgnoreCase("LOGOUT"))) {
        //send Auth request to cookie (original) server
        try {
            SessionID sessionID = new SessionID(authCookieValue);
            cookieURL = AuthUtils.getCookieURL(sessionID);
        } catch (Exception e) {
            if (debug.messageEnabled()) {
                debug.message("LoginServlet error in Session : " + e.toString());
            }
        }
        if (debug.messageEnabled()) {
            debug.message("cookieURL : " + cookieURL);
        }
        if (isLoginRequest && cookieURL != null && !cookieURL.isEmpty() && !AuthUtils.isLocalServer(cookieURL, true) && !AuthUtils.isSessionUpgradeOrForceAuth(request)) {
            rerouteRequest(request, response, cookieURL);
        }
    }
}
Also used : L10NMessageImpl(com.sun.identity.shared.locale.L10NMessageImpl) RequestContextImpl(com.iplanet.jato.RequestContextImpl) CompleteRequestException(com.iplanet.jato.CompleteRequestException) HttpServletResponse(javax.servlet.http.HttpServletResponse) ViewBeanManager(com.iplanet.jato.ViewBeanManager) RequestDispatcher(javax.servlet.RequestDispatcher) ServletException(javax.servlet.ServletException) CompleteRequestException(com.iplanet.jato.CompleteRequestException) HttpServletRequest(javax.servlet.http.HttpServletRequest) ISLocaleContext(com.sun.identity.common.ISLocaleContext) SessionID(com.iplanet.dpro.session.SessionID)

Aggregations

CompleteRequestException (com.iplanet.jato.CompleteRequestException)17 ViewBeanManager (com.iplanet.jato.ViewBeanManager)10 ViewBean (com.iplanet.jato.view.ViewBean)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 IOException (java.io.IOException)2 ServletException (javax.servlet.ServletException)2 SessionID (com.iplanet.dpro.session.SessionID)1 RequestContext (com.iplanet.jato.RequestContext)1 RequestContextImpl (com.iplanet.jato.RequestContextImpl)1 NonSyncStringBuffer (com.iplanet.jato.util.NonSyncStringBuffer)1 SSOException (com.iplanet.sso.SSOException)1 SSOToken (com.iplanet.sso.SSOToken)1 AuthViewBeanBase (com.sun.identity.authentication.UI.AuthViewBeanBase)1 ISLocaleContext (com.sun.identity.common.ISLocaleContext)1 L10NMessageImpl (com.sun.identity.shared.locale.L10NMessageImpl)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URL (java.net.URL)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 Cookie (javax.servlet.http.Cookie)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1