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