Java Code Examples for sun.security.util.DerValue#tag_Integer()

The following examples show how to use sun.security.util.DerValue#tag_Integer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InhibitAnyPolicyExtension.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Create the extension from the passed DER encoded value of the same.
 *
 * @param critical criticality flag to use.  Must be true for this
 *                 extension.
 * @param value a byte array holding the DER-encoded extension value.
 * @exception ClassCastException if value is not an array of bytes
 * @exception IOException on error.
 */
public InhibitAnyPolicyExtension(Boolean critical, Object value)
    throws IOException {

    this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;

    if (!critical.booleanValue())
        throw new IOException("Criticality cannot be false for " +
                              "InhibitAnyPolicy");
    this.critical = critical.booleanValue();

    this.extensionValue = (byte[]) value;
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Integer)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "data not integer");

    if (val.data == null)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "null data");
    int skipCertsValue = val.getInteger();
    if (skipCertsValue < -1)
        throw new IOException("Invalid value for skipCerts");
    if (skipCertsValue == -1) {
        this.skipCerts = Integer.MAX_VALUE;
    } else {
        this.skipCerts = skipCertsValue;
    }
}
 
Example 2
Source File: TimestampToken.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void parse(byte[] timestampTokenInfo) throws IOException {

        DerValue tstInfo = new DerValue(timestampTokenInfo);
        if (tstInfo.tag != DerValue.tag_Sequence) {
            throw new IOException("Bad encoding for timestamp token info");
        }
        // Parse version
        version = tstInfo.data.getInteger();

        // Parse policy
        policy = tstInfo.data.getOID();

        // Parse messageImprint
        DerValue messageImprint = tstInfo.data.getDerValue();
        hashAlgorithm = AlgorithmId.parse(messageImprint.data.getDerValue());
        hashedMessage = messageImprint.data.getOctetString();

        // Parse serialNumber
        serialNumber = tstInfo.data.getBigInteger();

        // Parse genTime
        genTime = tstInfo.data.getGeneralizedTime();

        // Parse optional elements, if present
        while (tstInfo.data.available() > 0) {
            DerValue d = tstInfo.data.getDerValue();
            if (d.tag == DerValue.tag_Integer) {    // must be the nonce
                nonce = d.getBigInteger();
                break;
            }

            // Additional fields:
            // Parse accuracy
            // Parse ordering
            // Parse tsa
            // Parse extensions
        }
    }
 
Example 3
Source File: InhibitAnyPolicyExtension.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the extension from the passed DER encoded value of the same.
 *
 * @param critical criticality flag to use.  Must be true for this
 *                 extension.
 * @param value a byte array holding the DER-encoded extension value.
 * @exception ClassCastException if value is not an array of bytes
 * @exception IOException on error.
 */
public InhibitAnyPolicyExtension(Boolean critical, Object value)
    throws IOException {

    this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;

    if (!critical.booleanValue())
        throw new IOException("Criticality cannot be false for " +
                              "InhibitAnyPolicy");
    this.critical = critical.booleanValue();

    this.extensionValue = (byte[]) value;
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Integer)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "data not integer");

    if (val.data == null)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "null data");
    int skipCertsValue = val.getInteger();
    if (skipCertsValue < -1)
        throw new IOException("Invalid value for skipCerts");
    if (skipCertsValue == -1) {
        this.skipCerts = Integer.MAX_VALUE;
    } else {
        this.skipCerts = skipCertsValue;
    }
}
 
Example 4
Source File: TimestampToken.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void parse(byte[] timestampTokenInfo) throws IOException {

        DerValue tstInfo = new DerValue(timestampTokenInfo);
        if (tstInfo.tag != DerValue.tag_Sequence) {
            throw new IOException("Bad encoding for timestamp token info");
        }
        // Parse version
        version = tstInfo.data.getInteger();

        // Parse policy
        policy = tstInfo.data.getOID();

        // Parse messageImprint
        DerValue messageImprint = tstInfo.data.getDerValue();
        hashAlgorithm = AlgorithmId.parse(messageImprint.data.getDerValue());
        hashedMessage = messageImprint.data.getOctetString();

        // Parse serialNumber
        serialNumber = tstInfo.data.getBigInteger();

        // Parse genTime
        genTime = tstInfo.data.getGeneralizedTime();

        // Parse optional elements, if present
        while (tstInfo.data.available() > 0) {
            DerValue d = tstInfo.data.getDerValue();
            if (d.tag == DerValue.tag_Integer) {    // must be the nonce
                nonce = d.getBigInteger();
                break;
            }

            // Additional fields:
            // Parse accuracy
            // Parse ordering
            // Parse tsa
            // Parse extensions
        }
    }
 
Example 5
Source File: InhibitAnyPolicyExtension.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the extension from the passed DER encoded value of the same.
 *
 * @param critical criticality flag to use.  Must be true for this
 *                 extension.
 * @param value a byte array holding the DER-encoded extension value.
 * @exception ClassCastException if value is not an array of bytes
 * @exception IOException on error.
 */
public InhibitAnyPolicyExtension(Boolean critical, Object value)
    throws IOException {

    this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;

    if (!critical.booleanValue())
        throw new IOException("Criticality cannot be false for " +
                              "InhibitAnyPolicy");
    this.critical = critical.booleanValue();

    this.extensionValue = (byte[]) value;
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Integer)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "data not integer");

    if (val.data == null)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "null data");
    int skipCertsValue = val.getInteger();
    if (skipCertsValue < -1)
        throw new IOException("Invalid value for skipCerts");
    if (skipCertsValue == -1) {
        this.skipCerts = Integer.MAX_VALUE;
    } else {
        this.skipCerts = skipCertsValue;
    }
}
 
Example 6
Source File: TimestampToken.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void parse(byte[] timestampTokenInfo) throws IOException {

        DerValue tstInfo = new DerValue(timestampTokenInfo);
        if (tstInfo.tag != DerValue.tag_Sequence) {
            throw new IOException("Bad encoding for timestamp token info");
        }
        // Parse version
        version = tstInfo.data.getInteger();

        // Parse policy
        policy = tstInfo.data.getOID();

        // Parse messageImprint
        DerValue messageImprint = tstInfo.data.getDerValue();
        hashAlgorithm = AlgorithmId.parse(messageImprint.data.getDerValue());
        hashedMessage = messageImprint.data.getOctetString();

        // Parse serialNumber
        serialNumber = tstInfo.data.getBigInteger();

        // Parse genTime
        genTime = tstInfo.data.getGeneralizedTime();

        // Parse optional elements, if present
        while (tstInfo.data.available() > 0) {
            DerValue d = tstInfo.data.getDerValue();
            if (d.tag == DerValue.tag_Integer) {    // must be the nonce
                nonce = d.getBigInteger();
                break;
            }

            // Additional fields:
            // Parse accuracy
            // Parse ordering
            // Parse tsa
            // Parse extensions
        }
    }
 
Example 7
Source File: InhibitAnyPolicyExtension.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the extension from the passed DER encoded value of the same.
 *
 * @param critical criticality flag to use.  Must be true for this
 *                 extension.
 * @param value a byte array holding the DER-encoded extension value.
 * @exception ClassCastException if value is not an array of bytes
 * @exception IOException on error.
 */
public InhibitAnyPolicyExtension(Boolean critical, Object value)
    throws IOException {

    this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;

    if (!critical.booleanValue())
        throw new IOException("Criticality cannot be false for " +
                              "InhibitAnyPolicy");
    this.critical = critical.booleanValue();

    this.extensionValue = (byte[]) value;
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Integer)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "data not integer");

    if (val.data == null)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "null data");
    int skipCertsValue = val.getInteger();
    if (skipCertsValue < -1)
        throw new IOException("Invalid value for skipCerts");
    if (skipCertsValue == -1) {
        this.skipCerts = Integer.MAX_VALUE;
    } else {
        this.skipCerts = skipCertsValue;
    }
}
 
Example 8
Source File: InhibitAnyPolicyExtension.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the extension from the passed DER encoded value of the same.
 *
 * @param critical criticality flag to use.  Must be true for this
 *                 extension.
 * @param value a byte array holding the DER-encoded extension value.
 * @exception ClassCastException if value is not an array of bytes
 * @exception IOException on error.
 */
public InhibitAnyPolicyExtension(Boolean critical, Object value)
    throws IOException {

    this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;

    if (!critical.booleanValue())
        throw new IOException("Criticality cannot be false for " +
                              "InhibitAnyPolicy");
    this.critical = critical.booleanValue();

    this.extensionValue = (byte[]) value;
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Integer)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "data not integer");

    if (val.data == null)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "null data");
    int skipCertsValue = val.getInteger();
    if (skipCertsValue < -1)
        throw new IOException("Invalid value for skipCerts");
    if (skipCertsValue == -1) {
        this.skipCerts = Integer.MAX_VALUE;
    } else {
        this.skipCerts = skipCertsValue;
    }
}
 
Example 9
Source File: InhibitAnyPolicyExtension.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the extension from the passed DER encoded value of the same.
 *
 * @param critical criticality flag to use.  Must be true for this
 *                 extension.
 * @param value a byte array holding the DER-encoded extension value.
 * @exception ClassCastException if value is not an array of bytes
 * @exception IOException on error.
 */
public InhibitAnyPolicyExtension(Boolean critical, Object value)
    throws IOException {

    this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;

    if (!critical.booleanValue())
        throw new IOException("Criticality cannot be false for " +
                              "InhibitAnyPolicy");
    this.critical = critical.booleanValue();

    this.extensionValue = (byte[]) value;
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Integer)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "data not integer");

    if (val.data == null)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "null data");
    int skipCertsValue = val.getInteger();
    if (skipCertsValue < -1)
        throw new IOException("Invalid value for skipCerts");
    if (skipCertsValue == -1) {
        this.skipCerts = Integer.MAX_VALUE;
    } else {
        this.skipCerts = skipCertsValue;
    }
}
 
Example 10
Source File: TimestampToken.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void parse(byte[] timestampTokenInfo) throws IOException {

        DerValue tstInfo = new DerValue(timestampTokenInfo);
        if (tstInfo.tag != DerValue.tag_Sequence) {
            throw new IOException("Bad encoding for timestamp token info");
        }
        // Parse version
        version = tstInfo.data.getInteger();

        // Parse policy
        policy = tstInfo.data.getOID();

        // Parse messageImprint
        DerValue messageImprint = tstInfo.data.getDerValue();
        hashAlgorithm = AlgorithmId.parse(messageImprint.data.getDerValue());
        hashedMessage = messageImprint.data.getOctetString();

        // Parse serialNumber
        serialNumber = tstInfo.data.getBigInteger();

        // Parse genTime
        genTime = tstInfo.data.getGeneralizedTime();

        // Parse optional elements, if present
        while (tstInfo.data.available() > 0) {
            DerValue d = tstInfo.data.getDerValue();
            if (d.tag == DerValue.tag_Integer) {    // must be the nonce
                nonce = d.getBigInteger();
                break;
            }

            // Additional fields:
            // Parse accuracy
            // Parse ordering
            // Parse tsa
            // Parse extensions
        }
    }
 
Example 11
Source File: TimestampToken.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void parse(byte[] timestampTokenInfo) throws IOException {

        DerValue tstInfo = new DerValue(timestampTokenInfo);
        if (tstInfo.tag != DerValue.tag_Sequence) {
            throw new IOException("Bad encoding for timestamp token info");
        }
        // Parse version
        version = tstInfo.data.getInteger();

        // Parse policy
        policy = tstInfo.data.getOID();

        // Parse messageImprint
        DerValue messageImprint = tstInfo.data.getDerValue();
        hashAlgorithm = AlgorithmId.parse(messageImprint.data.getDerValue());
        hashedMessage = messageImprint.data.getOctetString();

        // Parse serialNumber
        serialNumber = tstInfo.data.getBigInteger();

        // Parse genTime
        genTime = tstInfo.data.getGeneralizedTime();

        // Parse optional elements, if present
        while (tstInfo.data.available() > 0) {
            DerValue d = tstInfo.data.getDerValue();
            if (d.tag == DerValue.tag_Integer) {    // must be the nonce
                nonce = d.getBigInteger();
                break;
            }

            // Additional fields:
            // Parse accuracy
            // Parse ordering
            // Parse tsa
            // Parse extensions
        }
    }
 
Example 12
Source File: TimestampToken.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void parse(byte[] timestampTokenInfo) throws IOException {

        DerValue tstInfo = new DerValue(timestampTokenInfo);
        if (tstInfo.tag != DerValue.tag_Sequence) {
            throw new IOException("Bad encoding for timestamp token info");
        }
        // Parse version
        version = tstInfo.data.getInteger();

        // Parse policy
        policy = tstInfo.data.getOID();

        // Parse messageImprint
        DerValue messageImprint = tstInfo.data.getDerValue();
        hashAlgorithm = AlgorithmId.parse(messageImprint.data.getDerValue());
        hashedMessage = messageImprint.data.getOctetString();

        // Parse serialNumber
        serialNumber = tstInfo.data.getBigInteger();

        // Parse genTime
        genTime = tstInfo.data.getGeneralizedTime();

        // Parse optional elements, if present
        while (tstInfo.data.available() > 0) {
            DerValue d = tstInfo.data.getDerValue();
            if (d.tag == DerValue.tag_Integer) {    // must be the nonce
                nonce = d.getBigInteger();
                break;
            }

            // Additional fields:
            // Parse accuracy
            // Parse ordering
            // Parse tsa
            // Parse extensions
        }
    }
 
Example 13
Source File: InhibitAnyPolicyExtension.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the extension from the passed DER encoded value of the same.
 *
 * @param critical criticality flag to use.  Must be true for this
 *                 extension.
 * @param value a byte array holding the DER-encoded extension value.
 * @exception ClassCastException if value is not an array of bytes
 * @exception IOException on error.
 */
public InhibitAnyPolicyExtension(Boolean critical, Object value)
    throws IOException {

    this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;

    if (!critical.booleanValue())
        throw new IOException("Criticality cannot be false for " +
                              "InhibitAnyPolicy");
    this.critical = critical.booleanValue();

    this.extensionValue = (byte[]) value;
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Integer)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "data not integer");

    if (val.data == null)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "null data");
    int skipCertsValue = val.getInteger();
    if (skipCertsValue < -1)
        throw new IOException("Invalid value for skipCerts");
    if (skipCertsValue == -1) {
        this.skipCerts = Integer.MAX_VALUE;
    } else {
        this.skipCerts = skipCertsValue;
    }
}
 
Example 14
Source File: InhibitAnyPolicyExtension.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Create the extension from the passed DER encoded value of the same.
 *
 * @param critical criticality flag to use.  Must be true for this
 *                 extension.
 * @param value a byte array holding the DER-encoded extension value.
 * @exception ClassCastException if value is not an array of bytes
 * @exception IOException on error.
 */
public InhibitAnyPolicyExtension(Boolean critical, Object value)
    throws IOException {

    this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;

    if (!critical.booleanValue())
        throw new IOException("Criticality cannot be false for " +
                              "InhibitAnyPolicy");
    this.critical = critical.booleanValue();

    this.extensionValue = (byte[]) value;
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Integer)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "data not integer");

    if (val.data == null)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "null data");
    int skipCertsValue = val.getInteger();
    if (skipCertsValue < -1)
        throw new IOException("Invalid value for skipCerts");
    if (skipCertsValue == -1) {
        this.skipCerts = Integer.MAX_VALUE;
    } else {
        this.skipCerts = skipCertsValue;
    }
}
 
Example 15
Source File: InhibitAnyPolicyExtension.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the extension from the passed DER encoded value of the same.
 *
 * @param critical criticality flag to use.  Must be true for this
 *                 extension.
 * @param value a byte array holding the DER-encoded extension value.
 * @exception ClassCastException if value is not an array of bytes
 * @exception IOException on error.
 */
public InhibitAnyPolicyExtension(Boolean critical, Object value)
    throws IOException {

    this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;

    if (!critical.booleanValue())
        throw new IOException("Criticality cannot be false for " +
                              "InhibitAnyPolicy");
    this.critical = critical.booleanValue();

    this.extensionValue = (byte[]) value;
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Integer)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "data not integer");

    if (val.data == null)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "null data");
    int skipCertsValue = val.getInteger();
    if (skipCertsValue < -1)
        throw new IOException("Invalid value for skipCerts");
    if (skipCertsValue == -1) {
        this.skipCerts = Integer.MAX_VALUE;
    } else {
        this.skipCerts = skipCertsValue;
    }
}
 
Example 16
Source File: TimestampToken.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void parse(byte[] timestampTokenInfo) throws IOException {

        DerValue tstInfo = new DerValue(timestampTokenInfo);
        if (tstInfo.tag != DerValue.tag_Sequence) {
            throw new IOException("Bad encoding for timestamp token info");
        }
        // Parse version
        version = tstInfo.data.getInteger();

        // Parse policy
        policy = tstInfo.data.getOID();

        // Parse messageImprint
        DerValue messageImprint = tstInfo.data.getDerValue();
        hashAlgorithm = AlgorithmId.parse(messageImprint.data.getDerValue());
        hashedMessage = messageImprint.data.getOctetString();

        // Parse serialNumber
        serialNumber = tstInfo.data.getBigInteger();

        // Parse genTime
        genTime = tstInfo.data.getGeneralizedTime();

        // Parse optional elements, if present
        while (tstInfo.data.available() > 0) {
            DerValue d = tstInfo.data.getDerValue();
            if (d.tag == DerValue.tag_Integer) {    // must be the nonce
                nonce = d.getBigInteger();
                break;
            }

            // Additional fields:
            // Parse accuracy
            // Parse ordering
            // Parse tsa
            // Parse extensions
        }
    }
 
Example 17
Source File: InhibitAnyPolicyExtension.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the extension from the passed DER encoded value of the same.
 *
 * @param critical criticality flag to use.  Must be true for this
 *                 extension.
 * @param value a byte array holding the DER-encoded extension value.
 * @exception ClassCastException if value is not an array of bytes
 * @exception IOException on error.
 */
public InhibitAnyPolicyExtension(Boolean critical, Object value)
    throws IOException {

    this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;

    if (!critical.booleanValue())
        throw new IOException("Criticality cannot be false for " +
                              "InhibitAnyPolicy");
    this.critical = critical.booleanValue();

    this.extensionValue = (byte[]) value;
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Integer)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "data not integer");

    if (val.data == null)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "null data");
    int skipCertsValue = val.getInteger();
    if (skipCertsValue < -1)
        throw new IOException("Invalid value for skipCerts");
    if (skipCertsValue == -1) {
        this.skipCerts = Integer.MAX_VALUE;
    } else {
        this.skipCerts = skipCertsValue;
    }
}
 
Example 18
Source File: TimestampToken.java    From j2objc with Apache License 2.0 5 votes vote down vote up
private void parse(byte[] timestampTokenInfo) throws IOException {

        DerValue tstInfo = new DerValue(timestampTokenInfo);
        if (tstInfo.tag != DerValue.tag_Sequence) {
            throw new IOException("Bad encoding for timestamp token info");
        }
        // Parse version
        version = tstInfo.data.getInteger();

        // Parse policy
        policy = tstInfo.data.getOID();

        // Parse messageImprint
        DerValue messageImprint = tstInfo.data.getDerValue();
        hashAlgorithm = AlgorithmId.parse(messageImprint.data.getDerValue());
        hashedMessage = messageImprint.data.getOctetString();

        // Parse serialNumber
        serialNumber = tstInfo.data.getBigInteger();

        // Parse genTime
        genTime = tstInfo.data.getGeneralizedTime();

        // Parse optional elements, if present
        while (tstInfo.data.available() > 0) {
            DerValue d = tstInfo.data.getDerValue();
            if (d.tag == DerValue.tag_Integer) {    // must be the nonce
                nonce = d.getBigInteger();
                break;
            }

            // Additional fields:
            // Parse accuracy
            // Parse ordering
            // Parse tsa
            // Parse extensions
        }
    }
 
Example 19
Source File: InhibitAnyPolicyExtension.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the extension from the passed DER encoded value of the same.
 *
 * @param critical criticality flag to use.  Must be true for this
 *                 extension.
 * @param value a byte array holding the DER-encoded extension value.
 * @exception ClassCastException if value is not an array of bytes
 * @exception IOException on error.
 */
public InhibitAnyPolicyExtension(Boolean critical, Object value)
    throws IOException {

    this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;

    if (!critical.booleanValue())
        throw new IOException("Criticality cannot be false for " +
                              "InhibitAnyPolicy");
    this.critical = critical.booleanValue();

    this.extensionValue = (byte[]) value;
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Integer)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "data not integer");

    if (val.data == null)
        throw new IOException("Invalid encoding of InhibitAnyPolicy: "
                              + "null data");
    int skipCertsValue = val.getInteger();
    if (skipCertsValue < -1)
        throw new IOException("Invalid value for skipCerts");
    if (skipCertsValue == -1) {
        this.skipCerts = Integer.MAX_VALUE;
    } else {
        this.skipCerts = skipCertsValue;
    }
}
 
Example 20
Source File: TimestampToken.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void parse(byte[] timestampTokenInfo) throws IOException {

        DerValue tstInfo = new DerValue(timestampTokenInfo);
        if (tstInfo.tag != DerValue.tag_Sequence) {
            throw new IOException("Bad encoding for timestamp token info");
        }
        // Parse version
        version = tstInfo.data.getInteger();

        // Parse policy
        policy = tstInfo.data.getOID();

        // Parse messageImprint
        DerValue messageImprint = tstInfo.data.getDerValue();
        hashAlgorithm = AlgorithmId.parse(messageImprint.data.getDerValue());
        hashedMessage = messageImprint.data.getOctetString();

        // Parse serialNumber
        serialNumber = tstInfo.data.getBigInteger();

        // Parse genTime
        genTime = tstInfo.data.getGeneralizedTime();

        // Parse optional elements, if present
        while (tstInfo.data.available() > 0) {
            DerValue d = tstInfo.data.getDerValue();
            if (d.tag == DerValue.tag_Integer) {    // must be the nonce
                nonce = d.getBigInteger();
                break;
            }

            // Additional fields:
            // Parse accuracy
            // Parse ordering
            // Parse tsa
            // Parse extensions
        }
    }