CrlID.java
上传用户:lior1029
上传日期:2013-05-07
资源大小:209k
文件大小:2k
源码类别:

CA认证

开发平台:

Java

  1. package org.bouncycastle.asn1.ocsp;
  2. import java.util.Enumeration;
  3. import org.bouncycastle.asn1.ASN1Sequence;
  4. import org.bouncycastle.asn1.ASN1TaggedObject;
  5. import org.bouncycastle.asn1.DERIA5String;
  6. import org.bouncycastle.asn1.DERObject;
  7. import org.bouncycastle.asn1.DERInteger;
  8. import org.bouncycastle.asn1.DERSequence;
  9. import org.bouncycastle.asn1.DERTaggedObject;
  10. import org.bouncycastle.asn1.DEREncodable;
  11. import org.bouncycastle.asn1.ASN1EncodableVector;
  12. import org.bouncycastle.asn1.DERGeneralizedTime;
  13. public class CrlID
  14.     implements DEREncodable
  15. {
  16. DERIA5String     crlUrl;
  17. DERInteger     crlNum;
  18. DERGeneralizedTime crlTime;
  19. public CrlID(
  20. ASN1Sequence seq)
  21. {
  22. Enumeration e = seq.getObjects();
  23. while (e.hasMoreElements())
  24. {
  25. ASN1TaggedObject o = (ASN1TaggedObject)e.nextElement();
  26. switch (o.getTagNo())
  27. {
  28. case 0:
  29. crlUrl = DERIA5String.getInstance(o, true);
  30. break;
  31. case 1:
  32. crlNum = DERInteger.getInstance(o, true);
  33. break;
  34. case 2:
  35. crlTime = DERGeneralizedTime.getInstance(o, true);
  36. break;
  37. default:
  38. throw new IllegalArgumentException(
  39. "unknown tag number: " + o.getTagNo());
  40. }
  41. }
  42. }
  43. public DERIA5String getCrlUrl()
  44. {
  45. return crlUrl;
  46. }
  47. public DERInteger getCrlNum()
  48. {
  49. return crlNum;
  50. }
  51. public DERGeneralizedTime getCrlTime()
  52. {
  53. return crlTime;
  54. }
  55.     /**
  56.  * <pre>
  57.      * CrlID ::= SEQUENCE {
  58.      *     crlUrl               [0]     EXPLICIT IA5String OPTIONAL,
  59.      *     crlNum               [1]     EXPLICIT INTEGER OPTIONAL,
  60.      *     crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }
  61.  * </pre>
  62.  */
  63. public DERObject getDERObject()
  64. {
  65. ASN1EncodableVector v = new ASN1EncodableVector();
  66. if (crlUrl != null)
  67. {
  68. v.add(new DERTaggedObject(true, 0, crlUrl));
  69. }
  70. if (crlNum != null)
  71. {
  72. v.add(new DERTaggedObject(true, 1, crlNum));
  73. }
  74. if (crlTime != null)
  75. {
  76. v.add(new DERTaggedObject(true, 2, crlTime));
  77. }
  78. return new DERSequence(v);
  79. }
  80. }