DisconnectClientPlugin.java revision 2efcb9667318c099d8723dd578f198c16b4a22c4
/*
* 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
* 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
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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 2006-2008 Sun Microsystems, Inc.
*/
/**
* This class defines a very simple plugin that terminates the client connection
* at any point in the plugin processing if the client request contains an
* appropriate control with a value string that matches the plugin type. The
* valid sections for this plugin include:
* <BR>
* <UL>
* <LI>PreParse -- available for all types of operations</LI>
* <LI>PreOperation -- available for all types of operations except abandon
* and unbind</LI>
* <LI>PostOperation -- available for all types of operations</LI>
* <LI>PostResponse -- available for all types of operations except abandon
* and unbind</LI>
* </UL>
*/
public class DisconnectClientPlugin
extends DirectoryServerPlugin<PluginCfg>
{
/**
* The OID for the disconnect request control, which is used to flag
* operations that should cause the client connection to be terminated.
*/
public static final String OID_DISCONNECT_REQUEST =
"1.3.6.1.4.1.26027.1.999.2";
/**
* The control used by this plugin.
*/
public static class DisconnectClientControl extends Control
{
/**
* ControlDecoder implentation to decode this control from a ByteString.
*/
private final static class Decoder
implements ControlDecoder<DisconnectClientControl>
{
/**
* {@inheritDoc}
*/
throws DirectoryException
{
}
{
return OID_DISCONNECT_REQUEST;
}
}
/**
* The Control Decoder that can be used to decode this control.
*/
new Decoder();
/**
* Constructs a new change number control.
*
* @param isCritical Indicates whether support for this control should be
* considered a critical part of the server processing.
* @param section The section to use for the disconnect.
*/
{
super(OID_DISCONNECT_REQUEST, isCritical);
}
/**
* Writes this control's value to an ASN.1 writer. The value (if any)
* must be written as an ASN1OctetString.
*
* @param writer The ASN.1 writer to use.
* @throws java.io.IOException If a problem occurs while writing to the stream.
*/
}
/**
* Retrieves the delay duration.
*
* @return The delay duration.
*/
public String getSection()
{
return section;
}
}
/**
* Creates a new instance of this Directory Server plugin. Every
* plugin must implement a default constructor (it is the only one
* that will be used to create plugins defined in the
* configuration), and every plugin constructor must call
* <CODE>super()</CODE> as its first element.
*/
public DisconnectClientPlugin()
{
super();
}
/**
* {@inheritDoc}
*/
@Override()
throws ConfigException
{
// This plugin may only be used as a pre-parse, pre-operation,
// post-operation, or post-response plugin.
for (PluginType t : pluginTypes)
{
switch (t)
{
case PRE_PARSE_ABANDON:
case PRE_PARSE_ADD:
case PRE_PARSE_BIND:
case PRE_PARSE_COMPARE:
case PRE_PARSE_DELETE:
case PRE_PARSE_EXTENDED:
case PRE_PARSE_MODIFY:
case PRE_PARSE_MODIFY_DN:
case PRE_PARSE_SEARCH:
case PRE_PARSE_UNBIND:
case PRE_OPERATION_ADD:
case PRE_OPERATION_BIND:
case PRE_OPERATION_COMPARE:
case PRE_OPERATION_DELETE:
case PRE_OPERATION_EXTENDED:
case PRE_OPERATION_MODIFY:
case PRE_OPERATION_MODIFY_DN:
case PRE_OPERATION_SEARCH:
case POST_OPERATION_ABANDON:
case POST_OPERATION_ADD:
case POST_OPERATION_BIND:
case POST_OPERATION_COMPARE:
case POST_OPERATION_DELETE:
case POST_OPERATION_EXTENDED:
case POST_OPERATION_MODIFY:
case POST_OPERATION_MODIFY_DN:
case POST_OPERATION_SEARCH:
case POST_OPERATION_UNBIND:
case POST_RESPONSE_ADD:
case POST_RESPONSE_BIND:
case POST_RESPONSE_COMPARE:
case POST_RESPONSE_DELETE:
case POST_RESPONSE_EXTENDED:
case POST_RESPONSE_MODIFY:
case POST_RESPONSE_MODIFY_DN:
case POST_RESPONSE_SEARCH:
// This is fine.
break;
default:
" for the disconnect plugin."));
}
}
}
/**
* {@inheritDoc}
*/
@Override()
{
}
/**
* {@inheritDoc}
*/
@Override()
throws CanceledOperationException {
{
addOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreParse
throws CanceledOperationException {
{
compareOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreParse
throws CanceledOperationException {
{
deleteOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreParse
throws CanceledOperationException {
{
extendedOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreParse
throws CanceledOperationException {
{
modifyOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreParse
throws CanceledOperationException {
{
modifyDNOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreParse
throws CanceledOperationException {
{
searchOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreParse
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreOperation
throws CanceledOperationException {
{
addOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreOperation
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreOperation
throws CanceledOperationException {
{
compareOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreOperation
throws CanceledOperationException {
{
deleteOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreOperation
throws CanceledOperationException {
{
extendedOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreOperation
throws CanceledOperationException {
{
modifyOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreOperation
throws CanceledOperationException {
{
modifyDNOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PreOperation
throws CanceledOperationException {
{
searchOperation.checkIfCanceled(false);
}
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostOperation
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostOperation
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostOperation
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostOperation
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostOperation
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostOperation
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostOperation
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostOperation
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostOperation
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostOperation
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostResponse
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostResponse
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostResponse
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostResponse
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostResponse
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostResponse
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostResponse
{
}
/**
* {@inheritDoc}
*/
@Override()
public PluginResult.PostResponse
{
}
/**
* Looks for a disconnect request control in the operation and if one is found
* with the correct section then terminate the client connection.
*
* @param operation The operation to be processed.
* @param section The section to match in the control value.
*
* @return <CODE>true</CODE> if the client connection was terminated, or
* <CODE>false</CODE> if it was not.
*/
{
try
{
{
section + ")"));
return true;
}
}
catch (Exception e)
{
e));
}
// If we've gotten here, then we shouldn't disconnect the client.
return false;
}
/**
* Creates a disconnect request control with the specified section.
*
* @param section The section to use for the disconnect.
*
* @return The appropriate disconnect request control.
*/
{
return new DisconnectClientControl(false, section);
}
/**
* Retrieves a list containing a disconnect control with the specified
* section.
*
* @param section The section to use for the disconnect.
*
* @return A list containing the appropriate disconnect request control.
*/
{
return controlList;
}
}