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

CA认证

开发平台:

Java

  1. package org.bouncycastle.asn1.x509;
  2. import org.bouncycastle.asn1.*;
  3. /**
  4.  * an object for the elements in the X.509 V3 extension block.
  5.  */
  6. public class X509Extension
  7. {
  8.     boolean             critical;
  9.     ASN1OctetString      value;
  10.     public X509Extension(
  11.         DERBoolean              critical,
  12.         ASN1OctetString         value)
  13.     {
  14.         this.critical = critical.isTrue();
  15.         this.value = value;
  16.     }
  17.     public X509Extension(
  18.         boolean                 critical,
  19.         ASN1OctetString         value)
  20.     {
  21.         this.critical = critical;
  22.         this.value = value;
  23.     }
  24.     public boolean isCritical()
  25.     {
  26.         return critical;
  27.     }
  28.     public ASN1OctetString getValue()
  29.     {
  30.         return value;
  31.     }
  32.     public int hashCode()
  33.     {
  34.         if (this.isCritical())
  35.         {
  36.             return this.getValue().hashCode();
  37.         }
  38.         
  39.         return ~this.getValue().hashCode();
  40.     }
  41.     public boolean equals(
  42.         Object  o)
  43.     {
  44.         if (o == null || !(o instanceof X509Extension))
  45.         {
  46.             return false;
  47.         }
  48.         X509Extension   other = (X509Extension)o;
  49.         return other.getValue().equals(this.getValue())
  50.             && (other.isCritical() == this.isCritical());
  51.     }
  52. }