Package com.isode.dsapi.config
Class PeerAuthData
java.lang.Object
com.isode.dsapi.config.PeerAuthData
- All Implemented Interfaces:
Comparable<PeerAuthData>
Peer authentication data.
This is an immutable class.
- Since:
- 15.0
-
Constructor Summary
ConstructorsConstructorDescriptionPeerAuthData
(PeerAuthData copy) Copy constructor.PeerAuthData
(PeerAuthMode authModeISend, PeerAuthMode authModeIExpect, String passwordISend, String passwordIExpect) Constructor that creates an object according to given data.PeerAuthData
(PeerAuthMode authModeISend, PeerAuthMode authModeIExpect, String passwordISend, String passwordIExpect, ConnectionPolicy instConnectionPolicy) PeerAuthData
(PeerAuthMode authMode, String password) Constructor that creates an object in the basic form according to given data.PeerAuthData
(PeerAuthMode authModeISend, List<PeerAuthMode> authModesIExpect, String passwordISend, String passwordIExpect) Constructor that creates an object according to given data.PeerAuthData
(PeerAuthMode authModeISend, List<PeerAuthMode> authModesIExpect, String passwordISend, String passwordIExpect, ConnectionPolicy instConnectionPolicy) -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
Returns a new auth data that copies from this auth data, but copies the send info to expect and vice versa.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.int
hashCode()
boolean
Check if the given authentication mode is permitted for incoming associations.boolean
isBasic()
Determine if auth data is in basic form.boolean
isReverse
(PeerAuthData reverse) Determine if given auth data is reverse of this one.toString()
Returns human-readable version of the object, for debugging
-
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 nullauthModesIExpect
- 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 modepasswordIExpect
- 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 nullauthModeIExpect
- authentication mode expected when receiving a message from the peer, must not be nullpasswordISend
- password to be used when sending a message to the peer, can be null if no password is associated with the authentication modepasswordIExpect
- 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
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 nullpassword
- password to be used when exchanging a message with the peer, can be null if no password is associated with the authentication mode
-
PeerAuthData
Copy constructor.- Parameters:
copy
- Authentication data to copy, must not be null
-
-
Method Details
-
isAuthModePermitted
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
- Returns:
- authentication mode to be used when sending a message to the peer, can not be null
-
getAuthModeISend
- Returns:
- authentication mode to be used when sending a message to the peer, can not be null
-
getAuthModesIExpect
- Returns:
- list of authentication modes to be used when receiving a message from the peer, can not be null or empty
-
getPasswordISend
- Returns:
- password to be used when sending a message to the peer, can be null if not set
-
getPasswordIExpect
- Returns:
- password to be used when receiving a message from the peer, can be null if not set
-
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
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
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
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<PeerAuthData>
-
toString
Returns human-readable version of the object, for debugging
-