org.apache.geronimo.crypto.asn1
abstract public class: ASN1OctetString [javadoc |
source]
java.lang.Object
org.apache.geronimo.crypto.asn1.ASN1Encodable
org.apache.geronimo.crypto.asn1.DERObject
org.apache.geronimo.crypto.asn1.ASN1OctetString
All Implemented Interfaces:
DERTags, DEREncodable
Direct Known Subclasses:
BERConstructedOctetString, DEROctetString
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.
| Field Summary |
|---|
| byte[] | string | |
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from org.apache.geronimo.crypto.asn1.ASN1OctetString Detail: |
abstract void encode(DEROutputStream out) throws IOException
|
public boolean equals(Object o) {
if (o == null || !(o instanceof DEROctetString))
{
return false;
}
DEROctetString other = (DEROctetString)o;
byte[] b1 = other.getOctets();
byte[] b2 = this.getOctets();
if (b1.length != b2.length)
{
return false;
}
for (int i = 0; i != b1.length; i++)
{
if (b1[i] != b2[i])
{
return false;
}
}
return true;
}
|
public static ASN1OctetString getInstance(Object obj) {
if (obj == null || obj instanceof ASN1OctetString)
{
return (ASN1OctetString)obj;
}
if (obj instanceof ASN1TaggedObject)
{
return getInstance(((ASN1TaggedObject)obj).getObject());
}
if (obj instanceof ASN1Sequence)
{
Vector v = new Vector();
Enumeration e = ((ASN1Sequence)obj).getObjects();
while (e.hasMoreElements())
{
v.addElement(e.nextElement());
}
return new BERConstructedOctetString(v);
}
throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
}
return an Octet String from the given object. |
public static ASN1OctetString getInstance(ASN1TaggedObject obj,
boolean explicit) {
return getInstance(obj.getObject());
}
return an Octet String from a tagged object. |
public byte[] getOctets() {
return string;
}
|
public int hashCode() {
byte[] b = this.getOctets();
int value = 0;
for (int i = 0; i != b.length; i++)
{
value ^= (b[i] & 0xff) < < (i % 4);
}
return value;
}
|