Search in sources :

Example 6 with DerOutputStream

use of sun.security.util.DerOutputStream in project j2objc by google.

the class IssuingDistributionPointExtension method encode.

/**
     * Encodes the issuing distribution point extension and writes it to the
     * DerOutputStream.
     *
     * @param out the output stream.
     * @exception IOException on encoding error.
     */
public void encode(OutputStream out) throws IOException {
    DerOutputStream tmp = new DerOutputStream();
    if (this.extensionValue == null) {
        this.extensionId = PKIXExtensions.IssuingDistributionPoint_Id;
        this.critical = false;
        encodeThis();
    }
    super.encode(tmp);
    out.write(tmp.toByteArray());
}
Also used : DerOutputStream(sun.security.util.DerOutputStream)

Example 7 with DerOutputStream

use of sun.security.util.DerOutputStream in project j2objc by google.

the class IssuingDistributionPointExtension method encodeThis.

// Encodes this extension value
private void encodeThis() throws IOException {
    if (distributionPoint == null && revocationReasons == null && !hasOnlyUserCerts && !hasOnlyCACerts && !hasOnlyAttributeCerts && !isIndirectCRL) {
        this.extensionValue = null;
        return;
    }
    DerOutputStream tagged = new DerOutputStream();
    if (distributionPoint != null) {
        DerOutputStream tmp = new DerOutputStream();
        distributionPoint.encode(tmp);
        tagged.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT, true, TAG_DISTRIBUTION_POINT), tmp);
    }
    if (hasOnlyUserCerts) {
        DerOutputStream tmp = new DerOutputStream();
        tmp.putBoolean(hasOnlyUserCerts);
        tagged.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT, false, TAG_ONLY_USER_CERTS), tmp);
    }
    if (hasOnlyCACerts) {
        DerOutputStream tmp = new DerOutputStream();
        tmp.putBoolean(hasOnlyCACerts);
        tagged.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT, false, TAG_ONLY_CA_CERTS), tmp);
    }
    if (revocationReasons != null) {
        DerOutputStream tmp = new DerOutputStream();
        revocationReasons.encode(tmp);
        tagged.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT, false, TAG_ONLY_SOME_REASONS), tmp);
    }
    if (isIndirectCRL) {
        DerOutputStream tmp = new DerOutputStream();
        tmp.putBoolean(isIndirectCRL);
        tagged.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT, false, TAG_INDIRECT_CRL), tmp);
    }
    if (hasOnlyAttributeCerts) {
        DerOutputStream tmp = new DerOutputStream();
        tmp.putBoolean(hasOnlyAttributeCerts);
        tagged.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT, false, TAG_ONLY_ATTRIBUTE_CERTS), tmp);
    }
    DerOutputStream seq = new DerOutputStream();
    seq.write(DerValue.tag_Sequence, tagged);
    this.extensionValue = seq.toByteArray();
}
Also used : DerOutputStream(sun.security.util.DerOutputStream)

Example 8 with DerOutputStream

use of sun.security.util.DerOutputStream in project j2objc by google.

the class AuthorityInfoAccessExtension method encode.

/**
     * Write the extension to the DerOutputStream.
     *
     * @param out the DerOutputStream to write the extension to.
     * @exception IOException on encoding errors.
     */
public void encode(OutputStream out) throws IOException {
    DerOutputStream tmp = new DerOutputStream();
    if (this.extensionValue == null) {
        this.extensionId = PKIXExtensions.AuthInfoAccess_Id;
        this.critical = false;
        encodeThis();
    }
    super.encode(tmp);
    out.write(tmp.toByteArray());
}
Also used : DerOutputStream(sun.security.util.DerOutputStream)

Example 9 with DerOutputStream

use of sun.security.util.DerOutputStream in project j2objc by google.

the class PKCS9Attributes method generateDerEncoding.

private byte[] generateDerEncoding() throws IOException {
    DerOutputStream out = new DerOutputStream();
    Object[] attribVals = attributes.values().toArray();
    out.putOrderedSetOf(DerValue.tag_SetOf, castToDerEncoder(attribVals));
    return out.toByteArray();
}
Also used : DerOutputStream(sun.security.util.DerOutputStream)

Example 10 with DerOutputStream

use of sun.security.util.DerOutputStream in project j2objc by google.

the class DistributionPoint method encode.

/**
     * Write the DistributionPoint value to the DerOutputStream.
     *
     * @param out the DerOutputStream to write the extension to.
     * @exception IOException on error.
     */
public void encode(DerOutputStream out) throws IOException {
    DerOutputStream tagged = new DerOutputStream();
    // NOTE: only one of pointNames and pointRDN can be set
    if ((fullName != null) || (relativeName != null)) {
        DerOutputStream distributionPoint = new DerOutputStream();
        if (fullName != null) {
            DerOutputStream derOut = new DerOutputStream();
            fullName.encode(derOut);
            distributionPoint.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT, true, TAG_FULL_NAME), derOut);
        } else if (relativeName != null) {
            DerOutputStream derOut = new DerOutputStream();
            relativeName.encode(derOut);
            distributionPoint.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT, true, TAG_REL_NAME), derOut);
        }
        tagged.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, TAG_DIST_PT), distributionPoint);
    }
    if (reasonFlags != null) {
        DerOutputStream reasons = new DerOutputStream();
        BitArray rf = new BitArray(reasonFlags);
        reasons.putTruncatedUnalignedBitString(rf);
        tagged.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT, false, TAG_REASONS), reasons);
    }
    if (crlIssuer != null) {
        DerOutputStream issuer = new DerOutputStream();
        crlIssuer.encode(issuer);
        tagged.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT, true, TAG_ISSUER), issuer);
    }
    out.write(DerValue.tag_Sequence, tagged);
}
Also used : DerOutputStream(sun.security.util.DerOutputStream) BitArray(sun.security.util.BitArray)

Aggregations

DerOutputStream (sun.security.util.DerOutputStream)79 IOException (java.io.IOException)9 DerValue (sun.security.util.DerValue)8 ObjectIdentifier (sun.security.util.ObjectIdentifier)6 CertificateException (java.security.cert.CertificateException)5 BitArray (sun.security.util.BitArray)5 X509Certificate (java.security.cert.X509Certificate)4 AlgorithmId (sun.security.x509.AlgorithmId)4 KeyStoreException (java.security.KeyStoreException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 UnrecoverableEntryException (java.security.UnrecoverableEntryException)3 UnrecoverableKeyException (java.security.UnrecoverableKeyException)3 CertificateEncodingException (java.security.cert.CertificateEncodingException)3 Date (java.util.Date)3 SecretKey (javax.crypto.SecretKey)3 DestroyFailedException (javax.security.auth.DestroyFailedException)3 ContentInfo (sun.security.pkcs.ContentInfo)3 DerInputStream (sun.security.util.DerInputStream)3 PolicyQualifierInfo (java.security.cert.PolicyQualifierInfo)2 X509CertSelector (java.security.cert.X509CertSelector)2