Home | History | Annotate | Download | only in tsp
      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 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     PKIStatus(int status) {
     74         this.status = status;
     75     }
     76 
     77     /**
     78      * @return int value of the status
     79      */
     80     public int getStatus(){
     81         return status;
     82     }
     83 
     84     public static PKIStatus getInstance(int status) {
     85         for (PKIStatus curStatus : values()) {
     86             if (status == curStatus.status) {
     87                 return curStatus;
     88             }
     89         }
     90         throw new InvalidParameterException("Unknown PKIStatus value");
     91     }
     92 }
     93 
     94