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


Java ApplicationSessionCookieConfig类代码示例

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


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

示例1: changeSessionId

import org.apache.catalina.core.ApplicationSessionCookieConfig; //导入依赖的package包/类
/**
 * Change the ID of the session that this request is associated with. There
 * are several things that may trigger an ID change. These include moving
 * between nodes in a cluster and session fixation prevention during the
 * authentication process.
 *
 * @param newSessionId   The session to change the session ID for
 */
public void changeSessionId(String newSessionId) {
    // This should only ever be called if there was an old session ID but
    // double check to be sure
    if (requestedSessionId != null && requestedSessionId.length() > 0) {
        requestedSessionId = newSessionId;
    }

    if (context != null && !context.getServletContext()
            .getEffectiveSessionTrackingModes().contains(
                    SessionTrackingMode.COOKIE)) {
        return;
    }

    if (response != null) {
        Cookie newCookie =
            ApplicationSessionCookieConfig.createSessionCookie(context,
                    newSessionId, secure);
        response.addSessionCookieInternal(newCookie);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:29,代码来源:Request.java

示例2: changeSessionId

import org.apache.catalina.core.ApplicationSessionCookieConfig; //导入依赖的package包/类
/**
 * Change the ID of the session that this request is associated with. There
 * are several things that may trigger an ID change. These include moving
 * between nodes in a cluster and session fixation prevention during the
 * authentication process.
 *
 * @param newSessionId
 *            The session to change the session ID for
 */
public void changeSessionId(String newSessionId) {
	// This should only ever be called if there was an old session ID but
	// double check to be sure
	if (requestedSessionId != null && requestedSessionId.length() > 0) {
		requestedSessionId = newSessionId;
	}

	if (context != null && !context.getServletContext().getEffectiveSessionTrackingModes()
			.contains(SessionTrackingMode.COOKIE)) {
		return;
	}

	if (response != null) {
		Cookie newCookie = ApplicationSessionCookieConfig.createSessionCookie(context, newSessionId, secure);
		response.addSessionCookieInternal(newCookie);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:Request.java

示例3: changeSessionId

import org.apache.catalina.core.ApplicationSessionCookieConfig; //导入依赖的package包/类
/**
 * Change the ID of the session that this request is associated with. There
 * are several things that may trigger an ID change. These include moving
 * between nodes in a cluster and session fixation prevention during the
 * authentication process.
 * 
 * @param newSessionId   The session to change the session ID for
 */
public void changeSessionId(String newSessionId) {
    // This should only ever be called if there was an old session ID but
    // double check to be sure
    if (requestedSessionId != null && requestedSessionId.length() > 0) {
        requestedSessionId = newSessionId;
    }
    
    if (context != null && !context.getServletContext()
            .getEffectiveSessionTrackingModes().contains(
                    SessionTrackingMode.COOKIE))
        return;
    
    if (response != null) {
        Cookie newCookie =
            ApplicationSessionCookieConfig.createSessionCookie(context,
                    newSessionId, secure);
        response.addSessionCookieInternal(newCookie);
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:28,代码来源:Request.java

示例4: toEncoded

import org.apache.catalina.core.ApplicationSessionCookieConfig; //导入依赖的package包/类
/**
 * Return the specified URL with the specified session identifier
 * suitably encoded.
 *
 * @param url URL to be encoded with the session id
 * @param sessionId Session id to be included in the encoded URL
 */
protected String toEncoded(String url, String sessionId) {

    if ((url == null) || (sessionId == null))
        return (url);

    String path = url;
    String query = "";
    String anchor = "";
    int question = url.indexOf('?');
    if (question >= 0) {
        path = url.substring(0, question);
        query = url.substring(question);
    }
    int pound = path.indexOf('#');
    if (pound >= 0) {
        anchor = path.substring(pound);
        path = path.substring(0, pound);
    }
    StringBuilder sb = new StringBuilder(path);
    if( sb.length() > 0 ) { // jsessionid can't be first.
        sb.append(";");
        sb.append(ApplicationSessionCookieConfig.getSessionUriParamName(
                request.getContext()));
        sb.append("=");
        sb.append(sessionId);
    }
    sb.append(anchor);
    sb.append(query);
    return (sb.toString());

}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:39,代码来源:Response.java

示例5: doGetSession

import org.apache.catalina.core.ApplicationSessionCookieConfig; //导入依赖的package包/类
protected Session doGetSession(boolean create) {

        // 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()) {
            session = null;
        }
        if (session != null) {
            return (session);
        }

        // Return the requested session if it exists and is valid
        Manager manager = null;
        if (context != null) {
            manager = context.getManager();
        }
        if (manager == null)
         {
            return (null);      // Sessions are not supported
        }
        if (requestedSessionId != null) {
            try {
                session = manager.findSession(requestedSessionId);
            } catch (IOException e) {
                session = null;
            }
            if ((session != null) && !session.isValid()) {
                session = null;
            }
            if (session != null) {
                session.access();
                return (session);
            }
        }

        // Create a new session if requested and the response is not committed
        if (!create) {
            return (null);
        }
        if ((context != null) && (response != null) &&
            context.getServletContext().getEffectiveSessionTrackingModes().
                    contains(SessionTrackingMode.COOKIE) &&
            response.getResponse().isCommitted()) {
            throw new IllegalStateException
              (sm.getString("coyoteRequest.sessionCreateCommitted"));
        }

        // Attempt to reuse session id if one was submitted in a cookie
        // Do not reuse the session id if it is from a URL, to prevent possible
        // phishing attacks
        // Use the SSL session ID if one is present.
        if (("/".equals(context.getSessionCookiePath())
                && isRequestedSessionIdFromCookie()) || requestedSessionSSL ) {
            session = manager.createSession(getRequestedSessionId());
        } else {
            session = manager.createSession(null);
        }

        // Creating a new session cookie based on that session
        if ((session != null) && (getContext() != null)
               && getContext().getServletContext().
                       getEffectiveSessionTrackingModes().contains(
                               SessionTrackingMode.COOKIE)) {
            Cookie cookie =
                ApplicationSessionCookieConfig.createSessionCookie(
                        context, session.getIdInternal(), isSecure());

            response.addSessionCookieInternal(cookie);
        }

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

        session.access();
        return session;
    }
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:82,代码来源:Request.java

示例6: parseSessionCookiesId

import org.apache.catalina.core.ApplicationSessionCookieConfig; //导入依赖的package包/类
/**
 * Parse session id in URL.
 */
protected void parseSessionCookiesId(org.apache.coyote.Request req, Request request) {

    // If session tracking via cookies has been disabled for the current
    // context, don't go looking for a session ID in a cookie as a cookie
    // from a parent context with a session ID may be present which would
    // overwrite the valid session ID encoded in the URL
    Context context = (Context) request.getMappingData().context;
    if (context != null && !context.getServletContext()
            .getEffectiveSessionTrackingModes().contains(
                    SessionTrackingMode.COOKIE))
        return;
    
    // Parse session id from cookies
    Cookies serverCookies = req.getCookies();
    int count = serverCookies.getCookieCount();
    if (count <= 0)
        return;

    String sessionCookieName =
        ApplicationSessionCookieConfig.getSessionCookieName(context);

    for (int i = 0; i < count; i++) {
        ServerCookie scookie = serverCookies.getCookie(i);
        if (scookie.getName().equals(sessionCookieName)) {
            // Override anything requested in the URL
            if (!request.isRequestedSessionIdFromCookie()) {
                // Accept only the first session id cookie
                convertMB(scookie.getValue());
                request.setRequestedSessionId
                    (scookie.getValue().toString());
                request.setRequestedSessionCookie(true);
                request.setRequestedSessionURL(false);
                if (log.isDebugEnabled())
                    log.debug(" Requested cookie session id is " +
                        request.getRequestedSessionId());
            } else {
                if (!request.isRequestedSessionIdValid()) {
                    // Replace the session id until one is valid
                    convertMB(scookie.getValue());
                    request.setRequestedSessionId
                        (scookie.getValue().toString());
                }
            }
        }
    }

}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:51,代码来源:CoyoteAdapter.java

示例7: doGetSession

import org.apache.catalina.core.ApplicationSessionCookieConfig; //导入依赖的package包/类
protected Session doGetSession(boolean create) {

        // 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())
            session = null;
        if (session != null)
            return (session);

        // Return the requested session if it exists and is valid
        Manager manager = null;
        if (context != null)
            manager = context.getManager();
        if (manager == null)
            return (null);      // Sessions are not supported
        if (requestedSessionId != null) {
            try {
                session = manager.findSession(requestedSessionId);
            } catch (IOException e) {
                session = null;
            }
            if ((session != null) && !session.isValid())
                session = null;
            if (session != null) {
                session.access();
                return (session);
            }
        }

        // Create a new session if requested and the response is not committed
        if (!create)
            return (null);
        if ((context != null) && (response != null) &&
            context.getServletContext().getEffectiveSessionTrackingModes().
                    contains(SessionTrackingMode.COOKIE) &&
            response.getResponse().isCommitted()) {
            throw new IllegalStateException
              (sm.getString("coyoteRequest.sessionCreateCommitted"));
        }

        // Attempt to reuse session id if one was submitted in a cookie
        // Do not reuse the session id if it is from a URL, to prevent possible
        // phishing attacks
        // Use the SSL session ID if one is present. 
        if (("/".equals(context.getSessionCookiePath()) 
                && isRequestedSessionIdFromCookie()) || requestedSessionSSL ) {
            session = manager.createSession(getRequestedSessionId());
        } else {
            session = manager.createSession(null);
        }

        // Creating a new session cookie based on that session
        if ((session != null) && (getContext() != null)
               && getContext().getServletContext().
                       getEffectiveSessionTrackingModes().contains(
                               SessionTrackingMode.COOKIE)) {
            Cookie cookie =
                ApplicationSessionCookieConfig.createSessionCookie(
                        context, session.getIdInternal(), isSecure());
            
            response.addSessionCookieInternal(cookie);
        }

        if (session == null) {
            return null;
        }
        
        session.access();
        return session;
    }
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:74,代码来源:Request.java


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