本文整理汇总了Java中weblogic.servlet.security.ServletAuthentication.invalidateAll方法的典型用法代码示例。如果您正苦于以下问题:Java ServletAuthentication.invalidateAll方法的具体用法?Java ServletAuthentication.invalidateAll怎么用?Java ServletAuthentication.invalidateAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weblogic.servlet.security.ServletAuthentication
的用法示例。
在下文中一共展示了ServletAuthentication.invalidateAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFilter
import weblogic.servlet.security.ServletAuthentication; //导入方法依赖的package包/类
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest)req;
HttpSession session = request.getSession();
ncl.debug("AuthenticateFilter doFilter.");
if(req.getAttribute("cancelSession") != null) {
ncl.info("Cancelled session due to session timeout.");
ServletAuthentication.invalidateAll(request);
}
else if(session != null) {
Date fiveMinutesAgo = DateUtils.addMinutes(new Date(), -5);
//check that the time the session was last accessed was after 5 minutes ago..
Date timeLastAccessed = new Date(session.getLastAccessedTime());
if(timeLastAccessed.before(fiveMinutesAgo)) {
session.invalidate();
//make the user log back in.
ServletAuthentication.invalidateAll(request);
}
}
}
示例2: weblogicLogout
import weblogic.servlet.security.ServletAuthentication; //导入方法依赖的package包/类
/**
* Standar way: invalidateSession. But keep in mind: "the user's
* authentication information still remains valid and is stored in the
* context of the server or virtual host" See http://download.oracle.com/
* docs/cd/E17904_01/web.1111/e13712/sessions.htm#WBAPP300 The servlet
* specification does not provide an API for logging
*
* @param request
* @param isDebugEnabled
* @throws ServletException
*/
public static void weblogicLogout(HttpServletRequest request,
boolean isDebugEnabled) throws ServletException {
// Get user info. Debugging purposes
String userName = null;
if (isDebugEnabled) {
try {
userName = request.getUserPrincipal().getName();
nc.notice("Logging out user: " + userName);
} catch (Exception e) {
nc.error(e.getMessage());
}
}
// Invalidates all the sessions for the current user only (that is, the
// current cookie), and since the cookie is no longer required, kills
// the cookie too.
ServletAuthentication.invalidateAll(request);
// Kills the current cookie.
ServletAuthentication.killCookie(request);
if (isDebugEnabled) {
if (userName!=null){
nc.notice(userName + " has been logging out");
} else {
nc.notice("The session has been already killed: cookies deletion/expiration");
}
}
}