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

项目:ipack    文件:Time.java   
public static Time getInstance(
    Object  obj)
{
    if (obj == null || obj instanceof Time)
    {
        return (Time)obj;
    }
    else if (obj instanceof DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
}
项目:ipack    文件:Time.java   
public Date getDate()
{
    try
    {
        if (time instanceof DERUTCTime)
        {
            return ((DERUTCTime)time).getAdjustedDate();
        }
        else
        {
            return ((DERGeneralizedTime)time).getDate();
        }
    }
    catch (ParseException e)
    {         // this should never happen
        throw new IllegalStateException("invalid date string: " + e.getMessage());
    }
}
项目:ipack    文件:Time.java   
public static Time getInstance(
    Object  obj)
{
    if (obj == null || obj instanceof Time)
    {
        return (Time)obj;
    }
    else if (obj instanceof DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
}
项目:ipack    文件:Time.java   
public Date getDate()
{
    try
    {
        if (time instanceof DERUTCTime)
        {
            return ((DERUTCTime)time).getAdjustedDate();
        }
        else
        {
            return ((DERGeneralizedTime)time).getDate();
        }
    }
    catch (ParseException e)
    {         // this should never happen
        throw new IllegalStateException("invalid date string: " + e.getMessage());
    }
}
项目: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 Microsoft CRL Next Publish (1.3.6.1.4.1.311.21.4) extension value as a string.
 * 
 * @param bValue The octet string value
 * @return Extension value as a string
 * @throws IOException If an I/O problem occurs
 */
private String getMicrosoftCrlNextPublish(byte[] bValue)
    throws IOException
{
    DERUTCTime time = (DERUTCTime) ASN1Primitive.fromByteArray(bValue);
    String date = time.getAdjustedTime();
    try
    {
        date = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(time.getAdjustedDate());
    }
    catch (ParseException e)
    {
        // Ignored
    }
    return escapeHtml(date);
}
项目:Aki-SSL    文件:Time.java   
/**
 * Creates a time object from a given date - if the date is between 1950
 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime
 * is used.
 *
 * @param time a date object representing the time of interest.
 */
public Time(
    Date    time)
{
    SimpleTimeZone      tz = new SimpleTimeZone(0, "Z");
    SimpleDateFormat    dateF = new SimpleDateFormat("yyyyMMddHHmmss");

    dateF.setTimeZone(tz);

    String  d = dateF.format(time) + "Z";
    int     year = Integer.parseInt(d.substring(0, 4));

    if (year < 1950 || year > 2049)
    {
        this.time = new DERGeneralizedTime(d);
    }
    else
    {
        this.time = new DERUTCTime(d.substring(2));
    }
}
项目:Aki-SSL    文件:Time.java   
/**
 * Creates a time object from a given date and locale - if the date is between 1950
 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime
 * is used. You may need to use this constructor if the default locale
 * doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations.
 *
 * @param time a date object representing the time of interest.
 * @param locale an appropriate Locale for producing an ASN.1 GeneralizedTime value.
 */
public Time(
    Date    time,
    Locale locale)
{
    SimpleTimeZone      tz = new SimpleTimeZone(0, "Z");
    SimpleDateFormat    dateF = new SimpleDateFormat("yyyyMMddHHmmss", locale);

    dateF.setTimeZone(tz);

    String  d = dateF.format(time) + "Z";
    int     year = Integer.parseInt(d.substring(0, 4));

    if (year < 1950 || year > 2049)
    {
        this.time = new DERGeneralizedTime(d);
    }
    else
    {
        this.time = new DERUTCTime(d.substring(2));
    }
}
项目:Aki-SSL    文件:Time.java   
/**
 * Creates a time object from a given date - if the date is between 1950
 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime
 * is used.
 *
 * @param time a date object representing the time of interest.
 */
public Time(
    Date    time)
{
    SimpleTimeZone      tz = new SimpleTimeZone(0, "Z");
    SimpleDateFormat    dateF = new SimpleDateFormat("yyyyMMddHHmmss");

    dateF.setTimeZone(tz);

    String  d = dateF.format(time) + "Z";
    int     year = Integer.parseInt(d.substring(0, 4));

    if (year < 1950 || year > 2049)
    {
        this.time = new DERGeneralizedTime(d);
    }
    else
    {
        this.time = new DERUTCTime(d.substring(2));
    }
}
项目:Aki-SSL    文件:Time.java   
/**
 * Creates a time object from a given date and locale - if the date is between 1950
 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime
 * is used. You may need to use this constructor if the default locale
 * doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations.
 *
 * @param time a date object representing the time of interest.
 * @param locale an appropriate Locale for producing an ASN.1 GeneralizedTime value.
 */
public Time(
    Date    time,
    Locale locale)
{
    SimpleTimeZone      tz = new SimpleTimeZone(0, "Z");
    SimpleDateFormat    dateF = new SimpleDateFormat("yyyyMMddHHmmss", locale);

    dateF.setTimeZone(tz);

    String  d = dateF.format(time) + "Z";
    int     year = Integer.parseInt(d.substring(0, 4));

    if (year < 1950 || year > 2049)
    {
        this.time = new DERGeneralizedTime(d);
    }
    else
    {
        this.time = new DERUTCTime(d.substring(2));
    }
}
项目:TinyTravelTracker    文件:Time.java   
/**
 * Creates a time object from a given date - if the date is between 1950
 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime
 * is used.
 *
 * @param time a date object representing the time of interest.
 */
public Time(
    Date    time)
{
    SimpleTimeZone      tz = new SimpleTimeZone(0, "Z");
    SimpleDateFormat    dateF = new SimpleDateFormat("yyyyMMddHHmmss");

    dateF.setTimeZone(tz);

    String  d = dateF.format(time) + "Z";
    int     year = Integer.parseInt(d.substring(0, 4));

    if (year < 1950 || year > 2049)
    {
        this.time = new DERGeneralizedTime(d);
    }
    else
    {
        this.time = new DERUTCTime(d.substring(2));
    }
}
项目:TinyTravelTracker    文件:Time.java   
/**
 * Creates a time object from a given date and locale - if the date is between 1950
 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime
 * is used. You may need to use this constructor if the default locale
 * doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations.
 *
 * @param time a date object representing the time of interest.
 * @param locale an appropriate Locale for producing an ASN.1 GeneralizedTime value.
 */
public Time(
    Date    time,
    Locale locale)
{
    SimpleTimeZone      tz = new SimpleTimeZone(0, "Z");
    SimpleDateFormat    dateF = new SimpleDateFormat("yyyyMMddHHmmss", locale);

    dateF.setTimeZone(tz);

    String  d = dateF.format(time) + "Z";
    int     year = Integer.parseInt(d.substring(0, 4));

    if (year < 1950 || year > 2049)
    {
        this.time = new DERGeneralizedTime(d);
    }
    else
    {
        this.time = new DERUTCTime(d.substring(2));
    }
}
项目:TinyTravelTracker    文件:Time.java   
/**
 * Creates a time object from a given date - if the date is between 1950
 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime
 * is used.
 *
 * @param time a date object representing the time of interest.
 */
public Time(
    Date    time)
{
    SimpleTimeZone      tz = new SimpleTimeZone(0, "Z");
    SimpleDateFormat    dateF = new SimpleDateFormat("yyyyMMddHHmmss");

    dateF.setTimeZone(tz);

    String  d = dateF.format(time) + "Z";
    int     year = Integer.parseInt(d.substring(0, 4));

    if (year < 1950 || year > 2049)
    {
        this.time = new DERGeneralizedTime(d);
    }
    else
    {
        this.time = new DERUTCTime(d.substring(2));
    }
}
项目:TinyTravelTracker    文件:Time.java   
/**
 * Creates a time object from a given date and locale - if the date is between 1950
 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime
 * is used. You may need to use this constructor if the default locale
 * doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations.
 *
 * @param time a date object representing the time of interest.
 * @param locale an appropriate Locale for producing an ASN.1 GeneralizedTime value.
 */
public Time(
    Date    time,
    Locale locale)
{
    SimpleTimeZone      tz = new SimpleTimeZone(0, "Z");
    SimpleDateFormat    dateF = new SimpleDateFormat("yyyyMMddHHmmss", locale);

    dateF.setTimeZone(tz);

    String  d = dateF.format(time) + "Z";
    int     year = Integer.parseInt(d.substring(0, 4));

    if (year < 1950 || year > 2049)
    {
        this.time = new DERGeneralizedTime(d);
    }
    else
    {
        this.time = new DERUTCTime(d.substring(2));
    }
}
项目:ESign    文件:Time.java   
/**
 * Creates a time object from a given date - if the date is between 1950
 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime
 * is used.
 *
 * @param time a date object representing the time of interest.
 */
public Time(
    Date    time)
{
    SimpleTimeZone      tz = new SimpleTimeZone(0, "Z");
    SimpleDateFormat    dateF = new SimpleDateFormat("yyyyMMddHHmmss");

    dateF.setTimeZone(tz);

    String  d = dateF.format(time) + "Z";
    int     year = Integer.parseInt(d.substring(0, 4));

    if (year < 1950 || year > 2049)
    {
        this.time = new DERGeneralizedTime(d);
    }
    else
    {
        this.time = new DERUTCTime(d.substring(2));
    }
}
项目:ESign    文件:Time.java   
/**
 * Creates a time object from a given date and locale - if the date is between 1950
 * and 2049 a UTCTime object is generated, otherwise a GeneralizedTime
 * is used. You may need to use this constructor if the default locale
 * doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations.
 *
 * @param time a date object representing the time of interest.
 * @param locale an appropriate Locale for producing an ASN.1 GeneralizedTime value.
 */
public Time(
    Date    time,
    Locale locale)
{
    SimpleTimeZone      tz = new SimpleTimeZone(0, "Z");
    SimpleDateFormat    dateF = new SimpleDateFormat("yyyyMMddHHmmss", locale);

    dateF.setTimeZone(tz);

    String  d = dateF.format(time) + "Z";
    int     year = Integer.parseInt(d.substring(0, 4));

    if (year < 1950 || year > 2049)
    {
        this.time = new DERGeneralizedTime(d);
    }
    else
    {
        this.time = new DERUTCTime(d.substring(2));
    }
}
项目:AcademicTorrents-Downloader    文件:Time.java   
public static Time getInstance(
    Object  obj)
{
    if (obj instanceof Time)
    {
        return (Time)obj;
    }
    else if (obj instanceof DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory");
}
项目:AcademicTorrents-Downloader    文件:Time.java   
public Date getDate()
{
    try
    {
        if (time instanceof DERUTCTime)
        {
            return ((DERUTCTime)time).getAdjustedDate();
        }
        else
        {
            return ((DERGeneralizedTime)time).getDate();
        }
    }
    catch (ParseException e)
    {         // this should never happen
        throw new IllegalStateException("invalid date string: " + e.getMessage());
    }
}
项目:CryptMeme    文件:Time.java   
public static Time getInstance(
    Object  obj)
{
    if (obj == null || obj instanceof Time)
    {
        return (Time)obj;
    }
    else if (obj instanceof DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
}
项目:CryptMeme    文件:Time.java   
public Date getDate()
{
    try
    {
        if (time instanceof DERUTCTime)
        {
            return ((DERUTCTime)time).getAdjustedDate();
        }
        else
        {
            return ((DERGeneralizedTime)time).getDate();
        }
    }
    catch (ParseException e)
    {         // this should never happen
        throw new IllegalStateException("invalid date string: " + e.getMessage());
    }
}
项目:CryptMeme    文件: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 DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
}
项目:CryptMeme    文件:Time.java   
/**
 * Get java.util.Date version of date+time.
 */
public Date getDate()
{
    try
    {
        if (time instanceof DERUTCTime)
        {
            return ((DERUTCTime)time).getAdjustedDate();
        }
        else
        {
            return ((DERGeneralizedTime)time).getDate();
        }
    }
    catch (ParseException e)
    {         // this should never happen
        throw new IllegalStateException("invalid date string: " + e.getMessage());
    }
}
项目:irma_future_id    文件:Time.java   
public static Time getInstance(
    Object  obj)
{
    if (obj == null || obj instanceof Time)
    {
        return (Time)obj;
    }
    else if (obj instanceof DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
}
项目:irma_future_id    文件:Time.java   
public static Time getInstance(
    Object  obj)
{
    if (obj == null || obj instanceof Time)
    {
        return (Time)obj;
    }
    else if (obj instanceof DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
}
项目:irma_future_id    文件:Time.java   
public static Time getInstance(
    Object  obj)
{
    if (obj == null || obj instanceof Time)
    {
        return (Time)obj;
    }
    else if (obj instanceof DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
}
项目:irma_future_id    文件:Time.java   
public Date getDate()
{
    try
    {
        if (time instanceof DERUTCTime)
        {
            return ((DERUTCTime)time).getAdjustedDate();
        }
        else
        {
            return ((DERGeneralizedTime)time).getDate();
        }
    }
    catch (ParseException e)
    {         // this should never happen
        throw new IllegalStateException("invalid date string: " + e.getMessage());
    }
}
项目:irma_future_id    文件: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 DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
}
项目:irma_future_id    文件:Time.java   
/**
 * Get java.util.Date version of date+time.
 */
public Date getDate()
{
    try
    {
        if (time instanceof DERUTCTime)
        {
            return ((DERUTCTime)time).getAdjustedDate();
        }
        else
        {
            return ((DERGeneralizedTime)time).getDate();
        }
    }
    catch (ParseException e)
    {         // this should never happen
        throw new IllegalStateException("invalid date string: " + e.getMessage());
    }
}
项目:bc-java    文件:Time.java   
public static Time getInstance(
    Object  obj)
{
    if (obj == null || obj instanceof Time)
    {
        return (Time)obj;
    }
    else if (obj instanceof DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
}
项目:bc-java    文件:Time.java   
public static Time getInstance(
    Object  obj)
{
    if (obj == null || obj instanceof Time)
    {
        return (Time)obj;
    }
    else if (obj instanceof DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
}
项目:bc-java    文件:Time.java   
public static Time getInstance(
    Object  obj)
{
    if (obj == null || obj instanceof Time)
    {
        return (Time)obj;
    }
    else if (obj instanceof DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
}
项目:bc-java    文件:Time.java   
public Date getDate()
{
    try
    {
        if (time instanceof DERUTCTime)
        {
            return ((DERUTCTime)time).getAdjustedDate();
        }
        else
        {
            return ((DERGeneralizedTime)time).getDate();
        }
    }
    catch (ParseException e)
    {         // this should never happen
        throw new IllegalStateException("invalid date string: " + e.getMessage());
    }
}
项目:bc-java    文件: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 DERUTCTime)
    {
        return new Time((DERUTCTime)obj);
    }
    else if (obj instanceof DERGeneralizedTime)
    {
        return new Time((DERGeneralizedTime)obj);
    }

    throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
}
项目:bc-java    文件:Time.java   
/**
 * Get java.util.Date version of date+time.
 */
public Date getDate()
{
    try
    {
        if (time instanceof DERUTCTime)
        {
            return ((DERUTCTime)time).getAdjustedDate();
        }
        else
        {
            return ((DERGeneralizedTime)time).getDate();
        }
    }
    catch (ParseException e)
    {         // this should never happen
        throw new IllegalStateException("invalid date string: " + e.getMessage());
    }
}
项目:ipack    文件:Time.java   
public Time(
    ASN1Primitive   time)
{
    if (!(time instanceof DERUTCTime)
        && !(time instanceof DERGeneralizedTime))
    {
        throw new IllegalArgumentException("unknown object passed to Time");
    }

    this.time = time; 
}
项目:ipack    文件:Time.java   
public String getTime()
{
    if (time instanceof DERUTCTime)
    {
        return ((DERUTCTime)time).getAdjustedTime();
    }
    else
    {
        return ((DERGeneralizedTime)time).getTime();
    }
}
项目:ipack    文件:Time.java   
public Time(
    ASN1Primitive   time)
{
    if (!(time instanceof DERUTCTime)
        && !(time instanceof DERGeneralizedTime))
    {
        throw new IllegalArgumentException("unknown object passed to Time");
    }

    this.time = time; 
}
项目:ipack    文件:Time.java   
public String getTime()
{
    if (time instanceof DERUTCTime)
    {
        return ((DERUTCTime)time).getAdjustedTime();
    }
    else
    {
        return ((DERGeneralizedTime)time).getTime();
    }
}
项目:signer-source    文件:DerEncoder.java   
private Attribute createSigningTime(Date now) {
    final DEREncodableVector setEV = new DEREncodableVector();
    setEV.add(new DERUTCTime(now));

    DERSet set = new DERSet(setEV);
    Attribute seq1 = new Attribute(
            new DERObjectIdentifier(ID_SIGNING_TIME), set);
    return seq1;
}
项目:signer-source    文件:DerEncoder.java   
private Attribute createSigningTime(Date now) {
    final ASN1EncodableVector setEV = new ASN1EncodableVector();
    setEV.add(new DERUTCTime(now));

    DERSet set = new DERSet(setEV);
    Attribute seq1 = new Attribute(
            new ASN1ObjectIdentifier(ID_SIGNING_TIME), set);
    return seq1;
}