ASN1Primitive toDERObject() { return new DERGeneralizedTime(time); }
public ObjectStoreData(AlgorithmIdentifier integrityAlgorithm, Date creationDate, Date lastModifiedDate, ObjectDataSequence objectDataSequence, String comment) { this.version = BigInteger.valueOf(1); this.integrityAlgorithm = integrityAlgorithm; this.creationDate = new DERGeneralizedTime(creationDate); this.lastModifiedDate = new DERGeneralizedTime(lastModifiedDate); this.objectDataSequence = objectDataSequence; this.comment = comment; }
public ObjectData(BigInteger type, String identifier, Date creationDate, Date lastModifiedDate, byte[] data, String comment) { this.type = type; this.identifier = identifier; this.creationDate = new DERGeneralizedTime(creationDate); this.lastModifiedDate = new DERGeneralizedTime(lastModifiedDate); this.data = new DEROctetString(Arrays.clone(data)); this.comment = comment; }
/** * Creates a time object from a given date - if the date is between 1950 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime * is used. * * @param time a date object representing the time of interest. */ public Time( Date time) { SimpleTimeZone tz = new SimpleTimeZone(0, "Z"); SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmss"); dateF.setTimeZone(tz); String d = dateF.format(time) + "Z"; int year = Integer.parseInt(d.substring(0, 4)); if (year < 1950 || year > 2049) { this.time = new DERGeneralizedTime(d); } else { this.time = new DERUTCTime(d.substring(2)); } }
/** * Creates a time object from a given date - if the date is between 1950 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime * is used. * * @param time a date object representing the time of interest. */ public Time( Date time) { SimpleTimeZone tz = new SimpleTimeZone(0, "Z"); SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmss"); dateF.setTimeZone(tz); String d = dateF.format(time) + "Z"; int year = Integer.parseInt(d.substring(0, 4)); if (year < 1950 || year > 2049) { this.time = new DERGeneralizedTime(d); } else { this.time = new DERUTCTime(d.substring(2)); } }
/** * Creates a time object from a given date - if the date is between 1950 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime * is used. * * @param time a date object representing the time of interest. */ public Time( Date time) { SimpleTimeZone tz = new SimpleTimeZone(0, "Z"); SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmss"); dateF.setTimeZone(tz); String d = dateF.format(time) + "Z"; int year = Integer.parseInt(d.substring(0, 4)); if (year < 1950 || year > 2049) { this.time = new DERGeneralizedTime(d); } else { this.time = new DERUTCTime(d.substring(2)); } }
/** * Creates a time object from a given date - if the date is between 1950 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime * is used. * * @param time a date object representing the time of interest. */ public Time( Date time) { SimpleTimeZone tz = new SimpleTimeZone(0, "Z"); SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmss"); dateF.setTimeZone(tz); String d = dateF.format(time) + "Z"; int year = Integer.parseInt(d.substring(0, 4)); if (year < 1950 || year > 2049) { this.time = new DERGeneralizedTime(d); } else { this.time = new DERUTCTime(d.substring(2)); } }
/** * Creates a time object from a given date and locale - if the date is between 1950 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime * is used. You may need to use this constructor if the default locale * doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations. * * @param time a date object representing the time of interest. * @param locale an appropriate Locale for producing an ASN.1 GeneralizedTime value. */ public Time( Date time, Locale locale) { SimpleTimeZone tz = new SimpleTimeZone(0, "Z"); SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmss", locale); dateF.setTimeZone(tz); String d = dateF.format(time) + "Z"; int year = Integer.parseInt(d.substring(0, 4)); if (year < 1950 || year > 2049) { this.time = new DERGeneralizedTime(d); } else { this.time = new DERUTCTime(d.substring(2)); } }
/** * Creates a time object from a given date and locale - if the date is between 1950 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime * is used. You may need to use this constructor if the default locale * doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations. * * @param time a date object representing the time of interest. * @param locale an appropriate Locale for producing an ASN.1 GeneralizedTime value. */ public Time( Date time, Locale locale) { SimpleTimeZone tz = new SimpleTimeZone(0, "Z"); SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmss", locale); dateF.setTimeZone(tz); String d = dateF.format(time) + "Z"; int year = Integer.parseInt(d.substring(0, 4)); if (year < 1950 || year > 2049) { this.time = new DERGeneralizedTime(d); } else { this.time = new DERUTCTime(d.substring(2)); } }
/** * Creates a time object from a given date and locale - if the date is between 1950 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime * is used. You may need to use this constructor if the default locale * doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations. * * @param time a date object representing the time of interest. * @param locale an appropriate Locale for producing an ASN.1 GeneralizedTime value. */ public Time( Date time, Locale locale) { SimpleTimeZone tz = new SimpleTimeZone(0, "Z"); SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmss", locale); dateF.setTimeZone(tz); String d = dateF.format(time) + "Z"; int year = Integer.parseInt(d.substring(0, 4)); if (year < 1950 || year > 2049) { this.time = new DERGeneralizedTime(d); } else { this.time = new DERUTCTime(d.substring(2)); } }
/** * Creates a time object from a given date and locale - if the date is between 1950 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime * is used. You may need to use this constructor if the default locale * doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations. * * @param time a date object representing the time of interest. * @param locale an appropriate Locale for producing an ASN.1 GeneralizedTime value. */ public Time( Date time, Locale locale) { SimpleTimeZone tz = new SimpleTimeZone(0, "Z"); SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmss", locale); dateF.setTimeZone(tz); String d = dateF.format(time) + "Z"; int year = Integer.parseInt(d.substring(0, 4)); if (year < 1950 || year > 2049) { this.time = new DERGeneralizedTime(d); } else { this.time = new DERUTCTime(d.substring(2)); } }
private static RDN createDateOfBirthRdn(ASN1ObjectIdentifier type, ASN1Encodable rdnValue) throws BadCertTemplateException { Args.notNull(type, "type"); String text; ASN1Encodable newRdnValue = null; if (rdnValue instanceof ASN1GeneralizedTime) { text = ((ASN1GeneralizedTime) rdnValue).getTimeString(); newRdnValue = rdnValue; } else if (rdnValue instanceof ASN1String && !(rdnValue instanceof DERUniversalString)) { text = ((ASN1String) rdnValue).getString(); } else { throw new BadCertTemplateException("Value of RDN dateOfBirth has incorrect syntax"); } if (!SubjectDnSpec.PATTERN_DATE_OF_BIRTH.matcher(text).matches()) { throw new BadCertTemplateException( "Value of RDN dateOfBirth does not have format YYYMMDD000000Z"); } if (newRdnValue == null) { newRdnValue = new DERGeneralizedTime(text); } return new RDN(type, newRdnValue); }
private void okPressed() { Date notBefore = jdtNotBefore.getDateTime(); Date notAfter = jdtNotAfter.getDateTime(); if ((notBefore == null) && (notAfter == null)) { JOptionPane.showMessageDialog(this, res.getString("DPrivateKeyUsagePeriod.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } // BC forgot the value constructor for PrivateKeyUsagePeriod... ASN1EncodableVector v = new ASN1EncodableVector(); if (notBefore != null) { DERGeneralizedTime notBeforeGenTime = new DERGeneralizedTime(notBefore); v.add(new DERTaggedObject(false, 0, notBeforeGenTime)); } if (notAfter != null) { DERGeneralizedTime notAfterGenTime = new DERGeneralizedTime(notAfter); v.add(new DERTaggedObject(false, 1, notAfterGenTime)); } PrivateKeyUsagePeriod privateKeyUsagePeriod = PrivateKeyUsagePeriod.getInstance(new DERSequence(v)); try { value = privateKeyUsagePeriod.getEncoded(ASN1Encoding.DER); } catch (IOException e) { DError.displayError(this, e); return; } closeDialog(); }
return new DERGeneralizedTime(value);
return new DERGeneralizedTime(value);
vec.add(new DERTaggedObject(false, 0, new DERGeneralizedTime(notBefore))); vec.add(new DERTaggedObject(false, 1, new DERGeneralizedTime(tmpNotAfter))); ExtensionValue extValue = new ExtensionValue(extensionControls.get(type).isCritical(), new DERSequence(vec));
vec.add(new DERTaggedObject(false, 0, new DERGeneralizedTime(notBefore))); vec.add(new DERTaggedObject(false, 1, new DERGeneralizedTime(tmpNotAfter))); ExtensionValue extValue = new ExtensionValue(extensionControls.get(type).isCritical(), new DERSequence(vec));