use of io.undertow.server.session.SessionManager in project wildfly by wildfly.
the class DistributableSingleSignOnTestCase method add.
@Test
public void add() {
String deployment = "deployment";
String sessionId = "session";
BatchContext context = mock(BatchContext.class);
Session session = mock(Session.class);
SessionManager manager = mock(SessionManager.class);
Sessions<String, String> sessions = mock(Sessions.class);
when(this.batcher.resumeBatch(this.batch)).thenReturn(context);
when(session.getId()).thenReturn(sessionId);
when(session.getSessionManager()).thenReturn(manager);
when(manager.getDeploymentName()).thenReturn(deployment);
when(this.sso.getSessions()).thenReturn(sessions);
this.subject.add(session);
verify(sessions).addSession(deployment, sessionId);
verifyZeroInteractions(this.batch);
verify(context).close();
}
use of io.undertow.server.session.SessionManager in project wildfly by wildfly.
the class DistributableSingleSignOn method iterator.
@Override
public Iterator<Session> iterator() {
try (BatchContext context = this.batcher.resumeBatch(this.batch)) {
Sessions<String, String> sessions = this.sso.getSessions();
Set<String> deployments = sessions.getDeployments();
List<Session> result = new ArrayList<>(deployments.size());
for (String deployment : sessions.getDeployments()) {
String sessionId = sessions.getSession(deployment);
if (sessionId != null) {
SessionManager manager = this.registry.getSessionManager(deployment);
if (manager != null) {
result.add(new InvalidatableSession(manager, sessionId));
}
}
}
return result.iterator();
}
}
use of io.undertow.server.session.SessionManager in project wildfly by wildfly.
the class DistributableSingleSignOnTestCase method getSession.
@Test
public void getSession() {
String deployment = "deployment";
String sessionId = "session";
BatchContext context = mock(BatchContext.class);
SessionManager manager = mock(SessionManager.class);
Sessions<String, String> sessions = mock(Sessions.class);
when(this.batcher.resumeBatch(this.batch)).thenReturn(context);
when(manager.getDeploymentName()).thenReturn(deployment);
when(this.sso.getSessions()).thenReturn(sessions);
when(sessions.getSession(deployment)).thenReturn(sessionId);
Session result = this.subject.getSession(manager);
assertSame(sessionId, result.getId());
assertSame(manager, result.getSessionManager());
verifyZeroInteractions(this.batch);
verify(context).close();
}
use of io.undertow.server.session.SessionManager in project wildfly by wildfly.
the class DistributableSingleSignOnTestCase method contains.
@Test
public void contains() {
String deployment = "deployment";
BatchContext context = mock(BatchContext.class);
Session session = mock(Session.class);
SessionManager manager = mock(SessionManager.class);
Sessions<String, String> sessions = mock(Sessions.class);
when(this.batcher.resumeBatch(this.batch)).thenReturn(context);
when(session.getSessionManager()).thenReturn(manager);
when(manager.getDeploymentName()).thenReturn(deployment);
when(this.sso.getSessions()).thenReturn(sessions);
when(sessions.getDeployments()).thenReturn(Collections.<String>emptySet());
boolean result = this.subject.contains(session);
assertFalse(result);
verifyZeroInteractions(this.batch);
verify(context).close();
reset(context);
when(sessions.getDeployments()).thenReturn(Collections.singleton(deployment));
result = this.subject.contains(session);
assertTrue(result);
verifyZeroInteractions(this.batch);
verify(context).close();
}
use of io.undertow.server.session.SessionManager in project spring-boot by spring-projects.
the class UndertowServletWebServerFactory method createDeploymentManager.
private DeploymentManager createDeploymentManager(ServletContextInitializer... initializers) {
DeploymentInfo deployment = Servlets.deployment();
registerServletContainerInitializerToDriveServletContextInitializers(deployment, initializers);
deployment.setClassLoader(getServletClassLoader());
deployment.setContextPath(getContextPath());
deployment.setDisplayName(getDisplayName());
deployment.setDeploymentName("spring-boot");
if (isRegisterDefaultServlet()) {
deployment.addServlet(Servlets.servlet("default", DefaultServlet.class));
}
configureErrorPages(deployment);
deployment.setServletStackTraces(ServletStackTraces.NONE);
deployment.setResourceManager(getDocumentRootResourceManager());
configureMimeMappings(deployment);
for (UndertowDeploymentInfoCustomizer customizer : this.deploymentInfoCustomizers) {
customizer.customize(deployment);
}
if (isAccessLogEnabled()) {
configureAccessLog(deployment);
}
if (isPersistSession()) {
File dir = getValidSessionStoreDir();
deployment.setSessionPersistenceManager(new FileSessionPersistence(dir));
}
addLocaleMappings(deployment);
DeploymentManager manager = Servlets.newContainer().addDeployment(deployment);
manager.deploy();
SessionManager sessionManager = manager.getDeployment().getSessionManager();
int sessionTimeout = (getSessionTimeout() > 0 ? getSessionTimeout() : -1);
sessionManager.setDefaultSessionTimeout(sessionTimeout);
return manager;
}
Aggregations