Search in sources :

Example 1 with UTCTime

use of org.mozilla.jss.asn1.UTCTime in project jss by dogtagpki.

the class CertificateInfo method encodeValidityDate.

/**
 * Returns the correct ASN1Value (UTCTime or GeneralizedTime) to represent
 * the given certificate validity date.
 */
private static ASN1Value encodeValidityDate(Date d) {
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    cal.setTime(d);
    if (cal.get(Calendar.YEAR) <= UTCTIME_CUTOFF_YEAR) {
        return new UTCTime(d);
    } else {
        return new GeneralizedTime(d);
    }
}
Also used : UTCTime(org.mozilla.jss.asn1.UTCTime) Calendar(java.util.Calendar) GeneralizedTime(org.mozilla.jss.asn1.GeneralizedTime)

Example 2 with UTCTime

use of org.mozilla.jss.asn1.UTCTime in project jss by dogtagpki.

the class CertTemplate method dateToASN1.

/**
 * Converts a Date into a UTCTime or GeneralizedTime, depending on
 * whether it falls before or after the cutoff date.
 */
private static TimeBase dateToASN1(Date d) {
    if (d == null) {
        return null;
    }
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    cal.setTime(d);
    if (cal.get(Calendar.YEAR) <= UTCTIME_CUTOFF_YEAR) {
        return new UTCTime(d);
    } else {
        return new GeneralizedTime(d);
    }
}
Also used : UTCTime(org.mozilla.jss.asn1.UTCTime) Calendar(java.util.Calendar) GeneralizedTime(org.mozilla.jss.asn1.GeneralizedTime)

Aggregations

Calendar (java.util.Calendar)2 GeneralizedTime (org.mozilla.jss.asn1.GeneralizedTime)2 UTCTime (org.mozilla.jss.asn1.UTCTime)2