View Javadoc

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.server.kerberos.shared.messages;
21  
22  
23  import javax.security.auth.kerberos.KerberosPrincipal;
24  
25  import org.apache.directory.server.kerberos.shared.KerberosMessageType;
26  import org.apache.directory.server.kerberos.shared.messages.components.EncKdcRepPart;
27  import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
28  import org.apache.directory.server.kerberos.shared.messages.value.EncryptedData;
29  import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
30  import org.apache.directory.server.kerberos.shared.messages.value.HostAddresses;
31  import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
32  import org.apache.directory.server.kerberos.shared.messages.value.LastRequest;
33  import org.apache.directory.server.kerberos.shared.messages.value.PaData;
34  import org.apache.directory.server.kerberos.shared.messages.value.flags.TicketFlags;
35  
36  
37  /**
38   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
39   * @version $Rev: 591019 $, $Date: 2007-11-01 15:16:34 +0100 (Do, 01 Nov 2007) $
40   */
41  public class KdcReply extends KerberosMessage implements Encodable
42  {
43      private PaData[] paData; //optional
44      private KerberosPrincipal clientPrincipal;
45      private Ticket ticket;
46  
47      private EncKdcRepPart encKDCRepPart = new EncKdcRepPart();
48      private EncryptedData encPart;
49  
50  
51      /**
52       * Creates a new instance of KdcReply.
53       *
54       * @param msgType
55       */
56      public KdcReply( KerberosMessageType msgType )
57      {
58          super( msgType );
59      }
60  
61  
62      /**
63       * Creates a new instance of KdcReply.
64       *
65       * @param paData
66       * @param clientPrincipal
67       * @param ticket
68       * @param encPart
69       * @param msgType
70       */
71      public KdcReply( PaData[] paData, KerberosPrincipal clientPrincipal, Ticket ticket,
72          EncryptedData encPart, KerberosMessageType msgType )
73      {
74          this( msgType );
75          this.paData = paData;
76          this.clientPrincipal = clientPrincipal;
77          this.ticket = ticket;
78          this.encPart = encPart;
79      }
80  
81  
82      /**
83       * Returns the client {@link KerberosPrincipal}.
84       *
85       * @return The client {@link KerberosPrincipal}.
86       */
87      public KerberosPrincipal getClientPrincipal()
88      {
89          return clientPrincipal;
90      }
91  
92  
93      /**
94       * Returns the client realm.
95       *
96       * @return The client realm.
97       */
98      public String getClientRealm()
99      {
100         return clientPrincipal.getRealm();
101     }
102 
103 
104     /**
105      * Returns the {@link EncryptedData}.
106      *
107      * @return The {@link EncryptedData}.
108      */
109     public EncryptedData getEncPart()
110     {
111         return encPart;
112     }
113 
114 
115     /**
116      * Returns an array of {@link PaData}s.
117      *
118      * @return The array of {@link PaData}s.
119      */
120     public PaData[] getPaData()
121     {
122         return paData;
123     }
124 
125 
126     /**
127      * Returns the {@link Ticket}.
128      *
129      * @return The {@link Ticket}.
130      */
131     public Ticket getTicket()
132     {
133         return ticket;
134     }
135 
136 
137     /**
138      * Sets the client {@link KerberosPrincipal}.
139      *
140      * @param clientPrincipal
141      */
142     public void setClientPrincipal( KerberosPrincipal clientPrincipal )
143     {
144         this.clientPrincipal = clientPrincipal;
145     }
146 
147 
148     /**
149      * Sets the {@link EncKdcRepPart}.
150      *
151      * @param repPart
152      */
153     public void setEncKDCRepPart( EncKdcRepPart repPart )
154     {
155         encKDCRepPart = repPart;
156     }
157 
158 
159     /**
160      * Sets the {@link EncryptedData}.
161      *
162      * @param part
163      */
164     public void setEncPart( EncryptedData part )
165     {
166         encPart = part;
167     }
168 
169 
170     /**
171      * Sets the array of {@link PaData}s.
172      *
173      * @param data
174      */
175     public void setPaData( PaData[] data )
176     {
177         paData = data;
178     }
179 
180 
181     /**
182      * Sets the {@link Ticket}.
183      *
184      * @param ticket
185      */
186     public void setTicket( Ticket ticket )
187     {
188         this.ticket = ticket;
189     }
190 
191 
192     // EncKdcRepPart delegate getters
193 
194     /**
195      * Returns the auth {@link KerberosTime}.
196      *
197      * @return The auth {@link KerberosTime}.
198      */
199     public KerberosTime getAuthTime()
200     {
201         return encKDCRepPart.getAuthTime();
202     }
203 
204 
205     /**
206      * Returns the client {@link HostAddresses}.
207      *
208      * @return The client {@link HostAddresses}.
209      */
210     public HostAddresses getClientAddresses()
211     {
212         return encKDCRepPart.getClientAddresses();
213     }
214 
215 
216     /**
217      * Return the end {@link KerberosTime}.
218      *
219      * @return The end {@link KerberosTime}.
220      */
221     public KerberosTime getEndTime()
222     {
223         return encKDCRepPart.getEndTime();
224     }
225 
226 
227     /**
228      * Returns the {@link TicketFlags}.
229      *
230      * @return The {@link TicketFlags}.
231      */
232     public TicketFlags getFlags()
233     {
234         return encKDCRepPart.getFlags();
235     }
236 
237 
238     /**
239      * Returns the {@link EncryptionKey}.
240      *
241      * @return The {@link EncryptionKey}.
242      */
243     public EncryptionKey getKey()
244     {
245         return encKDCRepPart.getKey();
246     }
247 
248 
249     /**
250      * Returns the key expiration {@link KerberosTime}.
251      *
252      * @return The key expiration {@link KerberosTime}.
253      */
254     public KerberosTime getKeyExpiration()
255     {
256         return encKDCRepPart.getKeyExpiration();
257     }
258 
259 
260     /**
261      * Returns the {@link LastRequest}.
262      *
263      * @return The {@link LastRequest}.
264      */
265     public LastRequest getLastRequest()
266     {
267         return encKDCRepPart.getLastRequest();
268     }
269 
270 
271     /**
272      * Returns the nonce.
273      *
274      * @return The nonce.
275      */
276     public int getNonce()
277     {
278         return encKDCRepPart.getNonce();
279     }
280 
281 
282     /**
283      * Returns the renew till {@link KerberosTime}.
284      *
285      * @return The renew till {@link KerberosTime}.
286      */
287     public KerberosTime getRenewTill()
288     {
289         return encKDCRepPart.getRenewTill();
290     }
291 
292 
293     /**
294      * Returns the server {@link KerberosPrincipal}.
295      *
296      * @return The server {@link KerberosPrincipal}.
297      */
298     public KerberosPrincipal getServerPrincipal()
299     {
300         return encKDCRepPart.getServerPrincipal();
301     }
302 
303 
304     /**
305      * Return the server realm.
306      *
307      * @return The server realm.
308      */
309     public String getServerRealm()
310     {
311         return encKDCRepPart.getServerRealm();
312     }
313 
314 
315     /**
316      * Returns the start {@link KerberosTime}.
317      *
318      * @return The start {@link KerberosTime}.
319      */
320     public KerberosTime getStartTime()
321     {
322         return encKDCRepPart.getStartTime();
323     }
324 
325 
326     // EncKdcRepPart delegate setters
327 
328     /**
329      * Sets the auth {@link KerberosTime}.
330      *
331      * @param time
332      */
333     public void setAuthTime( KerberosTime time )
334     {
335         encKDCRepPart.setAuthTime( time );
336     }
337 
338 
339     /**
340      * Sets the client {@link HostAddresses}.
341      *
342      * @param addresses
343      */
344     public void setClientAddresses( HostAddresses addresses )
345     {
346         encKDCRepPart.setClientAddresses( addresses );
347     }
348 
349 
350     /**
351      * Sets the end {@link KerberosTime}.
352      *
353      * @param time
354      */
355     public void setEndTime( KerberosTime time )
356     {
357         encKDCRepPart.setEndTime( time );
358     }
359 
360 
361     /**
362      * Sets the {@link TicketFlags}.
363      *
364      * @param flags
365      */
366     public void setFlags( TicketFlags flags )
367     {
368         encKDCRepPart.setFlags( flags );
369     }
370 
371 
372     /**
373      * Sets the {@link EncryptionKey}.
374      *
375      * @param key
376      */
377     public void setKey( EncryptionKey key )
378     {
379         encKDCRepPart.setKey( key );
380     }
381 
382 
383     /**
384      * Sets the key expiration {@link KerberosTime}.
385      *
386      * @param expiration
387      */
388     public void setKeyExpiration( KerberosTime expiration )
389     {
390         encKDCRepPart.setKeyExpiration( expiration );
391     }
392 
393 
394     /**
395      * Sets the {@link LastRequest}.
396      *
397      * @param request
398      */
399     public void setLastRequest( LastRequest request )
400     {
401         encKDCRepPart.setLastRequest( request );
402     }
403 
404 
405     /**
406      * Sets the nonce.
407      *
408      * @param nonce
409      */
410     public void setNonce( int nonce )
411     {
412         encKDCRepPart.setNonce( nonce );
413     }
414 
415 
416     /**
417      * Sets the renew till {@link KerberosTime}.
418      *
419      * @param till
420      */
421     public void setRenewTill( KerberosTime till )
422     {
423         encKDCRepPart.setRenewTill( till );
424     }
425 
426 
427     /**
428      * Sets the server {@link KerberosPrincipal}.
429      *
430      * @param principal
431      */
432     public void setServerPrincipal( KerberosPrincipal principal )
433     {
434         encKDCRepPart.setServerPrincipal( principal );
435     }
436 
437 
438     /**
439      * Sets the start {@link KerberosTime}.
440      *
441      * @param time
442      */
443     public void setStartTime( KerberosTime time )
444     {
445         encKDCRepPart.setStartTime( time );
446     }
447 }