|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.ws.security.components.crypto.DERDecoder
public class DERDecoder
Provides the means to navigate through a DER-encoded byte array, to help in decoding the contents.
It maintains a "current position" in the array that advances with each operation, providing a simple means to handle the type-length-value encoding of DER. For example
decoder.expect(TYPE); int length = decoder.getLength(); byte[] value = decoder.getBytes(len);
| Field Summary | |
|---|---|
static byte |
TYPE_BIT_STRING
DER type identifier for a bit string value |
static byte |
TYPE_OCTET_STRING
DER type identifier for a octet string value |
static byte |
TYPE_SEQUENCE
DER type identifier for a sequence value |
| Constructor Summary | |
|---|---|
DERDecoder(byte[] derEncoded)
Construct a DERDecoder for the given byte array. |
|
| Method Summary | |
|---|---|
void |
expect(byte val)
Confirm that the byte at the current position matches the given value. |
void |
expect(int val)
Confirm that the byte at the current position matches the given value. |
byte[] |
getBytes(int length)
Return an array of bytes from the current position. |
int |
getLength()
Get the DER length at the current position. |
void |
reset()
Reset the current position to the start of the array. |
void |
skip(int length)
Advance the current position by the given number of bytes. |
boolean |
test(byte val)
Test if the byte at the current position matches the given value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final byte TYPE_BIT_STRING
public static final byte TYPE_OCTET_STRING
public static final byte TYPE_SEQUENCE
| Constructor Detail |
|---|
public DERDecoder(byte[] derEncoded)
throws WSSecurityException
derEncoded - the DER-encoded array to decode.
WSSecurityException - if the given array is null.| Method Detail |
|---|
public void reset()
public void skip(int length)
throws WSSecurityException
length - the number of bytes to skip.
WSSecurityException - if length is negative.
public void expect(int val)
throws WSSecurityException
val - the expected next byte.
WSSecurityException - if the current position is at the end of the array, or if the
byte at the current position doesn't match the expected value.
public void expect(byte val)
throws WSSecurityException
val - the expected next byte.
WSSecurityException - if the current position is at the end of the array, or if the
byte at the current position doesn't match the expected value.
public boolean test(byte val)
throws WSSecurityException
val - the value to test for a match with the current byte.
WSSecurityException - if the current position is at the end of
the array.
public int getLength()
throws WSSecurityException
DER length is encoded as
WSSecurityException - if the current position is at the end of the array or there is
an incomplete length specification.
public byte[] getBytes(int length)
throws WSSecurityException
length - the number of bytes to return.
WSSecurityException - if the current position is at the end of the array, or the
length is negative.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||