DisconnectClientPlugin.java revision ea1068c292e9b341af6d6b563cd8988a96be20a9
1691N/A/*
2887N/A * CDDL HEADER START
1691N/A *
1691N/A * The contents of this file are subject to the terms of the
1691N/A * Common Development and Distribution License, Version 1.0 only
1691N/A * (the "License"). You may not use this file except in compliance
1691N/A * with the License.
1691N/A *
1691N/A * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
1691N/A * or http://forgerock.org/license/CDDLv1.0.html.
1691N/A * See the License for the specific language governing permissions
1691N/A * and limitations under the License.
1691N/A *
1691N/A * When distributing Covered Code, include this CDDL HEADER in each
1691N/A * file and include the License file at legal-notices/CDDLv1_0.txt.
1691N/A * If applicable, add the following below this CDDL HEADER, with the
1691N/A * fields enclosed by brackets "[]" replaced with your own identifying
1691N/A * information:
1691N/A * Portions Copyright [yyyy] [name of copyright owner]
1691N/A *
1691N/A * CDDL HEADER END
1691N/A *
1691N/A *
1691N/A * Copyright 2006-2008 Sun Microsystems, Inc.
1691N/A * Portions Copyright 2014-2015 ForgeRock AS
4618N/A */
1691N/Apackage org.opends.server.plugins;
1691N/A
1691N/A
1691N/A
4618N/Aimport java.io.IOException;
1691N/Aimport java.util.ArrayList;
4618N/Aimport java.util.List;
1691N/Aimport java.util.Set;
1691N/A
1691N/Aimport org.forgerock.i18n.LocalizableMessage;
4618N/Aimport org.forgerock.i18n.slf4j.LocalizedLogger;
4618N/Aimport org.forgerock.opendj.ldap.ByteString;
4618N/Aimport org.opends.server.admin.std.server.PluginCfg;
1691N/Aimport org.opends.server.api.plugin.DirectoryServerPlugin;
4618N/Aimport org.opends.server.api.plugin.PluginResult;
4618N/Aimport org.opends.server.api.plugin.PluginType;
4618N/Aimport org.forgerock.opendj.config.server.ConfigException;
4618N/Aimport org.opends.server.controls.ControlDecoder;
4618N/Aimport org.forgerock.opendj.io.ASN1Writer;
4618N/Aimport org.opends.server.types.CanceledOperationException;
4618N/Aimport org.opends.server.types.Control;
4618N/Aimport org.opends.server.types.DirectoryException;
4618N/Aimport org.opends.server.types.DisconnectReason;
4618N/Aimport org.opends.server.types.operation.*;
4618N/A
4618N/A
4618N/A/**
4618N/A * This class defines a very simple plugin that terminates the client connection
4618N/A * at any point in the plugin processing if the client request contains an
4618N/A * appropriate control with a value string that matches the plugin type. The
4618N/A * valid sections for this plugin include:
4618N/A * <BR>
4618N/A * <UL>
4618N/A * <LI>PreParse -- available for all types of operations</LI>
4618N/A * <LI>PreOperation -- available for all types of operations except abandon
4618N/A * and unbind</LI>
4618N/A * <LI>PostOperation -- available for all types of operations</LI>
4618N/A * <LI>PostResponse -- available for all types of operations except abandon
4618N/A * and unbind</LI>
4618N/A * </UL>
4618N/A */
4618N/Apublic class DisconnectClientPlugin
4618N/A extends DirectoryServerPlugin<PluginCfg>
4618N/A{
4618N/A
4618N/A private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
4618N/A
4618N/A /**
4618N/A * The OID for the disconnect request control, which is used to flag
4618N/A * operations that should cause the client connection to be terminated.
4618N/A */
4618N/A public static final String OID_DISCONNECT_REQUEST =
4618N/A "1.3.6.1.4.1.26027.1.999.2";
4618N/A
4618N/A
4618N/A /**
4618N/A * The control used by this plugin.
4618N/A */
4618N/A public static class DisconnectClientControl extends Control
4618N/A {
4618N/A /**
4618N/A * ControlDecoder implementation to decode this control from a ByteString.
4618N/A */
4618N/A private final static class Decoder
4618N/A implements ControlDecoder<DisconnectClientControl>
4618N/A {
1691N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public DisconnectClientControl decode(boolean isCritical,
4618N/A ByteString value)
4618N/A throws DirectoryException
4618N/A {
4618N/A return new DisconnectClientControl(isCritical, value.toString());
4618N/A }
4618N/A
4618N/A @Override
4618N/A public String getOID()
4618N/A {
4618N/A return OID_DISCONNECT_REQUEST;
4618N/A }
4618N/A
4618N/A }
4618N/A
4618N/A /**
4618N/A * The Control Decoder that can be used to decode this control.
4618N/A */
4618N/A public static final ControlDecoder<DisconnectClientControl> DECODER =
4618N/A new Decoder();
4618N/A
4618N/A
4618N/A private String section;
4618N/A
4618N/A /**
4618N/A * Constructs a new control of this class.
4618N/A *
4618N/A * @param isCritical
4618N/A * Indicates whether support for this control should be considered
4618N/A * a critical part of the server processing.
4618N/A * @param section
4618N/A * The section to use for the disconnect.
4618N/A */
4618N/A public DisconnectClientControl(boolean isCritical, String section)
4618N/A {
4618N/A super(OID_DISCONNECT_REQUEST, isCritical);
4618N/A this.section = section;
4618N/A }
4618N/A
4618N/A /**
4618N/A * Writes this control's value to an ASN.1 writer. The value (if any)
4618N/A * must be written as an ASN1OctetString.
4618N/A *
4618N/A * @param writer The ASN.1 writer to use.
4618N/A * @throws java.io.IOException If a problem occurs while writing to the stream.
4618N/A */
4618N/A @Override
4618N/A protected void writeValue(ASN1Writer writer) throws IOException {
4618N/A writer.writeOctetString(section);
4618N/A }
4618N/A
4618N/A /**
4618N/A * Retrieves the delay duration.
4618N/A *
4618N/A * @return The delay duration.
4618N/A */
4618N/A public String getSection()
4618N/A {
4618N/A return section;
4618N/A }
4618N/A }
4618N/A
4618N/A /**
4618N/A * Creates a new instance of this Directory Server plugin. Every
4618N/A * plugin must implement a default constructor (it is the only one
4618N/A * that will be used to create plugins defined in the
4618N/A * configuration), and every plugin constructor must call
4618N/A * <CODE>super()</CODE> as its first element.
4618N/A */
4618N/A public DisconnectClientPlugin()
4618N/A {
4618N/A super();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public void initializePlugin(Set<PluginType> pluginTypes,
4618N/A PluginCfg configuration)
4618N/A throws ConfigException
4618N/A {
4618N/A // This plugin may only be used as a pre-parse, pre-operation,
4618N/A // post-operation, or post-response plugin.
4618N/A for (PluginType t : pluginTypes)
4618N/A {
4618N/A switch (t)
4618N/A {
4618N/A case PRE_PARSE_ABANDON:
4618N/A case PRE_PARSE_ADD:
4618N/A case PRE_PARSE_BIND:
4618N/A case PRE_PARSE_COMPARE:
4618N/A case PRE_PARSE_DELETE:
4618N/A case PRE_PARSE_EXTENDED:
4618N/A case PRE_PARSE_MODIFY:
4618N/A case PRE_PARSE_MODIFY_DN:
4618N/A case PRE_PARSE_SEARCH:
4618N/A case PRE_PARSE_UNBIND:
4618N/A case PRE_OPERATION_ADD:
4618N/A case PRE_OPERATION_BIND:
4618N/A case PRE_OPERATION_COMPARE:
4618N/A case PRE_OPERATION_DELETE:
4618N/A case PRE_OPERATION_EXTENDED:
4618N/A case PRE_OPERATION_MODIFY:
4618N/A case PRE_OPERATION_MODIFY_DN:
4618N/A case PRE_OPERATION_SEARCH:
4618N/A case POST_OPERATION_ABANDON:
4618N/A case POST_OPERATION_ADD:
4618N/A case POST_OPERATION_BIND:
4618N/A case POST_OPERATION_COMPARE:
4618N/A case POST_OPERATION_DELETE:
4618N/A case POST_OPERATION_EXTENDED:
4618N/A case POST_OPERATION_MODIFY:
4618N/A case POST_OPERATION_MODIFY_DN:
4618N/A case POST_OPERATION_SEARCH:
4618N/A case POST_OPERATION_UNBIND:
4618N/A case POST_RESPONSE_ADD:
4618N/A case POST_RESPONSE_BIND:
4618N/A case POST_RESPONSE_COMPARE:
4618N/A case POST_RESPONSE_DELETE:
4618N/A case POST_RESPONSE_EXTENDED:
4618N/A case POST_RESPONSE_MODIFY:
4618N/A case POST_RESPONSE_MODIFY_DN:
4618N/A case POST_RESPONSE_SEARCH:
4618N/A // This is fine.
4618N/A break;
4618N/A default:
4618N/A throw new ConfigException(LocalizableMessage.raw("Invalid plugin type " + t +
4618N/A " for the disconnect plugin."));
4618N/A }
4618N/A }
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreParse doPreParse(
4618N/A PreParseAbandonOperation abandonOperation)
4618N/A {
4618N/A disconnectInternal(abandonOperation, "PreParse");
4618N/A return PluginResult.PreParse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreParse doPreParse(PreParseAddOperation addOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(addOperation, "PreParse"))
4618N/A {
4618N/A addOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreParse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreParse doPreParse(PreParseBindOperation bindOperation)
4618N/A {
4618N/A disconnectInternal(bindOperation, "PreParse");
4618N/A return PluginResult.PreParse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreParse
4618N/A doPreParse(PreParseCompareOperation compareOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(compareOperation, "PreParse"))
4618N/A {
4618N/A compareOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreParse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreParse
4618N/A doPreParse(PreParseDeleteOperation deleteOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(deleteOperation, "PreParse"))
4618N/A {
4618N/A deleteOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreParse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreParse
4618N/A doPreParse(PreParseExtendedOperation extendedOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(extendedOperation, "PreParse"))
4618N/A {
4618N/A extendedOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreParse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreParse
4618N/A doPreParse(PreParseModifyOperation modifyOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(modifyOperation, "PreParse"))
4618N/A {
4618N/A modifyOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreParse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreParse
4618N/A doPreParse(PreParseModifyDNOperation modifyDNOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(modifyDNOperation, "PreParse"))
4618N/A {
4618N/A modifyDNOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreParse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreParse
4618N/A doPreParse(PreParseSearchOperation searchOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(searchOperation, "PreParse"))
4618N/A {
4618N/A searchOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreParse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreParse
4618N/A doPreParse(PreParseUnbindOperation unbindOperation)
4618N/A {
4618N/A disconnectInternal(unbindOperation, "PreParse");
4618N/A return PluginResult.PreParse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreOperation
4618N/A doPreOperation(PreOperationAddOperation addOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(addOperation, "PreOperation"))
4618N/A {
4618N/A addOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreOperation
4618N/A doPreOperation(PreOperationBindOperation bindOperation)
4618N/A {
4618N/A disconnectInternal(bindOperation, "PreOperation");
4618N/A return PluginResult.PreOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreOperation
4618N/A doPreOperation(PreOperationCompareOperation compareOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(compareOperation, "PreOperation"))
4618N/A {
4618N/A compareOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreOperation
4618N/A doPreOperation(PreOperationDeleteOperation deleteOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(deleteOperation, "PreOperation"))
4618N/A {
4618N/A deleteOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreOperation
4618N/A doPreOperation(PreOperationExtendedOperation extendedOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(extendedOperation, "PreOperation"))
4618N/A {
4618N/A extendedOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreOperation
4618N/A doPreOperation(PreOperationModifyOperation modifyOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(modifyOperation, "PreOperation"))
4618N/A {
4618N/A modifyOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreOperation
4618N/A doPreOperation(PreOperationModifyDNOperation modifyDNOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(modifyDNOperation, "PreOperation"))
4618N/A {
4618N/A modifyDNOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PreOperation
4618N/A doPreOperation(PreOperationSearchOperation searchOperation)
4618N/A throws CanceledOperationException {
4618N/A if (disconnectInternal(searchOperation, "PreOperation"))
4618N/A {
4618N/A searchOperation.checkIfCanceled(false);
4618N/A }
4618N/A return PluginResult.PreOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostOperation
4618N/A doPostOperation(PostOperationAbandonOperation abandonOperation)
4618N/A {
4618N/A disconnectInternal(abandonOperation, "PostOperation");
4618N/A return PluginResult.PostOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostOperation
4618N/A doPostOperation(PostOperationAddOperation addOperation)
4618N/A {
4618N/A disconnectInternal(addOperation, "PostOperation");
4618N/A return PluginResult.PostOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostOperation
4618N/A doPostOperation(PostOperationBindOperation bindOperation)
4618N/A {
4618N/A disconnectInternal(bindOperation, "PostOperation");
4618N/A return PluginResult.PostOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostOperation
4618N/A doPostOperation(PostOperationCompareOperation compareOperation)
4618N/A {
4618N/A disconnectInternal(compareOperation, "PostOperation");
4618N/A return PluginResult.PostOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostOperation
4618N/A doPostOperation(PostOperationDeleteOperation deleteOperation)
4618N/A {
4618N/A disconnectInternal(deleteOperation, "PostOperation");
4618N/A return PluginResult.PostOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostOperation
4618N/A doPostOperation(PostOperationExtendedOperation extendedOperation)
4618N/A {
4618N/A disconnectInternal(extendedOperation, "PostOperation");
4618N/A return PluginResult.PostOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostOperation
4618N/A doPostOperation(PostOperationModifyOperation modifyOperation)
4618N/A {
4618N/A disconnectInternal(modifyOperation, "PostOperation");
4618N/A return PluginResult.PostOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostOperation
4618N/A doPostOperation(PostOperationModifyDNOperation modifyDNOperation)
4618N/A {
4618N/A disconnectInternal(modifyDNOperation, "PostOperation");
4618N/A return PluginResult.PostOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostOperation
4618N/A doPostOperation(PostOperationSearchOperation searchOperation)
4618N/A {
4618N/A disconnectInternal(searchOperation, "PostOperation");
4618N/A return PluginResult.PostOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostOperation
4618N/A doPostOperation(PostOperationUnbindOperation unbindOperation)
4618N/A {
4618N/A disconnectInternal(unbindOperation, "PostOperation");
4618N/A return PluginResult.PostOperation.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostResponse
4618N/A doPostResponse(PostResponseAddOperation addOperation)
4618N/A {
4618N/A disconnectInternal(addOperation, "PostResponse");
4618N/A return PluginResult.PostResponse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostResponse
4618N/A doPostResponse(PostResponseBindOperation bindOperation)
4618N/A {
4618N/A disconnectInternal(bindOperation, "PostResponse");
4618N/A return PluginResult.PostResponse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostResponse
4618N/A doPostResponse(PostResponseCompareOperation compareOperation)
4618N/A {
4618N/A disconnectInternal(compareOperation, "PostResponse");
4618N/A return PluginResult.PostResponse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostResponse
4618N/A doPostResponse(PostResponseDeleteOperation deleteOperation)
4618N/A {
4618N/A disconnectInternal(deleteOperation, "PostResponse");
4618N/A return PluginResult.PostResponse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostResponse
4618N/A doPostResponse(PostResponseExtendedOperation extendedOperation)
4618N/A {
4618N/A disconnectInternal(extendedOperation, "PostResponse");
4618N/A return PluginResult.PostResponse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostResponse
4618N/A doPostResponse(PostResponseModifyOperation modifyOperation)
4618N/A {
4618N/A disconnectInternal(modifyOperation, "PostResponse");
4618N/A return PluginResult.PostResponse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostResponse
4618N/A doPostResponse(PostResponseModifyDNOperation modifyDNOperation)
4618N/A {
4618N/A disconnectInternal(modifyDNOperation, "PostResponse");
4618N/A return PluginResult.PostResponse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * {@inheritDoc}
4618N/A */
4618N/A @Override
4618N/A public PluginResult.PostResponse
4618N/A doPostResponse(PostResponseSearchOperation searchOperation)
4618N/A {
4618N/A disconnectInternal(searchOperation, "PostResponse");
4618N/A return PluginResult.PostResponse.continueOperationProcessing();
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * Looks for a disconnect request control in the operation and if one is found
4618N/A * with the correct section then terminate the client connection.
4618N/A *
4618N/A * @param operation The operation to be processed.
4618N/A * @param section The section to match in the control value.
4618N/A *
4618N/A * @return <CODE>true</CODE> if the client connection was terminated, or
4618N/A * <CODE>false</CODE> if it was not.
4618N/A */
4618N/A private boolean disconnectInternal(PluginOperation operation,
4618N/A String section)
4618N/A {
4618N/A try
4618N/A {
4618N/A DisconnectClientControl control =
4618N/A operation.getRequestControl(DisconnectClientControl.DECODER);
4618N/A
4618N/A if (control != null && control.getSection().equalsIgnoreCase(section))
4618N/A {
4618N/A operation.disconnectClient(DisconnectReason.CLOSED_BY_PLUGIN, true,
4618N/A LocalizableMessage.raw("Closed by disconnect client plugin (section " +
4618N/A section + ")"));
4618N/A
4618N/A return true;
4618N/A }
4618N/A }
4618N/A catch (Exception e)
4618N/A {
4618N/A logger.error(LocalizableMessage.raw("Unable to decode the disconnect client control: " +
4618N/A e));
4618N/A }
4618N/A
4618N/A
4618N/A // If we've gotten here, then we shouldn't disconnect the client.
4618N/A return false;
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * Creates a disconnect request control with the specified section.
4618N/A *
4618N/A * @param section The section to use for the disconnect.
4618N/A *
4618N/A * @return The appropriate disconnect request control.
4618N/A */
4618N/A public static Control createDisconnectControl(String section)
4618N/A {
4618N/A return new DisconnectClientControl(false, section);
4618N/A }
4618N/A
4618N/A
4618N/A
4618N/A /**
4618N/A * Retrieves a list containing a disconnect control with the specified
4618N/A * section.
4618N/A *
4618N/A * @param section The section to use for the disconnect.
4618N/A *
4618N/A * @return A list containing the appropriate disconnect request control.
4618N/A */
4618N/A public static List<Control> createDisconnectControlList(String section)
4618N/A {
4618N/A ArrayList<Control> controlList = new ArrayList<Control>(1);
4618N/A
4618N/A controlList.add(new DisconnectClientControl(false, section));
4618N/A
4618N/A return controlList;
4618N/A }
4618N/A}
4618N/A
4618N/A