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.value;
21  
22  
23  import java.util.Set;
24  
25  import javax.security.auth.kerberos.KerberosPrincipal;
26  
27  import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
28  import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
29  
30  
31  /**
32   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33   * @version $Rev: 590715 $, $Date: 2007-10-31 16:23:32 +0100 (Mi, 31 Okt 2007) $
34   */
35  public class RequestBodyModifier
36  {
37      private KerberosPrincipalModifier clientModifier = new KerberosPrincipalModifier(); //optional in TgsReq only
38      private KerberosPrincipalModifier serverModifier = new KerberosPrincipalModifier();
39      private KdcOptions kdcOptions;
40      private KerberosTime from; //optional
41      private KerberosTime till;
42      private KerberosTime rtime; //optional
43      private int nonce;
44      private Set<EncryptionType> eType;
45      private HostAddresses addresses; //optional
46      private EncryptedData encAuthorizationData; //optional
47      private Ticket[] additionalTickets; //optional
48  
49  
50      /**
51       * Returns the {@link RequestBody}.
52       *
53       * @return The {@link RequestBody}.
54       */
55      public RequestBody getRequestBody()
56      {
57          KerberosPrincipal clientPrincipal = clientModifier.getKerberosPrincipal();
58          KerberosPrincipal serverPrincipal = serverModifier.getKerberosPrincipal();
59  
60          return new RequestBody( kdcOptions, clientPrincipal, serverPrincipal, from, till, rtime, nonce, eType,
61              addresses, encAuthorizationData, additionalTickets );
62      }
63  
64  
65      /**
66       * Sets the client {@link PrincipalName}.
67       *
68       * @param clientName
69       */
70      public void setClientName( PrincipalName clientName )
71      {
72          clientModifier.setPrincipalName( clientName );
73      }
74  
75  
76      /**
77       * Sets the server {@link PrincipalName}.
78       *
79       * @param serverName
80       */
81      public void setServerName( PrincipalName serverName )
82      {
83          serverModifier.setPrincipalName( serverName );
84      }
85  
86  
87      /**
88       * Sets the realm.
89       *
90       * @param realm
91       */
92      public void setRealm( String realm )
93      {
94          clientModifier.setRealm( realm );
95          serverModifier.setRealm( realm );
96      }
97  
98  
99      /**
100      * Sets additional {@link Ticket}s.
101      *
102      * @param tickets
103      */
104     public void setAdditionalTickets( Ticket[] tickets )
105     {
106         additionalTickets = tickets;
107     }
108 
109 
110     /**
111      * Sets the {@link HostAddresses}.
112      *
113      * @param addresses
114      */
115     public void setAddresses( HostAddresses addresses )
116     {
117         this.addresses = addresses;
118     }
119 
120 
121     /**
122      * Sets the encrypted authorization data.
123      *
124      * @param authorizationData
125      */
126     public void setEncAuthorizationData( EncryptedData authorizationData )
127     {
128         encAuthorizationData = authorizationData;
129     }
130 
131 
132     /**
133      * Sets the requested {@link EncryptionType}s.
134      *
135      * @param type
136      */
137     public void setEType( Set<EncryptionType> type )
138     {
139         eType = type;
140     }
141 
142 
143     /**
144      * Sets the from {@link KerberosTime}.
145      *
146      * @param from
147      */
148     public void setFrom( KerberosTime from )
149     {
150         this.from = from;
151     }
152 
153 
154     /**
155      * Sets the {@link KdcOptions}.
156      *
157      * @param options
158      */
159     public void setKdcOptions( KdcOptions options )
160     {
161         kdcOptions = options;
162     }
163 
164 
165     /**
166      * Sets the nonce.
167      *
168      * @param nonce
169      */
170     public void setNonce( int nonce )
171     {
172         this.nonce = nonce;
173     }
174 
175 
176     /**
177      * Sets the "R" {@link KerberosTime}.
178      *
179      * @param rtime
180      */
181     public void setRtime( KerberosTime rtime )
182     {
183         this.rtime = rtime;
184     }
185 
186 
187     /**
188      * Sets the till {@link KerberosTime}.
189      *
190      * @param till
191      */
192     public void setTill( KerberosTime till )
193     {
194         this.till = till;
195     }
196 }