IkeSessionParams


public final class IkeSessionParams
extends Object

java.lang.Object
   ↳ android.net.ipsec.ike.IkeSessionParams


IkeSessionParams contains all user provided configurations for negotiating an IkeSession.

Note that all negotiated configurations will be reused during rekey including SA Proposal and lifetime.

Summary

Nested classes

class IkeSessionParams.Builder

This class can be used to incrementally construct a IkeSessionParams

class IkeSessionParams.IkeAuthConfig

This class contains common information of an IKEv2 authentication configuration. 

class IkeSessionParams.IkeAuthDigitalSignLocalConfig

This class represents the configuration to support IKEv2 public-key-signature-based authentication of the local side. 

class IkeSessionParams.IkeAuthDigitalSignRemoteConfig

This class represents the configuration to support IKEv2 public-key-signature-based authentication of the remote side. 

class IkeSessionParams.IkeAuthEapConfig

This class represents the configuration to support EAP authentication of the local side. 

class IkeSessionParams.IkeAuthPskConfig

This class represents the configuration to support IKEv2 pre-shared-key-based authentication of local or remote side. 

Constants

int IKE_DPD_DELAY_SEC_DISABLED

Setting timer to this value will disable the Dead Peer Detection(DPD).

int IKE_OPTION_ACCEPT_ANY_REMOTE_ID

If set, the IKE library will accept any remote (server) identity, even if it does not match the configured remote identity

See Builder.setRemoteIdentification(IkeIdentification)

int IKE_OPTION_EAP_ONLY_AUTH

If set, and EAP has been configured as the authentication method, the IKE library will request that the remote (also) use an EAP-only authentication flow.

int IKE_OPTION_FORCE_PORT_4500

Configures the IKE session to always send to port 4500.

int IKE_OPTION_INITIAL_CONTACT

If set, the IKE library will send INITIAL_CONTACT notification to the peers.

int IKE_OPTION_MOBIKE

If set, the IKE Session will attempt to handle IP address changes using RFC4555 MOBIKE.

Public methods

boolean equals(Object o)

Indicates whether some other object is "equal to" this one.

int getDpdDelaySeconds()

Retrieves the Dead Peer Detection(DPD) delay in seconds

int getHardLifetimeSeconds()

Retrieves hard lifetime in seconds

Set<Integer> getIkeOptions()

Return all the enabled IKE Options

List<IkeSaProposal> getIkeSaProposals()

Retrieves all IkeSaProposals configured

IkeSessionParams.IkeAuthConfig getLocalAuthConfig()

Retrieves the local (client) authentication configuration

IkeIdentification getLocalIdentification()

Retrieves the local (client) identity

int getNattKeepAliveDelaySeconds()

Retrieves the Network Address Translation Traversal (NATT) keepalive delay in seconds

Network getNetwork()

Retrieves the configured Network, or null if was not set.

IkeSessionParams.IkeAuthConfig getRemoteAuthConfig()

Retrieves the remote (server) authentication configuration

IkeIdentification getRemoteIdentification()

Retrieves the required remote (server) identity

int[] getRetransmissionTimeoutsMillis()

Retrieves the relative retransmission timeout list in milliseconds

@see Builder.setRetransmissionTimeoutsMillis(int[])

String getServerHostname()

Retrieves the configured server hostname

The configured server hostname will be resolved during IKE Session creation.

int getSoftLifetimeSeconds()

Retrieves soft lifetime in seconds

boolean hasIkeOption(int ikeOption)

Checks if the given IKE Session negotiation option is set

int hashCode()

Returns a hash code value for the object.

Inherited methods

Constants

IKE_DPD_DELAY_SEC_DISABLED

Added in API level 35
public static final int IKE_DPD_DELAY_SEC_DISABLED

Setting timer to this value will disable the Dead Peer Detection(DPD).

@see Builder.setDpdDelaySeconds

Constant Value: 2147483647 (0x7fffffff)

IKE_OPTION_ACCEPT_ANY_REMOTE_ID

Added in API level 31
public static final int IKE_OPTION_ACCEPT_ANY_REMOTE_ID

If set, the IKE library will accept any remote (server) identity, even if it does not match the configured remote identity

See Builder.setRemoteIdentification(IkeIdentification)

Constant Value: 0 (0x00000000)

IKE_OPTION_EAP_ONLY_AUTH

Added in API level 31
public static final int IKE_OPTION_EAP_ONLY_AUTH

If set, and EAP has been configured as the authentication method, the IKE library will request that the remote (also) use an EAP-only authentication flow.

@see Builder.setAuthEap(X509Certificate, EapSessionConfig)

Constant Value: 1 (0x00000001)

IKE_OPTION_FORCE_PORT_4500

Added in API level 31
public static final int IKE_OPTION_FORCE_PORT_4500

Configures the IKE session to always send to port 4500.

If set, the IKE Session will be initiated and maintained exclusively using destination port 4500, regardless of the presence of NAT. Otherwise, the IKE Session will be initiated on destination port 500; then, if either a NAT is detected or both MOBIKE and NAT-T are supported by the peer, it will proceed on port 4500.

Constant Value: 3 (0x00000003)

IKE_OPTION_INITIAL_CONTACT

Added in API level 33
public static final int IKE_OPTION_INITIAL_CONTACT

If set, the IKE library will send INITIAL_CONTACT notification to the peers.

If this option is set, the INITIAL_CONTACT notification payload is sent in IKE_AUTH. The client can use this option to assert to the peer that this IKE SA is the only IKE SA currently active between the authenticated identities.

@see "https://tools.ietf.org/html/rfc7296#section-2.4" RFC 7296, Internet Key Exchange Protocol Version 2 (IKEv2)

@see Builder.addIkeOption(int)

Constant Value: 4 (0x00000004)

IKE_OPTION_MOBIKE

Added in API level 31
public static final int IKE_OPTION_MOBIKE

If set, the IKE Session will attempt to handle IP address changes using RFC4555 MOBIKE.

Upon IP address changes (including Network changes), the IKE session will initiate an RFC 4555 MOBIKE procedure, migrating both this IKE Session and associated IPsec Transforms to the new local and remote address pair.

The IKE library will first attempt to enable MOBIKE to handle the changes of underlying network and addresses. For callers targeting SDK Build.VERSION_CODES.S_V2 and earlier, this option will implicitly enable the support for rekey-based mobility, and thus if the server does not support MOBIKE, the IKE Session will try migration by rekeying all associated IPsec SAs. This rekey-based mobility feature is not best-practice and has technical issues; accordingly, it will no longer be enabled for callers targeting SDK Build.VERSION_CODES.TIRAMISU and above.

Checking whether or not MOBIKE is supported by both the IKE library and the server in an IKE Session is done via IkeSessionConfiguration.isIkeExtensionEnabled(int).

It is recommended that IKE_OPTION_MOBIKE be enabled unless precluded for compatibility reasons.

If this option is set for an IKE Session, Transport-mode SAs will not be allowed in that Session.

Callers that need to perform migration of IPsec transforms and tunnels MUST implement migration specific methods in IkeSessionCallback and ChildSessionCallback.

Constant Value: 2 (0x00000002)

Public methods

equals

Added in API level 31
public boolean equals (Object o)

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o Object: the reference object with which to compare.
Returns
boolean true if this object is the same as the obj argument; false otherwise.

getDpdDelaySeconds

Added in API level 31
public int getDpdDelaySeconds ()

Retrieves the Dead Peer Detection(DPD) delay in seconds

Returns
int Value is ERROR(/#IKE_DPD_DELAY_SEC_MIN) or greater

getHardLifetimeSeconds

Added in API level 31
public int getHardLifetimeSeconds ()

Retrieves hard lifetime in seconds

Returns
int Value is between ERROR(/#IKE_HARD_LIFETIME_SEC_MINIMUM) and ERROR(/#IKE_HARD_LIFETIME_SEC_MAXIMUM) inclusive

getIkeOptions

Added in API level 35
public Set<Integer> getIkeOptions ()

Return all the enabled IKE Options

Returns
Set<Integer> A Set of enabled IKE options that have been added using Builder.addIkeOption(int)
This value cannot be null.
Value is one of the following:

getIkeSaProposals

Added in API level 31
public List<IkeSaProposal> getIkeSaProposals ()

Retrieves all IkeSaProposals configured

Returns
List<IkeSaProposal> This value cannot be null.

getLocalAuthConfig

Added in API level 31
public IkeSessionParams.IkeAuthConfig getLocalAuthConfig ()

Retrieves the local (client) authentication configuration

Returns
IkeSessionParams.IkeAuthConfig This value cannot be null.

getLocalIdentification

Added in API level 31
public IkeIdentification getLocalIdentification ()

Retrieves the local (client) identity

Returns
IkeIdentification This value cannot be null.

getNattKeepAliveDelaySeconds

Added in API level 31
public int getNattKeepAliveDelaySeconds ()

Retrieves the Network Address Translation Traversal (NATT) keepalive delay in seconds

Returns
int Value is between ERROR(/#IKE_NATT_KEEPALIVE_DELAY_SEC_MIN) and ERROR(/#IKE_NATT_KEEPALIVE_DELAY_SEC_MAX) inclusive

getNetwork

Added in API level 31
public Network getNetwork ()

Retrieves the configured Network, or null if was not set.

@see Builder.setNetwork(Network)

Returns
Network

getRemoteAuthConfig

Added in API level 31
public IkeSessionParams.IkeAuthConfig getRemoteAuthConfig ()

Retrieves the remote (server) authentication configuration

Returns
IkeSessionParams.IkeAuthConfig This value cannot be null.

getRemoteIdentification

Added in API level 31
public IkeIdentification getRemoteIdentification ()

Retrieves the required remote (server) identity

Returns
IkeIdentification This value cannot be null.

getRetransmissionTimeoutsMillis

Added in API level 31
public int[] getRetransmissionTimeoutsMillis ()

Retrieves the relative retransmission timeout list in milliseconds

@see Builder.setRetransmissionTimeoutsMillis(int[])

Returns
int[] This value cannot be null.

getServerHostname

Added in API level 31
public String getServerHostname ()

Retrieves the configured server hostname

The configured server hostname will be resolved during IKE Session creation.

Returns
String This value cannot be null.

getSoftLifetimeSeconds

Added in API level 31
public int getSoftLifetimeSeconds ()

Retrieves soft lifetime in seconds

Returns
int Value is between ERROR(/#IKE_SOFT_LIFETIME_SEC_MINIMUM) and ERROR(/#IKE_HARD_LIFETIME_SEC_MAXIMUM) inclusive

hasIkeOption

Added in API level 31
public boolean hasIkeOption (int ikeOption)

Checks if the given IKE Session negotiation option is set

Parameters
ikeOption int: the option to check.
Value is one of the following:
Returns
boolean
Throws
IllegalArgumentException if the provided option is invalid.

hashCode

Added in API level 31
public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns
int a hash code value for this object.