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 */ 020package org.apache.directory.api.ldap.model.message; 021 022 023import org.apache.directory.api.ldap.model.name.Dn; 024 025 026/** 027 * Bind protocol operation request which authenticates and begins a client 028 * session. Does not yet contain interfaces for SASL authentication mechanisms. 029 * 030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 031 */ 032public interface BindRequest extends SingleReplyRequest, AbandonableRequest 033{ 034 /** 035 * Checks to see if the authentication mechanism is simple and not SASL 036 * based. 037 * 038 * @return true if the mechanism is simple false if it is SASL based. 039 */ 040 boolean isSimple(); 041 042 043 /** 044 * Checks to see if the authentication mechanism is simple and not SASL 045 * based. 046 * 047 * @return true if the mechanism is simple false if it is SASL based. 048 */ 049 boolean getSimple(); 050 051 052 /** 053 * Sets the authentication mechanism to simple or to SASL based 054 * authentication. 055 * 056 * @param isSimple true if authentication is simple, false otherwise. 057 * @return The BindRequest instance 058 */ 059 BindRequest setSimple( boolean isSimple ); 060 061 062 /** 063 * Gets the simple credentials associated with a simple authentication 064 * attempt or null if this request uses SASL authentication mechanisms. 065 * 066 * @return null if the mechanism is SASL, or the credentials if it is simple. 067 */ 068 byte[] getCredentials(); 069 070 071 /** 072 * Sets the simple credentials associated with a simple authentication 073 * attempt. Ignored if this request uses SASL authentication mechanisms. 074 * 075 * @param credentials the credentials if authentication is simple 076 * @return The BindRequest instance 077 */ 078 BindRequest setCredentials( String credentials ); 079 080 081 /** 082 * Sets the simple credentials associated with a simple authentication 083 * attempt. Ignored if this request uses SASL authentication mechanisms. 084 * 085 * @param credentials the credentials if authentication is simple 086 * @return The BindRequest instance 087 */ 088 BindRequest setCredentials( byte[] credentials ); 089 090 091 /** 092 * Gets the name of the subject in this authentication 093 * request. This field may take on a null value (a zero length string) for 094 * the purposes of anonymous binds, when authentication has been performed 095 * at a lower layer, or when using SASL credentials with a mechanism that 096 * includes the name in the credentials. 097 * 098 * @return the name of the authenticating user. 099 */ 100 String getName(); 101 102 103 /** 104 * Sets the name of the subject in this authentication 105 * request. This field may take on a null value (or a zero length string) 106 * for the purposes of anonymous binds, when authentication has been 107 * performed at a lower layer, or when using SASL credentials with a 108 * mechanism that includes the name in the credentials. 109 * 110 * @param name the name of the authenticating user - leave null for anonymous user. 111 * @return The BindRequest instance 112 */ 113 BindRequest setName( String name ); 114 115 116 /** 117 * Gets the DN of the subject in this authentication 118 * request. This field may take on a null value (a zero length string) for 119 * the purposes of anonymous binds, when authentication has been performed 120 * at a lower layer, or when using SASL credentials with a mechanism that 121 * includes the DN in the credentials. 122 * 123 * @return the DN of the authenticating user. 124 */ 125 Dn getDn(); 126 127 128 /** 129 * Sets the DN of the subject in this authentication 130 * request. This field may take on a null value (or a zero length string) 131 * for the purposes of anonymous binds, when authentication has been 132 * performed at a lower layer, or when using SASL credentials with a 133 * mechanism that includes the DN in the credentials. 134 * 135 * @param name the DN of the authenticating user - leave null for anonymous user. 136 * @return The BindRequest instance 137 */ 138 BindRequest setDn( Dn name ); 139 140 141 /** 142 * Checks to see if the Ldap v3 protocol is used. Normally this would 143 * extract a version number from the bind request sent by the client 144 * indicating the version of the protocol to be used in this protocol 145 * session. The integer is either a 2 or a 3 at the moment. We thought it 146 * was better to just check if the protocol used is 3 or not rather than use 147 * an type-safe enumeration type for a binary value. If an LDAPv4 comes out 148 * then we shall convert the return type to a type safe enumeration. 149 * 150 * @return true if client using version 3 false if it is version 2. 151 */ 152 boolean isVersion3(); 153 154 155 /** 156 * Gets whether or not the Ldap v3 protocol is used. Normally this would 157 * extract a version number from the bind request sent by the client 158 * indicating the version of the protocol to be used in this protocol 159 * session. The integer is either a 2 or a 3 at the moment. We thought it 160 * was better to just check if the protocol used is 3 or not rather than use 161 * an type-safe enumeration type for a binary value. If an LDAPv4 comes out 162 * then we shall convert the return type to a type safe enumeration. 163 * 164 * @return true if client using version 3 false if it is version 2. 165 */ 166 boolean getVersion3(); 167 168 169 /** 170 * Sets whether or not the LDAP v3 or v2 protocol is used. Normally this 171 * would extract a version number from the bind request sent by the client 172 * indicating the version of the protocol to be used in this protocol 173 * session. The integer is either a 2 or a 3 at the moment. We thought it 174 * was better to just check if the protocol used is 3 or not rather than use 175 * an type-safe enumeration type for a binary value. If an LDAPv4 comes out 176 * then we shall convert the return type to a type safe enumeration. 177 * 178 * @param isVersion3 if true the client will be exhibiting version 3 bind behavior, 179 * If false is used version 2 behavior will be exhibited. 180 * @return The BindRequest instance 181 */ 182 BindRequest setVersion3( boolean isVersion3 ); 183 184 185 /** 186 * Gets the SASL mechanism String associated with this BindRequest if the 187 * bind operation is using SASL. 188 * 189 * @return the SASL mechanism or null if the bind operation is simple 190 */ 191 String getSaslMechanism(); 192 193 194 /** 195 * Sets the SASL mechanism String associated with this BindRequest if the 196 * bind operation is using SASL. 197 * 198 * @param saslMechanism the SASL mechanism 199 * @return The BindRequest instance 200 */ 201 BindRequest setSaslMechanism( String saslMechanism ); 202 203 204 /** 205 * {@inheritDoc} 206 */ 207 @Override 208 BindRequest setMessageId( int messageId ); 209 210 211 /** 212 * {@inheritDoc} 213 */ 214 @Override 215 BindRequest addControl( Control control ); 216 217 218 /** 219 * {@inheritDoc} 220 */ 221 @Override 222 BindRequest addAllControls( Control[] controls ); 223 224 225 /** 226 * {@inheritDoc} 227 */ 228 @Override 229 BindRequest removeControl( Control control ); 230}