本文整理汇总了Java中org.bouncycastle.asn1.ASN1GeneralizedTime类的典型用法代码示例。如果您正苦于以下问题:Java ASN1GeneralizedTime类的具体用法?Java ASN1GeneralizedTime怎么用?Java ASN1GeneralizedTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ASN1GeneralizedTime类属于org.bouncycastle.asn1包,在下文中一共展示了ASN1GeneralizedTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInvalidityDateExtension
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
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);
}
示例2: TSTInfo
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
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;
}
示例3: getInstance
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
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;
}
示例4: getInstance
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
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());
}
示例5: PrivateKeyUsagePeriod
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
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);
}
}
}
示例6: encodeStringValue
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
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);
}
示例7: CrlID
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
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());
}
}
}
示例8: parse
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
@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);
}
}
}
示例9: formatGeneralizedTime
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
/**
* 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);
}
示例10: getInstance
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
/**
* 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());
}
示例11: recoverDate
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
static Date recoverDate(ASN1GeneralizedTime time)
{
try
{
return time.getDate();
}
catch (ParseException e)
{
throw new IllegalStateException("unable to recover date: " + e.getMessage());
}
}
示例12: X509v2AttributeCertificateBuilder
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
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));
}
示例13: setMessageTime
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
/**
* 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;
}
示例14: extractDate
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
static Date extractDate(ASN1GeneralizedTime time)
{
try
{
return time.getDate();
}
catch (Exception e)
{
throw new IllegalStateException("exception processing GeneralizedTime: " + e.getMessage());
}
}
示例15: PersonalData
import org.bouncycastle.asn1.ASN1GeneralizedTime; //导入依赖的package包/类
/**
* 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());
}
}
}