Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/net/Ikev2VpnProfile#nestedclasses) \| [Inherited Constants](https://developer.android.com/reference/android/net/Ikev2VpnProfile#inhconstants) \| [Methods](https://developer.android.com/reference/android/net/Ikev2VpnProfile#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/Ikev2VpnProfile#inhmethods)

# Ikev2VpnProfile

*** ** * ** ***


`
public

final

class
Ikev2VpnProfile
`


`


`

`

extends https://developer.android.com/reference/android/net/PlatformVpnProfile


`

`


`

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.net.PlatformVpnProfile](https://developer.android.com/reference/android/net/PlatformVpnProfile) ||
|   | ↳ | android.net.Ikev2VpnProfile |

<br />

*** ** * ** ***

The Ikev2VpnProfile is a configuration for the platform setup of IKEv2/IPsec VPNs.

Together with VpnManager, this allows apps to provision IKEv2/IPsec VPNs that do not require
the VPN app to constantly run in the background.
**See also:**

- `https://developer.android.com/reference/android/net/VpnManager`
- [RFC 7296 - Internet Key
  Exchange, Version 2 (IKEv2)](https://tools.ietf.org/html/rfc7296#section-3.3.2)

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` A incremental builder for IKEv2 VPN profiles |

| ### Inherited constants |
|---|
| From class `https://developer.android.com/reference/android/net/PlatformVpnProfile` |---|---| | `int` | `https://developer.android.com/reference/android/net/PlatformVpnProfile#TYPE_IKEV2_IPSEC_PSK` | | `int` | `https://developer.android.com/reference/android/net/PlatformVpnProfile#TYPE_IKEV2_IPSEC_RSA` | | `int` | `https://developer.android.com/reference/android/net/PlatformVpnProfile#TYPE_IKEV2_IPSEC_USER_PASS` | |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#getAllowedAlgorithms()() ` Returns all the algorithms allowed by this VPN profile. |
| ` https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#getIkeTunnelConnectionParams()() ` Retrieves the ikeTunnelConnectionParams contains IKEv2 configurations, if any was set. |
| ` int` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#getMaxMtu()() ` Retrieves the maximum MTU set for this VPN profile. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#getPassword()() ` Retrieves the password. |
| ` byte[]` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#getPresharedKey()() ` Retrieves the pre-shared key. |
| ` https://developer.android.com/reference/android/net/ProxyInfo` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#getProxyInfo()() ` Retrieves the proxy information if any was set |
| ` https://developer.android.com/reference/java/security/PrivateKey` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#getRsaPrivateKey()() ` Retrieves the RSA private key. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#getServerAddr()() ` Retrieves the server address string. |
| ` https://developer.android.com/reference/java/security/cert/X509Certificate` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#getServerRootCaCert()() ` Retrieves the certificate for the server's root CA. |
| ` https://developer.android.com/reference/java/security/cert/X509Certificate` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#getUserCert()() ` Retrieves the user certificate, if any was set. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#getUserIdentity()() ` Retrieves the user identity. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#getUsername()() ` Retrieves the username. |
| ` int` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#hashCode()() ` Returns a hash code value for the object. |
| ` boolean` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#isAutomaticIpVersionSelectionEnabled()() ` Returns whether automatic IP version selection is enabled. |
| ` boolean` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#isAutomaticNattKeepaliveTimerEnabled()() ` Returns whether automatic NAT-T keepalive timers are enabled. |
| ` boolean` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#isBypassable()() ` Returns whether or not the VPN profile should be bypassable. |
| ` boolean` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#isMetered()() ` Returns whether or not the VPN profile should be always considered metered. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile#toString()() ` Returns a string representation of the object. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/android/net/PlatformVpnProfile ` |---|---| | ` final boolean` | ` https://developer.android.com/reference/android/net/PlatformVpnProfile#areLocalRoutesExcluded()() ` Returns whether the local traffic is exempted from the VPN. | | ` final int` | ` https://developer.android.com/reference/android/net/PlatformVpnProfile#getType()() ` Returns the profile integer type. | | ` final https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/PlatformVpnProfile#getTypeString()() ` Returns a type string describing the VPN profile type | | ` final boolean` | ` https://developer.android.com/reference/android/net/PlatformVpnProfile#isInternetValidationRequired()() ` Returns whether this VPN should undergo Internet validation. | ||
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public methods

### equals

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object obj)
```

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.

<br />

| Parameters ||
|---|---|
| `obj` | `Object`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this object is the same as the obj argument; `false` otherwise. <br /> |

### getAllowedAlgorithms

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public List<String> getAllowedAlgorithms ()
```

Returns all the algorithms allowed by this VPN profile.

May be an empty list if the profile is built from an `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String>` | This value cannot be `null`. <br /> |

### getIkeTunnelConnectionParams

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public IkeTunnelConnectionParams getIkeTunnelConnectionParams ()
```

Retrieves the ikeTunnelConnectionParams contains IKEv2 configurations, if any was set.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams` | This value may be `null`. <br /> |

### getMaxMtu

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getMaxMtu ()
```

Retrieves the maximum MTU set for this VPN profile.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getPassword

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getPassword ()
```

Retrieves the password.

May be null if the profile is not using Username/Password authentication, or the profile
is built from an `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getPresharedKey

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public byte[] getPresharedKey ()
```

Retrieves the pre-shared key.

May be null if the profile is not using Pre-shared key authentication, or the profile is
built from an `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`.

<br />

| Returns ||
|---|---|
| `byte[]` | <br /> |

### getProxyInfo

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ProxyInfo getProxyInfo ()
```

Retrieves the proxy information if any was set

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/ProxyInfo` | This value may be `null`. <br /> |

### getRsaPrivateKey

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrivateKey getRsaPrivateKey ()
```

Retrieves the RSA private key.

May be null if the profile is not using RSA Digital Signature authentication, or the
profile is built from an `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/PrivateKey` | <br /> |

### getServerAddr

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getServerAddr ()
```

Retrieves the server address string.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | This value cannot be `null`. <br /> |

### getServerRootCaCert

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public X509Certificate getServerRootCaCert ()
```

Retrieves the certificate for the server's root CA.

May be null if the profile is not using RSA Digital Signature Authentication or
Username/Password authentication, or the profile is built from an
`https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/cert/X509Certificate` | <br /> |

### getUserCert

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public X509Certificate getUserCert ()
```

Retrieves the user certificate, if any was set.

May be null if the profile is built from an `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/cert/X509Certificate` | <br /> |

### getUserIdentity

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getUserIdentity ()
```

Retrieves the user identity.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | This value cannot be `null`. <br /> |

### getUsername

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getUsername ()
```

Retrieves the username.

May be null if the profile is not using Username/Password authentication, or the profile
is built from an `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### hashCode

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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
`https://developer.android.com/reference/java/util/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 `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` 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 `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` 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.

<br />

<br />

| Returns ||
|---|---|
| `int` | a hash code value for this object. <br /> |

### isAutomaticIpVersionSelectionEnabled

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isAutomaticIpVersionSelectionEnabled ()
```

Returns whether automatic IP version selection is enabled.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isAutomaticNattKeepaliveTimerEnabled

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isAutomaticNattKeepaliveTimerEnabled ()
```

Returns whether automatic NAT-T keepalive timers are enabled.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isBypassable

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isBypassable ()
```

Returns whether or not the VPN profile should be bypassable.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isMetered

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isMetered ()
```

Returns whether or not the VPN profile should be always considered metered.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### toString

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |