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

项目:ipack    文件:V2TBSCertListGenerator.java   
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);
}
项目:ipack    文件:TSTInfo.java   
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;
}
项目:ipack    文件:DVCSTime.java   
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;
}
项目:Aki-SSL    文件:V2TBSCertListGenerator.java   
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);
}
项目: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    文件:V2TBSCertListGenerator.java   
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);
}
项目:gwt-crypto    文件:PrivateKeyUsagePeriod.java   
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);
        }
    }
}
项目:Aki-SSL    文件:PrivateKeyUsagePeriod.java   
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);
        }
    }
}
项目: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    文件:TSTInfo.java   
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;
}
项目:gwt-crypto    文件:BCStyle.java   
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);
}
项目:gwt-crypto    文件:DVCSTime.java   
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;
}
项目:Aki-SSL    文件:CrlID.java   
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());
        }
    }
}
项目:signer    文件:Time.java   
@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);
        }
    }
}
项目:portecle    文件:X509Ext.java   
/**
 * 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);
}
项目: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    文件:TSTInfo.java   
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;
}
项目:ipack    文件:CertUtils.java   
static Date recoverDate(ASN1GeneralizedTime time)
{
    try
    {
        return time.getDate();
    }
    catch (ParseException e)
    {
        throw new IllegalStateException("unable to recover date: " + e.getMessage());
    }
}
项目:ipack    文件:X509v2AttributeCertificateBuilder.java   
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));
}
项目:ipack    文件:ProtectedPKIMessageBuilder.java   
/**
 * 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;
}
项目:ipack    文件:OCSPUtils.java   
static Date extractDate(ASN1GeneralizedTime time)
{
    try
    {
        return time.getDate();
    }
    catch (Exception e)
    {
        throw new IllegalStateException("exception processing GeneralizedTime: " + e.getMessage());
    }
}
项目:ipack    文件:PersonalData.java   
/**
 * 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());
        }
    }
}
项目:ipack    文件:PersonalData.java   
/**
 * 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;
}
项目:ipack    文件:AttCertValidityPeriod.java   
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));
}
项目:ipack    文件:AttCertValidityPeriod.java   
/**
 * @param notBeforeTime
 * @param notAfterTime
 */
public AttCertValidityPeriod(
    ASN1GeneralizedTime notBeforeTime,
    ASN1GeneralizedTime notAfterTime)
{
    this.notBeforeTime = notBeforeTime;
    this.notAfterTime = notAfterTime;
}
项目:ipack    文件:DeclarationOfMajority.java   
public ASN1GeneralizedTime getDateOfBirth()
{
    if (declaration.getTagNo() != 2)
    {
        return null;
    }

    return ASN1GeneralizedTime.getInstance(declaration, false);
}
项目:ipack    文件:OcspIdentifier.java   
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);
}
项目:ipack    文件:KEKIdentifier.java   
public KEKIdentifier(
    byte[]              keyIdentifier,
    ASN1GeneralizedTime  date,
    OtherKeyAttribute   other)
{
    this.keyIdentifier = new DEROctetString(keyIdentifier);
    this.date = date;
    this.other = other;
}
项目:ipack    文件:PKIHeaderBuilder.java   
/**
 * @deprecated use ASN1GeneralizedTime
 */
public PKIHeaderBuilder setMessageTime(DERGeneralizedTime time)
{
    messageTime = ASN1GeneralizedTime.getInstance(time);

    return this;
}
项目:ipack    文件:RevAnnContent.java   
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));
    }
}
项目:ipack    文件:BCStyle.java   
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);
}
项目:ipack    文件:ResponseData.java   
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;
}
项目:ipack    文件:ResponseData.java   
/**
 * @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));
}
项目:ipack    文件:ResponseData.java   
public ResponseData(
    ResponderID         responderID,
    ASN1GeneralizedTime  producedAt,
    ASN1Sequence        responses,
    Extensions      responseExtensions)
{
    this(V1, responderID, producedAt, responses, responseExtensions);
}
项目:ipack    文件:ResponseData.java   
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);
    }
}
项目:ipack    文件:RevokedInfo.java   
public RevokedInfo(
    ASN1GeneralizedTime  revocationTime,
    CRLReason           revocationReason)
{
    this.revocationTime = revocationTime;
    this.revocationReason = revocationReason;
}
项目:ipack    文件:RevokedInfo.java   
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));
    }
}
项目:ipack    文件:SingleResponse.java   
/**
 * @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));
}
项目:ipack    文件:SingleResponse.java   
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;
}
项目:ipack    文件:SingleResponse.java   
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);
        }
    }
}