org.mozilla.jss.asn1
Class ANY
- ASN1Value
public class ANY
extends java.lang.Object
Represents an ASN.1
ANY
value. An ANY is just an arbitrary
ASN.1 value. It can be thought of as the simplest implementation of the
ASN1Value
interface. Although they can be created
from scratch (from raw BER), instances of
ANY
are usually
found after decoding
with a template that has an
ANY
field.
An
ANY
supports extracting the BER encoding, or decoding
with a different template.
static class | ANY.Template - A class for decoding
ANY values from BER.
|
ANY(byte[] encoded) - Creates an ANY value, which is just a generic ASN.1 value.
|
ANY(Tag tag, byte[] encoded) - Creates an ANY value, which is just a generic ASN.1 value.
|
ANY
public ANY(byte[] encoded)
throws InvalidBERException
Creates an ANY value, which is just a generic ASN.1 value.
encoded
- The complete BER encoding of this value, including
tag, form, length, and contents.
ANY
public ANY(Tag tag,
byte[] encoded)
Creates an ANY value, which is just a generic ASN.1 value.
This method is provided for efficiency if the tag is already known,
so that we don't have to parse the encoding for it.
tag
- The tag of this value. It must be the same as the actual tag
contained in the encoding.encoded
- The complete BER encoding of this value, including
tag, form, length, and contents.
decodeWith
public ASN1Value decodeWith(ASN1Template template)
throws InvalidBERException
Decodes this ANY using the given template. This is useful if you
originally decoded something as an ANY because you didn't know
what it was, but now you know what it is supposed to be.
template
- The template to use to decode this ANY.
- The output of the given template when it is fed the
encoding of this ANY.
decodeWith
public ASN1Value decodeWith(Tag implicitTag,
ASN1Template template)
throws IOException,
InvalidBERException
Decodes this ANY using the given template. This is useful if you
originally decoded something as an ANY because you didn't know
what it was, but now you know what it is supposed to be.
implicitTag
- The implicit tag for the encoding.template
- The template to use to decode this ANY.
- The output of the given template when it is fed the
encoding of this ANY.
encode
public void encode(OutputStream ostream)
throws IOException
- encode in interface ASN1Value
encode
public void encode(Tag implicitTag,
OutputStream ostream)
throws IOException
- encode in interface ASN1Value
implicitTag
- This parameter is ignored, because
ANY values cannot have implicit tags.
encodeWithAlternateTag
public void encodeWithAlternateTag(Tag alternateTag,
OutputStream ostream)
throws IOException,
InvalidBERException
Extracts the contents from the ANY and encodes them with
the provided tag.
getEncoded
public byte[] getEncoded()
Returns the complete encoding of header and contents, as passed into
the constructor or read from a BER input stream.
getTemplate
public static ANY.Template getTemplate()
Returns a singleton instance of a decoding template.