Search in sources :

Example 1 with VpnProfile

use of com.android.internal.net.VpnProfile in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VpnTests method testL2tpIpsecPskConnection.

/**
     * Test L2TP/IPSec PSK VPN connection
     */
@LargeTest
public void testL2tpIpsecPskConnection() throws Exception {
    mPreviousIpAddress = getIpAddress();
    VpnInfo curVpnInfo = mVpnInfoPool.get(VpnProfile.TYPE_L2TP_IPSEC_PSK);
    VpnProfile vpnProfile = curVpnInfo.getVpnProfile();
    connect(vpnProfile);
    validateVpnConnection(vpnProfile);
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 2 with VpnProfile

use of com.android.internal.net.VpnProfile in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VpnTests method testPPTPConnection.

/**
     * Test PPTP VPN connection
     */
@LargeTest
public void testPPTPConnection() throws Exception {
    mPreviousIpAddress = getIpAddress();
    VpnInfo curVpnInfo = mVpnInfoPool.get(VpnProfile.TYPE_PPTP);
    VpnProfile vpnProfile = curVpnInfo.getVpnProfile();
    connect(vpnProfile);
    validateVpnConnection(vpnProfile);
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 3 with VpnProfile

use of com.android.internal.net.VpnProfile in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VpnTests method testL2tpIpsecRsaConnection.

/**
     * Test L2TP/IPSec RSA VPN connection
     */
@LargeTest
public void testL2tpIpsecRsaConnection() throws Exception {
    mPreviousIpAddress = getIpAddress();
    VpnInfo curVpnInfo = mVpnInfoPool.get(VpnProfile.TYPE_L2TP_IPSEC_RSA);
    VpnProfile vpnProfile = curVpnInfo.getVpnProfile();
    if (DEBUG) {
        printVpnProfile(vpnProfile);
    }
    String certFile = curVpnInfo.getCertificateFile();
    String password = curVpnInfo.getPassword();
    installCertificatesFromFile(vpnProfile, certFile, password);
    connect(vpnProfile);
    validateVpnConnection(vpnProfile);
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 4 with VpnProfile

use of com.android.internal.net.VpnProfile in project android_frameworks_base by crdroidandroid.

the class ConnectivityService method updateLockdownVpn.

@Override
public boolean updateLockdownVpn() {
    if (Binder.getCallingUid() != Process.SYSTEM_UID) {
        Slog.w(TAG, "Lockdown VPN only available to AID_SYSTEM");
        return false;
    }
    // Tear down existing lockdown if profile was removed
    mLockdownEnabled = LockdownVpnTracker.isEnabled();
    if (mLockdownEnabled) {
        final String profileName = new String(mKeyStore.get(Credentials.LOCKDOWN_VPN));
        final VpnProfile profile = VpnProfile.decode(profileName, mKeyStore.get(Credentials.VPN + profileName));
        if (profile == null) {
            Slog.e(TAG, "Lockdown VPN configured invalid profile " + profileName);
            setLockdownTracker(null);
            return true;
        }
        int user = UserHandle.getUserId(Binder.getCallingUid());
        synchronized (mVpns) {
            Vpn vpn = mVpns.get(user);
            if (vpn == null) {
                Slog.w(TAG, "VPN for user " + user + " not ready yet. Skipping lockdown");
                return false;
            }
            setLockdownTracker(new LockdownVpnTracker(mContext, mNetd, this, vpn, profile));
        }
    } else {
        setLockdownTracker(null);
    }
    return true;
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) Vpn(com.android.server.connectivity.Vpn) LockdownVpnTracker(com.android.server.net.LockdownVpnTracker) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Example 5 with VpnProfile

use of com.android.internal.net.VpnProfile in project android_packages_apps_Settings by LineageOS.

the class ConfigDialog method getProfile.

VpnProfile getProfile() {
    // First, save common fields.
    VpnProfile profile = new VpnProfile(mProfile.key);
    profile.name = mName.getText().toString();
    profile.type = mType.getSelectedItemPosition();
    profile.server = mServer.getText().toString().trim();
    profile.username = mUsername.getText().toString();
    profile.password = mPassword.getText().toString();
    profile.searchDomains = mSearchDomains.getText().toString().trim();
    profile.dnsServers = mDnsServers.getText().toString().trim();
    profile.routes = mRoutes.getText().toString().trim();
    // Then, save type-specific fields.
    switch(profile.type) {
        case VpnProfile.TYPE_PPTP:
            profile.mppe = mMppe.isChecked();
            break;
        case VpnProfile.TYPE_L2TP_IPSEC_PSK:
            profile.l2tpSecret = mL2tpSecret.getText().toString();
        // fall through
        case VpnProfile.TYPE_IPSEC_XAUTH_PSK:
            profile.ipsecIdentifier = mIpsecIdentifier.getText().toString();
            profile.ipsecSecret = mIpsecSecret.getText().toString();
            break;
        case VpnProfile.TYPE_L2TP_IPSEC_RSA:
            profile.l2tpSecret = mL2tpSecret.getText().toString();
        // fall through
        case VpnProfile.TYPE_IPSEC_XAUTH_RSA:
            if (mIpsecUserCert.getSelectedItemPosition() != 0) {
                profile.ipsecUserCert = (String) mIpsecUserCert.getSelectedItem();
            }
        // fall through
        case VpnProfile.TYPE_IPSEC_HYBRID_RSA:
            if (mIpsecCaCert.getSelectedItemPosition() != 0) {
                profile.ipsecCaCert = (String) mIpsecCaCert.getSelectedItem();
            }
            if (mIpsecServerCert.getSelectedItemPosition() != 0) {
                profile.ipsecServerCert = (String) mIpsecServerCert.getSelectedItem();
            }
            break;
    }
    final boolean hasLogin = !profile.username.isEmpty() || !profile.password.isEmpty();
    profile.saveLogin = mSaveLogin.isChecked() || (mEditing && hasLogin);
    return profile;
}
Also used : VpnProfile(com.android.internal.net.VpnProfile)

Aggregations

VpnProfile (com.android.internal.net.VpnProfile)118 LegacyVpnInfo (com.android.internal.net.LegacyVpnInfo)63 LargeTest (android.test.suitebuilder.annotation.LargeTest)42 SmallTest (android.test.suitebuilder.annotation.SmallTest)21 VpnSettings (com.android.settings.vpn2.VpnSettings)18 Context (android.content.Context)14 Bundle (android.os.Bundle)14 RemoteException (android.os.RemoteException)14 WorkerThread (android.annotation.WorkerThread)7 Activity (android.app.Activity)7 Dialog (android.app.Dialog)7 Intent (android.content.Intent)7 PackageInfo (android.content.pm.PackageInfo)7 PackageManager (android.content.pm.PackageManager)7 UserHandle (android.os.UserHandle)7 KeyStore (android.security.KeyStore)7 AlertDialog (android.app.AlertDialog)6 LockdownVpnTracker (com.android.server.net.LockdownVpnTracker)6 ArgumentMatcher (org.mockito.compat.ArgumentMatcher)6 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)5