Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5069cc78 authored by Chung-yih Wang's avatar Chung-yih Wang
Browse files

Add the EAP related fields for WiFi configuration.

-- added the EAP/802.1X related fields in WifiConfiguration for
  supporting EAP/802.1X authentication.
-- hid the related fields for now.
parent 641bb3d8
Loading
Loading
Loading
Loading
+77 −0
Original line number Diff line number Diff line
@@ -1060,6 +1060,83 @@ public class WifiService extends IWifiManager.Stub {
                break setVariables;
            }

            if ((config.eap != null) && !WifiNative.setNetworkVariableCommand(
                    netId,
                    WifiConfiguration.eapVarName,
                    config.eap)) {
                if (DBG) {
                    Log.d(TAG, config.SSID + ": failed to set eap: "+
                          config.eap);
                }
                break setVariables;
            }

            if ((config.identity != null) && !WifiNative.setNetworkVariableCommand(
                    netId,
                    WifiConfiguration.identityVarName,
                    config.identity)) {
                if (DBG) {
                    Log.d(TAG, config.SSID + ": failed to set identity: "+
                          config.identity);
                }
                break setVariables;
            }

            if ((config.anonymousIdentity != null) && !WifiNative.setNetworkVariableCommand(
                    netId,
                    WifiConfiguration.anonymousIdentityVarName,
                    config.anonymousIdentity)) {
                if (DBG) {
                    Log.d(TAG, config.SSID + ": failed to set anonymousIdentity: "+
                          config.anonymousIdentity);
                }
                break setVariables;
            }

            if ((config.clientCert != null) && !WifiNative.setNetworkVariableCommand(
                    netId,
                    WifiConfiguration.clientCertVarName,
                    config.clientCert)) {
                if (DBG) {
                    Log.d(TAG, config.SSID + ": failed to set clientCert: "+
                          config.clientCert);
                }
                break setVariables;
            }

            if ((config.caCert != null) && !WifiNative.setNetworkVariableCommand(
                    netId,
                    WifiConfiguration.caCertVarName,
                    config.caCert)) {
                if (DBG) {
                    Log.d(TAG, config.SSID + ": failed to set caCert: "+
                          config.caCert);
                }
                break setVariables;
            }

            if ((config.privateKey != null) && !WifiNative.setNetworkVariableCommand(
                    netId,
                    WifiConfiguration.privateKeyVarName,
                    config.privateKey)) {
                if (DBG) {
                    Log.d(TAG, config.SSID + ": failed to set privateKey: "+
                          config.privateKey);
                }
                break setVariables;
            }

            if ((config.privateKeyPasswd != null) && !WifiNative.setNetworkVariableCommand(
                    netId,
                    WifiConfiguration.privateKeyPasswdVarName,
                    config.privateKeyPasswd)) {
                if (DBG) {
                    Log.d(TAG, config.SSID + ": failed to set privateKeyPasswd: "+
                          config.privateKeyPasswd);
                }
                break setVariables;
            }

            return netId;
        }

+102 −6
Original line number Diff line number Diff line
@@ -42,6 +42,20 @@ public class WifiConfiguration implements Parcelable {
    public static final String priorityVarName = "priority";
    /** {@hide} */
    public static final String hiddenSSIDVarName = "scan_ssid";
    /** {@hide} */
    public static final String eapVarName = "eap";
    /** {@hide} */
    public static final String identityVarName = "identity";
    /** {@hide} */
    public static final String anonymousIdentityVarName = "anonymous_identity";
    /** {@hide} */
    public static final String clientCertVarName = "client_cert";
    /** {@hide} */
    public static final String caCertVarName = "ca_cert";
    /** {@hide} */
    public static final String privateKeyVarName = "private_key";
    /** {@hide} */
    public static final String privateKeyPasswdVarName = "private_key_passwd";

    /**
     * Recognized key management schemes.
@@ -249,6 +263,38 @@ public class WifiConfiguration implements Parcelable {
     */
    public BitSet allowedGroupCiphers;

    /* The following fields are used for EAP/IEEE8021X authentication */

    /**
     * The eap mode should be PEAP, TLS or TTLS.
     * {@hide}
     */
    public String eap;
    /**
     * The identity of the user in string,
     * which is used for the authentication.
     * {@hide}
     */
    public String identity;
    /** {@hide} */
    public String anonymousIdentity;
    /** The path of the client certificate file.
     * {@hide}
     */
    public String clientCert;
    /** The path of the CA certificate file.
     * {@hide}
     */
    public String caCert;
    /** The path of the private key file.
     * {@hide}
     */
    public String privateKey;
    /** The password of the private key file if encrypted.
     * {@hide}
     */
    public String privateKeyPasswd;

    public WifiConfiguration() {
        networkId = -1;
        SSID = null;
@@ -263,6 +309,13 @@ public class WifiConfiguration implements Parcelable {
        wepKeys = new String[4];
        for (int i = 0; i < wepKeys.length; i++)
            wepKeys[i] = null;
        eap = null;
        identity = null;
        anonymousIdentity = null;
        clientCert = null;
        caCert = null;
        privateKey = null;
        privateKeyPasswd = null;
    }

    public String toString() {
@@ -333,10 +386,39 @@ public class WifiConfiguration implements Parcelable {
                }
            }
        }
        sbuf.append('\n');
        sbuf.append('\n').append(" PSK: ");
        if (this.preSharedKey != null) {
            sbuf.append(" PSK: ").append('*');
            sbuf.append('*');
        }
        sbuf.append('\n').append(" eap: ");
        if (this.eap != null) {
            sbuf.append(eap);
        }
        sbuf.append('\n').append(" Identity: ");
        if (this.identity != null) {
            sbuf.append(identity);
        }
        sbuf.append('\n').append(" AnonymousIdentity: ");
        if (this.anonymousIdentity != null) {
            sbuf.append(anonymousIdentity);
        }
        sbuf.append('\n').append(" ClientCert: ");
        if (this.clientCert != null) {
            sbuf.append(clientCert);
        }
        sbuf.append('\n').append(" CaCert: ");
        if (this.caCert != null) {
            sbuf.append(caCert);
        }
        sbuf.append('\n').append(" PrivateKey: ");
        if (this.privateKey != null) {
            sbuf.append(privateKey);
        }
        sbuf.append('\n').append(" PrivateKeyPasswd: ");
        if (this.privateKeyPasswd != null) {
            sbuf.append(privateKeyPasswd);
        }
        sbuf.append('\n');
        return sbuf.toString();
    }

@@ -394,6 +476,13 @@ public class WifiConfiguration implements Parcelable {
        writeBitSet(dest, allowedAuthAlgorithms);
        writeBitSet(dest, allowedPairwiseCiphers);
        writeBitSet(dest, allowedGroupCiphers);
        dest.writeString(eap);
        dest.writeString(identity);
        dest.writeString(anonymousIdentity);
        dest.writeString(clientCert);
        dest.writeString(caCert);
        dest.writeString(privateKey);
        dest.writeString(privateKeyPasswd);
    }

    /** Implement the Parcelable interface {@hide} */
@@ -416,6 +505,13 @@ public class WifiConfiguration implements Parcelable {
                config.allowedAuthAlgorithms  = readBitSet(in);
                config.allowedPairwiseCiphers = readBitSet(in);
                config.allowedGroupCiphers    = readBitSet(in);
                config.eap = in.readString();
                config.identity = in.readString();
                config.anonymousIdentity = in.readString();
                config.clientCert = in.readString();
                config.caCert = in.readString();
                config.privateKey = in.readString();
                config.privateKeyPasswd = in.readString();
                return config;
            }