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