use of org.apache.catalina.SessionIdGenerator in project tomcat70 by apache.
the class ManagerBase method startInternal.
@Override
protected void startInternal() throws LifecycleException {
// nulls.
while (sessionCreationTiming.size() < TIMING_STATS_CACHE_SIZE) {
sessionCreationTiming.add(null);
}
while (sessionExpirationTiming.size() < TIMING_STATS_CACHE_SIZE) {
sessionExpirationTiming.add(null);
}
/* Create sessionIdGenerator if not explicitly configured */
SessionIdGenerator sessionIdGenerator = getSessionIdGenerator();
if (sessionIdGenerator == null) {
sessionIdGenerator = new StandardSessionIdGenerator();
setSessionIdGenerator(sessionIdGenerator);
}
if (sessionIdLength != SESSION_ID_LENGTH_UNSET) {
sessionIdGenerator.setSessionIdLength(sessionIdLength);
}
sessionIdGenerator.setJvmRoute(getJvmRoute());
if (sessionIdGenerator instanceof SessionIdGeneratorBase) {
SessionIdGeneratorBase sig = (SessionIdGeneratorBase) sessionIdGenerator;
sig.setSecureRandomAlgorithm(getSecureRandomAlgorithm());
sig.setSecureRandomClass(getSecureRandomClass());
sig.setSecureRandomProvider(getSecureRandomProvider());
}
if (sessionIdGenerator instanceof Lifecycle) {
((Lifecycle) sessionIdGenerator).start();
} else {
// Force initialization of the random number generator
if (log.isDebugEnabled())
log.debug("Force random number initialization starting");
sessionIdGenerator.generateSessionId();
if (log.isDebugEnabled())
log.debug("Force random number initialization completed");
}
}
use of org.apache.catalina.SessionIdGenerator in project tomcat by apache.
the class PersistentManagerSF method storeChildren.
/**
* Store the specified PersistentManager properties.
*
* @param aWriter
* PrintWriter to which we are storing
* @param indent
* Number of spaces to indent this element
* @param aManager
* PersistentManager whose properties are being stored
*
* @exception Exception
* if an exception occurs while storing
*/
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aManager, StoreDescription parentDesc) throws Exception {
if (aManager instanceof PersistentManager) {
PersistentManager manager = (PersistentManager) aManager;
// Store nested <Store> element
Store store = manager.getStore();
storeElement(aWriter, indent, store);
// Store nested <SessionIdGenerator> element
SessionIdGenerator sessionIdGenerator = manager.getSessionIdGenerator();
if (sessionIdGenerator != null) {
storeElement(aWriter, indent, sessionIdGenerator);
}
}
}
use of org.apache.catalina.SessionIdGenerator in project tomcat by apache.
the class ManagerBase method startInternal.
@Override
protected void startInternal() throws LifecycleException {
// nulls.
while (sessionCreationTiming.size() < TIMING_STATS_CACHE_SIZE) {
sessionCreationTiming.add(null);
}
while (sessionExpirationTiming.size() < TIMING_STATS_CACHE_SIZE) {
sessionExpirationTiming.add(null);
}
/* Create sessionIdGenerator if not explicitly configured */
SessionIdGenerator sessionIdGenerator = getSessionIdGenerator();
if (sessionIdGenerator == null) {
sessionIdGenerator = new StandardSessionIdGenerator();
setSessionIdGenerator(sessionIdGenerator);
}
sessionIdGenerator.setJvmRoute(getJvmRoute());
if (sessionIdGenerator instanceof SessionIdGeneratorBase) {
SessionIdGeneratorBase sig = (SessionIdGeneratorBase) sessionIdGenerator;
sig.setSecureRandomAlgorithm(getSecureRandomAlgorithm());
sig.setSecureRandomClass(getSecureRandomClass());
sig.setSecureRandomProvider(getSecureRandomProvider());
}
if (sessionIdGenerator instanceof Lifecycle) {
((Lifecycle) sessionIdGenerator).start();
} else {
// Force initialization of the random number generator
if (log.isDebugEnabled()) {
log.debug("Force random number initialization starting");
}
sessionIdGenerator.generateSessionId();
if (log.isDebugEnabled()) {
log.debug("Force random number initialization completed");
}
}
}
use of org.apache.catalina.SessionIdGenerator in project tomcat70 by apache.
the class ClusterManagerBase method clone.
protected void clone(ClusterManagerBase copy) {
copy.setName("Clone-from-" + getName());
copy.setMaxActiveSessions(getMaxActiveSessions());
copy.setProcessExpiresFrequency(getProcessExpiresFrequency());
copy.setNotifyListenersOnReplication(isNotifyListenersOnReplication());
copy.setSessionAttributeNameFilter(getSessionAttributeNameFilter());
copy.setSessionAttributeValueClassNameFilter(getSessionAttributeValueClassNameFilter());
copy.setWarnOnSessionAttributeFilterFailure(getWarnOnSessionAttributeFilterFailure());
copy.setSecureRandomClass(getSecureRandomClass());
copy.setSecureRandomProvider(getSecureRandomProvider());
copy.setSecureRandomAlgorithm(getSecureRandomAlgorithm());
if (getSessionIdGenerator() != null) {
try {
SessionIdGenerator copyIdGenerator = sessionIdGeneratorClass.newInstance();
copyIdGenerator.setSessionIdLength(getSessionIdGenerator().getSessionIdLength());
copyIdGenerator.setJvmRoute(getSessionIdGenerator().getJvmRoute());
copy.setSessionIdGenerator(copyIdGenerator);
} catch (InstantiationException e) {
// Ignore
} catch (IllegalAccessException e) {
// Ignore
}
}
copy.setRecordAllActions(isRecordAllActions());
}
use of org.apache.catalina.SessionIdGenerator in project spring-boot by spring-projects.
the class TomcatServletWebServerFactoryTests method sessionIdGeneratorIsConfiguredWithAttributesFromTheManager.
@Test
void sessionIdGeneratorIsConfiguredWithAttributesFromTheManager() {
System.setProperty("jvmRoute", "test");
try {
TomcatServletWebServerFactory factory = getFactory();
this.webServer = factory.getWebServer();
this.webServer.start();
} finally {
System.clearProperty("jvmRoute");
}
Tomcat tomcat = ((TomcatWebServer) this.webServer).getTomcat();
Context context = (Context) tomcat.getHost().findChildren()[0];
SessionIdGenerator sessionIdGenerator = context.getManager().getSessionIdGenerator();
assertThat(sessionIdGenerator).isInstanceOf(LazySessionIdGenerator.class);
assertThat(sessionIdGenerator.getJvmRoute()).isEqualTo("test");
}
Aggregations