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
/** * is unlock db /*w w w .ja va 2 s. co m*/ * @param userDB * @return */ public static boolean isUnlockDB(final UserDBDAO userDB) { HttpSession sStore = RWT.getRequest().getSession(); List<Integer> listUnlockDB = (List) sStore.getAttribute(NAME.UNLOCK_DB_LIST.name()); return listUnlockDB.contains(userDB.getSeq()); }
From source file:org.frat.common.security.BaseSecurityContext.java
/** * ./*from w ww . jav a2s. c om*/ * * @param username */ public static void kickOutUnLogin() { try { WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext(); ServletContext servletContext = webApplicationContext.getServletContext(); // applicationHashSet?session @SuppressWarnings("unchecked") HashSet<HttpSession> sessions = (HashSet<HttpSession>) servletContext.getAttribute("loginSessions"); List<HttpSession> sessionList = new ArrayList<HttpSession>(); if (StringUtil.isObjNotNull(sessions)) { for (HttpSession session : sessions) { SysUserDto user = (SysUserDto) session.getAttribute("shiro.user"); if (null != session && StringUtil.isObjNull(user)) { // LOGGER.debug("getLastAccessedTime="+ new // Date(session.getLastAccessedTime())); // LOGGER.debug("now="+ new Date()); int diffTime = DateUtil.diffTime(new Date(), new Date(session.getLastAccessedTime())); // LOGGER.debug("diffTime="+diffTime); if (diffTime > 300) { sessionList.add(session); } } } for (HttpSession session : sessionList) { session.invalidate(); LOGGER.debug("success kick out UnLogin session [" + session.getId() + "]"); } } } catch (Exception e) { LOGGER.error(""); LOGGER.error(StackTraceUtil.getStackTrace(e)); } }
From source file:eionet.meta.DDUser.java
/** * Returns the value of {@link #hasPermission(String, String, String)}, using the given ACL path, the given permission, and the * name of the user found in the given session. If no user found in session, the method will be called with user name set to * null./*from w w w .j av a 2 s .c o m*/ * * @param session * @param aclPath * @param permission * @return */ public static boolean hasPermission(HttpSession session, String aclPath, String permission) { // if no session given, simply return false if (session == null) { return false; } // get user object from session DDUser ddUser = (DDUser) session.getAttribute(SecurityUtil.REMOTEUSER); // get user name from user object, or set to null if user object null String userName = ddUser == null ? null : ddUser.getUserName(); // check if user with this name has this permission in this ACL return DDUser.hasPermission(userName, aclPath, permission); }
From source file:org.craftercms.core.util.HttpServletUtils.java
public static Map<String, Object> createSessionMap(HttpServletRequest request) { Map<String, Object> sessionMap = new HashMap<String, Object>(); HttpSession session = request.getSession(false); if (session != null) { for (Enumeration attributeNameEnum = session.getAttributeNames(); attributeNameEnum .hasMoreElements();) {/*from ww w . j ava 2 s . c om*/ String attributeName = (String) attributeNameEnum.nextElement(); sessionMap.put(attributeName, session.getAttribute(attributeName)); } } return sessionMap; }
From source file:org.frat.common.security.BaseSecurityContext.java
/** * @param username/*from ww w.jav a 2 s . com*/ * @return */ public static HashSet<HttpSession> getSessionByUsername(String username) { @SuppressWarnings("unchecked") HashSet<HttpSession> sessions = (HashSet<HttpSession>) WebUtil.getThreadSession().getServletContext() .getAttribute("loginSessions"); HashSet<HttpSession> httpSessions = new HashSet<HttpSession>(); for (HttpSession session : sessions) { if (null != session && StringUtil.isEqualObj( String.valueOf(session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY)), username)) { httpSessions.add(session); } } return httpSessions; }
From source file:com.hangum.tadpole.session.manager.SessionManager.java
/** * ? User .//from w ww . j a va 2 s. c o m * * @param key * @param value * @return */ public static UserInfoDataDAO getUserInfo(String key, String value) { HttpSession sStore = RWT.getRequest().getSession(); Map<String, Object> mapUserInfoData = (Map<String, Object>) sStore.getAttribute(NAME.USER_INFO_DATA.name()); UserInfoDataDAO userData = (UserInfoDataDAO) mapUserInfoData.get(key); if (userData == null) { userData = new UserInfoDataDAO(SessionManager.getUserSeq(), key, value); try { TadpoleSystem_UserInfoData.insertUserInfoData(userData); } catch (Exception e) { logger.error("User data save exception [key]" + key + "[value]" + value, e); } mapUserInfoData.put(key, userData); } return userData; }
From source file:com.hangum.tadpole.session.manager.SessionManager.java
/** * . /* w ww . j a v a 2s . c o m*/ * @param key * @param obj */ public static void setUserInfo(String key, String obj) { HttpSession sStore = RWT.getRequest().getSession(); Map<String, Object> mapUserInfoData = (Map<String, Object>) sStore.getAttribute(NAME.USER_INFO_DATA.name()); UserInfoDataDAO userInfoDataDAO = (UserInfoDataDAO) mapUserInfoData.get(key); if (userInfoDataDAO == null) { userInfoDataDAO = new UserInfoDataDAO(SessionManager.getUserSeq(), key, obj); try { TadpoleSystem_UserInfoData.insertUserInfoData(userInfoDataDAO); } catch (Exception e) { logger.error("User data save exception [key]" + key + "[value]" + obj, e); } } else { userInfoDataDAO.setValue0(obj); } mapUserInfoData.put(key, userInfoDataDAO); sStore.setAttribute(NAME.USER_INFO_DATA.name(), mapUserInfoData); }
From source file:org.frat.common.security.BaseSecurityContext.java
/** * .//from ww w. ja v a2 s .c o m * * @param username */ public static void kickOutUser(String username) { try { // applicationHashSet?session @SuppressWarnings("unchecked") HashSet<HttpSession> sessions = (HashSet<HttpSession>) WebUtil.getServletContext() .getAttribute("loginSessions"); List<HttpSession> sessionList = new ArrayList<HttpSession>(); for (HttpSession session : sessions) { if (null != session && StringUtil.isEqualObj( String.valueOf(session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY)), username)) { // session if (!StringUtil.isEqualObj(session.getId(), WebUtil.getSessionId())) { sessionList.add(session); } } } for (HttpSession session : sessionList) { session.invalidate(); LOGGER.info("success kick out session [" + session.getId() + "]"); LOGGER.info("success kick out user [" + username + "]"); } } catch (Exception e) { LOGGER.error(""); LOGGER.error(StackTraceUtil.getStackTrace(e)); } }
From source file:fr.paris.lutece.portal.web.PortalJspBean.java
/** * Returns the url (asked before login) to redirect after login * @param request The Http request//ww w. j a va2s.c o m * @return The url asked before login * @since v1.1 */ public static String getLoginNextUrl(HttpServletRequest request) { HttpSession session = request.getSession(); String strNextUrl = (String) session.getAttribute(ATTRIBUTE_LOGIN_NEXT_URL); return strNextUrl; }
From source file:fr.paris.lutece.portal.web.PortalJspBean.java
/** * Get the upload filter site next url//from w ww.j a v a2 s. c o m * @param request the HTTP request * @return the next url */ public static String getUploadFilterSiteNextUrl(HttpServletRequest request) { HttpSession session = request.getSession(); String strNextUrl = (String) session.getAttribute(ATTRIBUTE_UPLOAD_FILTER_SITE_NEXT_URL); return strNextUrl; }