01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.crypto.asn1.x509;
17:
18: import org.apache.geronimo.crypto.asn1.ASN1OctetString;
19: import org.apache.geronimo.crypto.asn1.DERBoolean;
20:
21: /**
22: * an object for the elements in the X.509 V3 extension block.
23: */
24: public class X509Extension {
25: boolean critical;
26: ASN1OctetString value;
27:
28: public X509Extension(DERBoolean critical, ASN1OctetString value) {
29: this .critical = critical.isTrue();
30: this .value = value;
31: }
32:
33: public X509Extension(boolean critical, ASN1OctetString value) {
34: this .critical = critical;
35: this .value = value;
36: }
37:
38: public boolean isCritical() {
39: return critical;
40: }
41:
42: public ASN1OctetString getValue() {
43: return value;
44: }
45:
46: public int hashCode() {
47: if (this .isCritical()) {
48: return this .getValue().hashCode();
49: }
50:
51: return ~this .getValue().hashCode();
52: }
53:
54: public boolean equals(Object o) {
55: if (o == null || !(o instanceof X509Extension)) {
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: }
|