Package com.isode.dsapi.internal
Class ASNConv
java.lang.Object
com.isode.dsapi.internal.ASNConv
This class provides functions for conversion between native
Java-DSAPI types and the generated Java-ASN types.
- Author:
- jp
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
attrTypeToOID
(String type) Convert an attribute-type name into an OID, if it is known to the schema.static Attribute
convert
(IF.Attribute ifattr) Convert IF.Attribute to Attribute.static Attribute
convert
(IF.AttributeTypeAndValue ifatv) Convert IF.AttributeTypeAndValue to Attribute.static DN
convert
(IF.RDNSequence ifdn) Convert IF.RDNSequence to DN.static RDN
Convert IF.RelativeDistinguishedName to RDN.static IF.Attribute
Convert Attribute to IF.Attribute.static IF.RDNSequence
Convert DN to IF.RDNSequence.static IF.RelativeDistinguishedName
Convert RDN to IF.RelativeDistinguishedName.static IF.AttributeTypeAndValue
Convert a Attribute with one value to IF.AttributeTypeAndValue.static <T extends BERCodable>
TDecode the given BER byte[] as an instance of the given BERCodable class and return it.static <T extends BERCodable>
Tdecode
(AttributeValue av, Class<T> type) Decode the given AttributeValue as an instance of the given BERCodable class and return it.static byte[]
encode
(BERCodable obj) Encode the given BERCodable object as a BER byte[] and return it.static AttributeValue
encode
(BERCodable obj, AttributeType type) Encode the given BERCodable object as an AttributeValue of the given AttributeType and return it.static String
oclistToOIDList
(OCList oclist) Convert an OCList to a list of OIDs in a string, with spaces before and after each OID, suitable for passing to BAC.Refinement.eval().static String
Convert an objectclass name into an OID, if it is known to the schema.static String
oidToAttrType
(String oid) Convert an OID-string to a string attribute-type name if it is known to the schema, otherwise return the same OID.static String
Convert an OID-string to an objectclass name if it is known to the schema, otherwise return the same OID.
-
Constructor Details
-
ASNConv
public ASNConv()
-
-
Method Details
-
convert
public static Attribute convert(IF.AttributeTypeAndValue ifatv) throws BadAttributeTypeException, BadSyntaxException, BadValueException Convert IF.AttributeTypeAndValue to Attribute.- Throws:
BadAttributeTypeException
BadSyntaxException
BadValueException
- Since:
- 14.4
-
convert
public static Attribute convert(IF.Attribute ifattr) throws BadAttributeTypeException, BadSyntaxException, BadValueException Convert IF.Attribute to Attribute.- Throws:
BadAttributeTypeException
BadSyntaxException
BadValueException
- Since:
- 14.4
-
convert
Convert IF.RelativeDistinguishedName to RDN.- Throws:
BadDNException
- if there was any problem converting the attributes and forming the RDN.- Since:
- 14.4
-
convert
Convert IF.RDNSequence to DN.- Throws:
BadDNException
- if there was any problem converting the attributes and forming the DN.- Since:
- 14.4
-
convertToAttributeTypeAndValue
public static IF.AttributeTypeAndValue convertToAttributeTypeAndValue(Attribute attr) throws OperationFailedException, BadAttributeTypeException, BadValueException Convert a Attribute with one value to IF.AttributeTypeAndValue.- Throws:
OperationFailedException
- if the attribute didn't have exactly one valueBadAttributeTypeException
- if it wasn't possible to get the OID for the attribute-type (e.g. for 'unknown' types)BadValueException
- if it wasn't possible to convert the value to BER, e.g. for schema-invalid values- Since:
- 14.4
-
convert
public static IF.Attribute convert(Attribute attr) throws BadAttributeTypeException, BadValueException Convert Attribute to IF.Attribute.- Throws:
BadAttributeTypeException
- if it wasn't possible to get the OID for the attribute-type (e.g. for 'unknown' types)BadValueException
- if it wasn't possible to convert the value to BER, e.g. for schema-invalid values- Since:
- 14.4
-
convert
Convert RDN to IF.RelativeDistinguishedName.- Throws:
BadDNException
- if there is something invalid about the RDN: either that one of the RDN attributes doesn't have exactly one value, or that it wasn't possible to get an OID for one of the RDN attribute-types, or that it wasn't possible to convert the value to BER (e.g. for schema-invalid values). None of these problems should occur for a valid RDN.- Since:
- 14.4
-
convert
Convert DN to IF.RDNSequence.- Throws:
BadDNException
- if there is something invalid about one of the RDNs: either that one of the RDN attributes doesn't have exactly one value, or that it wasn't possible to get an OID for one of the RDN attribute-types, or that it wasn't possible to convert the value to BER (e.g. for schema-invalid values). None of these problems should occur for a valid DN.- Since:
- 14.4
-
decode
Decode the given BER byte[] as an instance of the given BERCodable class and return it. Throw a BadValueException if there is any problem with the decoding.- Parameters:
arr
- BER byte[] to decodetype
- Class to decode as (e.g. 'BAC.ACIItem.class')- Returns:
- Instance of class requested, filled with data from AttributeValue
- Throws:
BadValueException
- If there are decoding errors
-
decode
public static <T extends BERCodable> T decode(AttributeValue av, Class<T> type) throws BadValueException Decode the given AttributeValue as an instance of the given BERCodable class and return it. Throw a BadValueException if there is any problem with the decoding.- Parameters:
av
- AttributeValue to decodetype
- Class to decode as (e.g. 'BAC.ACIItem.class')- Returns:
- Instance of class requested, filled with data from AttributeValue
- Throws:
BadValueException
- If there are decoding errors
-
encode
Encode the given BERCodable object as a BER byte[] and return it. Throw a BadValueException if there is any problem with the encoding.- Parameters:
obj
- BERCodable object to encode- Returns:
- BER byte[]
- Throws:
BadValueException
- If there are encoding errors
-
encode
Encode the given BERCodable object as an AttributeValue of the given AttributeType and return it. Throw a BadValueException if there is any problem with the encoding.- Parameters:
obj
- BERCodable object to encodetype
- AttributeType to encode as- Returns:
- Valid AttributeValue
- Throws:
BadValueException
- If there are encoding errors
-
oidToAttrType
Convert an OID-string to a string attribute-type name if it is known to the schema, otherwise return the same OID.- Parameters:
oid
- oid string- Returns:
- an attribute name, if known to the schema, otherwise the same OID
- Since:
- 14.4
-
attrTypeToOID
Convert an attribute-type name into an OID, if it is known to the schema. If not, the original name is returned unchanged. The resulting string can be passed through to the ASN.1 encoder. If it happened to be a valid OID already, then all is well; otherwise the encoder will report the error.- Parameters:
type
- attribute type- Returns:
- the corresponding OID if known, otherwise the original name
- Since:
- 14.4
-
oidToOC
Convert an OID-string to an objectclass name if it is known to the schema, otherwise return the same OID.- Parameters:
oid
- an oid- Returns:
- corresponding objectclass name, if known, otherwise the original OID
- Since:
- 14.4
-
ocToOID
Convert an objectclass name into an OID, if it is known to the schema. If not, the original name is returned unchanged. The resulting string can be passed through to the ASN.1 encoder. If it happened to be a valid OID already, then all is well; otherwise the encoder will report the error.- Parameters:
type
- objectclass name- Returns:
- corresponding OID if known, otherwise the original name.
- Since:
- 14.4
-
oclistToOIDList
Convert an OCList to a list of OIDs in a string, with spaces before and after each OID, suitable for passing to BAC.Refinement.eval(). Any objectclasses which aren't known to the schema are passed through as text names, and so won't be matched.- Parameters:
oclist
- OCList- Since:
- 15.0
-