本文整理汇总了Java中org.mortbay.jetty.SessionManager类的典型用法代码示例。如果您正苦于以下问题:Java SessionManager类的具体用法?Java SessionManager怎么用?Java SessionManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionManager类属于org.mortbay.jetty包,在下文中一共展示了SessionManager类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invalidateAll
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
/**
* When told to invalidate all session instances that share the same id, we must
* tell all contexts on the server for which it is defined to delete any session
* object they might have matching the id.
*/
public void invalidateAll(String clusterId)
{
Handler[] contexts = _server.getChildHandlersByClass(WebAppContext.class);
for (int i = 0; contexts != null && i < contexts.length; i++)
{
WebAppContext webAppContext = (WebAppContext)contexts[i];
SessionManager sessionManager = webAppContext.getSessionHandler().getSessionManager();
if (sessionManager instanceof AbstractSessionManager)
{
Session session = ((AbstractSessionManager)sessionManager).getSession(clusterId);
if (session != null) session.invalidate();
}
}
}
示例2: controllerIdentification
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
@Test
public void controllerIdentification() throws Exception {
// setup
Messages messages = new Messages(Locale.getDefault());
Runtime runtime = new TestRuntime();
View view = new TestView();
Controller controller = new Controller(view, runtime, messages);
// make sure that the session cookies are passed during conversations
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cookieManager);
// operate
controller.run();
// verify
LOG.debug("verify...");
SessionHandler sessionHandler = this.servletTester.getContext().getSessionHandler();
SessionManager sessionManager = sessionHandler.getSessionManager();
LOG.debug("session manager type: " + sessionManager.getClass().getName());
HashSessionManager hashSessionManager = (HashSessionManager) sessionManager;
LOG.debug("# sessions: " + hashSessionManager.getSessions());
assertEquals(1, hashSessionManager.getSessions());
Map<String, HttpSession> sessionMap = hashSessionManager.getSessionMap();
LOG.debug("session map: " + sessionMap);
Entry<String, HttpSession> sessionEntry = sessionMap.entrySet().iterator().next();
HttpSession httpSession = sessionEntry.getValue();
assertNotNull(httpSession.getAttribute("eid"));
Identity identity = (Identity) httpSession.getAttribute("eid.identity");
assertNotNull(identity);
assertNotNull(identity.name);
LOG.debug("name: " + identity.name);
LOG.debug("document type: " + identity.getDocumentType());
LOG.debug("duplicate: " + identity.getDuplicate());
assertNull(httpSession.getAttribute("eid.identifier"));
assertNull(httpSession.getAttribute("eid.address"));
assertNull(httpSession.getAttribute("eid.photo"));
}
示例3: controllerAuthentication
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
@Test
public void controllerAuthentication() throws Exception {
// setup
Messages messages = new Messages(Locale.getDefault());
Runtime runtime = new TestRuntime();
View view = new TestView();
Controller controller = new Controller(view, runtime, messages);
// make sure that the session cookies are passed during conversations
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cookieManager);
this.servletHolder.setInitParameter("AuthenticationServiceClass", TestAuthenticationService.class.getName());
this.servletHolder.setInitParameter("Logoff", "true");
// operate
controller.run();
// verify
LOG.debug("verify...");
SessionHandler sessionHandler = this.servletTester.getContext().getSessionHandler();
SessionManager sessionManager = sessionHandler.getSessionManager();
LOG.debug("session manager type: " + sessionManager.getClass().getName());
HashSessionManager hashSessionManager = (HashSessionManager) sessionManager;
LOG.debug("# sessions: " + hashSessionManager.getSessions());
assertEquals(1, hashSessionManager.getSessions());
Map<String, HttpSession> sessionMap = hashSessionManager.getSessionMap();
LOG.debug("session map: " + sessionMap);
Entry<String, HttpSession> sessionEntry = sessionMap.entrySet().iterator().next();
HttpSession httpSession = sessionEntry.getValue();
assertNotNull(httpSession.getAttribute("eid"));
assertNull(httpSession.getAttribute("eid.identity"));
assertNull(httpSession.getAttribute("eid.address"));
assertNull(httpSession.getAttribute("eid.photo"));
String identifier = (String) httpSession.getAttribute("eid.identifier");
assertNotNull(identifier);
LOG.debug("identifier: " + identifier);
assertTrue(TestAuthenticationService.called);
}
示例4: initializeWebServer
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager)sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {contexts, requestLogHandler});
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}
示例5: TerracottaSessionHandler
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
public TerracottaSessionHandler(SessionManager manager)
{
super(manager);
}
示例6: WadiSessionHandler
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
public WadiSessionHandler(SessionManager sessionManager)
{
super(sessionManager);
}
示例7: initializeWebServer
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws FileNotFoundException, IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager)sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {contexts, requestLogHandler});
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}
示例8: controllerIdentificationWithAddressAndPhoto
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
@Test
public void controllerIdentificationWithAddressAndPhoto() throws Exception {
// setup
Messages messages = new Messages(Locale.getDefault());
Runtime runtime = new TestRuntime();
View view = new TestView();
Controller controller = new Controller(view, runtime, messages);
// make sure that the session cookies are passed during conversations
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cookieManager);
this.servletHolder.setInitParameter("IncludeAddress", "true");
this.servletHolder.setInitParameter("IncludePhoto", "true");
// operate
controller.run();
// verify
LOG.debug("verify...");
SessionHandler sessionHandler = this.servletTester.getContext().getSessionHandler();
SessionManager sessionManager = sessionHandler.getSessionManager();
LOG.debug("session manager type: " + sessionManager.getClass().getName());
HashSessionManager hashSessionManager = (HashSessionManager) sessionManager;
LOG.debug("# sessions: " + hashSessionManager.getSessions());
assertEquals(1, hashSessionManager.getSessions());
Map<String, HttpSession> sessionMap = hashSessionManager.getSessionMap();
LOG.debug("session map: " + sessionMap);
Entry<String, HttpSession> sessionEntry = sessionMap.entrySet().iterator().next();
HttpSession httpSession = sessionEntry.getValue();
assertNotNull(httpSession.getAttribute("eid"));
Identity identity = (Identity) httpSession.getAttribute("eid.identity");
assertNotNull(identity);
assertNotNull(identity.name);
LOG.debug("name: " + identity.name);
LOG.debug("nationality: " + identity.getNationality());
LOG.debug("national number: " + identity.getNationalNumber());
assertNull(httpSession.getAttribute("eid.identifier"));
assertNotNull(httpSession.getAttribute("eid.address"));
assertNotNull(httpSession.getAttribute("eid.photo"));
}
示例9: testAuthnSessionIdChannelBinding
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
@Test
public void testAuthnSessionIdChannelBinding() throws Exception {
// setup
Messages messages = new Messages(Locale.getDefault());
Runtime runtime = new TestRuntime();
View view = new TestView();
Controller controller = new Controller(view, runtime, messages);
// make sure that the session cookies are passed during conversations
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cookieManager);
this.servletHolder.setInitParameter("AuthenticationServiceClass", TestAuthenticationService.class.getName());
this.servletHolder.setInitParameter("Logoff", "true");
this.servletHolder.setInitParameter("SessionIdChannelBinding", "true");
// operate
controller.run();
// verify
LOG.debug("verify...");
SessionHandler sessionHandler = this.servletTester.getContext().getSessionHandler();
SessionManager sessionManager = sessionHandler.getSessionManager();
LOG.debug("session manager type: " + sessionManager.getClass().getName());
HashSessionManager hashSessionManager = (HashSessionManager) sessionManager;
LOG.debug("# sessions: " + hashSessionManager.getSessions());
assertEquals(1, hashSessionManager.getSessions());
Map<String, HttpSession> sessionMap = hashSessionManager.getSessionMap();
LOG.debug("session map: " + sessionMap);
Entry<String, HttpSession> sessionEntry = sessionMap.entrySet().iterator().next();
HttpSession httpSession = sessionEntry.getValue();
assertNotNull(httpSession.getAttribute("eid"));
assertNull(httpSession.getAttribute("eid.identity"));
assertNull(httpSession.getAttribute("eid.address"));
assertNull(httpSession.getAttribute("eid.photo"));
String identifier = (String) httpSession.getAttribute("eid.identifier");
assertNotNull(identifier);
LOG.debug("identifier: " + identifier);
assertTrue(TestAuthenticationService.called);
}
示例10: testAuthnServerCertificateChannelBinding
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
@Test
public void testAuthnServerCertificateChannelBinding() throws Exception {
// setup
Messages messages = new Messages(Locale.getDefault());
Runtime runtime = new TestRuntime();
View view = new TestView();
Controller controller = new Controller(view, runtime, messages);
// make sure that the session cookies are passed during conversations
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cookieManager);
this.servletHolder.setInitParameter("AuthenticationServiceClass", TestAuthenticationService.class.getName());
this.servletHolder.setInitParameter("Logoff", "true");
File tmpCertFile = File.createTempFile("ssl-server-cert-", ".crt");
FileUtils.writeByteArrayToFile(tmpCertFile, this.certificate.getEncoded());
this.servletHolder.setInitParameter("ChannelBindingServerCertificate", tmpCertFile.toString());
// operate
controller.run();
// verify
LOG.debug("verify...");
SessionHandler sessionHandler = this.servletTester.getContext().getSessionHandler();
SessionManager sessionManager = sessionHandler.getSessionManager();
LOG.debug("session manager type: " + sessionManager.getClass().getName());
HashSessionManager hashSessionManager = (HashSessionManager) sessionManager;
LOG.debug("# sessions: " + hashSessionManager.getSessions());
assertEquals(1, hashSessionManager.getSessions());
Map<String, HttpSession> sessionMap = hashSessionManager.getSessionMap();
LOG.debug("session map: " + sessionMap);
Entry<String, HttpSession> sessionEntry = sessionMap.entrySet().iterator().next();
HttpSession httpSession = sessionEntry.getValue();
assertNotNull(httpSession.getAttribute("eid"));
assertNull(httpSession.getAttribute("eid.identity"));
assertNull(httpSession.getAttribute("eid.address"));
assertNull(httpSession.getAttribute("eid.photo"));
String identifier = (String) httpSession.getAttribute("eid.identifier");
assertNotNull(identifier);
LOG.debug("identifier: " + identifier);
assertTrue(TestAuthenticationService.called);
}
示例11: testAuthnHybridChannelBinding
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
@Test
public void testAuthnHybridChannelBinding() throws Exception {
// setup
Messages messages = new Messages(Locale.getDefault());
Runtime runtime = new TestRuntime();
View view = new TestView();
Controller controller = new Controller(view, runtime, messages);
// make sure that the session cookies are passed during conversations
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cookieManager);
this.servletHolder.setInitParameter("AuthenticationServiceClass", TestAuthenticationService.class.getName());
this.servletHolder.setInitParameter("Logoff", "true");
File tmpCertFile = File.createTempFile("ssl-server-cert-", ".crt");
FileUtils.writeByteArrayToFile(tmpCertFile, this.certificate.getEncoded());
this.servletHolder.setInitParameter("ChannelBindingServerCertificate", tmpCertFile.toString());
this.servletHolder.setInitParameter("SessionIdChannelBinding", "true");
// operate
controller.run();
// verify
LOG.debug("verify...");
SessionHandler sessionHandler = this.servletTester.getContext().getSessionHandler();
SessionManager sessionManager = sessionHandler.getSessionManager();
LOG.debug("session manager type: " + sessionManager.getClass().getName());
HashSessionManager hashSessionManager = (HashSessionManager) sessionManager;
LOG.debug("# sessions: " + hashSessionManager.getSessions());
assertEquals(1, hashSessionManager.getSessions());
Map<String, HttpSession> sessionMap = hashSessionManager.getSessionMap();
LOG.debug("session map: " + sessionMap);
Entry<String, HttpSession> sessionEntry = sessionMap.entrySet().iterator().next();
HttpSession httpSession = sessionEntry.getValue();
assertNotNull(httpSession.getAttribute("eid"));
assertNull(httpSession.getAttribute("eid.identity"));
assertNull(httpSession.getAttribute("eid.address"));
assertNull(httpSession.getAttribute("eid.photo"));
String identifier = (String) httpSession.getAttribute("eid.identifier");
assertNotNull(identifier);
LOG.debug("identifier: " + identifier);
assertTrue(TestAuthenticationService.called);
}
示例12: initializeWebServer
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager)sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {contexts, requestLogHandler});
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
Map<String, String> xFrameParams = new HashMap<>();
xFrameParams.put(X_FRAME_ENABLED,
String.valueOf(this.xFrameOptionIsEnabled));
xFrameParams.put(X_FRAME_VALUE, this.xFrameOption.toString());
addGlobalFilter("safety", QuotingInputFilter.class.getName(), xFrameParams);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}
示例13: initializeWebServer
import org.mortbay.jetty.SessionManager; //导入依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws FileNotFoundException, IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager)sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { requestLogHandler, contexts });
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}