Java Code Examples for sun.security.util.DerOutputStream#putGeneralizedTime()

The following examples show how to use sun.security.util.DerOutputStream#putGeneralizedTime() . 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: SimpleOCSPServer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private byte[] encodeTbsResponse() throws IOException {
    DerOutputStream outerSeq = new DerOutputStream();
    DerOutputStream tbsStream = new DerOutputStream();

    // Note: We're not going explicitly assert the version
    tbsStream.write(respId.getEncoded());
    tbsStream.putGeneralizedTime(producedAtDate);

    // Sequence of responses
    encodeSingleResponses(tbsStream);

    // TODO: add response extension support
    encodeExtensions(tbsStream);

    outerSeq.write(DerValue.tag_Sequence, tbsStream);
    return outerSeq.toByteArray();
}
 
Example 2
Source File: SimpleOCSPServer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public byte[] getBytes() throws IOException {
    byte[] nullData = { };
    DerOutputStream responseSeq = new DerOutputStream();
    DerOutputStream srStream = new DerOutputStream();

    // Encode the CertId
    certId.encode(srStream);

    // Next, encode the CertStatus field
    CertStatus csiType = csInfo.getType();
    switch (csiType) {
        case CERT_STATUS_GOOD:
            srStream.write(DerValue.createTag(DerValue.TAG_CONTEXT,
                    false, (byte)0), nullData);
            break;
        case CERT_STATUS_REVOKED:
            DerOutputStream revInfo = new DerOutputStream();
            revInfo.putGeneralizedTime(csInfo.getRevocationTime());
            CRLReason revReason = csInfo.getRevocationReason();
            if (revReason != null) {
                byte[] revDer = new byte[3];
                revDer[0] = DerValue.tag_Enumerated;
                revDer[1] = 1;
                revDer[2] = (byte)revReason.ordinal();
                revInfo.write(DerValue.createTag(
                        DerValue.TAG_CONTEXT, true, (byte)0),
                        revDer);
            }
            srStream.write(DerValue.createTag(
                    DerValue.TAG_CONTEXT, true, (byte)1),
                    revInfo);
            break;
        case CERT_STATUS_UNKNOWN:
            srStream.write(DerValue.createTag(DerValue.TAG_CONTEXT,
                    false, (byte)2), nullData);
            break;
        default:
            throw new IOException("Unknown CertStatus: " + csiType);
    }

    // Add the necessary dates
    srStream.putGeneralizedTime(thisUpdate);
    if (lsrNextUpdate != null) {
        DerOutputStream nuStream = new DerOutputStream();
        nuStream.putGeneralizedTime(lsrNextUpdate);
        srStream.write(DerValue.createTag(DerValue.TAG_CONTEXT,
                true, (byte)0), nuStream);
    }

    // TODO add singleResponse Extension support

    // Add the single response to the response output stream
    responseSeq.write(DerValue.tag_Sequence, srStream);
    return responseSeq.toByteArray();
}
 
Example 3
Source File: KerberosTime.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}
 
Example 4
Source File: KerberosTime.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}
 
Example 5
Source File: KerberosTime.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}
 
Example 6
Source File: KerberosTime.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}
 
Example 7
Source File: KerberosTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}
 
Example 8
Source File: KerberosTime.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}
 
Example 9
Source File: KerberosTime.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}
 
Example 10
Source File: KerberosTime.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}
 
Example 11
Source File: KerberosTime.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}
 
Example 12
Source File: KerberosTime.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}
 
Example 13
Source File: KerberosTime.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}
 
Example 14
Source File: KerberosTime.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}
 
Example 15
Source File: KerberosTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Encodes this object to a byte array.
 * @return a byte array of encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream out = new DerOutputStream();
    out.putGeneralizedTime(this.toDate());
    return out.toByteArray();
}