List of usage examples for javax.servlet.http HttpServletRequest getSession
public HttpSession getSession();
From source file:com.o2o.util.WebUtils.java
public final static String getWebAppRootPath(HttpServletRequest request) { return request.getSession().getServletContext().getRealPath("/");// }
From source file:eionet.util.SecurityUtil.java
/** * Returns current user, or null, if the current session does not have user attached to it. *//*from w w w.jav a 2 s .com*/ public static final DDUser getUser(HttpServletRequest request) { HttpSession session = request.getSession(); DDUser user = session == null ? null : (DDUser) session.getAttribute(REMOTEUSER); if (user == null) { String casUserName = session == null ? null : (String) session.getAttribute(CASFilter.CAS_FILTER_USER); if (casUserName != null) { user = DDCASUser.create(casUserName); session.setAttribute(REMOTEUSER, user); } } else if (user instanceof DDCASUser) { String casUserName = (String) session.getAttribute(CASFilter.CAS_FILTER_USER); if (casUserName == null) { user.invalidate(); user = null; session.removeAttribute(REMOTEUSER); } else if (!casUserName.equals(user.getUserName())) { user.invalidate(); user = DDCASUser.create(casUserName); session.setAttribute(REMOTEUSER, user); } } if (user != null) { return user.isAuthentic() ? user : null; } else { return null; } }
From source file:com.bluexml.side.framework.alfresco.shareLanguagePicker.LanguageSetter.java
protected static String getUserLanguage(String currentUserId, HttpServletRequest req) throws ConnectorServiceException, ServletException, JSONException { // get a connector whose connector session is bound to the current // session// w ww . j a va 2 s.com Connector connector = FrameworkUtil.getConnector(req.getSession(), currentUserId, "alfresco"); // build the REST URL to retrieve user preferences String uri = "/api/people/" + URLEncoder.encode(currentUserId) + "/preferences?pf=" + profile_language; // invoke and check for OK response Response response = connector.call(uri); if (Status.STATUS_OK != response.getStatus().getCode()) { throw new ServletException("failed to retrieve user preferences: " + response.getStatus().getMessage(), (Exception) response.getStatus().getException()); } // Load the user properties via the JSON parser String responseString = response.getResponse(); JSONObject root = new JSONObject(responseString); String language = null; if (!root.isNull(profile_language)) { language = root.getString(profile_language); } return language; }
From source file:com.us.reflect.ClassFinder.java
private static Object[] getRuntimeArgs(ActionInvocation invocation, String[] paramers) { List<Object> runtime = new LinkedList<Object>(); HttpServletRequest request = ServletActionContext.getRequest();// HttpServletRequest for (String param : paramers) { char index0 = param.charAt(0); String parname = param.substring(1); if (index0 == '#') { // Session ?? runtime.add(request.getSession().getAttribute(parname)); } else if (index0 == '$') { runtime.add(request.getAttribute(parname)); } else if (index0 == '@' && parname.equals("request")) { runtime.add(request);/*from w w w.ja va 2 s . c o m*/ } else if (index0 == '@' && parname.equals("response")) { runtime.add(ServletActionContext.getResponse()); } else { runtime.add(DaoHelper.getBeanById(param)); } } return runtime.toArray(new Object[] {}); }
From source file:org.tapestry.surveys.DoSurveyAction.java
public static TapestrySurveyMap getSurveyMap(HttpServletRequest request) { TapestrySurveyMap userSurveys = (TapestrySurveyMap) request.getSession() .getAttribute("session_survey_list"); return userSurveys; }
From source file:com.sapienter.jbilling.server.user.validator.RepeatedPasswordValidator.java
/** * Struts validator that checks whether the password that is being set * by the user has been already used in the last two years. * @param bean/*from www .j a v a 2 s . c o m*/ * @param va * @param field * @param errors * @param request * @param application * @return <code>true</code> if the validation passes and the password * has not been used, otherwise <code>false</code>. */ public static boolean validateRepeatedPassword(Object bean, ValidatorAction va, Field field, ActionErrors errors, HttpServletRequest request, ServletContext application) { boolean result = true; String value = ValidatorUtils.getValueAsString(bean, field.getProperty()); // Determine the id and role of the user changing his password Integer userId = (Integer) request.getSession().getAttribute(Constants.SESSION_USER_ID); Integer userRole = null; try { IUserSessionBean user = (IUserSessionBean) Context.getBean(Context.Name.USER_SESSION); userRole = user.getUserDTOEx(userId).getMainRoleId(); } catch (Exception e) { result = false; } // Perform the check in the event_log table to see if the user has // previously used the password he's trying to set now. if (result && !GenericValidator.isBlankOrNull(value)) { result = basicValidation(userId, userRole, value); } if (result == false) { errors.add(field.getKey(), Resources.getActionError(request, va, field)); } return result; }
From source file:net.bluemix.newsaggregator.api.AuthenticationServlet.java
static public boolean checkAuthorization(HttpServletRequest httpServletRequest) { try {/*from w w w . ja va2 s . c om*/ String value = System.getenv("NA_LOCAL"); if ((value != null) && (!value.equalsIgnoreCase(""))) return true; String userName = (String) httpServletRequest.getSession().getAttribute("userName"); if (userName == null) return false; if (userName.equalsIgnoreCase("")) return false; String[] curators = ConfigUtilities.getSingleton().getCurators(); if (curators == null) return false; for (int i = 0; i < curators.length; i++) { if (curators[i].equalsIgnoreCase(userName)) return true; } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:com.jdon.strutsutil.FormBeanUtil.java
/** * ?struts_config.xmlattributeActionForm? * /* w ww .jav a 2s . c om*/ * @param form * @param mapping * @param request */ public static ActionForm loadActionForm(ActionMapping mapping, HttpServletRequest request) { if ("request".equals(mapping.getScope())) { return (ActionForm) request.getAttribute(mapping.getAttribute()); } else { HttpSession session = request.getSession(); return (ActionForm) session.getAttribute(mapping.getAttribute()); } }
From source file:com.acc.storefront.tags.Functions.java
/** * Returns the Spring bean with name <code>beanName</code> and of type <code>beanClass</code>. * // w w w.j a v a 2 s.c om * @param <T> * type of the bean * @param httpRequest * the http request * @param beanName * name of the bean * @param beanClass * expected type of the bean * @return the bean matching the given arguments or <code>null</code> if no bean could be resolved */ public static <T> T getSpringBean(final HttpServletRequest httpRequest, final String beanName, final Class<T> beanClass) { return RequestContextUtils .getWebApplicationContext(httpRequest, httpRequest.getSession().getServletContext()) .getBean(beanName, beanClass); }
From source file:eu.eidas.node.utils.EidasNodeErrorUtil.java
private static String getIssuer(final HttpServletRequest req) { Object issuer = req.getSession().getAttribute(EIDASParameters.ISSUER.toString()); return issuer == null ? "ConnectorExceptionHandlerServlet" : issuer.toString(); }