Search in sources :

Example 1 with ISLocaleContext

use of com.sun.identity.common.ISLocaleContext in project OpenAM by OpenRock.

the class PWResetUserValidationViewBean method forwardTo.

/**
     * Forwards to current view bean after validating organization
     *
     * @param context  request context
     */
public void forwardTo(RequestContext context) {
    String classMethod = "PWResetUserValidationViewBean:forwardTo : ";
    HttpServletRequest req = context.getRequest();
    PWResetUserValidationModel model = (PWResetUserValidationModel) getModel();
    ISLocaleContext localeContext = new ISLocaleContext();
    localeContext.setLocale(req);
    java.util.Locale locale = localeContext.getLocale();
    model.setUserLocale(locale.toString());
    String orgDN = (String) getPageSessionAttribute(ORG_DN);
    if (orgDN == null) {
        Hashtable reqDataHash = AuthUtils.parseRequestParameters(req);
        String orgParam = AuthUtils.getOrgParam(reqDataHash);
        String queryOrg = AuthUtils.getQueryOrgName(req, orgParam);
        orgDN = AuthUtils.getOrganizationDN(queryOrg, true, req);
        model.setValidRealm(orgDN);
        if (debug.messageEnabled()) {
            debug.message(classMethod + "orgDN is :" + orgDN);
        }
        setPageSessionAttribute(ORG_DN, orgDN);
        /*
             * Set the flag to indicate that user enter the orgname in
             * the url.
             */
        if (orgParam != null && orgParam.length() > 0) {
            setPageSessionAttribute(ORG_DN_FLAG, STRING_TRUE);
            model.setRealmFlag(true);
        }
    } else {
        model.setValidRealm(orgDN);
    }
    super.forwardTo(context);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PWResetUserValidationModel(com.sun.identity.password.ui.model.PWResetUserValidationModel) Hashtable(java.util.Hashtable) ISLocaleContext(com.sun.identity.common.ISLocaleContext)

Example 2 with ISLocaleContext

use of com.sun.identity.common.ISLocaleContext in project OpenAM by OpenRock.

the class PWResetUserValidationViewBean method handleBtnNextRequest.

/**
     * Handles form submission request
     *
     * @param event request invocation event
     */
public void handleBtnNextRequest(RequestInvocationEvent event) {
    PWResetUserValidationModel model = (PWResetUserValidationModel) getModel();
    String userAttrValue = (String) getDisplayFieldValue(TF_USER_ATTR);
    if (userAttrValue != null) {
        userAttrValue = userAttrValue.trim();
    }
    HiddenField hf = (HiddenField) getChild(FLD_USER_ATTR);
    String userAttrName = (String) hf.getValue();
    String orgDN = (String) getPageSessionAttribute(ORG_DN);
    String orgDNFlag = (String) getPageSessionAttribute(ORG_DN_FLAG);
    RequestContext reqContext = event.getRequestContext();
    ISLocaleContext localeContext = new ISLocaleContext();
    localeContext.setLocale(reqContext.getRequest());
    java.util.Locale localeObj = localeContext.getLocale();
    String locale = localeObj.toString();
    model.setUserLocale(locale);
    if (orgDNFlag != null && orgDNFlag.equals(STRING_TRUE)) {
        model.setRealmFlag(true);
    }
    if (userAttrValue == null || userAttrValue.length() == 0) {
        setErrorMessage(model.getErrorTitle(), model.getMissingUserAttrMessage(userAttrName));
        forwardTo();
    } else {
        if (model.isUserAttrValueValid(orgDN, userAttrValue) && model.isUserExists(userAttrValue, userAttrName, orgDN) && model.isUserActive(model.getUserRealm())) {
            forwardToPWResetQuestionVB(orgDN, userAttrValue, orgDNFlag, locale);
        } else {
            setErrorMessage(model.getErrorTitle(), model.getErrorMessage());
            forwardTo();
        }
    }
}
Also used : PWResetUserValidationModel(com.sun.identity.password.ui.model.PWResetUserValidationModel) HiddenField(com.iplanet.jato.view.html.HiddenField) RequestContext(com.iplanet.jato.RequestContext) ISLocaleContext(com.sun.identity.common.ISLocaleContext)

Example 3 with ISLocaleContext

use of com.sun.identity.common.ISLocaleContext in project OpenAM by OpenRock.

the class TokenResource method getLocale.

private java.util.Locale getLocale(Context context) throws SSOException, SMSException {
    ISLocaleContext locale = new ISLocaleContext();
    HttpContext httpContext = context.asContext(HttpContext.class);
    locale.setLocale(httpContext);
    return locale.getLocale();
}
Also used : HttpContext(org.forgerock.json.resource.http.HttpContext) ISLocaleContext(com.sun.identity.common.ISLocaleContext)

Example 4 with ISLocaleContext

use of com.sun.identity.common.ISLocaleContext in project OpenAM by OpenRock.

the class PWResetQuestionViewBean method handleBtnOKRequest.

/**
     * Handles form submission request for next button. It will
     * forward to <code>PWResetSuccessViewBean</code> if the answers
     * are correct for the questions.
     *
     * @param event request invocation event
     */
public void handleBtnOKRequest(RequestInvocationEvent event) {
    PWResetQuestionModel model = (PWResetQuestionModel) getModel();
    String orgDN = (String) getPageSessionAttribute(ORG_DN);
    String userDN = (String) getPageSessionAttribute(USER_DN);
    RequestContext reqContext = event.getRequestContext();
    ISLocaleContext localeContext = new ISLocaleContext();
    localeContext.setLocale(reqContext.getRequest());
    java.util.Locale localeObj = localeContext.getLocale();
    String locale = localeObj.toString();
    model.setUserLocale(locale);
    PWResetQuestionTiledView tView = (PWResetQuestionTiledView) getChild(PASSWORD_RESET_TILEDVIEW);
    Map map = tView.getAnswers();
    if (tView.isAnswerBlank()) {
        setErrorMessage(model.getErrorTitle(), model.getMissingAnswerMessage());
        forwardTo();
    } else {
        try {
            model.resetPassword(userDN, orgDN, map);
            PWResetSuccessViewBean vb = (PWResetSuccessViewBean) getViewBean(PWResetSuccessViewBean.class);
            vb.setResetMessage(model.getPasswordResetMessage());
            vb.setPageSessionAttribute(URL_LOCALE, locale);
            vb.forwardTo(getRequestContext());
        } catch (PWResetException pwe) {
            if (!model.isUserLockout(userDN, orgDN)) {
                setErrorMessage(model.getErrorTitle(), pwe.getMessage());
            }
            forwardTo();
        }
    }
}
Also used : PWResetException(com.sun.identity.password.ui.model.PWResetException) RequestContext(com.iplanet.jato.RequestContext) ISLocaleContext(com.sun.identity.common.ISLocaleContext) Map(java.util.Map) PWResetQuestionModel(com.sun.identity.password.ui.model.PWResetQuestionModel)

Example 5 with ISLocaleContext

use of com.sun.identity.common.ISLocaleContext in project OpenAM by OpenRock.

the class LoginLogoutMapping method processRequest.

/**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException
     * @throws java.io.IOException
     */
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
    // Check content length
    try {
        RequestUtils.checkContentLength(request);
    } catch (L10NMessageImpl e) {
        ISLocaleContext localeContext = new ISLocaleContext();
        localeContext.setLocale(request);
        java.util.Locale locale = localeContext.getLocale();
        if (Debug.getInstance("amLoginLogoutMapping").messageEnabled()) {
            Debug.getInstance("amLoginLogoutMapping").message("LoginLogoutMapping: " + e.getL10NMessage(locale));
        }
        throw new ServletException(e.getL10NMessage(locale));
    }
    String servletPath = request.getServletPath();
    String forwardUrl = "";
    if (servletPath.equals("/login")) {
        forwardUrl = "/UI/Login";
    } else if (servletPath.equals("/logout")) {
        forwardUrl = "/UI/Logout";
    }
    RequestDispatcher dispatcher = config.getServletContext().getRequestDispatcher(forwardUrl);
    dispatcher.forward(request, response);
    return;
}
Also used : Locale(java.util.Locale) L10NMessageImpl(com.sun.identity.shared.locale.L10NMessageImpl) ISLocaleContext(com.sun.identity.common.ISLocaleContext)

Aggregations

ISLocaleContext (com.sun.identity.common.ISLocaleContext)20 SSOException (com.iplanet.sso.SSOException)4 L10NMessageImpl (com.sun.identity.shared.locale.L10NMessageImpl)4 ServletException (javax.servlet.ServletException)4 HttpContext (org.forgerock.json.resource.http.HttpContext)4 SessionID (com.iplanet.dpro.session.SessionID)3 Map (java.util.Map)3 RequestDispatcher (javax.servlet.RequestDispatcher)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 InternalSession (com.iplanet.dpro.session.service.InternalSession)2 RequestContext (com.iplanet.jato.RequestContext)2 ModelControlException (com.iplanet.jato.model.ModelControlException)2 SSOToken (com.iplanet.sso.SSOToken)2 PWResetQuestionModel (com.sun.identity.password.ui.model.PWResetQuestionModel)2 PWResetUserValidationModel (com.sun.identity.password.ui.model.PWResetUserValidationModel)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Cookie (javax.servlet.http.Cookie)2 CompleteRequestException (com.iplanet.jato.CompleteRequestException)1