本文整理匯總了Java中org.apache.shiro.session.Session.getId方法的典型用法代碼示例。如果您正苦於以下問題:Java Session.getId方法的具體用法?Java Session.getId怎麽用?Java Session.getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.shiro.session.Session
的用法示例。
在下文中一共展示了Session.getId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validateSessions
import org.apache.shiro.session.Session; //導入方法依賴的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: doUpdate
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
protected void doUpdate(Session session) {
if (session == null || session.getId() == null) {
return;
}
HttpServletRequest request = Servlets.getRequest();
if (request != null) {
String uri = request.getServletPath();
// 如果是靜態文件,則不更新SESSION
if (Servlets.isStaticFile(uri)) {
return;
}
// 如果是視圖文件,則不更新SESSION
if (StringUtils.startsWith(uri, Global.getConfig("web.view.prefix")) && StringUtils.endsWith(uri, Global.getConfig("web.view.suffix"))) {
return;
}
// 手動控製不更新SESSION
String updateSession = request.getParameter("updateSession");
if (Global.FALSE.equals(updateSession) || Global.NO.equals(updateSession)) {
return;
}
}
super.doUpdate(session);
logger.debug("update {} {}", session.getId(), request != null ? request.getRequestURI() : "");
}
示例3: delete
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
public void delete(Session session) {
if (session == null || session.getId() == null) {
return;
}
Jedis jedis = null;
try {
jedis = JedisUtils.getResource();
jedis.hdel(JedisUtils.getBytesKey(sessionKeyPrefix), JedisUtils.getBytesKey(session.getId().toString()));
jedis.del(JedisUtils.getBytesKey(sessionKeyPrefix + session.getId()));
logger.debug("delete {} ", session.getId());
} catch (Exception e) {
logger.error("delete {} ", session.getId(), e);
} finally {
JedisUtils.returnResource(jedis);
}
}
示例4: saveSession
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
/**
* save session
* @param session
* @throws UnknownSessionException
*/
private void saveSession(Session session) throws UnknownSessionException{
if(session == null || session.getId() == null){
logger.error("session or session id is null");
return;
}
byte[] key = getByteKey(session.getId());
byte[] value = JavaSerializeUtil.serialize(session);
session.setTimeout(expire*1000);
try {
this.jedisClient.set(key, value, expire);
}catch (Exception e){
e.printStackTrace();
}
}
示例5: saveSession
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
public void saveSession(Session session) {
if (session == null || session.getId() == null)
throw new NullPointerException("session is empty");
try {
byte[] key = generateRedisSessionKey(session.getId()).getBytes();
//不存在才添加。
if(null == session.getAttribute(UserSessionServiceImpl.SESSION_STATUS)){
//session狀態
SessionStatus sessionStatus = new SessionStatus();
session.setAttribute(UserSessionServiceImpl.SESSION_STATUS, sessionStatus);
}
byte[] value = SerializeUtil.serialize(session);
long sessionTimeOut = session.getTimeout() / 1000;
Long expireTime = sessionTimeOut + SESSION_VAL_TIME_SPAN + (5 * 60);
getRedisManager().saveValueByKey(DB_INDEX, key, value, expireTime.intValue());
} catch (Exception e) {
logger.error("save session error,id:"+session.getId(), e);
}
}
示例6: delete
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
public void delete(Session session) {
if (session == null || session.getId() == null) {
return;
}
Jedis jedis = null;
try {
jedis = JedisUtils.getResource();
jedis.hdel(JedisUtils.getBytesKey(sessionKeyPrefix), JedisUtils.getBytesKey(session.getId().toString()));
jedis.del(JedisUtils.getBytesKey(sessionKeyPrefix + session.getId()));
logger.debug("delete {} ", session.getId());
} catch (Exception e) {
logger.error("delete {} ", session.getId(), e);
} finally {
JedisUtils.returnResource(jedis);
}
}
示例7: doDelete
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
protected void doDelete(Session session) {
if (session == null || session.getId() == null) {
return;
}
super.doDelete(session);
logger.debug("delete {} ", session.getId());
}
示例8: doCreate
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
protected Serializable doCreate(Session session) {
HttpServletRequest request = Servlets.getRequest();
if (request != null) {
String uri = request.getServletPath();
// 如果是靜態文件,則不創建SESSION
if (Servlets.isStaticFile(uri)) {
return null;
}
}
super.doCreate(session);
logger.debug("doCreate {} {}", session, request != null ? request.getRequestURI() : "");
return session.getId();
}
示例9: delete
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
public void delete(Session session) {
if (session != null) {
Serializable id = session.getId();
if (id != null) {
RedisConnection redisConnection = getRedisConnection();
try {
redisConnection.del(buildRedisSessionKey(id));
} finally {
redisConnection.close();
}
}
}
}
示例10: saveSession
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
private void saveSession(Session session) {
if (session == null || session.getId() == null) throw new UnknownSessionException("session is empty");
byte[] sessionKey = buildRedisSessionKey(session.getId());
int sessionTimeOut = PropertiesUtil.getInt("session.maxInactiveInterval", EXPIRE_TIME);
byte[] value = SerializeUtil.serialize(session);
RedisConnection redisConnection = getRedisConnection();
try {
redisConnection.set(sessionKey, value, Expiration.seconds(sessionTimeOut), SetOption.UPSERT);
} finally {
redisConnection.close();
}
}
示例11: delete
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
public void delete(Session session) {
logger.info("delete session "+session.toString());
if(session == null || session.getId() == null){
logger.error("session or session id is null");
return;
}
jedisClient.del(this.getByteKey(session.getId()));
}
示例12: delete
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
public void delete(Session session) {
if (session == null) {
logger.error("Session 不能為null");
return;
}
Serializable id = session.getId();
if (id != null)
shiroSessionRepository.deleteSession(id);
}
示例13: saveSession
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
public void saveSession(Session session) {
if (session == null || session.getId() == null)
throw new NullPointerException("session is empty");
try {
cacheManager.getCache(this.activeSessionsCacheName).put(session.getId(), SerializeUtil.serialize(session));
} catch (Exception e) {
logger.error("save session error,id:"+session.getId(), e);
}
}
示例14: doUpdate
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
protected void doUpdate(Session session) {
if (session == null || session.getId() == null) {
return;
}
HttpServletRequest request = Servlets.getRequest();
if (request != null){
String uri = request.getServletPath();
// 如果是靜態文件,則不更新SESSION
if (Servlets.isStaticFile(uri)){
return;
}
// 如果是視圖文件,則不更新SESSION
if (StringUtils.startsWith(uri, Global.getInstance().getConfig("app.view.prefix"))
&& StringUtils.endsWith(uri, Global.getInstance().getConfig("app.view.suffix"))){
return;
}
// 手動控製不更新SESSION
String updateSession = request.getParameter("updateSession");
if (Global.FALSE.equals(updateSession) || Global.NO.equals(updateSession)){
return;
}
}
super.doUpdate(session);
logger.debug("update {} {}", session.getId(), request != null ? request.getRequestURI() : "");
}
示例15: doDelete
import org.apache.shiro.session.Session; //導入方法依賴的package包/類
@Override
protected void doDelete(Session session) {
if (session == null || session.getId() == null) {
return;
}
super.doDelete(session);
logger.debug("delete {} ", session.getId());
}