【问题标题】:Android: How to create EAP wifi configuration programmatically?Android:如何以编程方式创建 EAP wifi 配置?
【发布时间】:2011-05-14 02:09:14
【问题描述】:

我知道如何以编程方式创建 Open/WEP/PSK/PSK2 配置。

例如

WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "ssid";
conf.preSharedKey = "\"password\"";
conf.status = WifiConfiguration.Status.ENABLED;        

conf.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);

conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); 
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);

conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);

conf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
conf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);

conf.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
conf.allowedProtocols.set(WifiConfiguration.Protocol.RSN);

int res = wifi.addNetwork(conf);
boolean b = wifi.enableNetwork(res, true);

但是如何为“802.1x EAP”创建一个? 查看源代码: ..\packages\apps\Settings\src\com\android\settings\wifi\WifiDialog.java

case AccessPoint.SECURITY_EAP:
                config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
                config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
                config.eap.setValue((String) mEapMethod.getSelectedItem());

                config.phase2.setValue((mPhase2.getSelectedItemPosition() == 0) ? "" :
                        "auth=" + mPhase2.getSelectedItem());
                config.ca_cert.setValue((mEapCaCert.getSelectedItemPosition() == 0) ? "" :
                        KEYSTORE_SPACE + Credentials.CA_CERTIFICATE +
                        (String) mEapCaCert.getSelectedItem());
                config.client_cert.setValue((mEapUserCert.getSelectedItemPosition() == 0) ? "" :
                        KEYSTORE_SPACE + Credentials.USER_CERTIFICATE +
                        (String) mEapUserCert.getSelectedItem());
                config.private_key.setValue((mEapUserCert.getSelectedItemPosition() == 0) ? "" :
                        KEYSTORE_SPACE + Credentials.USER_PRIVATE_KEY +
                        (String) mEapUserCert.getSelectedItem());
                config.identity.setValue((mEapIdentity.length() == 0) ? "" :
                        mEapIdentity.getText().toString());
                config.anonymous_identity.setValue((mEapAnonymous.length() == 0) ? "" :
                        mEapAnonymous.getText().toString());
                if (mPassword.length() != 0) {
                    config.password.setValue(mPassword.getText().toString());
                }

似乎可以完成这项工作,但我的应用程序无法访问“config.eap”。

有没有办法配置 EAP 类型?

【问题讨论】:

    标签: android configuration wifi


    【解决方案1】:

    Java Reflection API 可用于创建带有证书的 IEEE802.x 网络。您可以直接创建 IEEE802.x 网络连接是早期版本(如 1.6)。在最新的 android 中,“EnterpriseField”(一个内部类)不能通过程序直接访问。

    【讨论】:

      【解决方案2】:

      【讨论】:

        猜你喜欢
        • 2011-05-21
        • 2012-02-19
        • 1970-01-01
        • 2018-12-07
        • 2015-01-28
        • 1970-01-01
        • 1970-01-01
        • 2011-10-09
        • 2015-09-13
        相关资源
        最近更新 更多