ASN1Implicitpublic class ASN1Implicit extends ASN1Type Implicitly tagged ASN.1 type. |
Fields Summary |
---|
private static final int | TAGGING_PRIMITIVE | private static final int | TAGGING_CONSTRUCTED | private static final int | TAGGING_STRING | private final ASN1Type | type | private final int | taggingType |
Constructors Summary |
---|
public ASN1Implicit(int tagNumber, ASN1Type type)Constructs implicitly tagged ASN.1 type
with context-specific tag class and specified tag number.
this(CLASS_CONTEXTSPECIFIC, tagNumber, type);
| public ASN1Implicit(int tagClass, int tagNumber, ASN1Type type)Constructs implicitly tagged ASN.1 type
super(tagClass, tagNumber);
if ((type instanceof ASN1Choice) || (type instanceof ASN1Any)) {
// According to X.680:
// 'The IMPLICIT alternative shall not be used if the type
// defined by "Type" is an untagged choice type or an
// untagged open type'
throw new IllegalArgumentException(
Messages.getString("security.9F")); //$NON-NLS-1$
}
this.type = type;
if (type.checkTag(type.id)) {
if (type.checkTag(type.constrId)) {
// the base encoding can be primitive ot constructed
// use both encodings
taggingType = TAGGING_STRING;
} else {
// if the base encoding is primitive use primitive encoding
taggingType = TAGGING_PRIMITIVE;
}
} else {
// if the base encoding is constructed use constructed encoding
taggingType = TAGGING_CONSTRUCTED;
}
|
Methods Summary |
---|
public final boolean | checkTag(int identifier)TODO
switch (taggingType) {
case TAGGING_PRIMITIVE:
return id == identifier;
case TAGGING_CONSTRUCTED:
return constrId == identifier;
default: // TAGGING_STRING
return id == identifier || constrId == identifier;
}
| public java.lang.Object | decode(BerInputStream in)TODO
if (!checkTag(in.tag)) {
// FIXME need look for tagging type
throw new ASN1Exception(Messages.getString("security.100", //$NON-NLS-1$
new Object[] { in.tagOffset, Integer.toHexString(id),
Integer.toHexString(in.tag) }));
}
// substitute indentifier for further decoding
if (id == in.tag) {
in.tag = type.id;
} else {
in.tag = type.constrId;
}
in.content = type.decode(in);
if (in.isVerify) {
return null;
}
return getDecodedObject(in);
| public void | encodeASN(BerOutputStream out)
//FIXME need another way for specifying identifier to be encoded
if (taggingType == TAGGING_CONSTRUCTED) {
out.encodeTag(constrId);
} else {
out.encodeTag(id);
}
encodeContent(out);
| public void | encodeContent(BerOutputStream out)
type.encodeContent(out);
| public void | setEncodingContent(BerOutputStream out)
type.setEncodingContent(out);
|
|