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