/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008 Sun Microsystems, Inc.
* Portions Copyright 2012-2015 ForgeRock AS.
*/
/**
* This class defines a thread that will be used to terminate client
* connections if they have been idle for too long.
*/
public class IdleTimeLimitThread
extends DirectoryThread
implements ServerShutdownListener
{
/** The debug log tracer for this object. */
/** Shutdown monitor state. */
private volatile boolean shutdownRequested;
/**
* Creates a new instance of this idle time limit thread.
*/
public IdleTimeLimitThread()
{
super("Idle Time Limit Thread");
setDaemon(true);
shutdownRequested = false;
}
/**
* Operates in a loop, teriminating any client connections that have been idle
* for too long.
*/
public void run()
{
long sleepTime = 5000L;
while (! shutdownRequested)
{
try
{
synchronized (shutdownLock)
{
if (!shutdownRequested)
{
try
{
}
catch (InterruptedException e)
{
// Server shutdown monitor may interrupt slow threads.
logger.traceException(e);
shutdownRequested = true;
break;
}
}
}
sleepTime = 5000L;
{
{
if (c==null) {
continue;
}
long idleTime = c.getIdleTime();
if (idleTime > 0)
{
long idleTimeLimit = c.getIdleTimeLimit();
if (idleTimeLimit > 0)
{
if (idleTime >= idleTimeLimit)
{
if (logger.isTraceEnabled())
{
c.getConnectionID() +
" due to the idle time limit");
}
try
{
true, disconnectMessage);
}
catch (Exception e)
{
logger.traceException(e);
);
}
}
else
{
if (shouldSleepTime < sleepTime)
{
}
}
}
}
}
}
}
catch (Exception e)
{
logger.traceException(e);
}
}
}
/** {@inheritDoc} */
{
return "Idle Time Limit Thread";
}
/** {@inheritDoc} */
{
synchronized (shutdownLock)
{
shutdownRequested = true;
}
}
}