当前位置: 首页>>代码示例>>Java>>正文


Java Session.isValid方法代码示例

本文整理汇总了Java中org.apache.catalina.Session.isValid方法的典型用法代码示例。如果您正苦于以下问题:Java Session.isValid方法的具体用法?Java Session.isValid怎么用?Java Session.isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.catalina.Session的用法示例。


在下文中一共展示了Session.isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isRequestedSessionIdValid

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Return <code>true</code> if the session identifier included in this
 * request identifies a valid session.
 */
public boolean isRequestedSessionIdValid() {

    if (requestedSessionId == null)
        return (false);
    if (context == null)
        return (false);
    Manager manager = context.getManager();
    if (manager == null)
        return (false);
    Session session = null;
    try {
        session = manager.findSession(requestedSessionId);
    } catch (IOException e) {
        session = null;
    }
    if ((session != null) && session.isValid())
        return (true);
    else
        return (false);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:Request.java

示例2: writeSession

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Write the provided session to the Store without modifying
 * the copy in memory or triggering passivation events. Does
 * nothing if the session is invalid or past its expiration.
 */
protected void writeSession(Session session) throws IOException {

    if (store == null ||
            !session.isValid() ||
            isSessionStale(session, System.currentTimeMillis()))
        return;

    try {
        store.save(session);
    } catch (IOException e) {
        log(sm.getString
            ("persistentManager.serializeError", session.getId(), e));
        throw e;
    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:22,代码来源:PersistentManagerBase.java

示例3: storeSession

import org.apache.catalina.Session; //导入方法依赖的package包/类
private void storeSession(Request request, Response response) throws IOException {
	Session sessionInternal = request.getSessionInternal();
	if (sessionInternal != null) {
		MongoPersistentManager manager = (MongoPersistentManager) request.getContext().getManager();
		if (sessionInternal.isValid()) {
			log.debug(String.format("Request with session completed, saving session %s", sessionInternal.getId()));
			manager.getStore().save(sessionInternal);
		} else {
			log.debug(String.format("HTTP Session has been invalidated, removing %s", sessionInternal.getId()));
			manager.remove(sessionInternal);
		}
	}
}
 
开发者ID:appNG,项目名称:appng-tomcat-session,代码行数:14,代码来源:MongoSessionTrackerValve.java

示例4: swapOut

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Remove the session from the Manager's list of active
 * sessions and write it out to the Store. If the session
 * is past its expiration or invalid, this method does
 * nothing.
 *
 * @param session The Session to write out.
 */
protected void swapOut(Session session) throws IOException {

    if (store == null || !session.isValid()) {
        return;
    }

    ((StandardSession)session).passivate();
    writeSession(session);
    super.remove(session, true);
    session.recycle();

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:PersistentManagerBase.java

示例5: writeSession

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Write the provided session to the Store without modifying
 * the copy in memory or triggering passivation events. Does
 * nothing if the session is invalid or past its expiration.
 */
protected void writeSession(Session session) throws IOException {

    if (store == null || !session.isValid()) {
        return;
    }

    try {
        if (SecurityUtil.isPackageProtectionEnabled()){
            try{
                AccessController.doPrivileged(new PrivilegedStoreSave(session));
            }catch(PrivilegedActionException ex){
                Exception exception = ex.getException();
                if (exception instanceof IOException) {
                    throw (IOException) exception;
                }
                log.error("Exception in the Store during writeSession: "
                          + exception, exception);
            }
        } else {
             store.save(session);
        }   
    } catch (IOException e) {
        log.error(sm.getString
            ("persistentManager.serializeError", session.getIdInternal(), e));
        throw e;
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:34,代码来源:PersistentManagerBase.java

示例6: isRequestedSessionIdValid

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Returns true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 *
 * @return true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 */
@Override
public boolean isRequestedSessionIdValid() {

    if (crossContext) {

        String requestedSessionId = getRequestedSessionId();
        if (requestedSessionId == null)
            return (false);
        if (context == null)
            return (false);
        Manager manager = context.getManager();
        if (manager == null)
            return (false);
        Session session = null;
        try {
            session = manager.findSession(requestedSessionId);
        } catch (IOException e) {
            // Ignore
        }
        if ((session != null) && session.isValid()) {
            return (true);
        } else {
            return (false);
        }

    } else {
        return super.isRequestedSessionIdValid();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:37,代码来源:ApplicationHttpRequest.java

示例7: writeSession

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Write the provided session to the Store without modifying
 * the copy in memory or triggering passivation events. Does
 * nothing if the session is invalid or past its expiration.
 */
protected void writeSession(Session session) throws IOException {

    if (store == null || !session.isValid()) {
        return;
    }

    try {
        if (SecurityUtil.isPackageProtectionEnabled()){
            try{
                AccessController.doPrivileged(new PrivilegedStoreSave(session));
            }catch(PrivilegedActionException ex){
                Exception exception = ex.getException();
                log.error("Exception in the Store during writeSession: "
                          + exception);
                exception.printStackTrace();                        
            }
        } else {
             store.save(session);
        }   
    } catch (IOException e) {
        log.error(sm.getString
            ("persistentManager.serializeError", session.getIdInternal(), e));
        throw e;
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:PersistentManagerBase.java

示例8: isRequestedSessionIdValid

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Returns true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 *
 * @return true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 */
public boolean isRequestedSessionIdValid() {

    if (crossContext) {

        String requestedSessionId = getRequestedSessionId();
        if (requestedSessionId == null)
            return (false);
        if (context == null)
            return (false);
        Manager manager = context.getManager();
        if (manager == null)
            return (false);
        Session session = null;
        try {
            session = manager.findSession(requestedSessionId);
        } catch (IOException e) {
            session = null;
        }
        if ((session != null) && session.isValid()) {
            return (true);
        } else {
            return (false);
        }

    } else {
        return super.isRequestedSessionIdValid();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:ApplicationHttpRequest.java

示例9: swapIn

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Look for a session in the Store and, if found, restore
 * it in the Manager's list of active sessions if appropriate.
 * The session will be removed from the Store after swapping
 * in, but will not be added to the active session list if it
 * is invalid or past its expiration.
 */
protected Session swapIn(String id) throws IOException {

    if (store == null)
        return null;

    Session session = null;
    try {
        session = store.load(id);
    } catch (ClassNotFoundException e) {
        log(sm.getString("persistentManager.deserializeError", id, e));
        throw new IllegalStateException
            (sm.getString("persistentManager.deserializeError", id, e));
    }

    if (session == null)
        return (null);

    if (!session.isValid()
            || isSessionStale(session, System.currentTimeMillis())) {
        log("session swapped in is invalid or expired");
        session.expire();
        store.remove(id);
        return (null);
    }

    if(debug > 2)
        log(sm.getString("persistentManager.swapIn", id));

    session.setManager(this);
    add(session);
    ((StandardSession)session).activate();

    return (session);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:43,代码来源:PersistentManagerBase.java

示例10: swapOut

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Remove the session from the Manager's list of active
 * sessions and write it out to the Store. If the session
 * is past its expiration or invalid, this method does
 * nothing.
 *
 * @param session The Session to write out.
 */
protected void swapOut(Session session) throws IOException {

    if (store == null ||
            !session.isValid() ||
            isSessionStale(session, System.currentTimeMillis()))
        return;

    ((StandardSession)session).passivate();
    writeSession(session);
    super.remove(session);
    session.recycle();

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:22,代码来源:PersistentManagerBase.java

示例11: isRequestedSessionIdValid

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Returns true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 *
 * @return true if the request specifies a JSESSIONID that is valid within
 *         the context of this ApplicationHttpRequest, false otherwise.
 */
@Override
public boolean isRequestedSessionIdValid() {

	if (crossContext) {

		String requestedSessionId = getRequestedSessionId();
		if (requestedSessionId == null)
			return (false);
		if (context == null)
			return (false);
		Manager manager = context.getManager();
		if (manager == null)
			return (false);
		Session session = null;
		try {
			session = manager.findSession(requestedSessionId);
		} catch (IOException e) {
			// Ignore
		}
		if ((session != null) && session.isValid()) {
			return (true);
		} else {
			return (false);
		}

	} else {
		return super.isRequestedSessionIdValid();
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:37,代码来源:ApplicationHttpRequest.java

示例12: swapOut

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Remove the session from the Manager's list of active sessions and write
 * it out to the Store. If the session is past its expiration or invalid,
 * this method does nothing.
 *
 * @param session
 *            The Session to write out.
 */
protected void swapOut(Session session) throws IOException {

	if (store == null || !session.isValid()) {
		return;
	}

	((StandardSession) session).passivate();
	writeSession(session);
	super.remove(session, true);
	session.recycle();

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:21,代码来源:PersistentManagerBase.java

示例13: writeSession

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Write the provided session to the Store without modifying the copy in
 * memory or triggering passivation events. Does nothing if the session is
 * invalid or past its expiration.
 */
protected void writeSession(Session session) throws IOException {

	if (store == null || !session.isValid()) {
		return;
	}

	try {
		if (SecurityUtil.isPackageProtectionEnabled()) {
			try {
				AccessController.doPrivileged(new PrivilegedStoreSave(session));
			} catch (PrivilegedActionException ex) {
				Exception exception = ex.getException();
				if (exception instanceof IOException) {
					throw (IOException) exception;
				}
				log.error("Exception in the Store during writeSession: " + exception, exception);
			}
		} else {
			store.save(session);
		}
	} catch (IOException e) {
		log.error(sm.getString("persistentManager.serializeError", session.getIdInternal(), e));
		throw e;
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:32,代码来源:PersistentManagerBase.java

示例14: getSession

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Return the session associated with this Request, creating one
 * if necessary and requested.
 *
 * @param create Create a new session if one does not exist
 */
@Override
public HttpSession getSession(boolean create) {

    if (crossContext) {
        
        // There cannot be a session if no context has been assigned yet
        if (context == null)
            return (null);

        // Return the current session if it exists and is valid
        if (session != null && session.isValid()) {
            return (session.getSession());
        }

        HttpSession other = super.getSession(false);
        if (create && (other == null)) {
            // First create a session in the first context: the problem is
            // that the top level request is the only one which can 
            // create the cookie safely
            other = super.getSession(true);
        }
        if (other != null) {
            Session localSession = null;
            try {
                localSession =
                    context.getManager().findSession(other.getId());
                if (localSession != null && !localSession.isValid()) {
                    localSession = null;
                }
            } catch (IOException e) {
                // Ignore
            }
            if (localSession == null && create) {
                localSession = 
                    context.getManager().createSession(other.getId());
            }
            if (localSession != null) {
                localSession.access();
                session = localSession;
                return session.getSession();
            }
        }
        return null;

    } else {
        return super.getSession(create);
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:56,代码来源:ApplicationHttpRequest.java

示例15: getSession

import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
 * Return the session associated with this Request, creating one if
 * necessary and requested.
 *
 * @param create
 *            Create a new session if one does not exist
 */
@Override
public HttpSession getSession(boolean create) {

	if (crossContext) {

		// There cannot be a session if no context has been assigned yet
		if (context == null)
			return (null);

		// Return the current session if it exists and is valid
		if (session != null && session.isValid()) {
			return (session.getSession());
		}

		HttpSession other = super.getSession(false);
		if (create && (other == null)) {
			// First create a session in the first context: the problem is
			// that the top level request is the only one which can
			// create the cookie safely
			other = super.getSession(true);
		}
		if (other != null) {
			Session localSession = null;
			try {
				localSession = context.getManager().findSession(other.getId());
				if (localSession != null && !localSession.isValid()) {
					localSession = null;
				}
			} catch (IOException e) {
				// Ignore
			}
			if (localSession == null && create) {
				localSession = context.getManager().createSession(other.getId());
			}
			if (localSession != null) {
				localSession.access();
				session = localSession;
				return session.getSession();
			}
		}
		return null;

	} else {
		return super.getSession(create);
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:55,代码来源:ApplicationHttpRequest.java


注:本文中的org.apache.catalina.Session.isValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。