Search in sources :

Example 6 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 7 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 8 with ISLocaleContext

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

the class AuthViewBeanBase method setPageEncoding.

protected void setPageEncoding(HttpServletRequest request, HttpServletResponse response) {
    /** Set the codeset of the page **/
    String client_type = AuthClientUtils.getClientType(request);
    String content_type = AuthClientUtils.getContentType(client_type);
    accLocale = fallbackLocale;
    if (accLocale == null) {
        ISLocaleContext localeContext = new ISLocaleContext();
        localeContext.setLocale(request);
        accLocale = localeContext.getLocale();
    }
    String charset = AuthClientUtils.getCharSet(client_type, accLocale);
    if (response != null) {
        response.setContentType(content_type + ";charset=" + charset);
    }
    String jCharset = BrowserEncoding.mapHttp2JavaCharset(charset);
    if (loginDebug.messageEnabled()) {
        loginDebug.message("In setPageEncoding - charset : " + charset);
        loginDebug.message("In setPageEncoding - JCharset : " + jCharset);
    }
    setDisplayFieldValue(PAGE_ENCODING, jCharset);
}
Also used : ISLocaleContext(com.sun.identity.common.ISLocaleContext)

Example 9 with ISLocaleContext

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

the class Gateway method doPost.

/**
     * Performs the HTTP POST operation. 
     */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // Obtain goto URL and check if there are auth parameters
    String authScheme = null;
    String authLevel = null;
    String gotoUrl = null;
    ActionDecision ad = null;
    Map advices = null;
    String orgName = null;
    // 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.messageEnabled()) {
            debug.message("GatewayServlet: " + e.getL10NMessage(locale));
        }
        throw new ServletException(e.getL10NMessage(locale));
    }
    // Construct the default forwarding URL
    StringBuilder forwardUrl = new StringBuilder(200);
    forwardUrl.append(LOGIN_URL);
    String queryString = request.getQueryString();
    Enumeration paramNames = request.getParameterNames();
    while ((queryString != null) && paramNames.hasMoreElements()) {
        String key = (String) paramNames.nextElement();
        if (key.equalsIgnoreCase(GOTO_URL)) {
            gotoUrl = request.getParameter(key);
        } else if (key.equalsIgnoreCase(AUTH_SCHEME)) {
            authScheme = request.getParameter(key);
        } else if (key.equalsIgnoreCase(AUTH_LEVEL)) {
            authLevel = request.getParameter(key);
        }
    }
    if (debug.messageEnabled()) {
        debug.message("GatewayServlet: queryString : " + queryString);
        debug.message("GatewayServlet: gotoUrl : " + gotoUrl);
    }
    if (gotoUrl != null) {
        ad = getActionDecision(gotoUrl);
        if (ad != null) {
            advices = ad.getAdvices();
            orgName = getOrgNameFromAdvice(advices);
        }
    }
    AuthServiceConfigInfo info = null;
    // Construct the forward URL
    if ((gotoUrl != null) && ((authScheme == null) && (authLevel == null))) {
        if (debug.messageEnabled()) {
            debug.message("GatewayServlet: gotoUrl : " + gotoUrl);
        }
        // we have only goto URL, hence find from policy if there are
        // any advices on authentication modules
        forwardUrl.append('?').append(queryString);
        String advice = getPolicyAdvice(ad);
        info = getGWServletUtilsFromMap(advices);
        if (advice != null) {
            StringBuffer adv = new StringBuffer();
            int index1 = advice.indexOf("=");
            if (index1 != -1) {
                adv = adv.append(advice.substring(0, index1 + 1));
                int index2 = advice.indexOf(":");
                if (index2 != -1) {
                    orgName = advice.substring(index1 + 1, index2);
                    adv = adv.append(advice.substring(index2 + 1));
                    advice = adv.toString();
                }
            }
        }
        if (debug.messageEnabled()) {
            debug.message("GatewayServlet: advice from getPolicyAdvice(): " + advice);
        }
        if (advice != null && advice.length() > 0) {
            forwardUrl.append('&').append(advice);
        }
    } else if ((authScheme != null) || (authLevel != null)) {
        // Either query string contains goto url & auth parameters
        // which could be auth level or module, or no goto url
        forwardUrl.append('?').append(queryString);
        if (authScheme != null) {
            info = getGWServletUtilsByScheme(orgName, authScheme);
        } else if (authLevel != null) {
            info = getGWServletUtilsByLevel(orgName, authLevel);
        }
    }
    // If module is Cert, redirect to Cert module URL
    String fUrl = forwardUrl.toString();
    if (debug.messageEnabled()) {
        debug.message("GatewayServlet >>> Need to change URL !");
        debug.message("OLD URL : " + fUrl);
    }
    if ((info != null) && (info.getPortNumber() != null)) {
        fUrl = CERT_PROTOCOL + request.getServerName() + ":" + info.getPortNumber() + SystemProperties.get(AuthXMLTags.SERVER_DEPLOY_URI) + fUrl;
        if ((orgName != null) && (fUrl.indexOf("org=") == -1)) {
            fUrl = fUrl + "&" + ORG_NAME + "=" + DNtoName(orgName);
        }
        response.sendRedirect(fUrl);
    } else {
        // Forward the request to Login servlet
        if ((orgName != null) && (fUrl.indexOf("org=") == -1)) {
            fUrl = fUrl + "&" + ORG_NAME + "=" + DNtoName(orgName);
        }
        // Forward the request to Login servlet
        RequestDispatcher dispatcher = config.getServletContext().getRequestDispatcher(fUrl);
        dispatcher.forward(request, response);
    }
    if (debug.messageEnabled()) {
        debug.message("New URL : " + fUrl);
    }
}
Also used : Enumeration(java.util.Enumeration) L10NMessageImpl(com.sun.identity.shared.locale.L10NMessageImpl) ActionDecision(com.sun.identity.policy.ActionDecision) RequestDispatcher(javax.servlet.RequestDispatcher) ServletException(javax.servlet.ServletException) ISLocaleContext(com.sun.identity.common.ISLocaleContext) HashMap(java.util.HashMap) Map(java.util.Map)

Example 10 with ISLocaleContext

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

the class AuthClientUtils method getCharsetFileName.

/* insert chartset in the filename */
private static String getCharsetFileName(String fileName) {
    ISLocaleContext localeContext = new ISLocaleContext();
    String charset = localeContext.getMIMECharset();
    if (fileName == null) {
        return (null);
    }
    int i = fileName.indexOf(".");
    String charsetFilename = null;
    if (i != -1) {
        charsetFilename = fileName.substring(0, i) + "_" + charset + fileName.substring(i);
    } else {
        charsetFilename = fileName + "_" + charset;
    }
    if (utilDebug.messageEnabled()) {
        utilDebug.message("charsetFilename is : " + charsetFilename);
    }
    return charsetFilename;
}
Also used : 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