Class ASNConv

java.lang.Object
com.isode.dsapi.internal.ASNConv

public class ASNConv extends Object
This class provides functions for conversion between native Java-DSAPI types and the generated Java-ASN types.
Author:
jp
  • Constructor Details

    • ASNConv

      public ASNConv()
  • Method Details

    • convert

      Convert IF.AttributeTypeAndValue to Attribute.
      Throws:
      BadAttributeTypeException
      BadSyntaxException
      BadValueException
      Since:
      14.4
    • convert

      Convert IF.Attribute to Attribute.
      Throws:
      BadAttributeTypeException
      BadSyntaxException
      BadValueException
      Since:
      14.4
    • convert

      public static RDN convert(IF.RelativeDistinguishedName ifrdn) throws BadDNException
      Convert IF.RelativeDistinguishedName to RDN.
      Throws:
      BadDNException - if there was any problem converting the attributes and forming the RDN.
      Since:
      14.4
    • convert

      public static DN convert(IF.RDNSequence ifdn) throws BadDNException
      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 value
      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

      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

      public static IF.RelativeDistinguishedName convert(RDN rdn) throws BadDNException
      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

      public static IF.RDNSequence convert(DN dn) throws BadDNException
      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

      public static <T extends BERCodable> T decode(byte[] arr, Class<T> type) throws BadValueException
      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 decode
      type - 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 decode
      type - 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

      public static byte[] encode(BERCodable obj) throws BadValueException
      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

      public static AttributeValue encode(BERCodable obj, AttributeType type) throws BadValueException
      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 encode
      type - AttributeType to encode as
      Returns:
      Valid AttributeValue
      Throws:
      BadValueException - If there are encoding errors
    • oidToAttrType

      public 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.
      Parameters:
      oid - oid string
      Returns:
      an attribute name, if known to the schema, otherwise the same OID
      Since:
      14.4
    • attrTypeToOID

      public static String attrTypeToOID(String type)
      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

      public static String oidToOC(String oid)
      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

      public static String ocToOID(String type)
      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

      public 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(). 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