ResponseBytes.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.DERSequence;
  5. import org.bouncycastle.asn1.DERObject;
  6. import org.bouncycastle.asn1.DERObjectIdentifier;
  7. import org.bouncycastle.asn1.DEREncodable;
  8. import org.bouncycastle.asn1.ASN1EncodableVector;
  9. import org.bouncycastle.asn1.ASN1OctetString;
  10. public class ResponseBytes
  11.     implements DEREncodable
  12. {
  13. DERObjectIdentifier responseType;
  14. ASN1OctetString response;
  15.     public ResponseBytes(
  16.         ASN1Sequence    seq)
  17.     {
  18.         responseType = (DERObjectIdentifier)seq.getObjectAt(0);
  19.         response = (ASN1OctetString)seq.getObjectAt(1);
  20.     }
  21.     public static ResponseBytes getInstance(
  22.         ASN1TaggedObject obj,
  23.         boolean          explicit)
  24.     {
  25.         return getInstance(ASN1Sequence.getInstance(obj, explicit));
  26.     }
  27.     public static ResponseBytes getInstance(
  28.         Object  obj)
  29.     {
  30.         if (obj == null || obj instanceof ResponseBytes)
  31.         {
  32.             return (ResponseBytes)obj;
  33.         }
  34.         else if (obj instanceof ASN1Sequence)
  35.         {
  36.             return new ResponseBytes((ASN1Sequence)obj);
  37.         }
  38.         throw new IllegalArgumentException("unknown object in factory");
  39.     }
  40. public DERObjectIdentifier getResponseType()
  41. {
  42. return responseType;
  43. }
  44. public ASN1OctetString getResponse()
  45. {
  46. return response;
  47. }
  48. /**
  49.  * <pre>
  50.      * ResponseBytes ::=       SEQUENCE {
  51.      *     responseType   OBJECT IDENTIFIER,
  52.      *     response       OCTET STRING }
  53.  * </pre>
  54.  */
  55. public DERObject getDERObject()
  56. {
  57. ASN1EncodableVector v = new ASN1EncodableVector();
  58. v.add(responseType);
  59. v.add(response);
  60. return new DERSequence(v);
  61. }
  62. }