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-2016 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  @Override
055  public byte getType()
056  {
057    return OP_TYPE_UNBIND_REQUEST;
058  }
059
060
061
062  /**
063   * Retrieves the name for this protocol op type.
064   *
065   * @return  The name for this protocol op type.
066   */
067  @Override
068  public String getProtocolOpName()
069  {
070    return "Unbind Request";
071  }
072
073  /**
074   * Writes this protocol op to an ASN.1 output stream.
075   *
076   * @param stream The ASN.1 output stream to write to.
077   * @throws IOException If a problem occurs while writing to the stream.
078   */
079  @Override
080  public void write(ASN1Writer stream) throws IOException
081  {
082    stream.writeNull(OP_TYPE_UNBIND_REQUEST);
083  }
084
085
086
087  /**
088   * Appends a string representation of this LDAP protocol op to the provided
089   * buffer.
090   *
091   * @param  buffer  The buffer to which the string should be appended.
092   */
093  @Override
094  public void toString(StringBuilder buffer)
095  {
096    buffer.append("UnbindRequest()");
097  }
098
099
100
101  /**
102   * Appends a multi-line string representation of this LDAP protocol op to the
103   * provided buffer.
104   *
105   * @param  buffer  The buffer to which the information should be appended.
106   * @param  indent  The number of spaces from the margin that the lines should
107   *                 be indented.
108   */
109  @Override
110  public void toString(StringBuilder buffer, int indent)
111  {
112    for (int i=0; i < indent; i++)
113    {
114      buffer.append(' ');
115    }
116
117    buffer.append("Unbind Request");
118    buffer.append(EOL);
119  }
120}
121