IpSecTransform.Builder


public static class IpSecTransform.Builder
extends Object

java.lang.Object
   ↳ android.net.IpSecTransform.Builder


This class is used to build IpSecTransform objects.

Summary

Public constructors

Builder(Context context)

Create a new IpSecTransform.Builder.

Public methods

IpSecTransform buildTransportModeTransform(InetAddress sourceAddress, IpSecManager.SecurityParameterIndex spi)

Build a transport mode IpSecTransform.

IpSecTransform.Builder setAuthenticatedEncryption(IpSecAlgorithm algo)

Set the authenticated encryption algorithm.

IpSecTransform.Builder setAuthentication(IpSecAlgorithm algo)

Set the authentication (integrity) algorithm.

IpSecTransform.Builder setEncryption(IpSecAlgorithm algo)

Set the encryption algorithm.

IpSecTransform.Builder setIpv4Encapsulation(IpSecManager.UdpEncapsulationSocket localSocket, int remotePort)

Add UDP encapsulation to an IPv4 transform.

Inherited methods

Public constructors

Builder

Added in API level 28
public Builder (Context context)

Create a new IpSecTransform.Builder.

Parameters
context Context: current context This value cannot be null.

Public methods

buildTransportModeTransform

Added in API level 28
public IpSecTransform buildTransportModeTransform (InetAddress sourceAddress, 
                IpSecManager.SecurityParameterIndex spi)

Build a transport mode IpSecTransform.

This builds and activates a transport mode transform. Note that an active transform will not affect any network traffic until it has been applied to one or more sockets.

Parameters
sourceAddress InetAddress: the source InetAddress of traffic on sockets that will use this transform; this address must belong to the Network used by all sockets that utilize this transform; if provided, then only traffic originating from the specified source address will be processed. This value cannot be null.

spi IpSecManager.SecurityParameterIndex: a unique IpSecManager.SecurityParameterIndex to identify transformed traffic This value cannot be null.

Returns
IpSecTransform This value cannot be null.

Throws
IllegalArgumentException indicating that a particular combination of transform properties is invalid
IpSecManager.ResourceUnavailableException indicating that too many transforms are active
IpSecManager.SpiUnavailableException indicating the rare case where an SPI collides with an existing transform
IOException indicating other errors

setAuthenticatedEncryption

Added in API level 28
public IpSecTransform.Builder setAuthenticatedEncryption (IpSecAlgorithm algo)

Set the authenticated encryption algorithm.

The Authenticated Encryption (AE) class of algorithms are also known as Authenticated Encryption with Associated Data (AEAD) algorithms, or Combined mode algorithms (as referred to in RFC 4301).

Authenticated encryption is mutually exclusive with encryption and authentication.

Parameters
algo IpSecAlgorithm: IpSecAlgorithm specifying the authenticated encryption algorithm to be applied. This value cannot be null.

Returns
IpSecTransform.Builder This value cannot be null.

setAuthentication

Added in API level 28
public IpSecTransform.Builder setAuthentication (IpSecAlgorithm algo)

Set the authentication (integrity) algorithm.

Authentication is mutually exclusive with authenticated encryption.

Parameters
algo IpSecAlgorithm: IpSecAlgorithm specifying the authentication to be applied. This value cannot be null.

Returns
IpSecTransform.Builder This value cannot be null.

setEncryption

Added in API level 28
public IpSecTransform.Builder setEncryption (IpSecAlgorithm algo)

Set the encryption algorithm.

Encryption is mutually exclusive with authenticated encryption.

Parameters
algo IpSecAlgorithm: IpSecAlgorithm specifying the encryption to be applied. This value cannot be null.

Returns
IpSecTransform.Builder This value cannot be null.

setIpv4Encapsulation

Added in API level 28
public IpSecTransform.Builder setIpv4Encapsulation (IpSecManager.UdpEncapsulationSocket localSocket, 
                int remotePort)

Add UDP encapsulation to an IPv4 transform.

This allows IPsec traffic to pass through a NAT.

Parameters
localSocket IpSecManager.UdpEncapsulationSocket: a socket for sending and receiving encapsulated traffic This value cannot be null.

remotePort int: the UDP port number of the remote host that will send and receive encapsulated traffic. In the case of IKEv2, this should be port 4500.

Returns
IpSecTransform.Builder This value cannot be null.