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 java.util.Set;
24  
25  import javax.security.auth.kerberos.KerberosPrincipal;
26  
27  import org.apache.directory.server.kerberos.shared.KerberosMessageType;
28  import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
29  import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
30  import org.apache.directory.server.kerberos.shared.messages.value.EncryptedData;
31  import org.apache.directory.server.kerberos.shared.messages.value.HostAddresses;
32  import org.apache.directory.server.kerberos.shared.messages.value.KdcOptions;
33  import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
34  import org.apache.directory.server.kerberos.shared.messages.value.PaData;
35  import org.apache.directory.server.kerberos.shared.messages.value.RequestBody;
36  
37  
38  /**
39   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
40   * @version $Rev: 590715 $, $Date: 2007-10-31 16:23:32 +0100 (Mi, 31 Okt 2007) $
41   */
42  public class KdcRequest extends KerberosMessage
43  {
44      private PaData[] preAuthData; //optional
45      private RequestBody requestBody;
46      private byte[] bodyBytes;
47  
48  
49      /**
50       * Creates a new instance of KdcRequest.
51       *
52       * @param pvno
53       * @param messageType
54       * @param preAuthData
55       * @param requestBody
56       */
57      public KdcRequest( int pvno, KerberosMessageType messageType, PaData[] preAuthData, RequestBody requestBody )
58      {
59          super( pvno, messageType );
60          this.preAuthData = preAuthData;
61          this.requestBody = requestBody;
62      }
63  
64  
65      /**
66       * Creates a new instance of KdcRequest.
67       *
68       * @param pvno
69       * @param messageType
70       * @param preAuthData
71       * @param requestBody
72       * @param bodyBytes
73       */
74      public KdcRequest( int pvno, KerberosMessageType messageType, PaData[] preAuthData, RequestBody requestBody,
75          byte[] bodyBytes )
76      {
77          this( pvno, messageType, preAuthData, requestBody );
78          this.bodyBytes = bodyBytes;
79      }
80  
81  
82      /**
83       * Returns an array of {@link PaData}s.
84       *
85       * @return The array of {@link PaData}s.
86       */
87      public PaData[] getPreAuthData()
88      {
89          return preAuthData;
90      }
91  
92  
93      /**
94       * Returns the request body.
95       * 
96       * @return The request body.
97       */
98      public RequestBody getRequestBody()
99      {
100         return requestBody;
101     }
102 
103 
104     /**
105      * Returns the bytes of the body.  This is used for verifying checksums in
106      * the Ticket-Granting Service (TGS).
107      *
108      * @return The bytes of the body.
109      */
110     public byte[] getBodyBytes()
111     {
112         return bodyBytes;
113     }
114 
115 
116     // RequestBody delegate methods
117 
118     /**
119      * Returns additional {@link Ticket}s.
120      *
121      * @return The {@link Ticket}s.
122      */
123     public Ticket[] getAdditionalTickets()
124     {
125         return requestBody.getAdditionalTickets();
126     }
127 
128 
129     /**
130      * Returns the {@link HostAddresses}.
131      *
132      * @return The {@link HostAddresses}.
133      */
134     public HostAddresses getAddresses()
135     {
136         return requestBody.getAddresses();
137     }
138 
139 
140     /**
141      * Returns the client {@link KerberosPrincipal}.
142      *
143      * @return The client {@link KerberosPrincipal}.
144      */
145     public KerberosPrincipal getClientPrincipal()
146     {
147         return requestBody.getClientPrincipal();
148     }
149 
150 
151     /**
152      * Returns the realm of the server principal.
153      *
154      * @return The realm.
155      */
156     public String getRealm()
157     {
158         return requestBody.getServerPrincipal().getRealm();
159     }
160 
161 
162     /**
163      * Returns the {@link EncryptedData}.
164      *
165      * @return The {@link EncryptedData}.
166      */
167     public EncryptedData getEncAuthorizationData()
168     {
169         return requestBody.getEncAuthorizationData();
170     }
171 
172 
173     /**
174      * Returns an array of requested {@link EncryptionType}s.
175      *
176      * @return The array of {@link EncryptionType}s.
177      */
178     public Set<EncryptionType> getEType()
179     {
180         return requestBody.getEType();
181     }
182 
183 
184     /**
185      * Returns the from {@link KerberosTime}.
186      *
187      * @return The from {@link KerberosTime}.
188      */
189     public KerberosTime getFrom()
190     {
191         return requestBody.getFrom();
192     }
193 
194 
195     /**
196      * Returns the {@link KdcOptions}.
197      *
198      * @return The {@link KdcOptions}.
199      */
200     public KdcOptions getKdcOptions()
201     {
202         return requestBody.getKdcOptions();
203     }
204 
205 
206     /**
207      * Returns the nonce.
208      *
209      * @return The nonce.
210      */
211     public int getNonce()
212     {
213         return requestBody.getNonce();
214     }
215 
216 
217     /**
218      * Returns the "R" {@link KerberosTime}.
219      *
220      * @return The "R" {@link KerberosTime}.
221      */
222     public KerberosTime getRtime()
223     {
224         return requestBody.getRtime();
225     }
226 
227 
228     /**
229      * Returns the server {@link KerberosPrincipal}.
230      *
231      * @return The server {@link KerberosPrincipal}.
232      */
233     public KerberosPrincipal getServerPrincipal()
234     {
235         return requestBody.getServerPrincipal();
236     }
237 
238 
239     /**
240      * Returns the till {@link KerberosTime}.
241      *
242      * @return The till {@link KerberosTime}.
243      */
244     public KerberosTime getTill()
245     {
246         return requestBody.getTill();
247     }
248 
249 
250     // RequestBody KdcOptions delegate accesors
251 
252     /**
253      * Returns the option at the specified index.
254      *
255      * @param option
256      * @return The option.
257      */
258     public boolean getOption( int option )
259     {
260         return requestBody.getKdcOptions().get( option );
261     }
262 
263 
264     /**
265      * Sets the option at the specified index.
266      *
267      * @param option
268      */
269     public void setOption( int option )
270     {
271         requestBody.getKdcOptions().set( option );
272     }
273 
274 
275     /**
276      * Clears the option at the specified index.
277      *
278      * @param option
279      */
280     public void clearOption( int option )
281     {
282         requestBody.getKdcOptions().clear( option );
283     }
284 }