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();
}
}
}
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);
}
}
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);
}
}
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);
}
}
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();
}
Aggregations