001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.server.kerberos.shared.messages.components;
021
022
023 import javax.security.auth.kerberos.KerberosPrincipal;
024
025 import org.apache.directory.server.kerberos.shared.messages.value.AuthorizationData;
026 import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
027 import org.apache.directory.server.kerberos.shared.messages.value.HostAddresses;
028 import org.apache.directory.server.kerberos.shared.messages.value.KerberosPrincipalModifier;
029 import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
030 import org.apache.directory.server.kerberos.shared.messages.value.PrincipalName;
031 import org.apache.directory.server.kerberos.shared.messages.value.TransitedEncoding;
032 import org.apache.directory.server.kerberos.shared.messages.value.flags.KerberosFlag;
033 import org.apache.directory.server.kerberos.shared.messages.value.flags.TicketFlags;
034
035
036 /**
037 * Encrypted part of Tickets.
038 *
039 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
040 * @version $Rev: 591019 $, $Date: 2007-11-01 16:16:34 +0200 (Thu, 01 Nov 2007) $
041 */
042 public class EncTicketPartModifier
043 {
044 private TicketFlags flags = new TicketFlags();
045 private EncryptionKey sessionKey;
046 private KerberosPrincipalModifier modifier = new KerberosPrincipalModifier();
047 private KerberosPrincipal clientPrincipal;
048 private TransitedEncoding transitedEncoding;
049 private KerberosTime authTime;
050 private KerberosTime startTime; //optional
051 private KerberosTime endTime;
052 private KerberosTime renewTill; //optional
053 private HostAddresses clientAddresses; //optional
054 private AuthorizationData authorizationData; //optional
055
056
057 /**
058 * Returns the {@link EncTicketPart}.
059 *
060 * @return The {@link EncTicketPart}.
061 */
062 public EncTicketPart getEncTicketPart()
063 {
064 if ( clientPrincipal == null )
065 {
066 clientPrincipal = modifier.getKerberosPrincipal();
067 }
068
069 return new EncTicketPart( flags, sessionKey, clientPrincipal, transitedEncoding, authTime, startTime, endTime,
070 renewTill, clientAddresses, authorizationData );
071 }
072
073
074 /**
075 * Sets the client {@link PrincipalName}.
076 *
077 * @param name
078 */
079 public void setClientName( PrincipalName name )
080 {
081 modifier.setPrincipalName( name );
082 }
083
084
085 /**
086 * Sets the client realm.
087 *
088 * @param realm
089 */
090 public void setClientRealm( String realm )
091 {
092 modifier.setRealm( realm );
093 }
094
095
096 /**
097 * Sets the client {@link KerberosPrincipal}.
098 *
099 * @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 }