org.apache.shiro.session.InvalidSessionException Java Examples
The following examples show how to use
org.apache.shiro.session.InvalidSessionException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserUtils.java From easyweb with Apache License 2.0 | 6 votes |
public static Session getSession(){ try{ Subject subject = SecurityUtils.getSubject(); Session session = subject.getSession(false); if (session == null){ session = subject.getSession(); } if (session != null){ return session; } // subject.logout(); }catch (InvalidSessionException e){ } return null; }
Example #2
Source File: IamSecurityHolder.java From super-cloudops with Apache License 2.0 | 6 votes |
/** * Bind key-values map to session * * @param sessionKey * @param keyValues */ public static void bindKVParameters(String sessionKey, Object... keyValues) throws InvalidSessionException { hasTextOf(sessionKey, "sessionKey"); notEmptyOf(keyValues, "keyValues"); isTrueOf(keyValues.length % 2 == 0, "Illegal 'keyValues' length"); // Extract key values Map<Object, Object> parameters = new HashMap<>(); for (int i = 0; i < keyValues.length - 1; i++) { if (i % 2 == 0) { Object key = keyValues[i]; Object value = keyValues[i + 1]; if (!isNull(key) && isNotBlank(key.toString()) && !isNull(value) && isNotBlank(value.toString())) { parameters.put(key, value); } } } // Binding bind(sessionKey, parameters); }
Example #3
Source File: UserUtil.java From scaffold-cloud with MIT License | 6 votes |
public static Session getSession(){ try{ SecurityManager securityManager = ThreadContext.getSecurityManager(); if(securityManager == null){ return null; } Subject subject = SecurityUtils.getSubject(); Session session = subject.getSession(false); if (session == null){ session = subject.getSession(); } if (session != null){ return session; } }catch (InvalidSessionException e){ } return null; }
Example #4
Source File: UserUtils.java From Shop-for-JavaWeb with MIT License | 6 votes |
public static Session getSession(){ try{ Subject subject = SecurityUtils.getSubject(); Session session = subject.getSession(false); if (session == null){ session = subject.getSession(); } if (session != null){ return session; } // subject.logout(); }catch (InvalidSessionException e){ } return null; }
Example #5
Source File: ShiroSessionDAO.java From phone with Apache License 2.0 | 6 votes |
@Override protected Serializable doCreate(Session session) { logger.trace("shiro create session start"); super.doCreate(session); //先本地缓存,再存redis RedisClientSupport jedis = SpringBeanUtil.getRedisClientSupport(); if (jedis != null) { Serializable sessionId = generateSessionId(session); logger.trace("cache by jedis,and sessionId is {}",sessionId); assignSessionId(session, sessionId); String key = RedisKeyConfig.getShiroSessionCacheKey(sessionId); String value = SerializableUtils.serialize(session); try { jedis.putValue(key, value,session.getTimeout()/1000,TimeUnit.SECONDS); } catch (InvalidSessionException | CacheAccessException e) { } } return session.getId(); }
Example #6
Source File: BaseController.java From zheng with MIT License | 6 votes |
/** * 统一异常处理 * @param request * @param response * @param exception */ @ExceptionHandler public String exceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception exception) { LOGGER.error("统一异常处理:", exception); request.setAttribute("ex", exception); if (null != request.getHeader("X-Requested-With") && "XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With"))) { request.setAttribute("requestHeader", "ajax"); } // shiro没有权限异常 if (exception instanceof UnauthorizedException) { return "/403.jsp"; } // shiro会话已过期异常 if (exception instanceof InvalidSessionException) { return "/error.jsp"; } return "/error.jsp"; }
Example #7
Source File: ShiroSessionDAO.java From phone with Apache License 2.0 | 6 votes |
@Override public void update(Session session) { if (session instanceof ValidatingSession && !((ValidatingSession) session).isValid()) { return; // 如果会话过期/停止 没必要再更新了 } super.update(session); RedisClientSupport jedis = SpringBeanUtil.getRedisClientSupport(); if (jedis != null) { String key = RedisKeyConfig.getShiroSessionCacheKey(session.getId()); // String value = JSON.toJSONString(session); String value = SerializableUtils.serialize(session); try { jedis.putValue(key, value,session.getTimeout()/1000,TimeUnit.SECONDS); } catch (InvalidSessionException | CacheAccessException e) { } } }
Example #8
Source File: SessionManager.java From easyweb with Apache License 2.0 | 5 votes |
public void checkValid(SessionKey key) { try{ super.checkValid(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 } }
Example #9
Source File: BaseController.java From cms with Apache License 2.0 | 5 votes |
public Session getSession() { try { Subject subject = SecurityUtils.getSubject(); Session session = subject.getSession(false); if (session == null) { session = subject.getSession(); } if (session != null) { return session; } } catch (InvalidSessionException e) { } return null; }
Example #10
Source File: SessionCacheManager.java From easyweb with Apache License 2.0 | 5 votes |
public Session getSession(){ Session session = null; try{ Subject subject = SecurityUtils.getSubject(); session = subject.getSession(false); if (session == null){ session = subject.getSession(); } }catch (InvalidSessionException e){ logger.error("Invalid session error", e); }catch (UnavailableSecurityManagerException e2){ logger.error("Unavailable SecurityManager error", e2); } return session; }
Example #11
Source File: SessionManager.java From Shop-for-JavaWeb with MIT License | 5 votes |
public void touch(SessionKey key) { try{ super.touch(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 } }
Example #12
Source File: SessionManager.java From Shop-for-JavaWeb with MIT License | 5 votes |
public void checkValid(SessionKey key) { try{ super.checkValid(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 } }
Example #13
Source File: SessionManager.java From Shop-for-JavaWeb with MIT License | 5 votes |
public void stop(SessionKey key) { try{ super.stop(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 } }
Example #14
Source File: SessionManager.java From Shop-for-JavaWeb with MIT License | 5 votes |
public Object removeAttribute(SessionKey sessionKey, Object attributeKey) { try{ return super.removeAttribute(sessionKey, attributeKey); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 return null; } }
Example #15
Source File: SessionManager.java From Shop-for-JavaWeb with MIT License | 5 votes |
public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) { try{ super.setAttribute(sessionKey, attributeKey, value); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 } }
Example #16
Source File: SessionManager.java From Shop-for-JavaWeb with MIT License | 5 votes |
public Object getAttribute(SessionKey sessionKey, Object attributeKey) { try{ return super.getAttribute(sessionKey, attributeKey); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 return null; } }
Example #17
Source File: SessionManager.java From Shop-for-JavaWeb with MIT License | 5 votes |
public Collection<Object> getAttributeKeys(SessionKey key) { try{ return super.getAttributeKeys(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 return null; } }
Example #18
Source File: SessionManager.java From Shop-for-JavaWeb with MIT License | 5 votes |
public String getHost(SessionKey key) { try{ return super.getHost(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 return null; } }
Example #19
Source File: SessionManager.java From easyweb with Apache License 2.0 | 5 votes |
public void stop(SessionKey key) { try{ super.stop(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 } }
Example #20
Source File: SessionManager.java From easyweb with Apache License 2.0 | 5 votes |
public Object removeAttribute(SessionKey sessionKey, Object attributeKey) { try{ return super.removeAttribute(sessionKey, attributeKey); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 return null; } }
Example #21
Source File: HttpServletRequestSession.java From usergrid with Apache License 2.0 | 5 votes |
@Override public Object removeAttribute( Object objectKey ) throws InvalidSessionException { String key = stringify( objectKey ); Object formerValue = request.getAttribute( key ); request.removeAttribute( key ); return formerValue; }
Example #22
Source File: SessionManager.java From easyweb with Apache License 2.0 | 5 votes |
public Object getAttribute(SessionKey sessionKey, Object attributeKey) { try{ return super.getAttribute(sessionKey, attributeKey); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 return null; } }
Example #23
Source File: SessionManager.java From easyweb with Apache License 2.0 | 5 votes |
public Collection<Object> getAttributeKeys(SessionKey key) { try{ return super.getAttributeKeys(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 return null; } }
Example #24
Source File: SessionManager.java From easyweb with Apache License 2.0 | 5 votes |
public String getHost(SessionKey key) { try{ return super.getHost(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 return null; } }
Example #25
Source File: SessionManager.java From easyweb with Apache License 2.0 | 5 votes |
public void touch(SessionKey key) { try{ super.touch(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 } }
Example #26
Source File: SessionManager.java From easyweb with Apache License 2.0 | 5 votes |
public void setTimeout(SessionKey key, long maxIdleTimeInMillis) { try{ super.setTimeout(key, maxIdleTimeInMillis); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 } }
Example #27
Source File: SessionManager.java From easyweb with Apache License 2.0 | 5 votes |
public long getTimeout(SessionKey key){ try{ return super.getTimeout(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 return 0; } }
Example #28
Source File: SessionManager.java From easyweb with Apache License 2.0 | 5 votes |
public Date getLastAccessTime(SessionKey key) { try{ return super.getLastAccessTime(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 return null; } }
Example #29
Source File: SessionManager.java From easyweb with Apache License 2.0 | 5 votes |
public Date getStartTimestamp(SessionKey key) { try{ return super.getStartTimestamp(key); }catch (InvalidSessionException e) { // 获取不到SESSION不抛出异常 return null; } }
Example #30
Source File: OnlineWebSessionManager.java From es with Apache License 2.0 | 5 votes |
@Override public Object removeAttribute(SessionKey sessionKey, Object attributeKey) throws InvalidSessionException { Object removed = super.removeAttribute(sessionKey, attributeKey); if (removed != null) { OnlineSession s = (OnlineSession) doGetSession(sessionKey); s.markAttributeChanged(); } return removed; }