KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > protocol > FailInfo


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13  
14 /**
15  * $Header: /cvsroot/ejbca/ejbca/src/java/org/ejbca/core/protocol/FailInfo.java,v 1.5 2006/11/02 17:03:21 anatom Exp $
16  * $Revision: 1.5 $
17  * $Date: 2006/11/02 17:03:21 $
18  *
19  */

20 package org.ejbca.core.protocol;
21
22 import java.io.Serializable JavaDoc;
23
24 import org.bouncycastle.asn1.DERBitString;
25 import org.bouncycastle.asn1.x509.ReasonFlags;
26
27 /**
28  * Encapsulates the possible values for the failinfo part of a SCEP FAILURE response.
29  *
30  * @author Jon Barber (jon.barber@acm.org)
31  * @version $Id: FailInfo.java,v 1.5 2006/11/02 17:03:21 anatom Exp $
32  */

33
34 public class FailInfo implements Serializable JavaDoc {
35
36     /**
37      * Unrecognized or unsupported algorithm ident
38      */

39     public static final FailInfo BAD_ALGORITHM = new FailInfo(0);
40
41     /**
42      * Integrity check failed
43      */

44     public static final FailInfo BAD_MESSAGE_CHECK = new FailInfo(1);
45
46     /**
47      * Transaction not permitted or supported
48      */

49     public static final FailInfo BAD_REQUEST = new FailInfo(2);
50
51     /**
52      * Message time field was not sufficiently close to the system time
53      */

54     public static final FailInfo BAD_TIME = new FailInfo(3);
55
56     /**
57      * No certificate could be identified matching the provided criteria
58      */

59     public static final FailInfo BAD_CERTIFICATE_ID = new FailInfo(4);
60     /**
61      * Request for wrong certificate authority
62      */

63     public static final FailInfo WRONG_AUTHORITY = new FailInfo(6);
64     /**
65      * Data incorrect, for example request for a non-existing user
66      */

67     public static final FailInfo INCORRECT_DATA = new FailInfo(7);
68     /**
69      * Verification of Proof of possession failed
70      */

71     public static final FailInfo BAD_POP = new FailInfo(9);
72     /**
73      * Not authorized
74      */

75     public static final FailInfo NOT_AUTHORIZED = new FailInfo(23);
76     /**
77      * The value actually encoded into the response message as the failinfo attribute
78      */

79     private final int value;
80
81     private FailInfo(int value) {
82         this.value = value;
83     }
84
85     /**
86      * Gets the value embedded in the response message as a failinfo attribute
87      * @return the value to use
88      */

89     public String JavaDoc getValue() {
90         return Integer.toString(value);
91     }
92
93     /** Returns the FailInfo value as a bit string, where the value represents the bit that is set
94      *
95      * @return DERBitString
96      */

97     public DERBitString getAsBitString() {
98         int i = 1 << value;
99         // Use reasonflags, because it already has convertion between int and BitString in it
100
DERBitString str = new ReasonFlags(i);
101         return str;
102     }
103
104     public boolean equals(Object JavaDoc o) {
105         if (this == o) return true;
106         if (!(o instanceof FailInfo)) return false;
107
108         final FailInfo scepResponseStatus = (FailInfo) o;
109
110         if (value != scepResponseStatus.value) return false;
111
112         return true;
113     }
114
115     public int hashCode() {
116         return value;
117     }
118     public String JavaDoc toString() {
119         return Integer.toString(value);
120     }
121 }
122
Popular Tags