JSON String Format for createConnection
The createConnection method, new in version 2 of the API, accepts a VPN profile described in a JSON string format. The JSON strings vary depending on the type of authentication used in the VPN profile, as shown in the following examples.
Single Username/Password Authentication
The following sample JSON string is for a VPN profile that uses a username/password for authentication:
{
"MDM_VPN_PARAMETERS": {
"profile_attribute": {
"profileName":"MyVpnProfile",
"host":"https://vpn.xyz.com/auth",
"vpn_type":"ssl",
"isUserAuthEnabled":true
},
"ssl": {
"basic": {
"username":"testuser",
"password":"secret123"
}
},
"vendor": {
"realm":"",
"role":"",
"certAlias":""
}
}
}Certificate Authentication
The following sample JSON string is for a VPN profile that uses a certificate for authentication:
{
"MDM_VPN_PARAMETERS": {
"profile_attribute": {
"profileName":"MyVpnProfile",
"host":"https://vpn.xyz.com/auth",
"vpn_type":"ssl",
"isUserAuthEnabled":true
},
"ssl": {
"basic": {
}
},
"vendor": {
"realm":"",
"role":"",
"certAlias":"myCertName"
}
}
}The certificate must be installed in Android's keystore before this profile can be used. The certificate name is specified in the certAlias field in the vendor section.
Username/Password and Certificate Authentication
The following sample JSON string is for a VPN profile that uses both certificate and username/password for authentication:
{
"MDM_VPN_PARAMETERS": {
"profile_attribute": {
"profileName":"MyVpnProfile",
"host":"https://vpn.xyz.com/auth",
"vpn_type":"ssl",
"isUserAuthEnabled":true
},
"ssl": {
"basic": {
"username":"testuser",
"password":"secret123"
}
},
"vendor": {
"realm":"",
"role":"",
"certAlias":"myCertName"
}
}
}Dual Username/Password Authentication
The following sample JSON string is for a VPN profile that uses two usernames/passwords for authentication:
{
"MDM_VPN_PARAMETERS": {
"profile_attribute": {
"profileName":"MyVpnProfile",
"host":"https://vpn.xyz.com/auth",
"vpn_type":"ssl",
"isUserAuthEnabled":true
},
"ssl": {
"basic": {
"username":"testuser",
"password":"secret123"
}
},
"vendor": {
"realm":"",
"role":"",
"username2":"testuser2",
"password2":"passwd123"
}
}
}The primary username/password are specified in the ssl section and the secondary username/password are specified in the vendor section.
UiLess and Per-App VPN
The following sample JSON string is for UiLess and Per-App VPN connections:
For UiLess Connection, set UiLess parameter to true
For Per-App VPN connection:
1. vpn_route_type is set to1
2. action is set to 0 to allow and 1 to deny the application traffic through tunnel
3. Add applications to the appList in the specified format
{
"MDM_VPN_PARAMETERS": {
"profile_attribute": {
"profileName":"MDM Profile",
"host":"https://myvpn.net/vpn ",
"vpn_type":"ssl",
"vpn_route_type":1,
"isUserAuthEnabled":true
},
"ssl": {
"basic": {
"username":"",
"password":"",
"authentication_type":1
}
},
"vendor": {
"uiLess":true,
"realm":"",
"role":"",
"username2":"",
"password2":"",
"certAlias":"mycertalias",
"appVpn": {
"action":0,
"appList":
[{
"appId":"1",
"appPkg":"com.android.chrome",
"appName":"Chrome"
},
{
"appId":"2",
"appPkg":"com.google.android.apps.plus",
"appName":"Google Plus
}]
}
}
}}