List of usage examples for javax.servlet.http HttpSession getAttribute
public Object getAttribute(String name);
null
if no object is bound under the name. From source file:com.hangum.tadpole.session.manager.SessionManager.java
/** * UserManager object list .//w ww . j av a 2 s. co m * * @return */ public static List<ManagerListDTO> getManagerDBList() { HttpSession sStore = RWT.getRequest().getSession(); Object listObj = sStore.getAttribute(NAME.ALL_MANAGER_DB_LIST.name()); if (listObj == null) { return new ArrayList<ManagerListDTO>(); } else { return (List<ManagerListDTO>) listObj; } }
From source file:com.adito.vfs.VFSRepository.java
/** * Create a {@link VFSRepository} repository for the given session. The * repository will be placed in the users session and used for all VFS * operations.//from w w w . j a v a 2s .c o m * * @param session * @return VFS repository * @throws DAVBundleActionMessageException * @throws Exception */ public static VFSRepository getRepository(HttpSession session) throws DAVBundleActionMessageException, Exception { VFSRepository repository = (VFSRepository) session.getAttribute(REPOSITORY_ATTR); if (repository == null) { repository = new VFSRepository(session); session.setAttribute(REPOSITORY_ATTR, repository); if (log.isInfoEnabled()) log.info("Initialized repository"); } return repository; }
From source file:com.liusoft.dlog4j.UserLoginManager.java
/** * Velocity?// ww w . j a v a 2 s. com * * @param request * @param response * @param uuid * @param verify_host * @return * @see com.liusoft.dlog4j.velocity.DLOG_VelocityTool#verify_login_cookie(String, * boolean) */ public static SessionUserObject getLoginUser(HttpServletRequest request, HttpServletResponse response, boolean verify_host) { // sessionsession? Cookie uuidCookie = null; HttpSession ssn = request.getSession(false); if (ssn != null) { SessionUserObject user = (SessionUserObject) ssn.getAttribute(SESSION_USER_KEY); if (user != null) { uuidCookie = getUuidCookie(request); //sessioncookie? //(?s1s2?) if (uuidCookie != null) return user; ssn.invalidate(); return null; } } String uuid = null; if (uuidCookie == null) uuidCookie = getUuidCookie(request); if (uuidCookie != null) uuid = uuidCookie.getValue(); if (StringUtils.isEmpty(uuid)) return null; // session? try { UUID oUUID = new UUID(uuid); String new_host = request.getRemoteAddr(); if (verify_host && !StringUtils.equals(new_host, oUUID.host)) return null; UserBean user = UserDAO.getUserByID(oUUID.uid); // ? if (user == null || user.getStatus() != UserBean.STATUS_NORMAL || user.getPassword().hashCode() != oUUID.pwdCode) { RequestUtils.setCookie(request, response, COOKIE_UUID_KEY, "", 0); RequestUtils.setCookie(request, response, COOKIE_LASTLOGIN_KEY, "", 0); return null; } int keep_days = user.getKeepDays(); if (keep_days < 1) keep_days = 365; return loginUser(request, response, user, keep_days); } catch (Exception e) { log.error("Exception occur when get current user.", e); } return null; }
From source file:org.carewebframework.security.spring.DesktopSecurityContextRepository.java
/** * Returns the security context from the session, if it exists. * /* w w w . j a v a2s . co m*/ * @param session Session where security context is stored. * @param remove If true and a security context is found in the session, it is removed. * @return The security context, or null if none found. */ private static SecurityContext getSecurityContext(HttpSession session, boolean remove) { SecurityContext securityContext = (SecurityContext) session.getAttribute(CONTEXT_KEY); if (securityContext != null && remove) { session.removeAttribute(CONTEXT_KEY); } return securityContext; }
From source file:de.zib.gndms.kit.monitor.GroovyMoniServlet.java
@NotNull static GroovyMonitor lookupMonitorOrFail(@NotNull Principal principal, @NotNull HttpSession session, @NotNull String token) {/*from www . j a va2 s. com*/ synchronized (session) { final GroovyMonitor monitor = (GroovyMonitor) session.getAttribute(token); if (monitor == null) throw preCondFailed("Unknown token"); monitor.verifyPrincipal(principal); return monitor; } }
From source file:com.curl.orb.servlet.InstanceManagementServlet.java
static Object[] switchRemoteObject(Object[] args, HttpSession session) throws InstanceManagementException { if (args != null) { for (int i = 0; i < args.length; i++) { Object obj = args[i]; if (obj instanceof RemoteObject) { if (session == null) throw new InstanceManagementException("Does not exist HttpSession."); args[i] = session.getAttribute(((RemoteObject) obj).getObjectId()); if (args[i] == null) throw new InstanceManagementException( "No RemoteObject in HttpSession [argument:" + i + "]"); }//from ww w . j a va 2 s. c om } } return args; }
From source file:org.openmrs.module.logmanager.web.util.WebUtils.java
/** * Gets an int parameter from the request that is being "remembered" in the session * @param request the http request//from w w w. ja va 2 s . com * @param name the name of the parameter * @param def the default value of the parameter * @param sessionPrefix the prefix to generate session attribute from parameter name * @return the parameter value */ public static int getSessionedIntParameter(HttpServletRequest request, String name, int def, String sessionPrefix) { HttpSession session = request.getSession(); int val = def; // If specified in request, read that and store in session if (request.getParameter(name) != null) { val = ServletRequestUtils.getIntParameter(request, name, def); session.setAttribute(sessionPrefix + name, val); } // Otherwise look for a matching attribute in the session else { Integer sessionVal = (Integer) session.getAttribute(sessionPrefix + name); if (sessionVal != null) val = sessionVal; } return val; }
From source file:net.big_oh.common.web.WebUtil.java
/** * A convenience method that performs a reverse lookup to find all names * under which an attribute is stored in a user's {@link HttpSession}. * //from w ww . j a va2 s . c o m * @param session * An HttpSession object from any web application. * @param sessionAttribute * Attribute name of interest. * @return A seet of all attribute names under which the sessionAttribute * parameter is stored in the session. */ public static Set<String> getNamesForSessionAttribute(HttpSession session, Object sessionAttribute) { Set<String> attributeNames = new HashSet<String>(); Enumeration<?> attributeEnum = session.getAttributeNames(); while (attributeEnum.hasMoreElements()) { String attributeName = (String) attributeEnum.nextElement(); if (sessionAttribute == session.getAttribute(attributeName)) { attributeNames.add(attributeName); } } return attributeNames; }
From source file:org.carewebframework.security.spring.DesktopSecurityContextRepository.java
/** * Given a desktop, returns Spring security context object. * // w w w .j a v a 2 s.co m * @param desktop The desktop whose security context is sought. * @return SecurityContext The Spring security context. */ public static SecurityContext getSecurityContext(Desktop desktop) { final String key = getDesktopContextKey(desktop.getId()); HttpSession session = (HttpSession) desktop.getSession().getNativeSession(); return (SecurityContext) session.getAttribute(key); }
From source file:com.hangum.tadpole.session.manager.SessionManager.java
/** * set unlock db list/*from www .j a va2 s. co m*/ * @param userDB * @return */ public static boolean setUnlokDB(final UserDBDAO userDB) { HttpSession sStore = RWT.getRequest().getSession(); List<Integer> listUnlockDB = (List) sStore.getAttribute(NAME.UNLOCK_DB_LIST.name()); return listUnlockDB.add(userDB.getSeq()); }