Search in sources :

Example 71 with DerOutputStream

use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.

the class CertificateValidity method encode.

/**
 * Encode the CertificateValidity period in DER form to the stream.
 *
 * @param out the OutputStream to marshal the contents to.
 * @exception IOException on errors.
 */
@Override
public void encode(OutputStream out) throws IOException {
    // null values
    if (notBefore == null || notAfter == null) {
        throw new IOException("CertAttrSet:CertificateValidity:" + " null values to encode.\n");
    }
    try (DerOutputStream pair = new DerOutputStream();
        DerOutputStream seq = new DerOutputStream()) {
        if (notBefore.getTime() < YR_2050) {
            pair.putUTCTime(notBefore);
        } else
            pair.putGeneralizedTime(notBefore);
        if (notAfter.getTime() < YR_2050) {
            pair.putUTCTime(notAfter);
        } else {
            pair.putGeneralizedTime(notAfter);
        }
        seq.write(DerValue.tag_Sequence, pair);
        out.write(seq.toByteArray());
    }
}
Also used : DerOutputStream(org.mozilla.jss.netscape.security.util.DerOutputStream) IOException(java.io.IOException)

Example 72 with DerOutputStream

use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.

the class CertificateX509Key method encode.

/**
 * Encode the key in DER form to the stream.
 *
 * @param out the OutputStream to marshal the contents to.
 * @exception IOException on errors.
 */
@Override
public void encode(OutputStream out) throws IOException {
    DerOutputStream tmp = new DerOutputStream();
    key.encode(tmp);
    out.write(tmp.toByteArray());
}
Also used : DerOutputStream(org.mozilla.jss.netscape.security.util.DerOutputStream)

Example 73 with DerOutputStream

use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.

the class FreshestCRLExtension method encode.

/**
 * DER-encodes this extension to the given OutputStream.
 */
@Override
public void encode(OutputStream ostream) throws CertificateException, IOException {
    if (cachedEncoding == null) {
        // only re-encode if necessary
        DerOutputStream tmp = new DerOutputStream();
        encode(tmp);
        cachedEncoding = tmp.toByteArray();
    }
    ostream.write(cachedEncoding);
}
Also used : DerOutputStream(org.mozilla.jss.netscape.security.util.DerOutputStream)

Example 74 with DerOutputStream

use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.

the class CertificatePolicyMap method encode.

/**
 * Write the CertificatePolicyMap to the DerOutputStream.
 *
 * @param out the DerOutputStream to write the object to.
 * @exception IOException on errors.
 */
public void encode(DerOutputStream out) throws IOException {
    DerOutputStream tmp = new DerOutputStream();
    issuerDomain.encode(tmp);
    subjectDomain.encode(tmp);
    out.write(DerValue.tag_Sequence, tmp);
}
Also used : DerOutputStream(org.mozilla.jss.netscape.security.util.DerOutputStream)

Example 75 with DerOutputStream

use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.

the class CertificateSerialNumber method encode.

/**
 * Encode the serial number in DER form to the stream.
 *
 * @param out the DerOutputStream to marshal the contents to.
 * @exception IOException on errors.
 */
@Override
public void encode(OutputStream out) throws IOException {
    DerOutputStream tmp = new DerOutputStream();
    serial.encode(tmp);
    out.write(tmp.toByteArray());
}
Also used : DerOutputStream(org.mozilla.jss.netscape.security.util.DerOutputStream)

Aggregations

DerOutputStream (org.mozilla.jss.netscape.security.util.DerOutputStream)141 IOException (java.io.IOException)37 BigInt (org.mozilla.jss.netscape.security.util.BigInt)13 DerValue (org.mozilla.jss.netscape.security.util.DerValue)8 ObjectIdentifier (org.mozilla.jss.netscape.security.util.ObjectIdentifier)8 CRLException (java.security.cert.CRLException)7 CertificateException (java.security.cert.CertificateException)7 InvalidKeyException (java.security.InvalidKeyException)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 ANY (org.mozilla.jss.asn1.ANY)5 InvalidBERException (org.mozilla.jss.asn1.InvalidBERException)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 KeyFactory (java.security.KeyFactory)3 SignatureException (java.security.SignatureException)3 CertificateEncodingException (java.security.cert.CertificateEncodingException)3 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)3 NoSuchProviderException (java.security.NoSuchProviderException)2 Provider (java.security.Provider)2 PublicKey (java.security.PublicKey)2