001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.shared.ldap.message;
021
022 import org.apache.directory.shared.ldap.name.LdapDN;
023
024
025 /**
026 * Bind protocol operation request which authenticates and begins a client
027 * session. Does not yet contain interfaces for SASL authentication mechanisms.
028 *
029 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
030 * @version $Rev: 764131 $
031 */
032 public interface InternalBindRequest extends SingleReplyRequest, InternalAbandonableRequest
033 {
034 /** Bind request message type enumeration value */
035 MessageTypeEnum TYPE = MessageTypeEnum.BIND_REQUEST;
036
037 /** Bind response message type enumeration value */
038 MessageTypeEnum RESP_TYPE = InternalBindResponse.TYPE;
039
040
041 /**
042 * Checks to see if the authentication mechanism is simple and not SASL
043 * based.
044 *
045 * @return true if the mechanism is simple false if it is SASL based.
046 */
047 boolean isSimple();
048
049
050 /**
051 * Checks to see if the authentication mechanism is simple and not SASL
052 * based.
053 *
054 * @return true if the mechanism is simple false if it is SASL based.
055 */
056 boolean getSimple();
057
058
059 /**
060 * Sets the authentication mechanism to simple or to SASL based
061 * authentication.
062 *
063 * @param isSimple
064 * true if authentication is simple, false otherwise.
065 */
066 void setSimple( boolean isSimple );
067
068
069 /**
070 * Gets the simple credentials associated with a simple authentication
071 * attempt or null if this request uses SASL authentication mechanisms.
072 *
073 * @return null if the mechanism is SASL or the credentials if it is simple.
074 */
075 byte[] getCredentials();
076
077
078 /**
079 * Sets the simple credentials associated with a simple authentication
080 * attempt ignored if this request uses SASL authentication mechanisms.
081 *
082 * @param credentials
083 * the credentials if authentication is simple, null otherwise
084 */
085 void setCredentials( byte[] credentials );
086
087
088 /**
089 * Gets the distinguished name of the subject in this authentication
090 * request. This field may take on a null value (a zero length string) for
091 * the purposes of anonymous binds, when authentication has been performed
092 * at a lower layer, or when using SASL credentials with a mechanism that
093 * includes the LDAPDN in the credentials.
094 *
095 * @return the DN of the authenticating user.
096 */
097 LdapDN getName();
098
099
100 /**
101 * Sets the distinguished name of the subject in this authentication
102 * request. This field may take on a null value (or a zero length string)
103 * for the purposes of anonymous binds, when authentication has been
104 * performed at a lower layer, or when using SASL credentials with a
105 * mechanism that includes the LDAPDN in the credentials.
106 *
107 * @param name
108 * the DN of the authenticating user - leave null for annonymous
109 * user.
110 */
111 void setName( LdapDN name );
112
113
114 /**
115 * Checks to see if the Ldap v3 protocol is used. Normally this would
116 * extract a version number from the bind request sent by the client
117 * indicating the version of the protocol to be used in this protocol
118 * session. The integer is either a 2 or a 3 at the moment. We thought it
119 * was better to just check if the protocol used is 3 or not rather than use
120 * an type-safe enumeration type for a binary value. If an LDAPv4 comes out
121 * then we shall convert the return type to a type safe enumeration.
122 *
123 * @return true if client using version 3 false if it is version 2.
124 */
125 boolean isVersion3();
126
127
128 /**
129 * Gets whether or not the Ldap v3 protocol is used. Normally this would
130 * extract a version number from the bind request sent by the client
131 * indicating the version of the protocol to be used in this protocol
132 * session. The integer is either a 2 or a 3 at the moment. We thought it
133 * was better to just check if the protocol used is 3 or not rather than use
134 * an type-safe enumeration type for a binary value. If an LDAPv4 comes out
135 * then we shall convert the return type to a type safe enumeration.
136 *
137 * @return true if client using version 3 false if it is version 2.
138 */
139 boolean getVersion3();
140
141
142 /**
143 * Sets whether or not the LDAP v3 or v2 protocol is used. Normally this
144 * would extract a version number from the bind request sent by the client
145 * indicating the version of the protocol to be used in this protocol
146 * session. The integer is either a 2 or a 3 at the moment. We thought it
147 * was better to just check if the protocol used is 3 or not rather than use
148 * an type-safe enumeration type for a binary value. If an LDAPv4 comes out
149 * then we shall convert the return type to a type safe enumeration.
150 *
151 * @param isVersion3
152 * if true the client will be exhibiting version 3 bind behavoir,
153 * if false is used version 2 behavoir will be exhibited.
154 */
155 void setVersion3( boolean isVersion3 );
156
157
158 /**
159 * Gets the SASL mechanism String associated with this BindRequest if the
160 * bind operation is using SASL.
161 *
162 * @return the SASL mechanism or null if the bind op is simple
163 */
164 String getSaslMechanism();
165
166
167 /**
168 * Sets the SASL mechanism String associated with this BindRequest if the
169 * bind operation is using SASL.
170 *
171 * @param saslMechanism
172 * the SASL mechanism
173 */
174 void setSaslMechanism( String saslMechanism );
175 }