本文整理汇总了Java中org.apache.shiro.session.InvalidSessionException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidSessionException类的具体用法?Java InvalidSessionException怎么用?Java InvalidSessionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidSessionException类属于org.apache.shiro.session包,在下文中一共展示了InvalidSessionException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getSession
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
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;
}
开发者ID:egojit8,项目名称:easyweb,代码行数:17,代码来源:UserUtils.java
示例2: validateSessions
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
@Override
public void validateSessions() {
Collection<?> activeSessions = getActiveSessions();
if (null != activeSessions && !activeSessions.isEmpty()) {
for (Iterator<?> i$ = activeSessions.iterator(); i$.hasNext();) {
Session session = (Session) i$.next();
try {
SessionKey key = new DefaultSessionKey(session.getId());
validate(session, key);
} catch (InvalidSessionException e) {
if (null != cacheManager) {
SimpleSession s = (SimpleSession) session;
if (null != s.getAttribute(Constant.SESSION_ID))
cacheManager.getCache(null).remove(s.getAttribute(Constant.SESSION_ID));
}
}
}
}
}
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:20,代码来源:DefaultSessionManager.java
示例3: exceptionHandler
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
/**
* 统一异常处理
* @param request
* @param response
* @param exception
*/
@ExceptionHandler
public String exceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception exception) {
_log.error("统一异常处理:", exception);
request.setAttribute("ex", exception);
if (null != request.getHeader("X-Requested-With") && request.getHeader("X-Requested-With").equalsIgnoreCase("XMLHttpRequest")) {
request.setAttribute("requestHeader", "ajax");
}
// shiro没有权限异常
if (exception instanceof UnauthorizedException) {
return "/403.jsp";
}
// shiro会话已过期异常
if (exception instanceof InvalidSessionException) {
return "/error.jsp";
}
return "/error.jsp";
}
开发者ID:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:24,代码来源:BaseController.java
示例4: exceptionHandler
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
/**
* 统一异常处理
* @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";
}
开发者ID:ChangyiHuang,项目名称:shuzheng,代码行数:24,代码来源:BaseController.java
示例5: getSession
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
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;
}
开发者ID:ansafari,项目名称:melon,代码行数:17,代码来源:UserUtils.java
示例6: getSession
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
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;
}
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:17,代码来源:UserUtils.java
示例7: doCreate
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
@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();
}
开发者ID:leiyong0326,项目名称:phone,代码行数:20,代码来源:ShiroSessionDAO.java
示例8: update
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
@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) {
}
}
}
开发者ID:leiyong0326,项目名称:phone,代码行数:18,代码来源:ShiroSessionDAO.java
示例9: getKeyNames
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
protected Set<String> getKeyNames() {
Collection<Object> keySet;
try {
keySet = getSession().getAttributeKeys();
} catch (InvalidSessionException e) {
throw new IllegalStateException(e);
}
Set<String> keyNames;
if (keySet != null && !keySet.isEmpty()) {
keyNames = new HashSet<String>(keySet.size());
for (Object o : keySet) {
keyNames.add(o.toString());
}
} else {
keyNames = Collections.EMPTY_SET;
}
return keyNames;
}
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:20,代码来源:ShiroHttpSession.java
示例10: resolveSession
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
/**
* Attempts to resolve any associated session based on the context and returns a
* context that represents this resolved {@code Session} to ensure it may be referenced if necessary by the
* invoked {@link SubjectFactory} that performs actual {@link Subject} construction.
* <p/>
* If there is a {@code Session} already in the context because that is what the caller wants to be used for
* {@code Subject} construction, or if no session is resolved, this method effectively does nothing
* returns the context method argument unaltered.
*
* @param context the subject context data that may resolve a Session instance.
* @return The context to use to pass to a {@link SubjectFactory} for subject creation.
* @since 1.0
*/
@SuppressWarnings({"unchecked"})
protected SubjectContext resolveSession(SubjectContext context) {
if (context.resolveSession() != null) {
log.debug("Context already contains a session. Returning.");
return context;
}
try {
//Context couldn't resolve it directly, let's see if we can since we have direct access to
//the session manager:
Session session = resolveContextSession(context);
if (session != null) {
context.setSession(session);
}
} catch (InvalidSessionException e) {
log.debug("Resolved SubjectContext context session is invalid. Ignoring and creating an anonymous " +
"(session-less) Subject instance.", e);
}
return context;
}
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:33,代码来源:DefaultSecurityManager.java
示例11: setAttribute
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
@Override
public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) throws InvalidSessionException {
try {
super.setAttribute(sessionKey, attributeKey, value);
} catch (UnknownSessionException e) {
Subject subject = ThreadContext.getSubject();
if ((value instanceof PrincipalCollection) && sessionDAO != null && subject != null
&& (subject instanceof DelegatingSubject)) {
try {
SessionContext sessionContext = createSessionContext(((DelegatingSubject) subject).getHost());
Session session = newSessionInstance(sessionContext);
session.setAttribute(attributeKey, value);
session.setTimeout(getGlobalSessionTimeout());
((SimpleSession) session).setId(sessionKey.getSessionId());
sessionDAO.create(session);
} catch (Exception ex) {
throw e;
}
} else {
if (!(value instanceof SavedRequest)) {
throw e;
}
}
}
}
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:26,代码来源:SimpleSessionManager.java
示例12: deleteSession
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
@DELETE
public Response deleteSession() {
// Delete the Shiro session
try {
Session session = SecurityUtils.getSubject().getSession();
Object cookieValue = session.getAttribute(HttpHeaders.SET_COOKIE);
SecurityUtils.getSubject().logout();
if(cookieValue != null) {
NewCookie cookie = NewCookie.valueOf(cookieValue.toString());
if (OBIBA_ID_COOKIE_NAME.equals(cookie.getName())) {
return Response.ok().header(HttpHeaders.SET_COOKIE,
new NewCookie(OBIBA_ID_COOKIE_NAME, null, "/", cookie.getDomain(), "Obiba session deleted", 0, cookie.isSecure())).build();
}
}
} catch(InvalidSessionException e) {
// Ignore
}
return Response.ok().build();
}
开发者ID:obiba,项目名称:mica2,代码行数:21,代码来源:CurrentSessionResource.java
示例13: getStartTimestamp
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
public Date getStartTimestamp(SessionKey key) {
try {
return super.getStartTimestamp(key);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return null;
}
}
开发者ID:funtl,项目名称:framework,代码行数:9,代码来源:SessionManager.java
示例14: getLastAccessTime
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
public Date getLastAccessTime(SessionKey key) {
try {
return super.getLastAccessTime(key);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return null;
}
}
开发者ID:funtl,项目名称:framework,代码行数:9,代码来源:SessionManager.java
示例15: getTimeout
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
public long getTimeout(SessionKey key) {
try {
return super.getTimeout(key);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return 0;
}
}
开发者ID:funtl,项目名称:framework,代码行数:9,代码来源:SessionManager.java
示例16: setTimeout
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
public void setTimeout(SessionKey key, long maxIdleTimeInMillis) {
try {
super.setTimeout(key, maxIdleTimeInMillis);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
}
}
开发者ID:funtl,项目名称:framework,代码行数:8,代码来源:SessionManager.java
示例17: touch
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
public void touch(SessionKey key) {
try {
super.touch(key);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
}
}
开发者ID:funtl,项目名称:framework,代码行数:8,代码来源:SessionManager.java
示例18: getHost
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
public String getHost(SessionKey key) {
try {
return super.getHost(key);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return null;
}
}
开发者ID:funtl,项目名称:framework,代码行数:9,代码来源:SessionManager.java
示例19: getAttributeKeys
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
public Collection<Object> getAttributeKeys(SessionKey key) {
try {
return super.getAttributeKeys(key);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return null;
}
}
开发者ID:funtl,项目名称:framework,代码行数:9,代码来源:SessionManager.java
示例20: getAttribute
import org.apache.shiro.session.InvalidSessionException; //导入依赖的package包/类
public Object getAttribute(SessionKey sessionKey, Object attributeKey) {
try {
return super.getAttribute(sessionKey, attributeKey);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return null;
}
}
开发者ID:funtl,项目名称:framework,代码行数:9,代码来源:SessionManager.java
注:本文中的org.apache.shiro.session.InvalidSessionException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论