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 * The Authorization types 025 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 026 */ 027public enum AuthorizationType 028{ 029 /** 030 * Constant for the "null" authorization type. 031 */ 032 NULL(0), 033 034 /** 035 * Constant for the "if relevant" authorization type. 036 * 037 * RFC 4120 038 */ 039 AD_IF_RELEVANT(1), 040 041 /** 042 * Constant for the "intended for server" authorization type. 043 * 044 * RFC 4120 045 */ 046 AD_INTENDED_FOR_SERVER(2), 047 048 /** 049 * Constant for the "intended for application class" authorization type. 050 * 051 * RFC 4120 052 */ 053 AD_INTENDED_FOR_APPLICATION_CLASS(3), 054 055 /** 056 * Constant for the "kdc issued" authorization type. 057 * 058 * RFC 4120 059 */ 060 AD_KDC_ISSUED(4), 061 062 /** 063 * Constant for the "or" authorization type. 064 * 065 * RFC 4120 066 */ 067 AD_OR(5), 068 069 /** 070 * Constant for the "mandatory ticket extensions" authorization type. 071 * 072 * RFC 4120 073 */ 074 AD_MANDATORY_TICKET_EXTENSIONS(6), 075 076 /** 077 * Constant for the "in ticket extensions" authorization type. 078 * 079 * RFC 4120 080 */ 081 AD_IN_TICKET_EXTENSIONS(7), 082 083 /** 084 * Constant for the "mandatory-for-kdc" authorization type. 085 * 086 * RFC 4120 087 */ 088 AD_MANDATORY_FOR_KDC(8), 089 090 /** 091 * Constant for the "OSF DCE" authorization type. 092 * 093 * RFC 1510 094 */ 095 OSF_DCE(64), 096 097 /** 098 * Constant for the "sesame" authorization type. 099 * 100 * RFC 1510 101 */ 102 SESAME(65), 103 104 /** 105 * Constant for the "OSF-DCE pki certid" authorization type. 106 * 107 * RFC 1510 108 */ 109 AD_OSF_DCE_PKI_CERTID(66), 110 111 /** 112 * Constant for the "sesame" authorization type. 113 * 114 * RFC 1510 115 */ 116 AD_WIN2K_PAC(128), 117 118 /** 119 * Constant for the "sesame" authorization type. 120 * 121 * RFC 1510 122 */ 123 AD_ETYPE_NEGOTIATION(129); 124 125 /** 126 * The value/code for the authorization type. 127 */ 128 private final int value; 129 130 131 /** 132 * Private constructor prevents construction outside of this class. 133 */ 134 private AuthorizationType( int value ) 135 { 136 this.value = value; 137 } 138 139 140 /** 141 * Returns the authorization type when specified by its ordinal. 142 * 143 * @param type The numeric value 144 * @return The authorization type. 145 */ 146 public static AuthorizationType getTypeByValue( int type ) 147 { 148 switch ( type ) 149 { 150 case 1: 151 return AD_IF_RELEVANT; 152 case 2: 153 return AD_INTENDED_FOR_SERVER; 154 case 3: 155 return AD_INTENDED_FOR_APPLICATION_CLASS; 156 case 4: 157 return AD_KDC_ISSUED; 158 case 5: 159 return AD_OR; 160 case 6: 161 return AD_MANDATORY_TICKET_EXTENSIONS; 162 case 7: 163 return AD_IN_TICKET_EXTENSIONS; 164 case 8: 165 return AD_MANDATORY_FOR_KDC; 166 case 64: 167 return OSF_DCE; 168 case 65: 169 return SESAME; 170 case 66: 171 return AD_OSF_DCE_PKI_CERTID; 172 case 128: 173 return AD_WIN2K_PAC; 174 case 129: 175 return AD_ETYPE_NEGOTIATION; 176 default: 177 return NULL; 178 } 179 } 180 181 182 /** 183 * Returns the number associated with this authorization type. 184 * 185 * @return The authorization type ordinal. 186 */ 187 public int getValue() 188 { 189 return value; 190 } 191 192 193 /** 194 * @see Object#toString() 195 */ 196 @Override 197 public String toString() 198 { 199 switch ( this ) 200 { 201 case AD_IF_RELEVANT: 202 return "if relevant" + "(" + value + ")"; 203 204 case AD_INTENDED_FOR_SERVER: 205 return "intended for server" + "(" + value + ")"; 206 207 case AD_INTENDED_FOR_APPLICATION_CLASS: 208 return "intended for application class" + "(" + value + ")"; 209 210 case AD_KDC_ISSUED: 211 return "kdc issued" + "(" + value + ")"; 212 213 case AD_OR: 214 return "or" + "(" + value + ")"; 215 216 case AD_MANDATORY_TICKET_EXTENSIONS: 217 return "mandatory ticket extensions" + "(" + value + ")"; 218 219 case AD_IN_TICKET_EXTENSIONS: 220 return "in ticket extensions" + "(" + value + ")"; 221 222 case AD_MANDATORY_FOR_KDC: 223 return "mandatory-for-kdc" + "(" + value + ")"; 224 225 case OSF_DCE: 226 return "OSF DCE" + "(" + value + ")"; 227 228 case SESAME: 229 return "sesame" + "(" + value + ")"; 230 231 case AD_OSF_DCE_PKI_CERTID: 232 return "OSF DCE pki certid" + "(" + value + ")"; 233 234 case AD_WIN2K_PAC: 235 return "win 2000 PAC" + "(" + value + ")"; 236 237 case AD_ETYPE_NEGOTIATION: 238 return "etype negociation" + "(" + value + ")"; 239 240 default: 241 return "null" + "(" + value + ")"; 242 } 243 } 244}