KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > util > asn1 > x509 > X509Extension


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.util.asn1.x509;
19
20 import org.apache.geronimo.util.asn1.ASN1OctetString;
21 import org.apache.geronimo.util.asn1.DERBoolean;
22
23 /**
24  * an object for the elements in the X.509 V3 extension block.
25  */

26 public class X509Extension
27 {
28     boolean critical;
29     ASN1OctetString value;
30
31     public X509Extension(
32         DERBoolean critical,
33         ASN1OctetString value)
34     {
35         this.critical = critical.isTrue();
36         this.value = value;
37     }
38
39     public X509Extension(
40         boolean critical,
41         ASN1OctetString value)
42     {
43         this.critical = critical;
44         this.value = value;
45     }
46
47     public boolean isCritical()
48     {
49         return critical;
50     }
51
52     public ASN1OctetString getValue()
53     {
54         return value;
55     }
56
57     public int hashCode()
58     {
59         if (this.isCritical())
60         {
61             return this.getValue().hashCode();
62         }
63
64
65         return ~this.getValue().hashCode();
66     }
67
68     public boolean equals(
69         Object JavaDoc o)
70     {
71         if (o == null || !(o instanceof X509Extension))
72         {
73             return false;
74         }
75
76         X509Extension other = (X509Extension)o;
77
78         return other.getValue().equals(this.getValue())
79             && (other.isCritical() == this.isCritical());
80     }
81 }
82
Popular Tags