Search in sources :

Example 1 with AuthD

use of com.sun.identity.authentication.service.AuthD in project OpenAM by OpenRock.

the class LoginViewBean method getDisplayURL.

/**
     * Returns display url for auth auth Login UI
     * 
     * @return display url for auth auth Login  UI
     */
public String getDisplayURL() {
    loginDebug.message("In getDisplayURL()");
    // and customers want to use login failed url
    if ((redirect_url != null) && (redirect_url.length() != 0)) {
        jsp_page = "Redirect.jsp";
    } else if ((errorTemplate != null) && (errorTemplate.length() != 0)) {
        jsp_page = errorTemplate;
    } else if ((ErrorMessage != null) && (ErrorMessage.length() != 0)) {
        jsp_page = "Message.jsp";
    } else if ((pageTemplate != null) && (pageTemplate.length() != 0)) {
        if (loginDebug.messageEnabled()) {
            loginDebug.message("Using module Template : " + pageTemplate);
        }
        jsp_page = pageTemplate;
    } else {
        jsp_page = "Login.jsp";
    }
    jsp_page = getFileName(jsp_page);
    if (ac != null) {
        InternalSession oldSession = AuthUtils.getOldSession(ac);
        if (loginDebug.messageEnabled()) {
            loginDebug.message("Previous Session : " + oldSession);
        }
        if (ac.getStatus() == AuthContext.Status.SUCCESS) {
            response.setHeader("X-AuthErrorCode", "0");
            if (ac.getLoginState().getForceFlag()) {
                if (loginDebug.messageEnabled()) {
                    loginDebug.message("Forced Auth Succeed. " + "Restoring updated session");
                }
                clearCookieAndDestroySession(ac);
                if (oldSession != null) {
                    ac.getLoginState().setSession(oldSession);
                }
            } else {
                if (AuthUtils.isCookieSupported(ac)) {
                    setCookie();
                    clearCookie(AuthUtils.getAuthCookieName());
                }
                try {
                    if (oldSession != null) {
                        if (loginDebug.messageEnabled()) {
                            loginDebug.message("Destroy the " + "original session Successful!");
                        }
                        AuthD authD = AuthD.getAuth();
                        authD.destroySession(oldSession.getID());
                    }
                } catch (Exception e) {
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("Destroy " + "original session Failed! " + e.getMessage());
                    }
                }
            }
        } else if (ac.getStatus() == AuthContext.Status.FAILED) {
            if (loginDebug.messageEnabled()) {
                loginDebug.message("Destroy Session! for ac : " + ac);
            }
            if (AuthUtils.isSessionUpgrade(ac)) {
                // clear cookie ,destroy failed session
                clearCookieAndDestroySession(ac);
                loginDebug.message("Session upgrade - Restoring original Session!");
                if (oldSession != null) {
                    ac.getLoginState().setSession(oldSession);
                }
                loginDebug.message("Original session restored successful!");
            } else {
                // clear cookie ,destroy failed session
                clearCookieAndDestroySession(ac);
                if (oldSession != null) {
                    loginDebug.message("Destroy existing/old valid session");
                    AuthD authD = AuthD.getAuth();
                    authD.destroySession(oldSession.getID());
                }
            }
            loginDebug.message("Login failure, current session destroyed!");
        }
    }
    return AuthUtils.encodeURL(jsp_page, ac, response);
}
Also used : InternalSession(com.iplanet.dpro.session.service.InternalSession) AuthD(com.sun.identity.authentication.service.AuthD) ModelControlException(com.iplanet.jato.model.ModelControlException) AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException)

Example 2 with AuthD

use of com.sun.identity.authentication.service.AuthD in project OpenAM by OpenRock.

the class LoginViewBean method getLoginDisplay.

protected void getLoginDisplay() throws Exception {
    loginDebug.message("In getLoginDisplay()");
    if (!bAuthLevel) {
        prepareLoginParams();
    }
    if (loginDebug.messageEnabled()) {
        loginDebug.message("Login Parameters : IndexType = " + indexType + " IndexName = " + indexName);
    }
    try {
        if (indexType != null) {
            if (indexType.equals(AuthContext.IndexType.RESOURCE)) {
                ac.login(indexType, indexName, envMap, null);
            } else {
                ac.login(indexType, indexName);
            }
        } else {
            ac.login();
        }
    } catch (AuthLoginException le) {
        loginDebug.message("AuthContext()::login error ", le);
        if ((ac.getStatus() == AuthContext.Status.RESET) || (ac.getStatus() == AuthContext.Status.ORG_MISMATCH)) {
            loginDebug.message("getLoginDisplay(): Destroying current session!");
            InternalSession oldSession = AuthUtils.getOldSession(ac);
            if (AuthUtils.isSessionUpgrade(ac)) {
                clearCookieAndDestroySession(ac);
                loginDebug.message("getLoginDisplay(): Session upgrade - " + " Restoring original Session!");
                if (oldSession != null) {
                    ac.getLoginState().setSession(oldSession);
                    String redirect_url = AuthUtils.getSuccessURL(request, ac);
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("Session Upgrade - redirect_url : " + redirect_url);
                    }
                    response.sendRedirect(redirect_url);
                }
                forward = false;
            } else {
                clearCookieAndDestroySession(ac);
                if (oldSession != null) {
                    loginDebug.message("Destroy existing/old valid session");
                    AuthD authD = AuthD.getAuth();
                    authD.destroySession(oldSession.getID());
                }
                ac = null;
                handleAuthLoginException(le);
            }
        } else {
            handleAuthLoginException(le);
        }
        return;
    }
    try {
        // Get the information requested by the respective auth module
        if (ac.hasMoreRequirements()) {
            loginDebug.message("In getLoginDisplay, has More Requirements");
            callbacks = ac.getRequirements();
            for (int i = 0; i < callbacks.length; i++) {
                if (callbacks[i] instanceof HttpCallback) {
                    processHttpCallback((HttpCallback) callbacks[i]);
                    return;
                } else if (callbacks[i] instanceof RedirectCallback) {
                    processRedirectCallback((RedirectCallback) callbacks[i]);
                    return;
                } else if (!bAuthLevel && !newOrgExist) {
                    // Auth Level login will never do one page login.
                    if (callbacks[i] instanceof NameCallback) {
                        if (reqDataHash.get(TOKEN + Integer.toString(i)) != null) {
                            onePageLogin = true;
                            break;
                        } else if (reqDataHash.get(TOKEN_OLD + Integer.toString(i)) != null) {
                            onePageLogin = true;
                            break;
                        }
                    } else if (callbacks[i] instanceof PasswordCallback) {
                        if (reqDataHash.get(TOKEN + Integer.toString(i)) != null) {
                            onePageLogin = true;
                            break;
                        } else if (reqDataHash.get(TOKEN_OLD + Integer.toString(i)) != null) {
                            onePageLogin = true;
                            break;
                        }
                    } else if (callbacks[i] instanceof ChoiceCallback) {
                        if (reqDataHash.get(TOKEN + Integer.toString(i)) != null) {
                            onePageLogin = true;
                            break;
                        } else if (reqDataHash.get(TOKEN_OLD + Integer.toString(i)) != null) {
                            onePageLogin = true;
                            break;
                        }
                    } else if (callbacks[i] instanceof ConfirmationCallback) {
                        if (reqDataHash.get(BUTTON) != null) {
                            onePageLogin = true;
                            break;
                        } else if (reqDataHash.get(BUTTON_OLD) != null) {
                            onePageLogin = true;
                            break;
                        }
                    }
                }
            }
            if (onePageLogin && AuthUtils.isZeroPageLoginAllowed(ac.getLoginState().getZeroPageLoginConfig(), request)) {
                // user input login info in URL
                loginDebug.message("User input login information in URL!");
                processLoginDisplay();
            } else {
                addLoginCallbackMessage(callbacks);
                if (!LoginFail) {
                    //if the login already failed, then LoginState is already
                    //nullified, hence any attempt of calling this method
                    //the errormessage/code/template should be already set
                    //so a proper error page is shown.
                    AuthUtils.setCallbacksPerState(ac, pageState, callbacks);
                }
            }
        } else {
            if (loginDebug.messageEnabled()) {
                loginDebug.message("No more Requirements in getLoginDisplay");
                loginDebug.message("Status is : " + ac.getStatus());
            }
            if (ac.getStatus() == AuthContext.Status.SUCCESS) {
                LoginSuccess = true;
                ResultVal = rb.getString("authentication.successful");
                /*
                     * redirect to 'goto' parameter or SPI hook or default
                     * redirect URL.
                     */
                redirect_url = AuthUtils.getLoginSuccessURL(ac);
                if ((redirect_url != null) && (redirect_url.length() != 0)) {
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("LoginSuccessURL in getLoginDisplay " + "(in case of successful auth) : " + redirect_url);
                    }
                }
            } else if (ac.getStatus() == AuthContext.Status.FAILED) {
                handleAuthLoginException(null);
                /*
                     * redirect to 'goto' parameter or SPI hook or default
                     * redirect URL.
                     */
                redirect_url = AuthUtils.getLoginFailedURL(ac);
                if ((redirect_url != null) && (redirect_url.length() != 0)) {
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("LoginFailedURL in getLoginDisplay : " + redirect_url);
                    }
                }
            } else {
                /*
                     * redirect to 'goto' parameter or SPI hook or default
                     * redirect URL.
                     */
                redirect_url = AuthUtils.getLoginFailedURL(ac);
                if (loginDebug.warningEnabled()) {
                    loginDebug.warning("Login Status is " + ac.getStatus() + " - redirect to loginFailedURL : " + redirect_url);
                }
                setErrorMessage(null);
            }
        }
    } catch (Exception e) {
        setErrorMessage(e);
        throw new L10NMessageImpl(bundleName, "loginDisplay.get", new Object[] { e.getMessage() });
    }
}
Also used : RedirectCallback(com.sun.identity.authentication.spi.RedirectCallback) ConfirmationCallback(javax.security.auth.callback.ConfirmationCallback) L10NMessageImpl(com.sun.identity.shared.locale.L10NMessageImpl) HttpCallback(com.sun.identity.authentication.spi.HttpCallback) AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) ModelControlException(com.iplanet.jato.model.ModelControlException) AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) ChoiceCallback(javax.security.auth.callback.ChoiceCallback) NameCallback(javax.security.auth.callback.NameCallback) InternalSession(com.iplanet.dpro.session.service.InternalSession) AuthD(com.sun.identity.authentication.service.AuthD) PasswordCallback(javax.security.auth.callback.PasswordCallback)

Example 3 with AuthD

use of com.sun.identity.authentication.service.AuthD in project OpenAM by OpenRock.

the class LoginLogoutMapping method initializeAuth.

/**
     * Initializes OpenAM.
     **
     * @param servletCtx Servlet Context.
     */
public boolean initializeAuth(ServletContext servletCtx) {
    AuthD authD = AuthD.getAuth();
    if (authD == null) {
        return false;
    } else {
        authD.setServletContext(servletCtx);
    }
    // Intialize AdminTokenAction
    if (Debug.getInstance("amLoginLogoutMapping").messageEnabled()) {
        Debug.getInstance("amLoginLogoutMapping").message("LoginLogoutMapping.initializeAuth: " + "Initializing AdminTokenAction to use AuthN");
    }
    com.sun.identity.security.AdminTokenAction.getInstance().authenticationInitialized();
    return true;
}
Also used : AuthD(com.sun.identity.authentication.service.AuthD)

Example 4 with AuthD

use of com.sun.identity.authentication.service.AuthD in project OpenAM by OpenRock.

the class LoginViewBean method forwardTo.

/**
     * Forwards the request to this view bean, displaying the page. This
     * method is the equivalent of <code>RequestDispatcher.forward()</code>,
     * meaning that the same semantics apply to the use of this method.
     * This method makes implicit use of the display URL returned
     * by the <code>getDisplayURL()</code> method.
     * @param requestContext servlet context for auth request
     */
public void forwardTo(RequestContext requestContext) {
    loginDebug.message("In forwardTo()");
    SSOToken ssoToken = null;
    if (requestContext != null) {
        request = requestContext.getRequest();
        response = requestContext.getResponse();
    }
    response.setHeader("Pragma", "no-cache");
    response.setHeader("Expires", "0");
    if (AuthClientUtils.isVersionHeaderEnabled()) {
        response.setHeader("X-DSAMEVersion", AuthClientUtils.getDSAMEVersion());
    }
    // get request ( GET ) parameters for 'login' process
    reqDataHash = AuthUtils.parseRequestParameters(request);
    /*if (loginDebug.messageEnabled()) {
            loginDebug.message("request data hash : " + reqDataHash);
        }*/
    client_type = AuthUtils.getClientType(request);
    // Set header for Misrouted server's usage
    response.setHeader("AM_CLIENT_TYPE", client_type);
    if (loginDebug.messageEnabled()) {
        loginDebug.message("Client Type is: " + client_type);
        loginDebug.message("Request method is : " + request.getMethod());
    }
    if (request.getMethod().equalsIgnoreCase("POST")) {
        isPost = true;
    }
    SessionID sessionID = null;
    InternalSession intSession = null;
    try {
        boolean isBackPost = false;
        // if the request is a GET then iPlanetAMDirectoryPro cookie
        // will be used to retrieve the session for session upgrade
        sessionID = AuthUtils.getSessionIDFromRequest(request);
        ssoToken = AuthUtils.getExistingValidSSOToken(sessionID);
        //Check for session Timeout	 
        if ((ssoToken == null) && (sessionID != null) && (sessionID.toString().length() != 0)) {
            if (AuthUtils.isTimedOut(sessionID)) {
                clearCookie(request);
                errorCode = AMAuthErrorCode.AUTH_TIMEOUT;
                ErrorMessage = AuthUtils.getErrorVal(AMAuthErrorCode.AUTH_TIMEOUT, AuthUtils.ERROR_MESSAGE);
                errorTemplate = AuthUtils.getErrorVal(AMAuthErrorCode.AUTH_TIMEOUT, AuthUtils.ERROR_TEMPLATE);
                ISLocaleContext localeContext = new ISLocaleContext();
                localeContext.setLocale(request);
                java.util.Locale locale = localeContext.getLocale();
                rb = rbCache.getResBundle(bundleName, locale);
                super.forwardTo(requestContext);
                return;
            }
        }
        forceAuth = AuthUtils.forceAuthFlagExists(reqDataHash);
        if (ssoToken != null) {
            if (AuthUtils.newSessionArgExists(reqDataHash)) {
                SSOTokenManager.getInstance().destroyToken(ssoToken);
            } else {
                loginDebug.message("Old Session is Active.");
                newOrgExist = checkNewOrg(ssoToken);
                if (newOrg) {
                    sessionID = new SessionID();
                }
                if (!newOrgExist) {
                    if (isPost) {
                        isBackPost = canGetOrigCredentials(ssoToken);
                    }
                    if (forceAuth) {
                        sessionUpgrade = true;
                    } else {
                        sessionUpgrade = AuthUtils.checkSessionUpgrade(ssoToken, reqDataHash);
                    }
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("Session Upgrade = " + sessionUpgrade);
                    }
                }
            }
        }
        if ("true".equals(request.getParameter("new_org"))) {
            ssoToken = AuthUtils.getExistingValidSSOToken(new SessionID(request));
            handleNewOrgResponse(ssoToken);
            if (logIntoDiffOrg) {
                //session is already deleted, so we should just continue our login process
                newOrgExist = true;
            } else {
                ac = AuthUtils.getAuthContext(request, response, sessionID, sessionUpgrade, isBackPost);
                clearCookieAndDestroySession(ac);
            }
        }
        if ((ssoToken != null) && !sessionUpgrade && !newOrgExist) {
            try {
                loginDebug.message("Session is Valid / already " + "authenticated");
                bValidSession = true;
                /*
                     * redirect to 'goto' parameter or SPI hook or default
                     * redirect URL.
                     */
                if (request != null) {
                    redirect_url = AuthUtils.getValidGotoURL(request, ssoToken.getProperty("Organization"));
                    if ((redirect_url == null) || (redirect_url.length() == 0)) {
                        redirect_url = ssoToken.getProperty(ISAuthConstants.SUCCESS_URL);
                    }
                }
                if (redirect_url == null) {
                    ResultVal = rb.getString("authentication.already.login");
                }
                LoginSuccess = true;
                boolean doForward = AuthUtils.forwardSuccessExists(request);
                if (doForward || (redirect_url != null && (redirect_url.startsWith(SSO_REDIRECT) || redirect_url.startsWith(SSO_POST)))) {
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("LoginViewBean.forwardRequest=true");
                        loginDebug.message("LoginViewBean.forwardTo():Forward URL before appending cookie is " + redirect_url);
                        loginDebug.message("LoginViewBean.forwardTo():Final Forward URL is " + redirect_url);
                    }
                    RequestDispatcher dispatcher = request.getRequestDispatcher(redirect_url);
                    request.setAttribute(Constants.FORWARD_PARAM, Constants.FORWARD_YES_VALUE);
                    dispatcher.forward(request, response);
                } else {
                    response.sendRedirect(redirect_url);
                }
                return;
            } catch (Exception er) {
                if (loginDebug.messageEnabled()) {
                    loginDebug.message("Session getState exception: ", er);
                }
                setErrorMessage(er);
            }
        }
        ac = AuthUtils.getAuthContext(request, response, sessionID, sessionUpgrade, isBackPost);
        if (sessionID != null) {
            intSession = AuthD.getSession(sessionID);
        }
        if ((intSession != null) && (intSession.isTimedOut())) {
            //Session Timeout
            // clear the cookie only if cookie supported
            loginDebug.message("Session timeout TRUE");
            if (sessionUpgrade) {
                try {
                    redirect_url = getPrevSuccessURLAndSetCookie();
                    clearGlobals();
                    response.sendRedirect(redirect_url);
                    return;
                } catch (Exception e) {
                    loginDebug.message("Error redirecting :", e);
                }
            } else {
                // clear AM Cookie if it exists.
                if (CookieUtils.getCookieValueFromReq(request, AuthUtils.getCookieName()) != null) {
                    clearCookie(AuthUtils.getCookieName());
                }
                // clear Auth Cookie if it exists.
                if (CookieUtils.getCookieValueFromReq(request, AuthUtils.getAuthCookieName()) != null) {
                    clearCookie(AuthUtils.getAuthCookieName());
                }
                loginURL = intSession.getProperty(ISAuthConstants.FULL_LOGIN_URL);
                errorTemplate = AuthUtils.getErrorVal(AMAuthErrorCode.AUTH_TIMEOUT, AuthUtils.ERROR_TEMPLATE);
                errorCode = AMAuthErrorCode.AUTH_TIMEOUT;
                ErrorMessage = AuthUtils.getErrorVal(AMAuthErrorCode.AUTH_TIMEOUT, AuthUtils.ERROR_MESSAGE);
            }
        }
        java.util.Locale locale = com.sun.identity.shared.locale.Locale.getLocale(AuthUtils.getLocale(ac));
        fallbackLocale = locale;
        rb = rbCache.getResBundle(bundleName, locale);
        if (loginDebug.messageEnabled()) {
            loginDebug.message("ac = " + ac);
            loginDebug.message("JSPLocale = " + locale);
        }
        if (sessionUpgrade) {
            ac.getLoginState().setForceAuth(forceAuth);
        }
        if (!AuthUtils.getInetDomainStatus(ac)) {
            //domain inactive
            if ((errorTemplate == null) || (errorTemplate.length() == 0)) {
                setErrorMessage(null);
            }
        }
        // add cookie only if cookie is supported
        if (!isBackPost) {
            loginURL = AuthUtils.getLoginURL(ac);
        }
        /*if (loginDebug.messageEnabled()) {
                loginDebug.message("loginURL : " + loginURL);
            }*/
        // Check whether need to detect the cookie support in the browser
        String cookieless = (String) request.getAttribute("displayCookieError");
        if (cookieless != null && cookieless.equals("true")) {
            ErrorMessage = rb.getString("nocookiesupport");
            errorTemplate = "Message.jsp";
        }
        if (AuthUtils.isNewRequest(ac)) {
            loginDebug.message("New AuthContext created");
            if (AuthUtils.isCookieSupported(ac)) {
                if (AuthUtils.persistAMCookie(reqDataHash)) {
                    enableCookieTimeToLive();
                }
                setCookie();
                setlbCookie();
            }
        } else {
            // check if client still have the cookie we set.
            if (AuthUtils.isCookieSet(ac)) {
                if (AuthUtils.checkForCookies(request, ac)) {
                    loginDebug.message("Client support cookie");
                    AuthUtils.setCookieSupported(ac, true);
                } else {
                    loginDebug.message("Client do not support cookie");
                    AuthUtils.setCookieSupported(ac, false);
                }
            }
        }
    } catch (Exception e) {
        ISLocaleContext localeContext = new ISLocaleContext();
        localeContext.setLocale(request);
        fallbackLocale = localeContext.getLocale();
        rb = rbCache.getResBundle(bundleName, fallbackLocale);
        if (loginDebug.messageEnabled()) {
            loginDebug.message("JSPLocale = " + fallbackLocale);
        }
        setErrorMessage(e);
        jsp_page = errorTemplate;
        if (requestContext == null) {
            return;
        }
        super.forwardTo(requestContext);
        return;
    }
    if (errorTemplate == null || errorTemplate.isEmpty()) {
        processLogin();
        if (requestContext == null) {
            // solve the recursive case
            clearGlobals();
            return;
        }
    }
    if ((redirect_url != null) && (redirect_url.length() != 0)) {
        // forward check for liberty federation, if the redirect_url
        // is the federation post login servlet, use forward instead
        boolean doForward = AuthUtils.isForwardSuccess(ac, request);
        if (AuthUtils.isGenericHTMLClient(client_type) || doForward) {
            try {
                if (loginDebug.messageEnabled()) {
                    loginDebug.message("Send Redirect to " + redirect_url);
                }
                // destroy session if necessary.
                InternalSession oldSession = AuthUtils.getOldSession(ac);
                if (ac.getStatus() == AuthContext.Status.FAILED) {
                    loginDebug.message("forwardTo(): Auth failed - Destroy Session!");
                    if (AuthUtils.isSessionUpgrade(ac)) {
                        clearCookieAndDestroySession(ac);
                        loginDebug.message("forwardTo(): Session upgrade - " + "Restoring original Session!");
                        if (oldSession != null) {
                            ac.getLoginState().setSession(oldSession);
                        }
                    } else {
                        clearCookieAndDestroySession(ac);
                        if (oldSession != null) {
                            loginDebug.message("Destroy existing/old valid session");
                            AuthD authD = AuthD.getAuth();
                            authD.destroySession(oldSession.getID());
                        }
                    }
                    loginDebug.message("Login failure, current session destroyed!");
                } else if (ac.getStatus() == AuthContext.Status.SUCCESS) {
                    response.setHeader("X-AuthErrorCode", "0");
                    if (ac.getLoginState().getForceFlag()) {
                        if (loginDebug.messageEnabled()) {
                            loginDebug.message("Forced Auth Succeed." + "Restoring updated session");
                        }
                        clearCookieAndDestroySession(ac);
                        ac.getLoginState().setSession(oldSession);
                    } else {
                        if (AuthUtils.isCookieSupported(ac)) {
                            setCookie();
                            clearCookie(AuthUtils.getAuthCookieName());
                        }
                        if (SystemProperties.getAsBoolean(Constants.DESTROY_SESSION_AFTER_UPGRADE) && oldSession != null) {
                            loginDebug.message("Destroy existing/old valid session");
                            AuthD authD = AuthD.getAuth();
                            authD.destroySession(oldSession.getID());
                        }
                    }
                }
                Cookie appendCookie = AuthUtils.getCookieString(ac, null);
                clearGlobals();
                if (doForward || redirect_url.startsWith(SSO_REDIRECT) || redirect_url.startsWith(SSO_POST)) {
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("LoginViewBean.forwardRequest=true");
                        loginDebug.message("LoginViewBean.forwardTo():" + "Forward URL before appending cookie is " + redirect_url);
                    }
                    //but the new isn't.
                    if (redirect_url.indexOf("?") == -1) {
                        redirect_url = redirect_url + "?" + appendCookie.getName() + "=" + URLEncDec.encode(appendCookie.getValue());
                    } else {
                        redirect_url = redirect_url + "&" + appendCookie.getName() + "=" + URLEncDec.encode(appendCookie.getValue());
                    }
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("LoginViewBean.forwardTo():" + "Final Forward URL is " + redirect_url);
                    }
                    RequestDispatcher dispatcher = request.getRequestDispatcher(redirect_url);
                    request.setAttribute(Constants.FORWARD_PARAM, Constants.FORWARD_YES_VALUE);
                    dispatcher.forward(request, response);
                } else {
                    response.sendRedirect(redirect_url);
                }
                forward = false;
                return;
            } catch (IOException e) {
                loginDebug.error("LoginViewBean.forwardTo(): There was an IOException doing the forward/redirect", e);
                ResultVal = rb.getString("redirect.error");
            } catch (Exception e) {
                loginDebug.error("LoginViewBean.forwardTo(): There was an Exception doing the forward/redirect", e);
                setErrorMessage(e);
                redirect_url = null;
            }
        }
    }
    if (forward) {
        forward = false;
        super.forwardTo(requestContext);
    }
    clearGlobals();
}
Also used : Cookie(javax.servlet.http.Cookie) SSOToken(com.iplanet.sso.SSOToken) IOException(java.io.IOException) RequestDispatcher(javax.servlet.RequestDispatcher) ModelControlException(com.iplanet.jato.model.ModelControlException) AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) InternalSession(com.iplanet.dpro.session.service.InternalSession) AuthD(com.sun.identity.authentication.service.AuthD) ISLocaleContext(com.sun.identity.common.ISLocaleContext) SessionID(com.iplanet.dpro.session.SessionID)

Aggregations

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