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;
17:
18: import java.io.IOException;
19:
20: /**
21: * We insert one of these when we find a tag we don't recognise.
22: */
23: public class DERUnknownTag extends DERObject {
24: int tag;
25: byte[] data;
26:
27: /**
28: * @param tag the tag value.
29: * @param data the octets making up the time.
30: */
31: public DERUnknownTag(int tag, byte[] data) {
32: this .tag = tag;
33: this .data = data;
34: }
35:
36: public int getTag() {
37: return tag;
38: }
39:
40: public byte[] getData() {
41: return data;
42: }
43:
44: void encode(DEROutputStream out) throws IOException {
45: out.writeEncoded(tag, data);
46: }
47:
48: public boolean equals(Object o) {
49: if ((o == null) || !(o instanceof DERUnknownTag)) {
50: return false;
51: }
52:
53: DERUnknownTag other = (DERUnknownTag) o;
54:
55: if (tag != other.tag) {
56: return false;
57: }
58:
59: if (data.length != other.data.length) {
60: return false;
61: }
62:
63: for (int i = 0; i < data.length; i++) {
64: if (data[i] != other.data[i]) {
65: return false;
66: }
67: }
68:
69: return true;
70: }
71:
72: public int hashCode() {
73: byte[] b = this .getData();
74: int value = 0;
75:
76: for (int i = 0; i != b.length; i++) {
77: value ^= (b[i] & 0xff) << (i % 4);
78: }
79:
80: return value ^ this.getTag();
81: }
82: }
|