Search in sources :

Example 11 with ISLocaleContext

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

the class PLLNotificationServlet method doPost.

/*
     * Accepts POST requests, reads Inpt Stream, forwards the NotificationSet
     * XML Flushes the ResponseSet XML to OutputStream @param
     * HttpServletNotification Reference to HttpServletNotification object
     * @param HttpServletResponse Reference to HttpServletResponse object
     * 
     * @see javax.servlet.http.HttpServlet
     */
public void doPost(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();
        throw new ServletException(e.getL10NMessage(locale));
    }
    int length = request.getContentLength();
    if (length == -1) {
        throw new ServletException(PLLBundle.getString("unknownLength"));
    }
    byte[] reqData = new byte[length];
    InputStream in = request.getInputStream();
    int rlength = 0;
    int offset = 0;
    while (rlength != length) {
        int r = in.read(reqData, offset, length - offset);
        if (r == -1) {
            throw new ServletException(PLLBundle.getString("readRequestError"));
        }
        rlength += r;
        offset += r;
    }
    String xml = new String(reqData, 0, length, "UTF-8");
    ServletOutputStream out = response.getOutputStream();
    try {
        try {
            handleNotification(xml);
            out.print("OK");
        } catch (ServletException e) {
            out.print("NOT OK");
        }
        out.flush();
    } finally {
        if (out != null) {
            out.close();
        }
    }
}
Also used : ServletException(javax.servlet.ServletException) ServletOutputStream(javax.servlet.ServletOutputStream) L10NMessageImpl(com.sun.identity.shared.locale.L10NMessageImpl) InputStream(java.io.InputStream) ISLocaleContext(com.sun.identity.common.ISLocaleContext)

Example 12 with ISLocaleContext

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

the class PWResetSuccessViewBean method forwardTo.

/**
     * Forwards to current view bean after after verifying 
     * that reset reset message exists. It will forward to 
     * <code>PWResetUserValidationViewBean</code> if the user DN 
     * or organization DN does not exists.
     *
     * @param context  request context
     */
public void forwardTo(RequestContext context) {
    PWResetSuccessModel model = (PWResetSuccessModel) getModel();
    ISLocaleContext localeContext = new ISLocaleContext();
    localeContext.setLocale(context.getRequest());
    java.util.Locale locale = localeContext.getLocale();
    model.setUserLocale(locale.toString());
    if (resetMsg == null || resetMsg.length() == 0) {
        PWResetUserValidationViewBean vb = (PWResetUserValidationViewBean) getViewBean(PWResetUserValidationViewBean.class);
        vb.forwardTo(context);
    } else {
        super.forwardTo(context);
    }
}
Also used : PWResetSuccessModel(com.sun.identity.password.ui.model.PWResetSuccessModel) ISLocaleContext(com.sun.identity.common.ISLocaleContext)

Example 13 with ISLocaleContext

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

the class PWResetQuestionViewBean method forwardTo.

/**
     * Forwards to current view bean after populating questions. It
     * will forward to <code>PWResetUserValidationViewBean</code> if 
     * the user DN or organization does not exists.
     *
     * @param context request context
     */
public void forwardTo(RequestContext context) {
    String orgDN = (String) getPageSessionAttribute(ORG_DN);
    String userDN = (String) getPageSessionAttribute(USER_DN);
    ISLocaleContext localeContext = new ISLocaleContext();
    localeContext.setLocale(context.getRequest());
    java.util.Locale locale = localeContext.getLocale();
    if (orgDN == null || orgDN.length() == 0 || userDN == null || userDN.length() == 0) {
        PWResetUserValidationViewBean vb = (PWResetUserValidationViewBean) getViewBean(PWResetUserValidationViewBean.class);
        vb.forwardTo(context);
    } else {
        PWResetQuestionModel model = (PWResetQuestionModel) getModel();
        model.readPWResetProfile(orgDN);
        model.setUserLocale(locale.toString());
        populateQuestionsList(userDN, orgDN);
        super.forwardTo(context);
    }
}
Also used : ISLocaleContext(com.sun.identity.common.ISLocaleContext) PWResetQuestionModel(com.sun.identity.password.ui.model.PWResetQuestionModel)

Example 14 with ISLocaleContext

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

the class PWResetServlet method onBeforeRequest.

/**
     * Using this callback the character set to be used for
     * decoding POST/GET data will be set.
     * @param requestContext - request context
     * @throws ServletException 
     */
protected void onBeforeRequest(RequestContext requestContext) throws ServletException {
    try {
        HttpServletRequest req = requestContext.getRequest();
        req.setCharacterEncoding("UTF-8");
        HttpSession session = req.getSession(false);
        String sessLocale = null;
        if (session != null) {
            sessLocale = (String) session.getAttribute(URL_LOCALE);
        }
        ISLocaleContext lc = new ISLocaleContext();
        if (sessLocale != null && sessLocale.length() > 0) {
            lc.setLocale(ISLocaleContext.URL_LOCALE, sessLocale);
        }
        lc.setLocale(req);
        String reqLocale = lc.getLocale().toString();
        if (req.getParameter(URL_LOCALE) != null) {
            if (session == null) {
                session = req.getSession(true);
            }
            session.setAttribute(URL_LOCALE, reqLocale);
        }
    } catch (UnsupportedEncodingException ex) {
        debug.error("ampassword:encoding error", ex);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpSession(javax.servlet.http.HttpSession) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ISLocaleContext(com.sun.identity.common.ISLocaleContext)

Example 15 with ISLocaleContext

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

the class OAuth2UserApplications method getLocale.

private Locale getLocale(Context context) {
    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)

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