本文整理汇总了Java中org.apache.shiro.session.mgt.SessionKey类的典型用法代码示例。如果您正苦于以下问题:Java SessionKey类的具体用法?Java SessionKey怎么用?Java SessionKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionKey类属于org.apache.shiro.session.mgt包,在下文中一共展示了SessionKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateSessions
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的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));
}
}
}
}
}
示例2: getSession
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
public Session getSession(SessionKey key) throws SessionException {
if (!WebUtils.isHttp(key)) {
String msg = "SessionKey must be an HTTP compatible implementation.";
throw new IllegalArgumentException(msg);
}
HttpServletRequest request = WebUtils.getHttpRequest(key);
Session session = null;
HttpSession httpSession = request.getSession(false);
if (httpSession != null) {
session = createSession(httpSession, request.getRemoteHost());
}
return session;
}
示例3: setAttribute
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的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;
}
}
}
}
示例4: retrieveSession
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
protected Session retrieveSession(SessionKey sessionKey) throws UnknownSessionException {
Serializable sessionId = getSessionId(sessionKey);
if (sessionId == null) {
log.debug("Unable to resolve session ID from SessionKey [{}]. Returning null to indicate a "
+ "session could not be found.", sessionKey);
return null;
}
Session s = retrieveSessionFromDataSource(sessionId);
if (s == null) {
// session ID was provided, meaning one is expected to be found, but
// we couldn't find one:
String msg = "Could not find session with ID [" + sessionId + "]";
throw new UnknownSessionException(msg);
}
return s;
}
示例5: retrieveSession
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
protected Session retrieveSession(SessionKey sessionKey) {
try {
return super.retrieveSession(sessionKey);
} catch (UnknownSessionException e) {
// 获取不到SESSION不抛出异常
return null;
}
}
示例6: getStartTimestamp
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
public Date getStartTimestamp(SessionKey key) {
try {
return super.getStartTimestamp(key);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return null;
}
}
示例7: getLastAccessTime
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
public Date getLastAccessTime(SessionKey key) {
try {
return super.getLastAccessTime(key);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return null;
}
}
示例8: getTimeout
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
public long getTimeout(SessionKey key) {
try {
return super.getTimeout(key);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return 0;
}
}
示例9: setTimeout
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
public void setTimeout(SessionKey key, long maxIdleTimeInMillis) {
try {
super.setTimeout(key, maxIdleTimeInMillis);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
}
}
示例10: touch
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
public void touch(SessionKey key) {
try {
super.touch(key);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
}
}
示例11: getHost
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
public String getHost(SessionKey key) {
try {
return super.getHost(key);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return null;
}
}
示例12: getAttributeKeys
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
public Collection<Object> getAttributeKeys(SessionKey key) {
try {
return super.getAttributeKeys(key);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return null;
}
}
示例13: getAttribute
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
public Object getAttribute(SessionKey sessionKey, Object attributeKey) {
try {
return super.getAttribute(sessionKey, attributeKey);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return null;
}
}
示例14: setAttribute
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) {
try {
super.setAttribute(sessionKey, attributeKey, value);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
}
}
示例15: removeAttribute
import org.apache.shiro.session.mgt.SessionKey; //导入依赖的package包/类
public Object removeAttribute(SessionKey sessionKey, Object attributeKey) {
try {
return super.removeAttribute(sessionKey, attributeKey);
} catch (InvalidSessionException e) {
// 获取不到SESSION不抛出异常
return null;
}
}