本文整理汇总了Java中org.bouncycastle.asn1.ASN1UTCTime类的典型用法代码示例。如果您正苦于以下问题:Java ASN1UTCTime类的具体用法?Java ASN1UTCTime怎么用?Java ASN1UTCTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ASN1UTCTime类属于org.bouncycastle.asn1包,在下文中一共展示了ASN1UTCTime类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstance
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的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());
}
示例2: getDate
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的package包/类
public Date getDate()
{
try
{
if (time instanceof ASN1UTCTime)
{
return ((ASN1UTCTime)time).getAdjustedDate();
}
else
{
return ((ASN1GeneralizedTime)time).getDate();
}
}
catch (ParseException e)
{ // this should never happen
throw new IllegalStateException("invalid date string: " + e.getMessage());
}
}
示例3: getInstance
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的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());
}
示例4: getDate
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的package包/类
/**
* Get java.util.Date version of date+time.
*/
public Date getDate()
{
try
{
if (time instanceof ASN1UTCTime)
{
return ((ASN1UTCTime)time).getAdjustedDate();
}
else
{
return ((ASN1GeneralizedTime)time).getDate();
}
}
catch (ParseException e)
{ // this should never happen
throw new IllegalStateException("invalid date string: " + e.getMessage());
}
}
示例5: dumpUTCTime
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的package包/类
private String dumpUTCTime(ASN1UTCTime asn1Time) {
StringBuilder sb = new StringBuilder();
sb.append(indentSequence.toString(indentLevel));
sb.append("UTC TIME=");
// UTCTime, note does not support ms precision hence the different date format
Date date;
try {
date = asn1Time.getDate();
} catch (ParseException e) {
throw new RuntimeException("Cannot parse utc time");
}
String formattedDate = new SimpleDateFormat("dd/MMM/yyyy HH:mm:ss z").format(date);
sb.append(formattedDate);
sb.append(" (");
sb.append(asn1Time.getTime());
sb.append(")");
sb.append(NEWLINE);
return sb.toString();
}
示例6: makeEsteidCert
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的package包/类
private X509Certificate makeEsteidCert(KeyPair esteid, KeyPair root) throws InvalidKeyException, IllegalStateException,
NoSuchProviderException, SignatureException, IOException, NoSuchAlgorithmException, ParseException, OperatorCreationException,
CertificateException {
// Load current root certificate
X509CertificateHolder real = getRealCert("sk-esteid.pem");
JcaX509v3CertificateBuilder builder = new JcaX509v3CertificateBuilder(real.getIssuer(), real.getSerialNumber(),
Time.getInstance(new ASN1UTCTime(real.getNotBefore())), Time.getInstance(new ASN1GeneralizedTime(real.getNotAfter())), real.getSubject(), esteid.getPublic());
// Basic constraints
@SuppressWarnings("unchecked")
List<ASN1ObjectIdentifier> list = real.getExtensionOIDs();
// Copy all extensions
for (ASN1ObjectIdentifier extoid : list) {
Extension ext = real.getExtension(extoid);
builder.copyAndAddExtension(ext.getExtnId(), ext.isCritical(), real);
}
// Generate cert
ContentSigner sigGen = new JcaContentSignerBuilder("SHA384withRSA").setProvider(BouncyCastleProvider.PROVIDER_NAME).build(root.getPrivate());
X509CertificateHolder cert = builder.build(sigGen);
return new JcaX509CertificateConverter().setProvider(BouncyCastleProvider.PROVIDER_NAME).getCertificate(cert);
}
示例7: CrlIdentifier
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的package包/类
private CrlIdentifier(ASN1Sequence seq)
{
if (seq.size() < 2 || seq.size() > 3)
{
throw new IllegalArgumentException();
}
this.crlIssuer = X500Name.getInstance(seq.getObjectAt(0));
this.crlIssuedTime = ASN1UTCTime.getInstance(seq.getObjectAt(1));
if (seq.size() > 2)
{
this.crlNumber = ASN1Integer.getInstance(seq.getObjectAt(2));
}
}
示例8: Time
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的package包/类
public Time(
ASN1Primitive time)
{
if (!(time instanceof ASN1UTCTime)
&& !(time instanceof ASN1GeneralizedTime))
{
throw new IllegalArgumentException("unknown object passed to Time");
}
this.time = time;
}
示例9: getTime
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的package包/类
public String getTime()
{
if (time instanceof ASN1UTCTime)
{
return ((ASN1UTCTime)time).getAdjustedTime();
}
else
{
return ((ASN1GeneralizedTime)time).getTime();
}
}
示例10: getDate
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的package包/类
public Date getDate()
{
if (time instanceof ASN1UTCTime)
{
return ((ASN1UTCTime)time).getAdjustedDate();
}
else
{
return ((ASN1GeneralizedTime)time).getDate();
}
}
示例11: Time
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的package包/类
/**
* @deprecated use getInstance()
*/
public Time(
ASN1Primitive time)
{
if (!(time instanceof ASN1UTCTime)
&& !(time instanceof ASN1GeneralizedTime))
{
throw new IllegalArgumentException("unknown object passed to Time");
}
this.time = time;
}
示例12: getTime
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的package包/类
/**
* Get the date+tine as a String in full form century format.
*/
public String getTime()
{
if (time instanceof ASN1UTCTime)
{
return ((ASN1UTCTime)time).getAdjustedTime();
}
else
{
return ((ASN1GeneralizedTime)time).getTime();
}
}
示例13: dump
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的package包/类
/**
* Get dump of the supplied ASN.1 object.
*
* @param asn1Object
* ASN.1 object
* @return Dump of object
* @throws Asn1Exception
* A problem was encountered getting the ASN.1 dump
* @throws IOException
* If an I/O problem occurred
*/
public String dump(ASN1Primitive asn1Object) throws Asn1Exception, IOException {
// Get dump of the supplied ASN.1 object incrementing the indent level of the output
try {
indentLevel++;
if (asn1Object instanceof DERBitString) { // special case of ASN1String
return dumpBitString((DERBitString) asn1Object);
} else if (asn1Object instanceof ASN1String) {
return dumpString((ASN1String) asn1Object);
} else if (asn1Object instanceof ASN1UTCTime) {
return dumpUTCTime((ASN1UTCTime) asn1Object);
} else if (asn1Object instanceof ASN1GeneralizedTime) {
return dumpGeneralizedTime((ASN1GeneralizedTime) asn1Object);
} else if (asn1Object instanceof ASN1Sequence ||
asn1Object instanceof ASN1Set ) {
return dumpSetOrSequence(asn1Object);
} else if (asn1Object instanceof ASN1TaggedObject) {
return dumpTaggedObject((ASN1TaggedObject) asn1Object);
} else if (asn1Object instanceof ASN1Boolean) {
return dumpBoolean((ASN1Boolean) asn1Object);
} else if (asn1Object instanceof ASN1Enumerated) {
return dumpEnumerated((ASN1Enumerated) asn1Object);
} else if (asn1Object instanceof ASN1Integer) {
return dumpInteger((ASN1Integer) asn1Object);
} else if (asn1Object instanceof ASN1Null) {
return dumpNull((ASN1Null) asn1Object);
} else if (asn1Object instanceof ASN1ObjectIdentifier) {
return dumpObjectIdentifier((ASN1ObjectIdentifier) asn1Object);
} else if (asn1Object instanceof ASN1OctetString) {
return dumpOctetString((ASN1OctetString) asn1Object);
} else {
throw new Asn1Exception("Unknown ASN.1 object: " + asn1Object.toString());
}
} finally {
if (true) {
indentLevel--;
}
}
}
示例14: getSigningTime
import org.bouncycastle.asn1.ASN1UTCTime; //导入依赖的package包/类
@Override
public Date getSigningTime() {
final Attribute attr = getSignedAttribute(PKCSObjectIdentifiers.pkcs_9_at_signingTime);
if (attr == null) {
return null;
}
final ASN1Set attrValues = attr.getAttrValues();
final ASN1Encodable attrValue = attrValues.getObjectAt(0);
final Date signingDate = DSSASN1Utils.getDate(attrValue);
if (signingDate != null) {
/*
* RFC 3852 [4] states that "dates between January 1, 1950 and
* December 31, 2049 (inclusive) must be encoded as UTCTime. Any
* dates with year values before 1950 or after 2049 must be encoded
* as GeneralizedTime".
*/
if (!(signingDate.before(JANUARY_1950) && signingDate.after(JANUARY_2050))) {
// must be ASN1UTCTime
if (!(attrValue instanceof ASN1UTCTime)) {
LOG.error(
"RFC 3852 states that dates between January 1, 1950 and December 31, 2049 (inclusive) must be encoded as UTCTime. Any dates with year values before 1950 or after 2049 must be encoded as GeneralizedTime. Date found is {} encoded as {}",
signingDate.toString(), attrValue.getClass());
return null;
}
}
return signingDate;
}
if (LOG.isErrorEnabled()) {
LOG.error("Error when reading signing time. Unrecognized " + attrValue.getClass());
}
return null;
}