Methods Summary |
---|
void | encode(DEROutputStream out)
OIDTokenizer tok = new OIDTokenizer(identifier);
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
writeField(bOut,
Integer.parseInt(tok.nextToken()) * 40
+ Integer.parseInt(tok.nextToken()));
while (tok.hasMoreTokens())
{
String token = tok.nextToken();
if (token.length() < 18)
{
writeField(bOut, Long.parseLong(token));
}
else
{
writeField(bOut, new BigInteger(token));
}
}
dOut.close();
byte[] bytes = bOut.toByteArray();
out.writeEncoded(OBJECT_IDENTIFIER, bytes);
|
public boolean | equals(java.lang.Object o)
if ((o == null) || !(o instanceof DERObjectIdentifier))
{
return false;
}
return identifier.equals(((DERObjectIdentifier)o).identifier);
|
public java.lang.String | getId()
return identifier;
|
public static org.bouncycastle.asn1.DERObjectIdentifier | getInstance(java.lang.Object obj)return an OID from the passed in object
if (obj == null || obj instanceof DERObjectIdentifier)
{
return (DERObjectIdentifier)obj;
}
if (obj instanceof ASN1OctetString)
{
return new DERObjectIdentifier(((ASN1OctetString)obj).getOctets());
}
if (obj instanceof ASN1TaggedObject)
{
return getInstance(((ASN1TaggedObject)obj).getObject());
}
throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
|
public static org.bouncycastle.asn1.DERObjectIdentifier | getInstance(ASN1TaggedObject obj, boolean explicit)return an Object Identifier from a tagged object.
return getInstance(obj.getObject());
|
public int | hashCode()
return identifier.hashCode();
|
private static boolean | isValidIdentifier(java.lang.String identifier)
boolean periodAllowed = false;
for (int i = identifier.length() - 1; i >= 0; i--)
{
char ch = identifier.charAt(i);
if ('0" <= ch && ch <= '9")
{
periodAllowed = true;
continue;
}
if (ch == '.")
{
if (!periodAllowed)
{
return false;
}
periodAllowed = false;
continue;
}
return false;
}
return periodAllowed;
|
public java.lang.String | toString()
return getId();
|
private void | writeField(java.io.OutputStream out, long fieldValue)
if (fieldValue >= (1L << 7))
{
if (fieldValue >= (1L << 14))
{
if (fieldValue >= (1L << 21))
{
if (fieldValue >= (1L << 28))
{
if (fieldValue >= (1L << 35))
{
if (fieldValue >= (1L << 42))
{
if (fieldValue >= (1L << 49))
{
if (fieldValue >= (1L << 56))
{
out.write((int)(fieldValue >> 56) | 0x80);
}
out.write((int)(fieldValue >> 49) | 0x80);
}
out.write((int)(fieldValue >> 42) | 0x80);
}
out.write((int)(fieldValue >> 35) | 0x80);
}
out.write((int)(fieldValue >> 28) | 0x80);
}
out.write((int)(fieldValue >> 21) | 0x80);
}
out.write((int)(fieldValue >> 14) | 0x80);
}
out.write((int)(fieldValue >> 7) | 0x80);
}
out.write((int)fieldValue & 0x7f);
|
private void | writeField(java.io.OutputStream out, java.math.BigInteger fieldValue)
int byteCount = (fieldValue.bitLength()+6)/7;
if (byteCount == 0)
{
out.write(0);
}
else
{
BigInteger tmpValue = fieldValue;
byte[] tmp = new byte[byteCount];
for (int i = byteCount-1; i >= 0; i--)
{
tmp[i] = (byte) ((tmpValue.intValue() & 0x7f) | 0x80);
tmpValue = tmpValue.shiftRight(7);
}
tmp[byteCount-1] &= 0x7f;
out.write(tmp);
}
|