# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Ctors | Methods | Inherited Methods

# IkeSession

`public final class IkeSession`
`extends Object` `implements AutoCloseable`

java.lang.Object
↳ | android.net.ipsec.ike.IkeSession

This class represents an IKE Session management object that allows for keying and management of `IpSecTransform`s.

An IKE/Child Session represents an IKE/Child SA as well as its rekeyed successors. A Child Session is bounded by the lifecycle of the IKE Session under which it is set up. Closing an IKE Session implicitly closes any remaining Child Sessions under it.

An IKE procedure is one or multiple IKE message exchanges that are used to create, delete or rekey an IKE Session or Child Session.

This class provides methods for initiating IKE procedures, such as the Creation and Deletion of a Child Session, or the Deletion of the IKE session. All procedures (except for IKE deletion) will be initiated sequentially after IKE Session is set up.

See also:

- RFC 7296, Internet Key Exchange Protocol Version 2 (IKEv2)

## Summary

### Public constructors
`IkeSession(Context context, IkeSessionParams ikeSessionParams, ChildSessionParams firstChildSessionParams, Executor userCbExecutor, IkeSessionCallback ikeSessionCallback, ChildSessionCallback firstChildSessionCallback)` Constructs a new IKE session.

### Public methods
`void` | `close()` Close the IKE session gracefully.
`void` | `closeChildSession(ChildSessionCallback childSessionCallback)` Delete a Child Session.
`void` | `kill()` Terminate (forcibly close) the IKE session.
`void` | `openChildSession(ChildSessionParams childSessionParams, ChildSessionCallback childSessionCallback)` Request a new Child Session.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.
From interface `java.lang.AutoCloseable`
`abstract void` | `close()` Closes this resource, relinquishing any underlying resources.

## Public constructors

### IkeSession

    public IkeSession (Context context,
                    IkeSessionParams ikeSessionParams,
                    ChildSessionParams firstChildSessionParams,
                    Executor userCbExecutor,
                    IkeSessionCallback ikeSessionCallback,
                    ChildSessionCallback firstChildSessionCallback)

Constructs a new IKE session.

This method will immediately return an instance of `IkeSession` and asynchronously initiate the setup procedure of `IkeSession` as well as its first Child Session. Callers will be notified of these two setup results via the callback arguments.

FEATURE_IPSEC_TUNNELS is required for setting up a tunnel mode Child SA.

Parameters
`context` | `Context`: a valid `Context` instance. This value cannot be `null`.
`ikeSessionParams` | `IkeSessionParams`: the `IkeSessionParams` that contains a set of valid `IkeSession` configurations. This value cannot be `null`.
`firstChildSessionParams` | `ChildSessionParams`: the `ChildSessionParams` that contains a set of valid configurations for the first Child Session. This value cannot be `null`.
`userCbExecutor` | `Executor`: the `Executor` upon which all callbacks will be posted. For security and consistency, the callbacks posted to this executor MUST be executed serially and in the order they were posted, as guaranteed by executors such as `Executors.newSingleThreadExecutor()` This value cannot be `null`.
`ikeSessionCallback` | `IkeSessionCallback`: the `IkeSessionCallback` interface to notify callers of state changes within the `IkeSession`. This value cannot be `null`.
`firstChildSessionCallback` | `ChildSessionCallback`: the `ChildSessionCallback` interface to notify callers of state changes within the first Child Session. This value cannot be `null`.

Returns
`` | an instance of `IkeSession`.

## Public methods

### close

    public void close ()

Close the IKE session gracefully.

Implements `AutoCloseable#close()`

Upon closure, `IkeSessionCallback#onClosed()` or `IkeSessionCallback.onClosedWithException(IkeException)` will be fired.

Closing an IKE Session implicitly closes any remaining Child Sessions negotiated under it. Users SHOULD stop all outbound traffic that uses these Child Sessions (`IpSecTransform` pairs) before calling this method. Otherwise IPsec packets will be dropped due to the lack of a valid `IpSecTransform`.

Closure of an IKE session will take priority over, and cancel other procedures waiting in the queue (but will wait for ongoing locally initiated procedures to complete). After sending the Delete request, the IKE library will wait until a Delete response is received or retransmission timeout occurs.

### closeChildSession

    public void closeChildSession (ChildSessionCallback childSessionCallback)

Delete a Child Session.

Upon closure, `ChildSessionCallback#onClosed()` will be fired.

Parameters
`childSessionCallback` | `ChildSessionCallback`: The `ChildSessionCallback` instance that uniquely identify the Child Session. This value cannot be `null`.

Throws
`IllegalArgumentException` | if no Child Session found bound with this callback.

### kill

    public void kill ()

Terminate (forcibly close) the IKE session.

Upon closing, `IkeSessionCallback#onClosed()` will be fired.

Closing an IKE Session implicitly closes any remaining Child Sessions negotiated under it. Users SHOULD stop all outbound traffic that uses these Child Sessions (`IpSecTransform` pairs) before calling this method. Otherwise IPsec packets will be dropped due to the lack of a valid `IpSecTransform`.

Forcible closure of an IKE session will take priority over, and cancel other procedures waiting in the queue. It will also interrupt any ongoing locally initiated procedure.

### openChildSession

    public void openChildSession (ChildSessionParams childSessionParams,
                    ChildSessionCallback childSessionCallback)

Request a new Child Session.

Users MUST provide a unique `ChildSessionCallback` instance for each new Child Session.

Upon setup, `ChildSessionCallback#onOpened(ChildSessionConfiguration)` will be fired.

FEATURE_IPSEC_TUNNELS is required for setting up a tunnel mode Child SA.

Parameters
`childSessionParams` | `ChildSessionParams`: the `ChildSessionParams` that contains the Child Session configurations to negotiate. This value cannot be `null`.
`childSessionCallback` | `ChildSessionCallback`: the `ChildSessionCallback` interface to notify users the state changes of the Child Session. It will be posted to the callback `Executor` of this `IkeSession`. This value cannot be `null`.

Throws
`IllegalArgumentException` | if the ChildSessionCallback is already in use.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*