/*
* 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-2009 Sun Microsystems, Inc.
*/
/**
* This class provides an implementation of a Directory Server task that can be
* used to terminate a client connection.
*/
public class DisconnectClientTask
extends Task
{
// Indicates whether to send a notification message to the client.
private boolean notifyClient;
// The connection ID for the client connection to terminate.
private long connectionID;
// The disconnect message to send to the client.
/**
* {@inheritDoc}
*/
return INFO_TASK_DISCONNECT_CLIENT_NAME.get();
}
/**
* {@inheritDoc}
*/
public void initializeTask()
throws DirectoryException
{
// If the client connection is available, then make sure the client has the
// DISCONNECT_CLIENT privilege.
{
{
message);
}
}
// Get the connection ID for the client connection.
connectionID = -1L;
{
{
for (AttributeValue v : a)
{
try
{
break connIDLoop;
}
catch (Exception e)
{
message, e);
}
}
}
}
if (connectionID < 0)
{
message);
}
// Determine whether to notify the client.
notifyClient = false;
attrType =
true);
{
{
for (AttributeValue v : a)
{
{
notifyClient = true;
break notifyClientLoop;
}
{
break notifyClientLoop;
}
else
{
message);
}
}
}
}
// Get the disconnect message.
true);
{
{
for (AttributeValue v : a)
{
break disconnectMessageLoop;
}
}
}
}
/**
* {@inheritDoc}
*/
{
// Get the specified client connection.
{
{
if (c.getConnectionID() == connectionID)
{
clientConnection = c;
break;
}
}
}
// If there is no such client connection, then return an error. Otherwise,
// terminate it.
if (clientConnection == null)
{
return TaskState.COMPLETED_WITH_ERRORS;
}
else
{
return TaskState.COMPLETED_SUCCESSFULLY;
}
}
}