01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
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: package org.apache.harmony.security.x509.tsp;
21:
22: import java.security.InvalidParameterException;
23:
24: /**
25: Corresponds to PKIStatus structure.
26: See RFC 3161 -
27: Internet X.509 Public Key Infrastructure
28: Time-Stamp Protocol (TSP)
29: http://www.ietf.org/rfc/rfc3161.txt)
30:
31: PKIStatus ::= INTEGER {
32: granted (0),
33: -- when the PKIStatus contains the value zero a TimeStampToken, as
34: requested, is present.
35: grantedWithMods (1),
36: -- when the PKIStatus contains the value one a TimeStampToken,
37: with modifications, is present.
38: rejection (2),
39: waiting (3),
40: revocationWarning (4),
41: -- this message contains a warning that a revocation is
42: -- imminent
43: revocationNotification (5)
44: -- notification that a revocation has occurred }
45: */
46: public enum PKIStatus {
47: /**
48: * TimeStampToken is present as requested
49: */
50: GRANTED(0),
51: /**
52: * TimeStampToken is present with modifications
53: */
54: GRANTED_WITH_MODS(1),
55: /**
56: * rejected
57: */
58: REJECTION(2),
59: /**
60: * waiting
61: */
62: WAITING(3),
63: /**
64: * revocation time comes soon
65: */
66: REVOCATION_WARNING(4),
67: /**
68: * revoked
69: */
70: REVOCATION_NOTIFICATION(5);
71:
72: private final int status;
73:
74: PKIStatus(int status) {
75: this .status = status;
76: }
77:
78: /**
79: * @return int value of the status
80: */
81: public int getStatus() {
82: return status;
83: }
84:
85: public static PKIStatus getInstance(int status) {
86: for (PKIStatus curStatus : values()) {
87: if (status == curStatus.status) {
88: return curStatus;
89: }
90: }
91: throw new InvalidParameterException("Unknown PKIStatus value");
92: }
93: }
|