1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.directory.ldap.client.api;
22
23
24 import java.util.ArrayList;
25 import java.util.Arrays;
26 import java.util.List;
27
28 import org.apache.directory.api.ldap.model.constants.SaslQoP;
29 import org.apache.directory.api.ldap.model.constants.SaslSecurityStrength;
30 import org.apache.directory.api.ldap.model.message.Control;
31 import org.apache.directory.api.util.StringConstants;
32 import org.apache.directory.api.util.Strings;
33
34
35
36
37
38
39
40 public abstract class SaslRequest
41 {
42
43 protected String saslMechanism;
44
45
46 protected List<Control> controls = new ArrayList<Control>();
47
48
49 protected String username;
50
51
52 protected byte[] credentials;
53
54
55 protected String realmName;
56
57
58 protected String authorizationId;
59
60
61 protected SaslQoP qualityOfProtection;
62
63
64 protected SaslSecurityStrength securityStrength;
65
66
67 protected boolean mutualAuthentication = false;
68
69
70
71
72
73
74
75
76 protected SaslRequest( String saslMechanism )
77 {
78 this.saslMechanism = saslMechanism;
79 }
80
81
82
83
84
85
86
87 public void addAllControls( Control[] controls )
88 {
89 this.controls.addAll( Arrays.asList( controls ) );
90 }
91
92
93
94
95
96
97
98 public void addControl( Control control )
99 {
100 this.controls.add( control );
101 }
102
103
104
105
106
107
108
109 public String getAuthorizationId()
110 {
111 return authorizationId;
112 }
113
114
115
116
117
118
119
120 public Control[] getControls()
121 {
122 return controls.toArray( new Control[0] );
123 }
124
125
126
127
128
129
130
131 public byte[] getCredentials()
132 {
133 if ( credentials != null )
134 {
135 return credentials;
136 }
137 else
138 {
139 return StringConstants.EMPTY_BYTES;
140 }
141 }
142
143
144
145
146
147
148
149 public SaslQoP getQualityOfProtection()
150 {
151 return qualityOfProtection;
152 }
153
154
155
156
157
158
159
160 public String getRealmName()
161 {
162 return realmName;
163 }
164
165
166
167
168
169
170
171 public String getSaslMechanism()
172 {
173 return saslMechanism;
174 }
175
176
177
178
179
180
181
182 public SaslSecurityStrength getSecurityStrength()
183 {
184 return securityStrength;
185 }
186
187
188
189
190
191
192
193 public String getUsername()
194 {
195 return username;
196 }
197
198
199
200
201
202
203
204 public boolean isMutualAuthentication()
205 {
206 return mutualAuthentication;
207 }
208
209
210
211
212
213
214
215 public void setAuthorizationId( String authorizationId )
216 {
217 this.authorizationId = authorizationId;
218 }
219
220
221
222
223
224
225
226 public void setCredentials( byte[] credentials )
227 {
228 this.credentials = credentials;
229 }
230
231
232
233
234
235
236
237 public void setCredentials( String credentials )
238 {
239 this.credentials = Strings.getBytesUtf8( credentials );
240 }
241
242
243
244
245
246
247
248 public void setMutualAuthentication( boolean mutualAuthentication )
249 {
250 this.mutualAuthentication = mutualAuthentication;
251 }
252
253
254
255
256
257
258
259 public void setQualityOfProtection( SaslQoP qualityOfProtection )
260 {
261 this.qualityOfProtection = qualityOfProtection;
262 }
263
264
265
266
267
268
269
270 protected void setRealmName( String realmName )
271 {
272 this.realmName = realmName;
273 }
274
275
276
277
278
279
280
281 protected void setSaslMechanism( String saslMechanism )
282 {
283 this.saslMechanism = saslMechanism;
284 }
285
286
287
288
289
290
291
292 public void setSecurityStrength( SaslSecurityStrength securityStrength )
293 {
294 this.securityStrength = securityStrength;
295 }
296
297
298
299
300
301
302
303 public void setUsername( String username )
304 {
305 this.username = username;
306 }
307 }