本文整理汇总了Java中org.mortbay.jetty.servlet.HashSessionManager类的典型用法代码示例。如果您正苦于以下问题:Java HashSessionManager类的具体用法?Java HashSessionManager怎么用?Java HashSessionManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HashSessionManager类属于org.mortbay.jetty.servlet包,在下文中一共展示了HashSessionManager类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: controllerIdentification
import org.mortbay.jetty.servlet.HashSessionManager; //导入依赖的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"));
}
示例2: controllerAuthentication
import org.mortbay.jetty.servlet.HashSessionManager; //导入依赖的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);
}
示例3: controllerIdentificationWithAddressAndPhoto
import org.mortbay.jetty.servlet.HashSessionManager; //导入依赖的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"));
}
示例4: testAuthnSessionIdChannelBinding
import org.mortbay.jetty.servlet.HashSessionManager; //导入依赖的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);
}
示例5: testAuthnServerCertificateChannelBinding
import org.mortbay.jetty.servlet.HashSessionManager; //导入依赖的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);
}
示例6: testAuthnHybridChannelBinding
import org.mortbay.jetty.servlet.HashSessionManager; //导入依赖的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);
}
示例7: setHashSessionManager
import org.mortbay.jetty.servlet.HashSessionManager; //导入依赖的package包/类
/**
* Set the HashSessionManager
*
* @param hashSessionManager
*/
public void setHashSessionManager(HashSessionManager hashSessionManager)
{
this.hashSessionManager = hashSessionManager;
}