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 * http://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.extras.extended.startTls;
21
22
23 import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
24 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
25
26
27 /**
28 * The RFC 4511 StartTLS response :
29 *
30 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
31 */
32 public class StartTlsResponseImpl extends ExtendedResponseImpl implements StartTlsResponse
33 {
34 /**
35 * Create a new instance for the StartTls response
36 * @param messageId The Message ID
37 * @param rcode The result code
38 * @param diagnosticMessage The diagnostic message
39 */
40 public StartTlsResponseImpl( int messageId, ResultCodeEnum rcode, String diagnosticMessage )
41 {
42 super( messageId, EXTENSION_OID );
43
44 super.getLdapResult().setMatchedDn( null );
45 super.getLdapResult().setResultCode( rcode );
46 super.getLdapResult().setDiagnosticMessage( diagnosticMessage );
47 }
48
49
50 /**
51 * Create a new instance for the StartTls response
52 * @param messageId The Message ID
53 * @param rcode The result code
54 */
55 public StartTlsResponseImpl( int messageId, ResultCodeEnum rcode )
56 {
57 super( messageId, EXTENSION_OID );
58
59 super.getLdapResult().setMatchedDn( null );
60 super.getLdapResult().setResultCode( rcode );
61 }
62
63
64 /**
65 * Instantiates a new StartTls response.
66 *
67 * @param messageId the message id
68 */
69 public StartTlsResponseImpl( int messageId )
70 {
71 super( messageId, EXTENSION_OID );
72 super.getLdapResult().setMatchedDn( null );
73 super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
74 }
75
76
77 /**
78 * Instantiates a new StartTls response.
79 */
80 public StartTlsResponseImpl()
81 {
82 super( EXTENSION_OID );
83 super.getLdapResult().setMatchedDn( null );
84 super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
85 }
86
87
88 /**
89 * @see Object#toString()
90 */
91 @Override
92 public String toString()
93 {
94 StringBuilder sb = new StringBuilder();
95
96 sb.append( "StartTlsResponse :" );
97 sb.append( getLdapResult() );
98
99 return sb.toString();
100 }
101 }