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

CA认证

开发平台:

Java

  1. package org.bouncycastle.asn1.ocsp;
  2. import org.bouncycastle.asn1.ASN1Sequence;
  3. import org.bouncycastle.asn1.ASN1TaggedObject;
  4. import org.bouncycastle.asn1.DERObject;
  5. import org.bouncycastle.asn1.DERSequence;
  6. import org.bouncycastle.asn1.DEREncodable;
  7. import org.bouncycastle.asn1.ASN1EncodableVector;
  8. import org.bouncycastle.asn1.DERInteger;
  9. import org.bouncycastle.asn1.ASN1OctetString;
  10. import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
  11. public class CertID
  12.     implements DEREncodable
  13. {
  14. AlgorithmIdentifier hashAlgorithm;
  15. ASN1OctetString issuerNameHash;
  16. ASN1OctetString issuerKeyHash;
  17. DERInteger serialNumber;
  18. public CertID(
  19. ASN1Sequence seq)
  20. {
  21. hashAlgorithm = AlgorithmIdentifier.getInstance(seq.getObjectAt(0));
  22. issuerNameHash = (ASN1OctetString)seq.getObjectAt(1);
  23. issuerKeyHash = (ASN1OctetString)seq.getObjectAt(2);
  24. serialNumber = (DERInteger)seq.getObjectAt(3);
  25. }
  26.     public static CertID getInstance(
  27.         ASN1TaggedObject obj,
  28.         boolean          explicit)
  29.     {
  30.         return getInstance(ASN1Sequence.getInstance(obj, explicit));
  31.     }
  32.     public static CertID getInstance(
  33.         Object  obj)
  34.     {
  35.         if (obj == null || obj instanceof CertID)
  36.         {
  37.             return (CertID)obj;
  38.         }
  39.         else if (obj instanceof ASN1Sequence)
  40.         {
  41.             return new CertID((ASN1Sequence)obj);
  42.         }
  43.         throw new IllegalArgumentException("unknown object in factory");
  44.     }
  45. public AlgorithmIdentifier getHashAlgorithm()
  46. {
  47. return hashAlgorithm;
  48. }
  49. public ASN1OctetString getIssuerNameHash()
  50. {
  51. return issuerNameHash;
  52. }
  53. public ASN1OctetString getIssuerKeyHash()
  54. {
  55. return issuerKeyHash;
  56. }
  57. public DERInteger getSerialNumber()
  58. {
  59. return serialNumber;
  60. }
  61. /**
  62.  * <pre>
  63.  * CertID          ::=     SEQUENCE {
  64.  *     hashAlgorithm       AlgorithmIdentifier,
  65.  *     issuerNameHash      OCTET STRING, -- Hash of Issuer's DN
  66.  *     issuerKeyHash       OCTET STRING, -- Hash of Issuers public key
  67.  *     serialNumber        CertificateSerialNumber }
  68.  * </pre>
  69.  */
  70. public DERObject getDERObject()
  71. {
  72. ASN1EncodableVector v = new ASN1EncodableVector();
  73. v.add(hashAlgorithm);
  74. v.add(issuerNameHash);
  75. v.add(issuerKeyHash);
  76. v.add(serialNumber);
  77. return new DERSequence(v);
  78. }
  79. }