/** * * Copyright 2003-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.geronimo.util.asn1; import java.io.IOException; /** * We insert one of these when we find a tag we don't recognise. */ public class DERUnknownTag extends DERObject { int tag; byte[] data; /** * @param tag the tag value. * @param data the octets making up the time. */ public DERUnknownTag( int tag, byte[] data) { this.tag = tag; this.data = data; } public int getTag() { return tag; } public byte[] getData() { return data; } void encode( DEROutputStream out) throws IOException { out.writeEncoded(tag, data); } public boolean equals( Object o) { if ((o == null) || !(o instanceof DERUnknownTag)) { return false; } DERUnknownTag other = (DERUnknownTag)o; if (tag != other.tag) { return false; } if (data.length != other.data.length) { return false; } for (int i = 0; i < data.length; i++) { if(data[i] != other.data[i]) { return false; } } return true; } public int hashCode() { byte[] b = this.getData(); int value = 0; for (int i = 0; i != b.length; i++) { value ^= (b[i] & 0xff) << (i % 4); } return value ^ this.getTag(); } }