Search in sources :

Example 11 with L10NMessageImpl

use of com.sun.identity.shared.locale.L10NMessageImpl 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

L10NMessageImpl (com.sun.identity.shared.locale.L10NMessageImpl)11 SSOException (com.iplanet.sso.SSOException)4 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)4 ISLocaleContext (com.sun.identity.common.ISLocaleContext)4 IOException (java.io.IOException)3 ServletException (javax.servlet.ServletException)3 ModelControlException (com.iplanet.jato.model.ModelControlException)2 HttpCallback (com.sun.identity.authentication.spi.HttpCallback)2 RedirectCallback (com.sun.identity.authentication.spi.RedirectCallback)2 ChoiceCallback (javax.security.auth.callback.ChoiceCallback)2 ConfirmationCallback (javax.security.auth.callback.ConfirmationCallback)2 NameCallback (javax.security.auth.callback.NameCallback)2 PasswordCallback (javax.security.auth.callback.PasswordCallback)2 RequestDispatcher (javax.servlet.RequestDispatcher)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 SessionID (com.iplanet.dpro.session.SessionID)1 InternalSession (com.iplanet.dpro.session.service.InternalSession)1 CompleteRequestException (com.iplanet.jato.CompleteRequestException)1 RequestContextImpl (com.iplanet.jato.RequestContextImpl)1