1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd. 4 // ------------------------------------------------------------------------ 5 // All rights reserved. This program and the accompanying materials 6 // are made available under the terms of the Eclipse Public License v1.0 7 // and Apache License v2.0 which accompanies this distribution. 8 // 9 // The Eclipse Public License is available at 10 // http://www.eclipse.org/legal/epl-v10.html 11 // 12 // The Apache License v2.0 is available at 13 // http://www.opensource.org/licenses/apache2.0.php 14 // 15 // You may elect to redistribute this code under either of these licenses. 16 // ======================================================================== 17 // 18 19 package org.eclipse.jetty.server; 20 21 import javax.servlet.http.HttpServletRequest; 22 import javax.servlet.http.HttpSession; 23 24 import org.eclipse.jetty.util.component.LifeCycle; 25 26 /** Session ID Manager. 27 * Manages session IDs across multiple contexts. 28 */ 29 public interface SessionIdManager extends LifeCycle 30 { 31 /** 32 * @param id The session ID without any cluster node extension 33 * @return True if the session ID is in use by at least one context. 34 */ 35 public boolean idInUse(String id); 36 37 /** 38 * Add a session to the list of known sessions for a given ID. 39 * @param session The session 40 */ 41 public void addSession(HttpSession session); 42 43 /** 44 * Remove session from the list of known sessions for a given ID. 45 * @param session the session to remove 46 */ 47 public void removeSession(HttpSession session); 48 49 /** 50 * Call {@link HttpSession#invalidate()} on all known sessions for the given id. 51 * @param id The session ID without any cluster node extension 52 */ 53 public void invalidateAll(String id); 54 55 /** 56 * Create a new Session ID. 57 * 58 * @param request the request with the sesion 59 * @param created the timestamp for when the session was created 60 * @return the new session id 61 */ 62 public String newSessionId(HttpServletRequest request,long created); 63 64 65 66 public String getWorkerName(); 67 68 69 /* ------------------------------------------------------------ */ 70 /** Get a cluster ID from a node ID. 71 * Strip node identifier from a located session ID. 72 * @param nodeId the node id 73 * @return the cluster id 74 */ 75 public String getClusterId(String nodeId); 76 77 /* ------------------------------------------------------------ */ 78 /** Get a node ID from a cluster ID and a request 79 * @param clusterId The ID of the session 80 * @param request The request that for the session (or null) 81 * @return The session ID qualified with the node ID. 82 */ 83 public String getNodeId(String clusterId,HttpServletRequest request); 84 85 86 /* ------------------------------------------------------------ */ 87 /** Change the existing session id. 88 * 89 * @param oldClusterId the old cluster id 90 * @param oldNodeId the old node id 91 * @param request the request containing the session 92 */ 93 public void renewSessionId(String oldClusterId, String oldNodeId, HttpServletRequest request); 94 95 96 }