1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * https://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19 */
20 package org.apache.directory.api.ldap.model.message;
21
22
23 import org.apache.directory.api.i18n.I18n;
24
25
26 /**
27 * Lockable UnbindRequest implementation.
28 *
29 * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
30 */
31 public class UnbindRequestImpl extends AbstractRequest implements UnbindRequest
32 {
33 static final long serialVersionUID = -6217184085100410116L;
34
35
36 /**
37 * Creates an UnbindRequest which takes no parameter other than those in the
38 * outer envelope to disconnect and end a client session on the server
39 * without producing any response.
40 */
41 public UnbindRequestImpl()
42 {
43 super( -1, MessageTypeEnum.UNBIND_REQUEST, false );
44 }
45
46
47 /**
48 * RFC 2251 [Section 4.11]: Abandon, Bind, Unbind, and StartTLS operations
49 * cannot be abandoned.
50 */
51 public void abandon()
52 {
53 throw new UnsupportedOperationException( I18n.err( I18n.ERR_13506_CANNOT_ABANDON_OPERATION ) );
54 }
55
56
57 /**
58 * {@inheritDoc}
59 */
60 @Override
61 public UnbindRequest setMessageId( int messageId )
62 {
63 super.setMessageId( messageId );
64
65 return this;
66 }
67
68
69 /**
70 * {@inheritDoc}
71 */
72 @Override
73 public UnbindRequest addControl( Control control )
74 {
75 return ( UnbindRequest ) super.addControl( control );
76 }
77
78
79 /**
80 * {@inheritDoc}
81 */
82 @Override
83 public UnbindRequest addAllControls( Control[] controls )
84 {
85 return ( UnbindRequest ) super.addAllControls( controls );
86 }
87
88
89 /**
90 * {@inheritDoc}
91 */
92 @Override
93 public UnbindRequest removeControl( Control control )
94 {
95 return ( UnbindRequest ) super.removeControl( control );
96 }
97
98
99 /**
100 * Get a String representation of a UnBindRequest
101 *
102 * @return A UnBindRequest String
103 */
104 @Override
105 public String toString()
106 {
107 StringBuilder sb = new StringBuilder();
108
109 sb.append( " UnBind Request" );
110
111 // The controls
112 sb.append( super.toString() );
113
114 return super.toString( sb.toString() );
115 }
116 }