001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2006-2008 Sun Microsystems, Inc. 025 * Portions Copyright 2014 ForgeRock AS 026 */ 027package org.opends.server.protocols.ldap; 028 029 030 031import org.forgerock.opendj.io.ASN1Writer; 032 033import org.forgerock.i18n.slf4j.LocalizedLogger; 034import static org.opends.server.protocols.ldap.LDAPConstants.*; 035import static org.opends.server.util.ServerConstants.*; 036 037import java.io.IOException; 038 039 040/** 041 * This class defines the structures and methods for an LDAP unbind request 042 * protocol op, which is used to indicate that the client wishes to disconnect 043 * from the Directory Server. 044 */ 045public class UnbindRequestProtocolOp 046 extends ProtocolOp 047{ 048 private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); 049 050 /** 051 * Creates a new LDAP unbind request protocol op. 052 */ 053 public UnbindRequestProtocolOp() 054 { 055 } 056 057 058 059 /** 060 * Retrieves the BER type for this protocol op. 061 * 062 * @return The BER type for this protocol op. 063 */ 064 public byte getType() 065 { 066 return OP_TYPE_UNBIND_REQUEST; 067 } 068 069 070 071 /** 072 * Retrieves the name for this protocol op type. 073 * 074 * @return The name for this protocol op type. 075 */ 076 public String getProtocolOpName() 077 { 078 return "Unbind Request"; 079 } 080 081 /** 082 * Writes this protocol op to an ASN.1 output stream. 083 * 084 * @param stream The ASN.1 output stream to write to. 085 * @throws IOException If a problem occurs while writing to the stream. 086 */ 087 public void write(ASN1Writer stream) throws IOException 088 { 089 stream.writeNull(OP_TYPE_UNBIND_REQUEST); 090 } 091 092 093 094 /** 095 * Appends a string representation of this LDAP protocol op to the provided 096 * buffer. 097 * 098 * @param buffer The buffer to which the string should be appended. 099 */ 100 public void toString(StringBuilder buffer) 101 { 102 buffer.append("UnbindRequest()"); 103 } 104 105 106 107 /** 108 * Appends a multi-line string representation of this LDAP protocol op to the 109 * provided buffer. 110 * 111 * @param buffer The buffer to which the information should be appended. 112 * @param indent The number of spaces from the margin that the lines should 113 * be indented. 114 */ 115 public void toString(StringBuilder buffer, int indent) 116 { 117 for (int i=0; i < indent; i++) 118 { 119 buffer.append(' '); 120 } 121 122 buffer.append("Unbind Request"); 123 buffer.append(EOL); 124 } 125} 126