1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.directory.server.changepw.exceptions;
22
23
24 import java.util.Arrays;
25 import java.util.Collections;
26 import java.util.List;
27
28
29
30
31
32
33
34
35 public final class ErrorType implements Comparable<ErrorType>
36 {
37
38
39
40 public static final ErrorType KRB5_KPASSWD_MALFORMED = new ErrorType( 1, "Request failed due to being malformed." );
41
42
43
44
45 public static final ErrorType KRB5_KPASSWD_HARDERROR = new ErrorType( 2,
46 "Request failed due to a hard error in processing the request." );
47
48
49
50
51 public static final ErrorType KRB5_KPASSWD_AUTHERROR = new ErrorType( 3,
52 "Request failed due to an error in authentication processing." );
53
54
55
56
57 public static final ErrorType KRB5_KPASSWD_SOFTERROR = new ErrorType( 4,
58 "Request failed due to a soft error in processing the request." );
59
60
61
62
63 public static final ErrorType KRB5_KPASSWD_ACCESSDENIED = new ErrorType( 5, "Requestor not authorized." );
64
65
66
67
68 public static final ErrorType KRB5_KPASSWD_BAD_VERSION = new ErrorType( 6, "Protocol version unsupported." );
69
70
71
72
73 public static final ErrorType KRB5_KPASSWD_INITIAL_FLAG_NEEDED = new ErrorType( 7, "Initial flag required." );
74
75
76
77
78 public static final ErrorType KRB5_KPASSWD_UNKNOWN_ERROR = new ErrorType( 8,
79 "Request failed for an unknown reason." );
80
81
82
83
84 private static final ErrorType[] values =
85 { KRB5_KPASSWD_MALFORMED, KRB5_KPASSWD_HARDERROR, KRB5_KPASSWD_AUTHERROR, KRB5_KPASSWD_SOFTERROR,
86 KRB5_KPASSWD_ACCESSDENIED, KRB5_KPASSWD_BAD_VERSION, KRB5_KPASSWD_INITIAL_FLAG_NEEDED,
87 KRB5_KPASSWD_UNKNOWN_ERROR };
88
89
90
91
92 public static final List<ErrorType> VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
93
94
95
96
97 private final String name;
98
99
100
101
102 private final int ordinal;
103
104
105
106
107
108 private ErrorType( int ordinal, String name )
109 {
110 this.ordinal = ordinal;
111 this.name = name;
112 }
113
114
115
116
117
118
119
120 public String getMessage()
121 {
122 return name;
123 }
124
125
126
127
128
129
130
131 public String toString()
132 {
133 return name;
134 }
135
136
137
138
139
140
141
142
143
144 public int compareTo( ErrorType that )
145 {
146 return this.ordinal - that.ordinal;
147 }
148
149
150
151
152
153
154
155
156 public static ErrorType getTypeByOrdinal( int ordinal )
157 {
158 for ( int ii = 0; ii < values.length; ii++ )
159 {
160 if ( values[ii].ordinal == ordinal )
161 {
162 return values[ii];
163 }
164 }
165
166 return KRB5_KPASSWD_UNKNOWN_ERROR;
167 }
168
169
170
171
172
173
174
175 public int getOrdinal()
176 {
177 return ordinal;
178 }
179 }