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.Encodable; 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.KerberosTime; 029 import org.apache.directory.server.kerberos.shared.messages.value.LastRequest; 030 import org.apache.directory.server.kerberos.shared.messages.value.flags.TicketFlags; 031 032 033 /** 034 * Base class for encrypted parts of KDC responses. 035 * 036 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 037 * @version $Rev: 591019 $, $Date: 2007-11-01 15:16:34 +0100 (Thu, 01 Nov 2007) $ 038 */ 039 public class EncKdcRepPart implements Encodable 040 { 041 private EncryptionKey key; 042 private LastRequest lastRequest; 043 private int nonce; 044 private KerberosTime keyExpiration; //optional 045 private TicketFlags flags = new TicketFlags(); 046 private KerberosTime authTime; 047 private KerberosTime startTime; //optional 048 private KerberosTime endTime; 049 private KerberosTime renewTill; //optional 050 private KerberosPrincipal serverPrincipal; 051 private HostAddresses clientAddresses; //optional 052 private MessageComponentType componentType; 053 054 055 /** 056 * Creates a new instance of EncKdcRepPart. 057 */ 058 public EncKdcRepPart() 059 { 060 // built up by setter during reply generation 061 } 062 063 064 /** 065 * Creates a new instance of EncKdcRepPart. 066 * 067 * @param key 068 * @param lastReq 069 * @param nonce 070 * @param keyExpiration 071 * @param flags 072 * @param authtime 073 * @param starttime 074 * @param endtime 075 * @param renewTill 076 * @param serverPrincipal 077 * @param caddr 078 * @param componentType 079 */ 080 public EncKdcRepPart( EncryptionKey key, LastRequest lastReq, int nonce, KerberosTime keyExpiration, 081 TicketFlags flags, KerberosTime authtime, KerberosTime starttime, KerberosTime endtime, KerberosTime renewTill, 082 KerberosPrincipal serverPrincipal, HostAddresses caddr, MessageComponentType componentType ) 083 { 084 this.key = key; 085 this.lastRequest = lastReq; 086 this.nonce = nonce; 087 this.keyExpiration = keyExpiration; 088 this.flags = flags; 089 this.authTime = authtime; 090 this.startTime = starttime; 091 this.endTime = endtime; 092 this.renewTill = renewTill; 093 this.serverPrincipal = serverPrincipal; 094 this.clientAddresses = caddr; 095 this.componentType = componentType; 096 } 097 098 099 /** 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 }