Java 类org.bouncycastle.asn1.ASN1UTCTime 实例源码

项目:gwt-crypto    文件:Time.java   
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());
}
项目:gwt-crypto    文件:Time.java   
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());
}
项目:Aki-SSL    文件:Time.java   
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());
}
项目:Aki-SSL    文件:Time.java   
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());
    }
}
项目:Aki-SSL    文件:Time.java   
/**
 * Return a Time object from the given object.
 * <p>
 * Accepted inputs:
 * <ul>
 * <li> null &rarr; 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());
}
项目:Aki-SSL    文件:Time.java   
/**
 * 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());
    }
}
项目:keystore-explorer    文件:Asn1Dump.java   
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();
}
项目:TinyTravelTracker    文件:Time.java   
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());
}
项目:TinyTravelTracker    文件:Time.java   
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());
    }
}
项目:TinyTravelTracker    文件:Time.java   
/**
 * Return a Time object from the given object.
 * <p>
 * Accepted inputs:
 * <ul>
 * <li> null &rarr; 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());
}
项目:TinyTravelTracker    文件:Time.java   
/**
 * 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());
    }
}
项目:ESign    文件:Time.java   
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());
}
项目:ESign    文件:Time.java   
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());
    }
}
项目:esteidhacker    文件:FakeEstEIDCA.java   
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);
}
项目:ipack    文件:CrlIdentifier.java   
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));
    }
}
项目:ipack    文件:CrlIdentifier.java   
public CrlIdentifier(X500Name crlIssuer, ASN1UTCTime crlIssuedTime,
                     BigInteger crlNumber)
{
    this.crlIssuer = crlIssuer;
    this.crlIssuedTime = crlIssuedTime;
    if (null != crlNumber)
    {
        this.crlNumber = new ASN1Integer(crlNumber);
    }
}
项目:gwt-crypto    文件:Time.java   
public Time(
    ASN1Primitive   time)
{
    if (!(time instanceof ASN1UTCTime)
        && !(time instanceof ASN1GeneralizedTime))
    {
        throw new IllegalArgumentException("unknown object passed to Time");
    }

    this.time = time; 
}
项目:gwt-crypto    文件:Time.java   
public String getTime()
{
    if (time instanceof ASN1UTCTime)
    {
        return ((ASN1UTCTime)time).getAdjustedTime();
    }
    else
    {
        return ((ASN1GeneralizedTime)time).getTime();
    }
}
项目:gwt-crypto    文件:Time.java   
public Date getDate()
{
    if (time instanceof ASN1UTCTime)
    {
        return ((ASN1UTCTime)time).getAdjustedDate();
    }
    else
    {
        return ((ASN1GeneralizedTime)time).getDate();
    }
}
项目:gwt-crypto    文件:CrlIdentifier.java   
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));
    }
}
项目:gwt-crypto    文件:CrlIdentifier.java   
public CrlIdentifier(X500Name crlIssuer, ASN1UTCTime crlIssuedTime,
                     BigInteger crlNumber)
{
    this.crlIssuer = crlIssuer;
    this.crlIssuedTime = crlIssuedTime;
    if (null != crlNumber)
    {
        this.crlNumber = new ASN1Integer(crlNumber);
    }
}
项目:gwt-crypto    文件:Time.java   
public Time(
    ASN1Primitive   time)
{
    if (!(time instanceof ASN1UTCTime)
        && !(time instanceof ASN1GeneralizedTime))
    {
        throw new IllegalArgumentException("unknown object passed to Time");
    }

    this.time = time; 
}
项目:gwt-crypto    文件:Time.java   
public String getTime()
{
    if (time instanceof ASN1UTCTime)
    {
        return ((ASN1UTCTime)time).getAdjustedTime();
    }
    else
    {
        return ((ASN1GeneralizedTime)time).getTime();
    }
}
项目:gwt-crypto    文件:Time.java   
public Date getDate()
{
    if (time instanceof ASN1UTCTime)
    {
        return ((ASN1UTCTime)time).getAdjustedDate();
    }
    else
    {
        return ((ASN1GeneralizedTime)time).getDate();
    }
}
项目:Aki-SSL    文件:Time.java   
public Time(
    ASN1Primitive   time)
{
    if (!(time instanceof ASN1UTCTime)
        && !(time instanceof ASN1GeneralizedTime))
    {
        throw new IllegalArgumentException("unknown object passed to Time");
    }

    this.time = time; 
}
项目:Aki-SSL    文件:Time.java   
public String getTime()
{
    if (time instanceof ASN1UTCTime)
    {
        return ((ASN1UTCTime)time).getAdjustedTime();
    }
    else
    {
        return ((ASN1GeneralizedTime)time).getTime();
    }
}
项目:Aki-SSL    文件:CrlIdentifier.java   
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));
    }
}
项目:Aki-SSL    文件:CrlIdentifier.java   
public CrlIdentifier(X500Name crlIssuer, ASN1UTCTime crlIssuedTime,
                     BigInteger crlNumber)
{
    this.crlIssuer = crlIssuer;
    this.crlIssuedTime = crlIssuedTime;
    if (null != crlNumber)
    {
        this.crlNumber = new ASN1Integer(crlNumber);
    }
}
项目:Aki-SSL    文件:Time.java   
/**
 * @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; 
}
项目:Aki-SSL    文件:Time.java   
/**
 * 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();
    }
}
项目:keystore-explorer    文件:Asn1Dump.java   
/**
 * 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--;
        }
    }
}
项目:dss    文件:CAdESSignature.java   
@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;
}
项目:TinyTravelTracker    文件:Time.java   
public Time(
    ASN1Primitive   time)
{
    if (!(time instanceof ASN1UTCTime)
        && !(time instanceof ASN1GeneralizedTime))
    {
        throw new IllegalArgumentException("unknown object passed to Time");
    }

    this.time = time; 
}
项目:TinyTravelTracker    文件:Time.java   
public String getTime()
{
    if (time instanceof ASN1UTCTime)
    {
        return ((ASN1UTCTime)time).getAdjustedTime();
    }
    else
    {
        return ((ASN1GeneralizedTime)time).getTime();
    }
}
项目:TinyTravelTracker    文件:CrlIdentifier.java   
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));
    }
}
项目:TinyTravelTracker    文件:CrlIdentifier.java   
public CrlIdentifier(X500Name crlIssuer, ASN1UTCTime crlIssuedTime,
                     BigInteger crlNumber)
{
    this.crlIssuer = crlIssuer;
    this.crlIssuedTime = crlIssuedTime;
    if (null != crlNumber)
    {
        this.crlNumber = new ASN1Integer(crlNumber);
    }
}
项目:TinyTravelTracker    文件:Time.java   
/**
 * @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; 
}
项目:TinyTravelTracker    文件:Time.java   
/**
 * 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();
    }
}
项目:ESign    文件:Time.java   
public Time(
    ASN1Primitive   time)
{
    if (!(time instanceof ASN1UTCTime)
        && !(time instanceof ASN1GeneralizedTime))
    {
        throw new IllegalArgumentException("unknown object passed to Time");
    }

    this.time = time; 
}
项目:ESign    文件:Time.java   
public String getTime()
{
    if (time instanceof ASN1UTCTime)
    {
        return ((ASN1UTCTime)time).getAdjustedTime();
    }
    else
    {
        return ((ASN1GeneralizedTime)time).getTime();
    }
}