public final class VpnProfile
- Object
- VpnProfile
A VPN configuration: which server, which protocol, and how to prove who you are.
VpnProfile p = new VpnProfile("vpn.example.com")
.protocol(VpnProtocol.IKEV2)
.remoteIdentifier("vpn.example.com")
.localIdentifier("alice")
.usernamePassword("alice", secret)
.onDemand(true);
Credentials are handed over, not held
The username and password given here are passed to the platform, which
stores them in its own keychain and does not hand them back. getPassword
therefore answers null for a profile that was loaded rather than built –
a loaded profile describes the configuration, not the secret.
Constructors
public VpnProfile(String serverAddress) | Creates a profile for a server. |
Methods
Inherited methods
Constructor details
VpnProfile
public VpnProfile(String serverAddress)Creates a profile for a server.
Parameters
serverAddressString- the host name or address, never null or empty
Method details
protocol
public VpnProfile protocol(VpnProtocol value)The tunnelling protocol. Defaults to
VpnProtocol.IKEV2.remoteIdentifier
public VpnProfile remoteIdentifier(String value)The server’s identity, as it appears in its certificate. Defaults to
the server address.
localIdentifier
public VpnProfile localIdentifier(String value)This client’s identity.
usernamePassword
public VpnProfile usernamePassword(String user, String pass)Authenticates with a username and password.
onDemand
public VpnProfile onDemand(boolean value)Whether the system should bring the tunnel up when traffic needs it.
displayName
public VpnProfile displayName(String value)The name the user sees for this configuration in system settings.
getServerAddress
public String getServerAddress()The host name or address.
getProtocol
public VpnProtocol getProtocol()The tunnelling protocol.
getRemoteIdentifier
public String getRemoteIdentifier()The server’s identity, or null for the server address.
getLocalIdentifier
public String getLocalIdentifier()This client’s identity, or null.
getUsername
public String getUsername()The username, or null.
getPassword
public String getPassword()The password, or null – always null for a loaded profile, because
the platform keeps the secret and does not return it.
isOnDemand
public boolean isOnDemand()Whether the tunnel comes up on demand.
getDisplayName
public String getDisplayName()The name shown in system settings, or null.
isPasswordKnown
public boolean isPasswordKnown()Whether a secret was supplied when this profile was built.
Distinguishes “built without a password” from “loaded, and the
platform kept the password”, which getPassword alone cannot.