1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 21 package org.apache.directory.kerberos.client; 22 23 24 /** 25 * The result codes returned by the change password server as defined in the <a href="http://www.ietf.org/rfc/rfc3244.txt">rfc3244</a> 26 * 27 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 28 */ 29 public enum ChangePasswordResultCode 30 { 31 32 /** request succeeds (This value is not allowed in a KRB-ERROR message) */ 33 KRB5_KPASSWD_SUCCESS(0), 34 35 /** request fails due to being malformed */ 36 KRB5_KPASSWD_MALFORMED(1), 37 38 /** 39 * request fails due to "hard" error in processing the request 40 * (for example, there is a resource or other problem causing 41 * the request to fail) 42 */ 43 KRB5_KPASSWD_HARDERROR(2), 44 45 /** request fails due to an error in authentication processing */ 46 KRB5_KPASSWD_AUTHERROR(3), 47 48 /** request fails due to a "soft" error in processing the request */ 49 KRB5_KPASSWD_SOFTERROR(4), 50 51 /** requestor not authorized */ 52 KRB5_KPASSWD_ACCESSDENIED(5), 53 54 /** protocol version unsupported */ 55 KRB5_KPASSWD_BAD_VERSION(6), 56 57 /** initial flag required */ 58 KRB5_KPASSWD_INITIAL_FLAG_NEEDED(7), 59 60 /** 0xFFFF(65535) is returned if the request fails for some other reason */ 61 OTHER(0xFFFF); 62 63 private int val; 64 65 66 private ChangePasswordResultCode( int val ) 67 { 68 this.val = val; 69 } 70 71 72 public int getVal() 73 { 74 return val; 75 } 76 77 78 public static ChangePasswordResultCode getByValue( int code ) 79 { 80 switch ( code ) 81 { 82 case 0: 83 return KRB5_KPASSWD_SUCCESS; 84 85 case 1: 86 return KRB5_KPASSWD_MALFORMED; 87 88 case 2: 89 return KRB5_KPASSWD_HARDERROR; 90 91 case 3: 92 return KRB5_KPASSWD_AUTHERROR; 93 94 case 4: 95 return KRB5_KPASSWD_SOFTERROR; 96 97 case 5: 98 return KRB5_KPASSWD_ACCESSDENIED; 99 100 case 6: 101 return KRB5_KPASSWD_BAD_VERSION; 102 103 case 7: 104 return KRB5_KPASSWD_INITIAL_FLAG_NEEDED; 105 106 case 0xFFFF: 107 return OTHER; 108 109 default: 110 throw new IllegalArgumentException( "Unknown result code " + code ); 111 } 112 } 113 114 115 @Override 116 public String toString() 117 { 118 return super.toString() + "(" + getVal() + ")"; 119 } 120 121 }