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.value.AuthorizationData;
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.KerberosPrincipalModifier;
29  import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
30  import org.apache.directory.server.kerberos.shared.messages.value.PrincipalName;
31  import org.apache.directory.server.kerberos.shared.messages.value.TransitedEncoding;
32  import org.apache.directory.server.kerberos.shared.messages.value.flags.KerberosFlag;
33  import org.apache.directory.server.kerberos.shared.messages.value.flags.TicketFlags;
34  
35  
36  /**
37   * Encrypted part of Tickets.
38   * 
39   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
40   * @version $Rev: 591019 $, $Date: 2007-11-01 15:16:34 +0100 (Do, 01 Nov 2007) $
41   */
42  public class EncTicketPartModifier
43  {
44      private TicketFlags flags = new TicketFlags();
45      private EncryptionKey sessionKey;
46      private KerberosPrincipalModifier modifier = new KerberosPrincipalModifier();
47      private KerberosPrincipal clientPrincipal;
48      private TransitedEncoding transitedEncoding;
49      private KerberosTime authTime;
50      private KerberosTime startTime; //optional
51      private KerberosTime endTime;
52      private KerberosTime renewTill; //optional
53      private HostAddresses clientAddresses; //optional
54      private AuthorizationData authorizationData; //optional
55  
56  
57      /**
58       * Returns the {@link EncTicketPart}.
59       *
60       * @return The {@link EncTicketPart}.
61       */
62      public EncTicketPart getEncTicketPart()
63      {
64          if ( clientPrincipal == null )
65          {
66              clientPrincipal = modifier.getKerberosPrincipal();
67          }
68  
69          return new EncTicketPart( flags, sessionKey, clientPrincipal, transitedEncoding, authTime, startTime, endTime,
70              renewTill, clientAddresses, authorizationData );
71      }
72  
73  
74      /**
75       * Sets the client {@link PrincipalName}.
76       *
77       * @param name
78       */
79      public void setClientName( PrincipalName name )
80      {
81          modifier.setPrincipalName( name );
82      }
83  
84  
85      /**
86       * Sets the client realm.
87       *
88       * @param realm
89       */
90      public void setClientRealm( String realm )
91      {
92          modifier.setRealm( realm );
93      }
94  
95  
96      /**
97       * Sets the client {@link KerberosPrincipal}.
98       *
99       * @param clientPrincipal
100      */
101     public void setClientPrincipal( KerberosPrincipal clientPrincipal )
102     {
103         this.clientPrincipal = clientPrincipal;
104     }
105 
106 
107     /**
108      * Sets the {@link AuthorizationData}.
109      *
110      * @param data
111      */
112     public void setAuthorizationData( AuthorizationData data )
113     {
114         authorizationData = data;
115     }
116 
117 
118     /**
119      * Sets the auth {@link KerberosTime}.
120      *
121      * @param authtime
122      */
123     public void setAuthTime( KerberosTime authtime )
124     {
125         authTime = authtime;
126     }
127 
128 
129     /**
130      * Sets the client {@link HostAddresses}.
131      *
132      * @param addresses
133      */
134     public void setClientAddresses( HostAddresses addresses )
135     {
136         clientAddresses = addresses;
137     }
138 
139 
140     /**
141      * Sets the end {@link KerberosTime}.
142      *
143      * @param time
144      */
145     public void setEndTime( KerberosTime time )
146     {
147         endTime = time;
148     }
149 
150 
151     /**
152      * Sets the {@link TicketFlags}.
153      *
154      * @param flags
155      */
156     public void setFlags( TicketFlags flags )
157     {
158         this.flags = flags;
159     }
160 
161 
162     /**
163      * Sets the flag at the given index.
164      *
165      * @param flag
166      */
167     public void setFlag( int flag )
168     {
169         flags.setFlag( flag );
170     }
171 
172 
173     /**
174      * Sets the flag at the given index.
175      *
176      * @param flag
177      */
178     public void setFlag( KerberosFlag flag )
179     {
180         flags.setFlag( flag );
181     }
182 
183 
184     /**
185      * Clears the flag at the given index.
186      *
187      * @param flag
188      */
189     public void clearFlag( int flag )
190     {
191         flags.clearFlag( flag );
192     }
193 
194 
195     /**
196      * Clears the flag at the given index.
197      *
198      * @param flag
199      */
200     public void clearFlag( KerberosFlag flag )
201     {
202         flags.clearFlag( flag );
203     }
204 
205 
206     /**
207      * Sets the renew till {@link KerberosTime}.
208      *
209      * @param till
210      */
211     public void setRenewTill( KerberosTime till )
212     {
213         renewTill = till;
214     }
215 
216 
217     /**
218      * Sets the sesson {@link EncryptionKey}.
219      *
220      * @param key
221      */
222     public void setSessionKey( EncryptionKey key )
223     {
224         sessionKey = key;
225     }
226 
227 
228     /**
229      * Sets the start {@link KerberosTime}.
230      *
231      * @param time
232      */
233     public void setStartTime( KerberosTime time )
234     {
235         startTime = time;
236     }
237 
238 
239     /**
240      * Sets the {@link TransitedEncoding}.
241      *
242      * @param encoding
243      */
244     public void setTransitedEncoding( TransitedEncoding encoding )
245     {
246         transitedEncoding = encoding;
247     }
248 }