private static ASN1Sequence createInvalidityDateExtension(ASN1GeneralizedTime invalidityDate) { ASN1EncodableVector v = new ASN1EncodableVector(); try { v.add(Extension.invalidityDate); v.add(new DEROctetString(invalidityDate.getEncoded())); } catch (IOException e) { throw new IllegalArgumentException("error encoding reason: " + e); } return new DERSequence(v); }
public TSTInfo(ASN1ObjectIdentifier tsaPolicyId, MessageImprint messageImprint, ASN1Integer serialNumber, ASN1GeneralizedTime genTime, Accuracy accuracy, ASN1Boolean ordering, ASN1Integer nonce, GeneralName tsa, Extensions extensions) { version = new ASN1Integer(1); this.tsaPolicyId = tsaPolicyId; this.messageImprint = messageImprint; this.serialNumber = serialNumber; this.genTime = genTime; this.accuracy = accuracy; this.ordering = ordering; this.nonce = nonce; this.tsa = tsa; this.extensions = extensions; }
public static DVCSTime getInstance(Object obj) { if (obj instanceof DVCSTime) { return (DVCSTime)obj; } else if (obj instanceof ASN1GeneralizedTime) { return new DVCSTime(ASN1GeneralizedTime.getInstance(obj)); } else if (obj != null) { return new DVCSTime(ContentInfo.getInstance(obj)); } return null; }
public static Time getInstance( Object obj) { if (obj == null || obj instanceof Time) { return (Time)obj; } else if (obj instanceof ASN1UTCTime) { return new Time((ASN1UTCTime)obj); } else if (obj instanceof ASN1GeneralizedTime) { return new Time((ASN1GeneralizedTime)obj); } throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName()); }
private PrivateKeyUsagePeriod(ASN1Sequence seq) { Enumeration en = seq.getObjects(); while (en.hasMoreElements()) { ASN1TaggedObject tObj = (ASN1TaggedObject)en.nextElement(); if (tObj.getTagNo() == 0) { _notBefore = ASN1GeneralizedTime.getInstance(tObj, false); } else if (tObj.getTagNo() == 1) { _notAfter = ASN1GeneralizedTime.getInstance(tObj, false); } } }
protected ASN1Encodable encodeStringValue(ASN1ObjectIdentifier oid, String value) { if (oid.equals(EmailAddress) || oid.equals(DC)) { return new DERIA5String(value); } else if (oid.equals(DATE_OF_BIRTH)) // accept time string as well as # (for compatibility) { return new ASN1GeneralizedTime(value); } else if (oid.equals(C) || oid.equals(SN) || oid.equals(DN_QUALIFIER) || oid.equals(TELEPHONE_NUMBER)) { return new DERPrintableString(value); } return super.encodeStringValue(oid, value); }
private CrlID( ASN1Sequence seq) { Enumeration e = seq.getObjects(); while (e.hasMoreElements()) { ASN1TaggedObject o = (ASN1TaggedObject)e.nextElement(); switch (o.getTagNo()) { case 0: crlUrl = DERIA5String.getInstance(o, true); break; case 1: crlNum = ASN1Integer.getInstance(o, true); break; case 2: crlTime = ASN1GeneralizedTime.getInstance(o, true); break; default: throw new IllegalArgumentException( "unknown tag number: " + o.getTagNo()); } } }
@Override public void parse(ASN1Primitive derObject) { if (derObject instanceof ASN1GeneralizedTime) { ASN1GeneralizedTime derGeneralizedTime = (ASN1GeneralizedTime) derObject; try { this.setTime(derGeneralizedTime.getDate()); } catch (ParseException ex) { this.setTime(null); } } else if (derObject instanceof DERUTCTime) { DERUTCTime derUTCTime = (DERUTCTime) derObject; try { this.setTime(derUTCTime.getDate()); } catch (ParseException exception) { this.setTime(null); } } }
/** * Get a formatted string value for the supplied generalized time object. * * @param time Generalized time * @return Formatted string * @throws ParseException If there is a problem formatting the generalized time */ private String formatGeneralizedTime(ASN1GeneralizedTime time) throws ParseException { // Get generalized time as a string String sTime = time.getTime(); // Setup date formatter with expected date format of string DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssz"); // Create date object from string using formatter Date date = dateFormat.parse(sTime); // Re-format date - include time zone sTime = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(date); return escapeHtml(sTime); }
/** * Return a Time object from the given object. * <p> * Accepted inputs: * <ul> * <li> null → null * <li> {@link Time} object * <li> {@link org.bouncycastle.asn1.DERUTCTime DERUTCTime} object * <li> {@link org.bouncycastle.asn1.DERGeneralizedTime DERGeneralizedTime} object * </ul> * * @param obj the object we want converted. * @exception IllegalArgumentException if the object cannot be converted. */ public static Time getInstance( Object obj) { if (obj == null || obj instanceof Time) { return (Time)obj; } else if (obj instanceof ASN1UTCTime) { return new Time((ASN1UTCTime)obj); } else if (obj instanceof ASN1GeneralizedTime) { return new Time((ASN1GeneralizedTime)obj); } throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName()); }
static Date recoverDate(ASN1GeneralizedTime time) { try { return time.getDate(); } catch (ParseException e) { throw new IllegalStateException("unable to recover date: " + e.getMessage()); } }
public X509v2AttributeCertificateBuilder(AttributeCertificateHolder holder, AttributeCertificateIssuer issuer, BigInteger serialNumber, Date notBefore, Date notAfter) { acInfoGen = new V2AttributeCertificateInfoGenerator(); extGenerator = new ExtensionsGenerator(); acInfoGen.setHolder(holder.holder); acInfoGen.setIssuer(AttCertIssuer.getInstance(issuer.form)); acInfoGen.setSerialNumber(new ASN1Integer(serialNumber)); acInfoGen.setStartDate(new ASN1GeneralizedTime(notBefore)); acInfoGen.setEndDate(new ASN1GeneralizedTime(notAfter)); }
/** * Set the creation time for the new message. * * @param time the message creation time. * @return the current builder instance. */ public ProtectedPKIMessageBuilder setMessageTime(Date time) { hdrBuilder.setMessageTime(new ASN1GeneralizedTime(time)); return this; }
static Date extractDate(ASN1GeneralizedTime time) { try { return time.getDate(); } catch (Exception e) { throw new IllegalStateException("exception processing GeneralizedTime: " + e.getMessage()); } }
/** * Constructor from ASN1Sequence. * <p/> * The sequence is of type NameOrPseudonym: * <p/> * <pre> * PersonalData ::= SEQUENCE { * nameOrPseudonym NameOrPseudonym, * nameDistinguisher [0] INTEGER OPTIONAL, * dateOfBirth [1] GeneralizedTime OPTIONAL, * placeOfBirth [2] DirectoryString OPTIONAL, * gender [3] PrintableString OPTIONAL, * postalAddress [4] DirectoryString OPTIONAL * } * </pre> * * @param seq The ASN.1 sequence. */ private PersonalData(ASN1Sequence seq) { if (seq.size() < 1) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } Enumeration e = seq.getObjects(); nameOrPseudonym = NameOrPseudonym.getInstance(e.nextElement()); while (e.hasMoreElements()) { ASN1TaggedObject o = ASN1TaggedObject.getInstance(e.nextElement()); int tag = o.getTagNo(); switch (tag) { case 0: nameDistinguisher = ASN1Integer.getInstance(o, false).getValue(); break; case 1: dateOfBirth = ASN1GeneralizedTime.getInstance(o, false); break; case 2: placeOfBirth = DirectoryString.getInstance(o, true); break; case 3: gender = DERPrintableString.getInstance(o, false).getString(); break; case 4: postalAddress = DirectoryString.getInstance(o, true); break; default: throw new IllegalArgumentException("Bad tag number: " + o.getTagNo()); } } }
/** * Constructor from a given details. * * @param nameOrPseudonym Name or pseudonym. * @param nameDistinguisher Name distinguisher. * @param dateOfBirth Date of birth. * @param placeOfBirth Place of birth. * @param gender Gender. * @param postalAddress Postal Address. */ public PersonalData(NameOrPseudonym nameOrPseudonym, BigInteger nameDistinguisher, ASN1GeneralizedTime dateOfBirth, DirectoryString placeOfBirth, String gender, DirectoryString postalAddress) { this.nameOrPseudonym = nameOrPseudonym; this.dateOfBirth = dateOfBirth; this.gender = gender; this.nameDistinguisher = nameDistinguisher; this.postalAddress = postalAddress; this.placeOfBirth = placeOfBirth; }
private AttCertValidityPeriod( ASN1Sequence seq) { if (seq.size() != 2) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } notBeforeTime = ASN1GeneralizedTime.getInstance(seq.getObjectAt(0)); notAfterTime = ASN1GeneralizedTime.getInstance(seq.getObjectAt(1)); }
/** * @param notBeforeTime * @param notAfterTime */ public AttCertValidityPeriod( ASN1GeneralizedTime notBeforeTime, ASN1GeneralizedTime notAfterTime) { this.notBeforeTime = notBeforeTime; this.notAfterTime = notAfterTime; }
public ASN1GeneralizedTime getDateOfBirth() { if (declaration.getTagNo() != 2) { return null; } return ASN1GeneralizedTime.getInstance(declaration, false); }
private OcspIdentifier(ASN1Sequence seq) { if (seq.size() != 2) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } this.ocspResponderID = ResponderID.getInstance(seq.getObjectAt(0)); this.producedAt = (ASN1GeneralizedTime)seq.getObjectAt(1); }
public KEKIdentifier( byte[] keyIdentifier, ASN1GeneralizedTime date, OtherKeyAttribute other) { this.keyIdentifier = new DEROctetString(keyIdentifier); this.date = date; this.other = other; }
/** * @deprecated use ASN1GeneralizedTime */ public PKIHeaderBuilder setMessageTime(DERGeneralizedTime time) { messageTime = ASN1GeneralizedTime.getInstance(time); return this; }
private RevAnnContent(ASN1Sequence seq) { status = PKIStatus.getInstance(seq.getObjectAt(0)); certId = CertId.getInstance(seq.getObjectAt(1)); willBeRevokedAt = ASN1GeneralizedTime.getInstance(seq.getObjectAt(2)); badSinceDate = ASN1GeneralizedTime.getInstance(seq.getObjectAt(3)); if (seq.size() > 4) { crlDetails = Extensions.getInstance(seq.getObjectAt(4)); } }
public ASN1Encodable stringToValue(ASN1ObjectIdentifier oid, String value) { if (value.length() != 0 && value.charAt(0) == '#') { try { return IETFUtils.valueFromHexString(value, 1); } catch (IOException e) { throw new RuntimeException("can't recode value for oid " + oid.getId()); } } else { if (value.length() != 0 && value.charAt(0) == '\\') { value = value.substring(1); } if (oid.equals(EmailAddress) || oid.equals(DC)) { return new DERIA5String(value); } else if (oid.equals(DATE_OF_BIRTH)) // accept time string as well as # (for compatibility) { return new ASN1GeneralizedTime(value); } else if (oid.equals(C) || oid.equals(SN) || oid.equals(DN_QUALIFIER) || oid.equals(TELEPHONE_NUMBER)) { return new DERPrintableString(value); } } return new DERUTF8String(value); }
public ResponseData( ASN1Integer version, ResponderID responderID, ASN1GeneralizedTime producedAt, ASN1Sequence responses, Extensions responseExtensions) { this.version = version; this.responderID = responderID; this.producedAt = producedAt; this.responses = responses; this.responseExtensions = responseExtensions; }
/** * @deprecated use method taking Extensions * @param responderID * @param producedAt * @param responses * @param responseExtensions */ public ResponseData( ResponderID responderID, DERGeneralizedTime producedAt, ASN1Sequence responses, X509Extensions responseExtensions) { this(V1, responderID, ASN1GeneralizedTime.getInstance(producedAt), responses, Extensions.getInstance(responseExtensions)); }
public ResponseData( ResponderID responderID, ASN1GeneralizedTime producedAt, ASN1Sequence responses, Extensions responseExtensions) { this(V1, responderID, producedAt, responses, responseExtensions); }
private ResponseData( ASN1Sequence seq) { int index = 0; if (seq.getObjectAt(0) instanceof ASN1TaggedObject) { ASN1TaggedObject o = (ASN1TaggedObject)seq.getObjectAt(0); if (o.getTagNo() == 0) { this.versionPresent = true; this.version = ASN1Integer.getInstance( (ASN1TaggedObject)seq.getObjectAt(0), true); index++; } else { this.version = V1; } } else { this.version = V1; } this.responderID = ResponderID.getInstance(seq.getObjectAt(index++)); this.producedAt = ASN1GeneralizedTime.getInstance(seq.getObjectAt(index++)); this.responses = (ASN1Sequence)seq.getObjectAt(index++); if (seq.size() > index) { this.responseExtensions = Extensions.getInstance( (ASN1TaggedObject)seq.getObjectAt(index), true); } }
public RevokedInfo( ASN1GeneralizedTime revocationTime, CRLReason revocationReason) { this.revocationTime = revocationTime; this.revocationReason = revocationReason; }
private RevokedInfo( ASN1Sequence seq) { this.revocationTime = ASN1GeneralizedTime.getInstance(seq.getObjectAt(0)); if (seq.size() > 1) { this.revocationReason = CRLReason.getInstance(DEREnumerated.getInstance( (ASN1TaggedObject)seq.getObjectAt(1), true)); } }
/** * @deprecated use method taking ASN1GeneralizedTime and Extensions * @param certID * @param certStatus * @param thisUpdate * @param nextUpdate * @param singleExtensions */ public SingleResponse( CertID certID, CertStatus certStatus, DERGeneralizedTime thisUpdate, DERGeneralizedTime nextUpdate, Extensions singleExtensions) { this(certID, certStatus, ASN1GeneralizedTime.getInstance(thisUpdate), ASN1GeneralizedTime.getInstance(nextUpdate), Extensions.getInstance(singleExtensions)); }
public SingleResponse( CertID certID, CertStatus certStatus, ASN1GeneralizedTime thisUpdate, ASN1GeneralizedTime nextUpdate, Extensions singleExtensions) { this.certID = certID; this.certStatus = certStatus; this.thisUpdate = thisUpdate; this.nextUpdate = nextUpdate; this.singleExtensions = singleExtensions; }
private SingleResponse( ASN1Sequence seq) { this.certID = CertID.getInstance(seq.getObjectAt(0)); this.certStatus = CertStatus.getInstance(seq.getObjectAt(1)); this.thisUpdate = ASN1GeneralizedTime.getInstance(seq.getObjectAt(2)); if (seq.size() > 4) { this.nextUpdate = ASN1GeneralizedTime.getInstance( (ASN1TaggedObject)seq.getObjectAt(3), true); this.singleExtensions = Extensions.getInstance( (ASN1TaggedObject)seq.getObjectAt(4), true); } else if (seq.size() > 3) { ASN1TaggedObject o = (ASN1TaggedObject)seq.getObjectAt(3); if (o.getTagNo() == 0) { this.nextUpdate = ASN1GeneralizedTime.getInstance(o, true); } else { this.singleExtensions = Extensions.getInstance(o, true); } } }