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 */ 020package org.apache.directory.shared.kerberos.codec.types; 021 022 023/** 024 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 025 */ 026public enum PaDataType 027{ 028 /** 029 * Constant for the "null" pre-authentication data type. 030 */ 031 NULL(0), 032 033 /** 034 * Constant for the "TGS request" pre-authentication data type. 035 */ 036 PA_TGS_REQ(1), 037 038 /** 039 * Constant for the "encrypted timestamp" pre-authentication data type. 040 */ 041 PA_ENC_TIMESTAMP(2), 042 043 /** 044 * Constant for the "password salt" pre-authentication data type. 045 */ 046 PA_PW_SALT(3), 047 048 /** 049 * Constant for the "enc unix time" pre-authentication data type. 050 */ 051 PA_ENC_UNIX_TIME(5), 052 053 /** 054 * Constant for the "sandia secureid" pre-authentication data type. 055 */ 056 PA_SANDIA_SECUREID(6), 057 058 /** 059 * Constant for the "sesame" pre-authentication data type. 060 */ 061 PA_SESAME(7), 062 063 /** 064 * Constant for the "OSF DCE" pre-authentication data type. 065 */ 066 PA_OSF_DCE(8), 067 068 /** 069 * Constant for the "cybersafe secureid" pre-authentication data type. 070 */ 071 PA_CYBERSAFE_SECUREID(9), 072 073 /** 074 * Constant for the "ASF3 salt" pre-authentication data type. 075 */ 076 PA_ASF3_SALT(10), 077 078 /** 079 * Constant for the "encryption info" pre-authentication data type. 080 */ 081 PA_ENCTYPE_INFO(11), 082 083 /** 084 * Constant for the "SAM challenge" pre-authentication data type. 085 */ 086 SAM_CHALLENGE(12), 087 088 /** 089 * Constant for the "SAM response" pre-authentication data type. 090 */ 091 SAM_RESPONSE(13), 092 093 /** 094 * Constant for the "PK as request" pre-authentication data type. 095 */ 096 PA_PK_AS_REQ(14), 097 098 /** 099 * Constant for the "PK as response" pre-authentication data type. 100 */ 101 PA_PK_AS_REP(15), 102 103 /** 104 * Constant for the "encryption info2" pre-authentication data type. 105 */ 106 PA_ENCTYPE_INFO2( 19 ), 107 108 /** 109 * Constant for the "use specified key version" pre-authentication data type. 110 */ 111 PA_USE_SPECIFIED_KVNO(20), 112 113 /** 114 * Constant for the "SAM redirect" pre-authentication data type. 115 */ 116 SAM_REDIRECT(21), 117 118 /** 119 * Constant for the "get from typed data" pre-authentication data type. 120 */ 121 PA_GET_FROM_TYPED_DATA(22); 122 123 /** 124 * The value/code for the pre-authentication type. 125 */ 126 private final int value; 127 128 129 /** 130 * Private constructor prevents construction outside of this class. 131 */ 132 private PaDataType( int value ) 133 { 134 this.value = value; 135 } 136 137 138 /** 139 * Returns the number associated with this pre-authentication type. 140 * 141 * @return The pre-authentication type value. 142 */ 143 public int getValue() 144 { 145 return value; 146 } 147 148 149 /** 150 * Returns the pre authentication data type when specified by its ordinal. 151 * 152 * @param type The value 153 * @return The pre authentication type. 154 */ 155 public static PaDataType getTypeByValue( int type ) 156 { 157 switch ( type ) 158 { 159 case 1: 160 return PA_TGS_REQ; 161 case 2: 162 return PA_ENC_TIMESTAMP; 163 case 3: 164 return PA_PW_SALT; 165 case 5: 166 return PA_ENC_UNIX_TIME; 167 case 6: 168 return PA_SANDIA_SECUREID; 169 case 7: 170 return PA_SESAME; 171 case 8: 172 return PA_OSF_DCE; 173 case 9: 174 return PA_CYBERSAFE_SECUREID; 175 case 10: 176 return PA_ASF3_SALT; 177 case 11: 178 return PA_ENCTYPE_INFO; 179 case 12: 180 return SAM_CHALLENGE; 181 case 13: 182 return SAM_RESPONSE; 183 case 14: 184 return PA_PK_AS_REQ; 185 case 15: 186 return PA_PK_AS_REQ; 187 case 19 : 188 return PA_ENCTYPE_INFO2; 189 case 20: 190 return PA_USE_SPECIFIED_KVNO; 191 case 21: 192 return SAM_REDIRECT; 193 case 22: 194 return PA_GET_FROM_TYPED_DATA; 195 default: 196 return NULL; 197 } 198 } 199 200 201 /** 202 * @see Object#toString() 203 */ 204 @Override 205 public String toString() 206 { 207 switch ( this ) 208 { 209 case PA_TGS_REQ: 210 return "TGS request." + "(" + value + ")"; 211 212 case PA_ENC_TIMESTAMP: 213 return "Encrypted timestamp." + "(" + value + ")"; 214 215 case PA_PW_SALT: 216 return "password salt" + "(" + value + ")"; 217 218 case PA_ENC_UNIX_TIME: 219 return "enc unix time" + "(" + value + ")"; 220 221 case PA_SANDIA_SECUREID: 222 return "sandia secureid" + "(" + value + ")"; 223 224 case PA_SESAME: 225 return "sesame" + "(" + value + ")"; 226 227 case PA_OSF_DCE: 228 return "OSF DCE" + "(" + value + ")"; 229 230 case PA_CYBERSAFE_SECUREID: 231 return "cybersafe secureid" + "(" + value + ")"; 232 233 case PA_ASF3_SALT: 234 return "ASF3 salt" + "(" + value + ")"; 235 236 case PA_ENCTYPE_INFO: 237 return "Encryption info." + "(" + value + ")"; 238 239 case SAM_CHALLENGE: 240 return "SAM challenge." + "(" + value + ")"; 241 242 case SAM_RESPONSE: 243 return "SAM response." + "(" + value + ")"; 244 245 case PA_PK_AS_REQ: 246 return "PK as request" + "(" + value + ")"; 247 248 case PA_ENCTYPE_INFO2 : 249 return "Encryption info." + "(" + value + ")"; 250 251 case PA_PK_AS_REP: 252 return "PK as response" + "(" + value + ")"; 253 254 case PA_USE_SPECIFIED_KVNO: 255 return "use specified key version" + "(" + value + ")"; 256 257 case SAM_REDIRECT: 258 return "SAM redirect." + "(" + value + ")"; 259 260 case PA_GET_FROM_TYPED_DATA: 261 return "Get from typed data" + "(" + value + ")"; 262 263 default: 264 return "null" + "(" + value + ")"; 265 } 266 } 267}