001    package org.apache.commons.ssl.asn1;
002    
003    import java.io.IOException;
004    
005    public abstract class ASN1Object
006        extends DERObject {
007        /**
008         * Create a base ASN.1 object from a byte stream.
009         *
010         * @param data the byte stream to parse.
011         * @return the base ASN.1 object represented by the byte stream.
012         * @throws IOException if there is a problem parsing the data.
013         */
014        public static ASN1Object fromByteArray(byte[] data)
015            throws IOException {
016            ASN1InputStream aIn = new ASN1InputStream(data);
017    
018            return (ASN1Object) aIn.readObject();
019        }
020    
021        public final boolean equals(Object o) {
022            if (this == o) {
023                return true;
024            }
025    
026            return (o instanceof DEREncodable) && asn1Equals(((DEREncodable) o).getDERObject());
027        }
028    
029        public abstract int hashCode();
030    
031        abstract void encode(DEROutputStream out) throws IOException;
032    
033        abstract boolean asn1Equals(DERObject o);
034    }