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

The following examples show how to use sun.security.util.DerOutputStream#putUTCTime() . 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: LocaleInTime.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}
 
Example 2
Source File: LocaleInTime.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}
 
Example 3
Source File: LocaleInTime.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}
 
Example 4
Source File: LocaleInTime.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}
 
Example 5
Source File: LocaleInTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}
 
Example 6
Source File: CertificateBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Encode the bytes for the TBSCertificate structure:
 * <PRE>
 *  TBSCertificate  ::=  SEQUENCE  {
 *      version         [0]  EXPLICIT Version DEFAULT v1,
 *      serialNumber         CertificateSerialNumber,
 *      signature            AlgorithmIdentifier,
 *      issuer               Name,
 *      validity             Validity,
 *      subject              Name,
 *      subjectPublicKeyInfo SubjectPublicKeyInfo,
 *      issuerUniqueID  [1]  IMPLICIT UniqueIdentifier OPTIONAL,
 *                        -- If present, version MUST be v2 or v3
 *      subjectUniqueID [2]  IMPLICIT UniqueIdentifier OPTIONAL,
 *                        -- If present, version MUST be v2 or v3
 *      extensions      [3]  EXPLICIT Extensions OPTIONAL
 *                        -- If present, version MUST be v3
 *      }
 *
 * @param issuerCert The certificate of the issuing authority, or
 * {@code null} if the resulting certificate is self-signed.
 * @param signAlg The signature algorithm object
 *
 * @return The DER-encoded bytes for the TBSCertificate structure
 *
 * @throws IOException if an encoding error occurs.
 */
private byte[] encodeTbsCert(X509Certificate issuerCert,
        AlgorithmId signAlg) throws IOException {
    DerOutputStream tbsCertSeq = new DerOutputStream();
    DerOutputStream tbsCertItems = new DerOutputStream();

    // Hardcode to V3
    byte[] v3int = {0x02, 0x01, 0x02};
    tbsCertItems.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
            (byte)0), v3int);

    // Serial Number
    SerialNumber sn = new SerialNumber(serialNumber);
    sn.encode(tbsCertItems);

    // Algorithm ID
    signAlg.derEncode(tbsCertItems);

    // Issuer Name
    if (issuerCert != null) {
        tbsCertItems.write(
                issuerCert.getSubjectX500Principal().getEncoded());
    } else {
        // Self-signed
        tbsCertItems.write(subjectName.getEncoded());
    }

    // Validity period (set as UTCTime)
    DerOutputStream valSeq = new DerOutputStream();
    valSeq.putUTCTime(notBefore);
    valSeq.putUTCTime(notAfter);
    tbsCertItems.write(DerValue.tag_Sequence, valSeq);

    // Subject Name
    tbsCertItems.write(subjectName.getEncoded());

    // SubjectPublicKeyInfo
    tbsCertItems.write(publicKey.getEncoded());

    // TODO: Extensions!
    encodeExtensions(tbsCertItems);

    // Wrap it all up in a SEQUENCE and return the bytes
    tbsCertSeq.write(DerValue.tag_Sequence, tbsCertItems);
    return tbsCertSeq.toByteArray();
}
 
Example 7
Source File: LocaleInTime.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}
 
Example 8
Source File: LocaleInTime.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}
 
Example 9
Source File: LocaleInTime.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}
 
Example 10
Source File: LocaleInTime.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}
 
Example 11
Source File: LocaleInTime.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}
 
Example 12
Source File: LocaleInTime.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}
 
Example 13
Source File: LocaleInTime.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}
 
Example 14
Source File: LocaleInTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    DerOutputStream out = new DerOutputStream();
    out.putUTCTime(new Date());
    DerValue val = new DerValue(out.toByteArray());
    System.out.println(val.getUTCTime());
}