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 2014 ForgeRock AS.
016 */
017package org.opends.server.protocols.ldap;
018
019
020
021import org.forgerock.opendj.io.ASN1Writer;
022
023import org.forgerock.i18n.slf4j.LocalizedLogger;
024import static org.opends.server.protocols.ldap.LDAPConstants.*;
025import static org.opends.server.util.ServerConstants.*;
026
027import java.io.IOException;
028
029
030/**
031 * This class defines the structures and methods for an LDAP unbind request
032 * protocol op, which is used to indicate that the client wishes to disconnect
033 * from the Directory Server.
034 */
035public class UnbindRequestProtocolOp
036       extends ProtocolOp
037{
038  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
039
040  /**
041   * Creates a new LDAP unbind request protocol op.
042   */
043  public UnbindRequestProtocolOp()
044  {
045  }
046
047
048
049  /**
050   * Retrieves the BER type for this protocol op.
051   *
052   * @return  The BER type for this protocol op.
053   */
054  public byte getType()
055  {
056    return OP_TYPE_UNBIND_REQUEST;
057  }
058
059
060
061  /**
062   * Retrieves the name for this protocol op type.
063   *
064   * @return  The name for this protocol op type.
065   */
066  public String getProtocolOpName()
067  {
068    return "Unbind Request";
069  }
070
071  /**
072   * Writes this protocol op to an ASN.1 output stream.
073   *
074   * @param stream The ASN.1 output stream to write to.
075   * @throws IOException If a problem occurs while writing to the stream.
076   */
077  public void write(ASN1Writer stream) throws IOException
078  {
079    stream.writeNull(OP_TYPE_UNBIND_REQUEST);
080  }
081
082
083
084  /**
085   * Appends a string representation of this LDAP protocol op to the provided
086   * buffer.
087   *
088   * @param  buffer  The buffer to which the string should be appended.
089   */
090  public void toString(StringBuilder buffer)
091  {
092    buffer.append("UnbindRequest()");
093  }
094
095
096
097  /**
098   * Appends a multi-line string representation of this LDAP protocol op to the
099   * provided buffer.
100   *
101   * @param  buffer  The buffer to which the information should be appended.
102   * @param  indent  The number of spaces from the margin that the lines should
103   *                 be indented.
104   */
105  public void toString(StringBuilder buffer, int indent)
106  {
107    for (int i=0; i < indent; i++)
108    {
109      buffer.append(' ');
110    }
111
112    buffer.append("Unbind Request");
113    buffer.append(EOL);
114  }
115}
116