Class BindProfileAddress

java.lang.Object
com.isode.dsapi.syntax.BindProfileAddress
All Implemented Interfaces:
Comparable<BindProfileAddress>

public class BindProfileAddress extends Object implements Comparable<BindProfileAddress>
This class stores information about a bind profile address in the following categories: LDAP URI, LDAPS URI, presentation address containing only a single ITOT network address (DAP), other valid presentation addresses (Advanced) and any other string that does not fit into the categories before (Other).

LDAP and LDAPS are used to support the bind profile ldap & ldaps url's. DAP is provided for those who are used to seeing single ITOT network addresses as "DAP" in their bind profile editors. "Advanced" allows support for any type of valid presentation address. "XMPP" is used for storing M-Link server administration details. "Other" is supported because it seems some users may want to put anything else as a bind profile address.

This is an immutable class.

Examples:

LDAP: ldap://localhost:29389

LDAPS: ldaps://localhost

DAP: URI+0000+URL+itot://localhost:29999

Advanced: "0aZ-."/ '0aff'H/'00'H/TELEX+00728722+IP-APP+11+127.0.0.1|URI+0000+URL+itot://[FFEF::1 ]

XMPP: xmpp://isode.com

Other: Anything else

Since:
15.0
Author:
mv
  • Constructor Details

    • BindProfileAddress

      public BindProfileAddress(String str) throws BadValueException, BadSyntaxException
      Constructor to create an object with the given data.
      Parameters:
      str - String representation of the bind profile address.
      Throws:
      BadValueException - if the input is invalid.
      BadSyntaxException - if it is not possible to parse the presentation address.
    • BindProfileAddress

      public BindProfileAddress(PresentationAddress pa) throws BadValueException
      Constructor to create an object with the given data.
      Parameters:
      pa - Bind profile address in the form of a presentation address.
      Throws:
      BadValueException - if the input is invalid.
    • BindProfileAddress

      public BindProfileAddress(URIData uriData) throws BadValueException
      Constructor to create a bind profile address of the type AddressType.LDAP AddressType.LDAPS or AddressType.XMPP.
      Parameters:
      uriData - URI data to create address with
      Throws:
      BadValueException - if the input is invalid.
    • BindProfileAddress

      public BindProfileAddress(BindProfileAddress bpaToCopy, String hostName, int portNo) throws BadValueException, BadSyntaxException
      Creates a copy of a given BindProfileAddress. But with the hostName and portNo replaced by the given values.
      Parameters:
      bpaToCopy - The BindProfileAddress to copy. This can not be null.
      hostName - The new value for host name. This can not be null.
      portNo - The new value for port no.
      Throws:
      BadValueException - If any of the input is invalid
      BadSyntaxException - If it was not possible to parse the PresentationAddress.
      Since:
      16.0
  • Method Details

    • getAddressType

      public BindProfileAddress.AddressType getAddressType()
      Returns the type of the bind profile address.
      Returns:
      Type of the bind profile address.
    • getStringRepresentation

      public String getStringRepresentation()
      Returns a String representation of this object, which can be used in BindProfileAddress(String) to construct another object that has the equivalent value.
      Returns:
      a String representation of the object, suitable for re-creating an equivalent BindProfileAddress object.
    • toString

      public String toString()
      Returns a String representation of this BindProfileAddress. The current implementation simply wraps getStringRepresentation()
      Overrides:
      toString in class Object
    • getPresentationAddress

      public PresentationAddress getPresentationAddress()
      Returns the bind profile address in the form of a presentation address.
      Returns:
      Bind profile address in the form of a presentation address; NULL if the bind profile address is not in the form AddressType.DAP or AddressType.ADVANCED.
    • getURIData

      public URIData getURIData()
      Returns the bind profile address in the form of URI data.
      Returns:
      Bind profile address in the form of URI data; NULL if the bind profile address is not in the form AddressType.LDAP, AddressType.LDAPS or AddressType.XMPP.
    • getOther

      public String getOther()
      Returns the bind profile address in the form of Other string.
      Returns:
      Bind profile address in the form of other string; NULL if the bind profile address is not in the form AddressType.OTHER.
    • getHost

      public String getHost()
      Returns the host name of the bind profile address if the bind profile address is not of the ADVANCED or OTHER type.
      Returns:
      Host name of the bind profile address; NULL if the bind profile address is of the ADVANCED or OTHER type.
    • getPort

      public int getPort()
      Returns the port of the bind profile address if the bind profile address is not of the ADVANCED or OTHER type.
      Returns:
      Port of the bind profile address; -1 if the bind profile address is of the ADVANCED or OTHER type, or if the bind profile address contains no explicit port number (e.g. "ldap://william.isode.net")
    • getHostnames

      public String getHostnames()
      Returns a String containing the names of any hosts that are contained in this object. If no host names are available, the method returns an empty String ("")
      Returns:
      a String containing all the distinct hostnames that are contained in this object.
      See Also:
    • getFriendlyString

      public String getFriendlyString()
      Return a String containing a short "user-friendly" version of the BindProfileAddress. The intention is that this String be used in situations where we want to enough information that's likely to allow the user to identify the address without having to overload the user with a full-blown String representation.

      The current implementation simply calls getHostnames(). A future implementation may do something more elaborate.

      Returns:
      a String representation of the PresentationAddress which contains enough information to be useful in most cases. If it's not possible to make a short name, then this method returns the empty String "".
    • getCanonicalForm

      public BindProfileAddress getCanonicalForm() throws BadSyntaxException
      The URI data and presentation address are converted to their canonical forms. The other string is converted to lower case.
      Returns:
      canonical form of object.
      Throws:
      BadSyntaxException - if it is not possible to parse the presentation address.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(BindProfileAddress o)
      Specified by:
      compareTo in interface Comparable<BindProfileAddress>
    • getBindableAddresses

      public static ArrayList<BindProfileAddress> getBindableAddresses(PresentationAddress pa) throws BadSyntaxException
      Creates a list of unique bindable addresses from the network addresses in the given presentation address. It uses the following order to create the list:

      If there are LDAP NetworkAddress.Type addresses in the presentation address (which do not have extra info in the URI if they are URI), it forms an LDAP BindProfileAddress.AddressType bind profile address out of each such LDAP network address. These bind profile addresses are ordered in the order the LDAP addresses are found in the presentation address.

      Then, if there are LDAPS NetworkAddress.Type addresses in the presentation address (which do not have extra info in the URI if they are URI), it forms an LDAPS BindProfileAddress.AddressType bind profile address out of each such LDAPS network address. These bind profile addresses are ordered in the order the LDAPS addresses are found in the presentation address.

      Then, if there are ITOT NetworkAddress.Type addresses in the presentation address, it forms a DAP BindProfileAddress.AddressType bind profile address out of each such ITOT network address. These bind profile addresses are ordered in the order the ITOT addresses are found in the presentation address.

      Then, it forms a bind profile address out of each remaining network addresses. These bind profile addresses are ordered in the order the remaining network addresses are found in the presentation address.

      Selectors in the given presentation address are ignored.

      An empty list is returned if presentation address is null.

      Parameters:
      pa - Presentation address to create bindable address list from, can be null.
      Returns:
      List of bindable bind profile addresses.
      Throws:
      BadSyntaxException - if it is not possible to parse the presentation address.
    • getMostBindableAddress

      public static BindProfileAddress getMostBindableAddress(PresentationAddress pa) throws BadSyntaxException
      Returns the most bindable address in the given presentation address. It uses getBindableAddresses(PresentationAddress) to get the list of bindable addresses and returns the first bind profile address in the list.

      If there are any selectors in the presentation address, the bind profile address is created out of the entire presentation address.

      Parameters:
      pa - Presentation address to create bindable address from, can be null.
      Returns:
      Most bindable bind profile address, will be null if given presentation address was null.
      Throws:
      BadSyntaxException - if it is not possible to parse the presentation address.