001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2006-2008 Sun Microsystems, Inc. 015 * Portions Copyright 2013-2016 ForgeRock AS. 016 */ 017package org.opends.server.core; 018 019import static org.opends.messages.CoreMessages.*; 020import static org.opends.server.core.DirectoryServer.*; 021import static org.opends.server.loggers.AccessLogger.*; 022 023import java.util.List; 024 025import org.forgerock.i18n.slf4j.LocalizedLogger; 026import org.forgerock.opendj.ldap.DN; 027import org.forgerock.opendj.ldap.ResultCode; 028import org.opends.server.api.ClientConnection; 029import org.opends.server.types.*; 030import org.opends.server.types.operation.PostOperationUnbindOperation; 031import org.opends.server.types.operation.PreParseUnbindOperation; 032 033/** 034 * This class defines an operation that may be used to close the connection 035 * between the client and the Directory Server. 036 */ 037public class UnbindOperationBasis 038 extends AbstractOperation 039 implements UnbindOperation, 040 PreParseUnbindOperation, 041 PostOperationUnbindOperation 042{ 043 private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); 044 045 /** 046 * Creates a new unbind operation with the provided information. 047 * 048 * @param clientConnection The client connection with which this operation 049 * is associated. 050 * @param operationID The operation ID for this operation. 051 * @param messageID The message ID of the request with which this 052 * operation is associated. 053 * @param requestControls The set of controls included in the request. 054 */ 055 public UnbindOperationBasis(ClientConnection clientConnection, 056 long operationID, 057 int messageID, List<Control> requestControls) 058 { 059 super(clientConnection, operationID, messageID, requestControls); 060 061 cancelResult = new CancelResult(ResultCode.CANNOT_CANCEL, 062 ERR_CANNOT_CANCEL_UNBIND.get()); 063 } 064 065 /** {@inheritDoc} */ 066 @Override 067 public final OperationType getOperationType() 068 { 069 // Note that no debugging will be done in this method because it is a likely 070 // candidate for being called by the logging subsystem. 071 return OperationType.UNBIND; 072 } 073 074 /** {@inheritDoc} */ 075 @Override 076 public DN getProxiedAuthorizationDN() 077 { 078 return null; 079 } 080 081 /** {@inheritDoc} */ 082 @Override 083 public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN) 084 { 085 } 086 087 /** {@inheritDoc} */ 088 @Override 089 public final List<Control> getResponseControls() 090 { 091 // An unbind operation can never have a response, so just return an empty 092 // list. 093 return NO_RESPONSE_CONTROLS; 094 } 095 096 /** {@inheritDoc} */ 097 @Override 098 public final void addResponseControl(Control control) 099 { 100 // An unbind operation can never have a response, so just ignore this. 101 } 102 103 /** {@inheritDoc} */ 104 @Override 105 public final void removeResponseControl(Control control) 106 { 107 // An unbind operation can never have a response, so just ignore this. 108 } 109 110 /** 111 * Performs the work of actually processing this operation. This 112 * should include all processing for the operation, including 113 * invoking plugins, logging messages, performing access control, 114 * managing synchronization, and any other work that might need to 115 * be done in the course of processing. 116 */ 117 @Override 118 public final void run() 119 { 120 setProcessingStartTime(); 121 122 // Invoke the pre-parse unbind plugins. We don't care about the result 123 // since we're going to close the connection anyway. 124 getPluginConfigManager().invokePreParseUnbindPlugins(this); 125 126 logUnbind(this); 127 128 129 // Check the set of controls included in the request. If there are any, 130 // see if any special processing is needed. 131 // NYI 132 133 134 // Disconnect the client. 135 getClientConnection().disconnect(DisconnectReason.UNBIND, false, null); 136 137 138 // Invoke the post-operation unbind plugins. 139 getPluginConfigManager().invokePostOperationUnbindPlugins(this); 140 141 setProcessingStopTime(); 142 } 143 144 /** {@inheritDoc} */ 145 @Override 146 public final void toString(StringBuilder buffer) 147 { 148 buffer.append("UnbindOperation(connID="); 149 buffer.append(clientConnection.getConnectionID()); 150 buffer.append(", opID="); 151 buffer.append(operationID); 152 buffer.append(")"); 153 } 154 155} 156