Class PeerAuthData

java.lang.Object
com.isode.dsapi.config.PeerAuthData
All Implemented Interfaces:
Comparable<PeerAuthData>

public class PeerAuthData extends Object implements Comparable<PeerAuthData>
Peer authentication data.

This is an immutable class.

Since:
15.0
  • Constructor Details

    • PeerAuthData

      public PeerAuthData(PeerAuthMode authModeISend, List<PeerAuthMode> authModesIExpect, String passwordISend, String passwordIExpect)
      Constructor that creates an object according to given data. This constructor should be used when there are multiple expected authentication modes.
      Parameters:
      authModeISend - authentication mode to be used when sending a message to the peer, must not be null
      authModesIExpect - list of authentication modes expected when receiving a message from the peer, must not be null. If this list contains multiple modes of the same type, the duplicates would be removed. Null elements are ignored. If the list is empty, a default authentication mode would be added.
      passwordISend - password to be used when sending a message to the peer, can be null if no password is associated with the authentication mode
      passwordIExpect - password expected when receiving a message from the peer, can be null if no password is associated with the authentication mode
    • PeerAuthData

      public PeerAuthData(PeerAuthMode authModeISend, List<PeerAuthMode> authModesIExpect, String passwordISend, String passwordIExpect, ConnectionPolicy instConnectionPolicy)
    • PeerAuthData

      public PeerAuthData(PeerAuthMode authModeISend, PeerAuthMode authModeIExpect, String passwordISend, String passwordIExpect)
      Constructor that creates an object according to given data. This constructor should be used when there is a single expected authentication mode.
      Parameters:
      authModeISend - authentication mode to be used when sending a message to the peer, must not be null
      authModeIExpect - authentication mode expected when receiving a message from the peer, must not be null
      passwordISend - password to be used when sending a message to the peer, can be null if no password is associated with the authentication mode
      passwordIExpect - password expected when receiving a message from the peer, can be null if no password is associated with the authentication mode
    • PeerAuthData

      public PeerAuthData(PeerAuthMode authModeISend, PeerAuthMode authModeIExpect, String passwordISend, String passwordIExpect, ConnectionPolicy instConnectionPolicy)
    • PeerAuthData

      public PeerAuthData(PeerAuthMode authMode, String password)
      Constructor that creates an object in the basic form according to given data. Basic form of auth data contains one expect auth mode which is the same as the send auth mode, and same passwords (can be null if no password is associated with the authentication mode).
      Parameters:
      authMode - authentication mode to be used when exchanging a message with the peer, must not be null
      password - password to be used when exchanging a message with the peer, can be null if no password is associated with the authentication mode
    • PeerAuthData

      public PeerAuthData(PeerAuthData copy)
      Copy constructor.
      Parameters:
      copy - Authentication data to copy, must not be null
  • Method Details

    • isAuthModePermitted

      public boolean isAuthModePermitted(PeerAuthMode mode)
      Check if the given authentication mode is permitted for incoming associations.
      Parameters:
      mode - Authentication mode, must not be null
      Returns:
      TRUE if authentication is configured, FALSE otherwise
    • getConnectionPolicy

      public ConnectionPolicy getConnectionPolicy()
      Returns:
      authentication mode to be used when sending a message to the peer, can not be null
    • getAuthModeISend

      public PeerAuthMode getAuthModeISend()
      Returns:
      authentication mode to be used when sending a message to the peer, can not be null
    • getAuthModesIExpect

      public List<PeerAuthMode> getAuthModesIExpect()
      Returns:
      list of authentication modes to be used when receiving a message from the peer, can not be null or empty
    • getPasswordISend

      public String getPasswordISend()
      Returns:
      password to be used when sending a message to the peer, can be null if not set
    • getPasswordIExpect

      public String getPasswordIExpect()
      Returns:
      password to be used when receiving a message from the peer, can be null if not set
    • getReverse

      public PeerAuthData getReverse()
      Returns a new auth data that copies from this auth data, but copies the send info to expect and vice versa. It copies the highest expected auth mode into the send auth mode.

      This can be useful when creating the auth data that would be configured on the peer.

      Returns:
      reverse auth data, will not be null
    • getReverse

      public PeerAuthData getReverse(List<PeerAuthMode> authModesAlreadyExpected)
      Returns a new auth data that copies from this auth data, but copies the send info to expect and vice versa. If authModesAlreadyExpected is not null, it uses the given list as it is but adds the send auth mode to the list too. It copies the highest expected auth mode into the send auth mode. If the send auth mode results in being a mode without a password, the send password is set to null too.

      This can be useful when creating the auth data that would be configured on the peer.

      Parameters:
      authModesAlreadyExpected - list of already expected auth modes to be present in the resulting reverse auth data, can be null
      Returns:
      reverse auth data, will not be null
    • isReverse

      public boolean isReverse(PeerAuthData reverse)
      Determine if given auth data is reverse of this one. It is considered reverse if the send auth mode of each exists in the expect list of the other and if the send auth mode on either requires a password, then the send password is the same as the expect password on the other.
      Parameters:
      reverse - peer auth data to determine if it is a reverse
      Returns:
      TRUE if reverse, FALSE if not.
    • isBasic

      public boolean isBasic()
      Determine if auth data is in basic form.
      Returns:
      TRUE if in basic form, FALSE if not.
    • equals

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

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

      public int compareTo(PeerAuthData o)
      Specified by:
      compareTo in interface Comparable<PeerAuthData>
    • toString

      public String toString()
      Returns human-readable version of the object, for debugging
      Overrides:
      toString in class Object
      Returns:
      a String representation of a PeerAuthData