1 7 8 package org.ietf.jgss; 9 10 25 public class GSSException extends Exception { 26 27 private static final long serialVersionUID = -2706218945227726672L; 28 29 32 public static final int BAD_BINDINGS = 1; 34 37 public static final int BAD_MECH = 2; 38 39 42 public static final int BAD_NAME = 3; 43 44 47 public static final int BAD_NAMETYPE = 4; 48 49 52 56 public static final int BAD_STATUS = 5; 57 58 61 public static final int BAD_MIC = 6; 62 63 66 public static final int CONTEXT_EXPIRED = 7; 67 68 71 public static final int CREDENTIALS_EXPIRED = 8; 72 73 77 public static final int DEFECTIVE_CREDENTIAL = 9; 78 79 83 public static final int DEFECTIVE_TOKEN = 10; 84 85 88 public static final int FAILURE = 11; 89 90 93 public static final int NO_CONTEXT = 12; 94 95 98 public static final int NO_CRED = 13; 99 100 103 public static final int BAD_QOP = 14; 104 105 108 public static final int UNAUTHORIZED = 15; 109 110 113 public static final int UNAVAILABLE = 16; 114 115 118 public static final int DUPLICATE_ELEMENT = 17; 119 120 123 public static final int NAME_NOT_MN = 18; 124 125 132 public static final int DUPLICATE_TOKEN = 19; 133 134 140 public static final int OLD_TOKEN = 20; 141 142 143 149 public static final int UNSEQ_TOKEN = 21; 150 151 152 158 public static final int GAP_TOKEN = 22; 159 160 161 private static String [] messages = { 162 "Channel binding mismatch", "Unsupported mechanism requested", "Invalid name provided", "Name of unsupported type provided", "Invalid input status selector", "Token had invalid integrity check", "Specified security context expired", "Expired credentials detected", "Defective credential detected", "Defective token detected", "Failure unspecified at GSS-API level", "Security context init/accept not yet called or context deleted", 174 "No valid credentials provided", "Unsupported QOP value", "Operation unauthorized", "Operation unavailable", "Duplicate credential element requested", "Name contains multi-mechanism elements", "The token was a duplicate of an earlier token", "The token's validity period has expired", "A later token has already been processed", "An expected per-message token was not received", }; 186 187 192 private int major; 193 194 199 private int minor = 0; 200 201 206 private String minorMessage = null; 207 208 213 214 private String majorString = null; 215 216 222 public GSSException (int majorCode) { 223 224 if (validateMajor(majorCode)) 225 major = majorCode; 226 else 227 major = FAILURE; 228 } 229 230 237 GSSException (int majorCode, String majorString) { 238 239 if (validateMajor(majorCode)) 240 major = majorCode; 241 else 242 major = FAILURE; 243 this.majorString = majorString; 244 } 245 246 247 261 public GSSException (int majorCode, int minorCode, String minorString) { 262 263 if (validateMajor(majorCode)) 264 major = majorCode; 265 else 266 major = FAILURE; 267 268 minor = minorCode; 269 minorMessage = minorString; 270 } 271 272 284 public int getMajor() { 285 return major; 286 } 287 288 298 public int getMinor(){ 299 return minor; 300 } 301 302 310 public String getMajorString() { 311 312 if (majorString != null) 313 return majorString; 314 else 315 return messages[major - 1]; 316 } 317 318 319 329 public String getMinorString() { 330 331 return minorMessage; 332 } 333 334 335 344 public void setMinor(int minorCode, String message) { 345 346 minor = minorCode; 347 minorMessage = message; 348 } 349 350 351 357 public String toString() { 358 return ("GSSException: " + getMessage()); 359 } 360 361 367 public String getMessage() { 368 if (minor == 0) 369 return (getMajorString()); 370 371 return (getMajorString() 372 + " (Mechanism level: " + getMinorString() + ")"); 373 } 374 375 376 379 private boolean validateMajor(int major) { 380 381 if (major > 0 && major <= messages.length) 382 return (true); 383 384 return (false); 385 } 386 } 387 | Popular Tags |