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.components;
21  
22  
23  import javax.security.auth.kerberos.KerberosPrincipal;
24  
25  import org.apache.directory.server.kerberos.shared.messages.Encodable;
26  import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
27  import org.apache.directory.server.kerberos.shared.messages.value.HostAddresses;
28  import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
29  import org.apache.directory.server.kerberos.shared.messages.value.LastRequest;
30  import org.apache.directory.server.kerberos.shared.messages.value.flags.TicketFlags;
31  
32  
33  /**
34   * Base class for encrypted parts of KDC responses.
35   * 
36   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
37   * @version $Rev: 591019 $, $Date: 2007-11-01 15:16:34 +0100 (Do, 01 Nov 2007) $
38   */
39  public class EncKdcRepPart implements Encodable
40  {
41      private EncryptionKey key;
42      private LastRequest lastRequest;
43      private int nonce;
44      private KerberosTime keyExpiration; //optional
45      private TicketFlags flags = new TicketFlags();
46      private KerberosTime authTime;
47      private KerberosTime startTime; //optional
48      private KerberosTime endTime;
49      private KerberosTime renewTill; //optional
50      private KerberosPrincipal serverPrincipal;
51      private HostAddresses clientAddresses; //optional
52      private MessageComponentType componentType;
53  
54  
55      /**
56       * Creates a new instance of EncKdcRepPart.
57       */
58      public EncKdcRepPart()
59      {
60          // built up by setter during reply generation
61      }
62  
63  
64      /**
65       * Creates a new instance of EncKdcRepPart.
66       *
67       * @param key
68       * @param lastReq
69       * @param nonce
70       * @param keyExpiration
71       * @param flags
72       * @param authtime
73       * @param starttime
74       * @param endtime
75       * @param renewTill
76       * @param serverPrincipal
77       * @param caddr
78       * @param componentType
79       */
80      public EncKdcRepPart( EncryptionKey key, LastRequest lastReq, int nonce, KerberosTime keyExpiration,
81          TicketFlags flags, KerberosTime authtime, KerberosTime starttime, KerberosTime endtime, KerberosTime renewTill,
82          KerberosPrincipal serverPrincipal, HostAddresses caddr, MessageComponentType componentType )
83      {
84          this.key = key;
85          this.lastRequest = lastReq;
86          this.nonce = nonce;
87          this.keyExpiration = keyExpiration;
88          this.flags = flags;
89          this.authTime = authtime;
90          this.startTime = starttime;
91          this.endTime = endtime;
92          this.renewTill = renewTill;
93          this.serverPrincipal = serverPrincipal;
94          this.clientAddresses = caddr;
95          this.componentType = componentType;
96      }
97  
98  
99      /**
100      * Returns the auth {@link KerberosTime}.
101      *
102      * @return The auth {@link KerberosTime}.
103      */
104     public KerberosTime getAuthTime()
105     {
106         return authTime;
107     }
108 
109 
110     /**
111      * Returns the client {@link HostAddresses}.
112      *
113      * @return The client {@link HostAddresses}.
114      */
115     public HostAddresses getClientAddresses()
116     {
117         return clientAddresses;
118     }
119 
120 
121     /**
122      * Returns the end {@link KerberosTime}.
123      *
124      * @return The end {@link KerberosTime}.
125      */
126     public KerberosTime getEndTime()
127     {
128         return endTime;
129     }
130 
131 
132     /**
133      * Returns the {@link TicketFlags}.
134      *
135      * @return The {@link TicketFlags}.
136      */
137     public TicketFlags getFlags()
138     {
139         return flags;
140     }
141 
142 
143     /**
144      * Returns the {@link EncryptionKey}.
145      *
146      * @return The {@link EncryptionKey}.
147      */
148     public EncryptionKey getKey()
149     {
150         return key;
151     }
152 
153 
154     /**
155      * Returns the key expiration {@link KerberosTime}.
156      *
157      * @return The key expiration {@link KerberosTime}.
158      */
159     public KerberosTime getKeyExpiration()
160     {
161         return keyExpiration;
162     }
163 
164 
165     /**
166      * Returns the {@link LastRequest}.
167      *
168      * @return The {@link LastRequest}.
169      */
170     public LastRequest getLastRequest()
171     {
172         return lastRequest;
173     }
174 
175 
176     /**
177      * Returns the nonce.
178      *
179      * @return The nonce.
180      */
181     public int getNonce()
182     {
183         return nonce;
184     }
185 
186 
187     /**
188      * Returns the renew till {@link KerberosTime}.
189      *
190      * @return The renew till {@link KerberosTime}.
191      */
192     public KerberosTime getRenewTill()
193     {
194         return renewTill;
195     }
196 
197 
198     /**
199      * Returns the server {@link KerberosPrincipal}.
200      *
201      * @return The server {@link KerberosPrincipal}.
202      */
203     public KerberosPrincipal getServerPrincipal()
204     {
205         return serverPrincipal;
206     }
207 
208 
209     /**
210      * Returns the server realm.
211      *
212      * @return The server realm.
213      */
214     public String getServerRealm()
215     {
216         return serverPrincipal.getRealm();
217     }
218 
219 
220     /**
221      * Returns the start {@link KerberosTime}.
222      *
223      * @return The start {@link KerberosTime}.
224      */
225     public KerberosTime getStartTime()
226     {
227         return startTime;
228     }
229 
230 
231     /**
232      * Returns the {@link MessageComponentType}.
233      *
234      * @return The {@link MessageComponentType}.
235      */
236     public MessageComponentType getComponentType()
237     {
238         return componentType;
239     }
240 
241 
242     /**
243      * Sets the auth {@link KerberosTime}.
244      *
245      * @param time
246      */
247     public void setAuthTime( KerberosTime time )
248     {
249         authTime = time;
250     }
251 
252 
253     /**
254      * Sets the client {@link HostAddresses}.
255      *
256      * @param addresses
257      */
258     public void setClientAddresses( HostAddresses addresses )
259     {
260         clientAddresses = addresses;
261     }
262 
263 
264     /**
265      * Sets the end {@link KerberosTime}.
266      *
267      * @param time
268      */
269     public void setEndTime( KerberosTime time )
270     {
271         endTime = time;
272     }
273 
274 
275     /**
276      * Sets the {@link TicketFlags}.
277      *
278      * @param flags
279      */
280     public void setFlags( TicketFlags flags )
281     {
282         this.flags = flags;
283     }
284 
285 
286     /**
287      * Sets the {@link EncryptionKey}.
288      *
289      * @param key
290      */
291     public void setKey( EncryptionKey key )
292     {
293         this.key = key;
294     }
295 
296 
297     /**
298      * Sets the key expiration {@link KerberosTime}.
299      *
300      * @param expiration
301      */
302     public void setKeyExpiration( KerberosTime expiration )
303     {
304         keyExpiration = expiration;
305     }
306 
307 
308     /**
309      * Sets the {@link LastRequest}.
310      *
311      * @param request
312      */
313     public void setLastRequest( LastRequest request )
314     {
315         lastRequest = request;
316     }
317 
318 
319     /**
320      * Sets the nonce.
321      *
322      * @param nonce
323      */
324     public void setNonce( int nonce )
325     {
326         this.nonce = nonce;
327     }
328 
329 
330     /**
331      * Sets the renew till {@link KerberosTime}.
332      *
333      * @param till
334      */
335     public void setRenewTill( KerberosTime till )
336     {
337         renewTill = till;
338     }
339 
340 
341     /**
342      * Sets the server {@link KerberosPrincipal}.
343      *
344      * @param principal
345      */
346     public void setServerPrincipal( KerberosPrincipal principal )
347     {
348         serverPrincipal = principal;
349     }
350 
351 
352     /**
353      * Sets the start {@link KerberosTime}.
354      *
355      * @param time
356      */
357     public void setStartTime( KerberosTime time )
358     {
359         startTime = time;
360     }
361 }