2010-11-22 35 views
3

Je sais créer une configuration Open/WEP/PSK/PSK2 par programme.Android: Comment créer une configuration wifi EAP par programme?

ex.

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); 

Mais comment en créer un pour 'EAP 802.1x'? En regardant dans le code source à: .. \ packages \ apps \ Settings \ src \ com \ paramètres Android \ \ 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()); 
       } 

Semble pour faire le travail, mais 'config.eap' est pas accessible depuis mon application.

Existe-t-il un moyen de configurer les types EAP ou est-ce impossible?

Répondre

0

L'API Java Reflection peut être utilisée pour créer un réseau IEEE802.x avec certificat. Vous pouvez directement créer une connexion réseau IEEE802.x est une version antérieure (comme 1.6). Dans le dernier Android, le "EnterpriseField" (une classe interne) n'est pas directement accessible via le programme.