001package org.apache.commons.ssl.org.bouncycastle.asn1.cmp;
002
003import org.apache.commons.ssl.org.bouncycastle.asn1.DERBitString;
004
005/**
006 * <pre>
007 * PKIFailureInfo ::= BIT STRING {
008 * badAlg               (0),
009 *   -- unrecognized or unsupported Algorithm Identifier
010 * badMessageCheck      (1), -- integrity check failed (e.g., signature did not verify)
011 * badRequest           (2),
012 *   -- transaction not permitted or supported
013 * badTime              (3), -- messageTime was not sufficiently close to the system time, as defined by local policy
014 * badCertId            (4), -- no certificate could be found matching the provided criteria
015 * badDataFormat        (5),
016 *   -- the data submitted has the wrong format
017 * wrongAuthority       (6), -- the authority indicated in the request is different from the one creating the response token
018 * incorrectData        (7), -- the requester's data is incorrect (for notary services)
019 * missingTimeStamp     (8), -- when the timestamp is missing but should be there (by policy)
020 * badPOP               (9)  -- the proof-of-possession failed
021 * certRevoked         (10),
022 * certConfirmed       (11),
023 * wrongIntegrity      (12),
024 * badRecipientNonce   (13), 
025 * timeNotAvailable    (14),
026 *   -- the TSA's time source is not available
027 * unacceptedPolicy    (15),
028 *   -- the requested TSA policy is not supported by the TSA
029 * unacceptedExtension (16),
030 *   -- the requested extension is not supported by the TSA
031 * addInfoNotAvailable (17)
032 *   -- the additional information requested could not be understood
033 *   -- or is not available
034 * badSenderNonce      (18),
035 * badCertTemplate     (19),
036 * signerNotTrusted    (20),
037 * transactionIdInUse  (21),
038 * unsupportedVersion  (22),
039 * notAuthorized       (23),
040 * systemUnavail       (24),    
041 * systemFailure       (25),
042 *   -- the request cannot be handled due to system failure
043 * duplicateCertReq    (26) 
044 * </pre>
045 */
046public class PKIFailureInfo
047    extends DERBitString
048{
049    public static final int badAlg               = (1 << 7); // unrecognized or unsupported Algorithm Identifier
050    public static final int badMessageCheck      = (1 << 6); // integrity check failed (e.g., signature did not verify)
051    public static final int badRequest           = (1 << 5);
052    public static final int badTime              = (1 << 4); // -- messageTime was not sufficiently close to the system time, as defined by local policy
053    public static final int badCertId            = (1 << 3); // no certificate could be found matching the provided criteria
054    public static final int badDataFormat        = (1 << 2);
055    public static final int wrongAuthority       = (1 << 1); // the authority indicated in the request is different from the one creating the response token
056    public static final int incorrectData        = 1;        // the requester's data is incorrect (for notary services)
057    public static final int missingTimeStamp     = (1 << 15); // when the timestamp is missing but should be there (by policy)
058    public static final int badPOP               = (1 << 14); // the proof-of-possession failed
059    public static final int certRevoked          = (1 << 13);
060    public static final int certConfirmed        = (1 << 12);
061    public static final int wrongIntegrity       = (1 << 11);
062    public static final int badRecipientNonce    = (1 << 10);
063    public static final int timeNotAvailable     = (1 << 9); // the TSA's time source is not available
064    public static final int unacceptedPolicy     = (1 << 8); // the requested TSA policy is not supported by the TSA
065    public static final int unacceptedExtension  = (1 << 23); //the requested extension is not supported by the TSA
066    public static final int addInfoNotAvailable  = (1 << 22); //the additional information requested could not be understood or is not available
067    public static final int badSenderNonce       = (1 << 21);
068    public static final int badCertTemplate      = (1 << 20);
069    public static final int signerNotTrusted     = (1 << 19);
070    public static final int transactionIdInUse   = (1 << 18);
071    public static final int unsupportedVersion   = (1 << 17);
072    public static final int notAuthorized        = (1 << 16);
073    public static final int systemUnavail        = (1 << 31);
074    public static final int systemFailure        = (1 << 30); //the request cannot be handled due to system failure
075    public static final int duplicateCertReq     = (1 << 29);
076
077    /** @deprecated use lower case version */
078    public static final int BAD_ALG                   = badAlg; // unrecognized or unsupported Algorithm Identifier
079    /** @deprecated use lower case version */
080    public static final int BAD_MESSAGE_CHECK         = badMessageCheck;
081    /** @deprecated use lower case version */
082    public static final int BAD_REQUEST               = badRequest; // transaction not permitted or supported
083    /** @deprecated use lower case version */
084    public static final int BAD_TIME                  = badTime;
085    /** @deprecated use lower case version */
086    public static final int BAD_CERT_ID               = badCertId;
087    /** @deprecated use lower case version */
088    public static final int BAD_DATA_FORMAT           = badDataFormat; // the data submitted has the wrong format
089    /** @deprecated use lower case version */
090    public static final int WRONG_AUTHORITY           = wrongAuthority;
091    /** @deprecated use lower case version */
092    public static final int INCORRECT_DATA            = incorrectData;
093    /** @deprecated use lower case version */
094    public static final int MISSING_TIME_STAMP        = missingTimeStamp;
095    /** @deprecated use lower case version */
096    public static final int BAD_POP                   = badPOP;
097    /** @deprecated use lower case version */
098    public static final int TIME_NOT_AVAILABLE        = timeNotAvailable;
099    /** @deprecated use lower case version */
100    public static final int UNACCEPTED_POLICY         = unacceptedPolicy;
101    /** @deprecated use lower case version */
102    public static final int UNACCEPTED_EXTENSION      = unacceptedExtension;
103    /** @deprecated use lower case version */
104    public static final int ADD_INFO_NOT_AVAILABLE    = addInfoNotAvailable; 
105    /** @deprecated use lower case version */
106    public static final int SYSTEM_FAILURE            = systemFailure; 
107    /**
108     * Basic constructor.
109     */
110    public PKIFailureInfo(
111        int info)
112    {
113        super(getBytes(info), getPadBits(info));
114    }
115
116    public PKIFailureInfo(
117        DERBitString info)
118    {
119        super(info.getBytes(), info.getPadBits());
120    }
121    
122    public String toString()
123    {
124        return "PKIFailureInfo: 0x" + Integer.toHexString(this.intValue());
125    }
126}