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; 021 022 023 import java.util.Set; 024 025 import javax.security.auth.kerberos.KerberosPrincipal; 026 027 import org.apache.directory.server.kerberos.shared.KerberosMessageType; 028 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType; 029 import org.apache.directory.server.kerberos.shared.messages.components.Ticket; 030 import org.apache.directory.server.kerberos.shared.messages.value.EncryptedData; 031 import org.apache.directory.server.kerberos.shared.messages.value.HostAddresses; 032 import org.apache.directory.server.kerberos.shared.messages.value.KdcOptions; 033 import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime; 034 import org.apache.directory.server.kerberos.shared.messages.value.PaData; 035 import org.apache.directory.server.kerberos.shared.messages.value.RequestBody; 036 037 038 /** 039 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 040 * @version $Rev: 590715 $, $Date: 2007-10-31 16:23:32 +0100 (Wed, 31 Oct 2007) $ 041 */ 042 public class KdcRequest extends KerberosMessage 043 { 044 private PaData[] preAuthData; //optional 045 private RequestBody requestBody; 046 private byte[] bodyBytes; 047 048 049 /** 050 * Creates a new instance of KdcRequest. 051 * 052 * @param pvno 053 * @param messageType 054 * @param preAuthData 055 * @param requestBody 056 */ 057 public KdcRequest( int pvno, KerberosMessageType messageType, PaData[] preAuthData, RequestBody requestBody ) 058 { 059 super( pvno, messageType ); 060 this.preAuthData = preAuthData; 061 this.requestBody = requestBody; 062 } 063 064 065 /** 066 * Creates a new instance of KdcRequest. 067 * 068 * @param pvno 069 * @param messageType 070 * @param preAuthData 071 * @param requestBody 072 * @param bodyBytes 073 */ 074 public KdcRequest( int pvno, KerberosMessageType messageType, PaData[] preAuthData, RequestBody requestBody, 075 byte[] bodyBytes ) 076 { 077 this( pvno, messageType, preAuthData, requestBody ); 078 this.bodyBytes = bodyBytes; 079 } 080 081 082 /** 083 * Returns an array of {@link PaData}s. 084 * 085 * @return The array of {@link PaData}s. 086 */ 087 public PaData[] getPreAuthData() 088 { 089 return preAuthData; 090 } 091 092 093 /** 094 * Returns the request body. 095 * 096 * @return The request body. 097 */ 098 public RequestBody getRequestBody() 099 { 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 }