Class VpnProfile

java.lang.Object
com.codename1.vpn.profile.VpnProfile

public final class VpnProfile extends Object

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.

  • Constructor Details

    • VpnProfile

      public VpnProfile(String serverAddress)
      Creates a profile for a server.
      Parameters:
      serverAddress - 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.
    • sharedSecret

      public VpnProfile sharedSecret(String value)
      Authenticates with a pre-shared key.
    • 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.
    • getSharedSecret

      public String getSharedSecret()
      The pre-shared key, or null.
    • 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.