2016-03-23 15 views
0

Mobil uygulamadan WIFI (EAP-AKA) güvenli bir şekilde bağlanmaya yönelik basit bir kod gerekiyor. Kodun altında var ama bilmiyorum ya da doğru ya da değil ve nasıl kullanacağımı bilmiyorum. Herhangi birinin örnek kodu varsa harika olacaktır.Android, EAP-AKA'ya bağlanın WiFi

// Initialize the WifiConfiguration object 
WifiConfiguration wifi = new WifiConfiguration(); 


WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig(); 
wifi = new WifiConfiguration(); 
wifi.SSID = ssid; 
wifi.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP); 
wifi.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X); 
enterpriseConfig.setIdentity(userName); 
enterpriseConfig.setPassword(passWord); 
enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.AKA); 
wifi.enterpriseConfig = enterpriseConfig; 

cevap

1

cevabı buldum ve kimseye yardımcı olabilir, bunu koymaya karar

kod uygulaması benim depo bulunabilir

Numune https://github.com/malah-code/Android-Eap-Aka-Sample

Kod

// Initialize the WifiConfiguration object 
     logThis("attemp to connect\n"); 
     mProgressView.refreshDrawableState(); 
     WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig(); 
     WifiConfiguration wifi = new WifiConfiguration(); 
     wifi.SSID = mSSIDView.getText().toString(); 
     wifi.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP); 
     wifi.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X); 
     enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.AKA); 
     wifi.enterpriseConfig = enterpriseConfig; 

     logThis("finding saved WiFi\n"); 
     wifi.networkId = ssidToNetworkId(wifi.SSID); 

     if (wifi.networkId == -1) { 
      logThis("WiFi not found - adding it.\n"); 
      wifiManager.addNetwork(wifi); 
     } else { 
      logThis("WiFi found - updating it.\n"); 
      wifiManager.updateNetwork(wifi); 
     } 
     logThis("saving config.\n"); 
     wifiManager.saveConfiguration(); 

     wifi.networkId = ssidToNetworkId(wifi.SSID); 
     logThis("wifi ID in device = " + wifi.networkId + "\n"); 

     SupplicantState supState; 
     int networkIdToConnect = wifi.networkId; 
     if (networkIdToConnect >= 0) { 
      logThis("Start connecting...\n"); 

      // We disable the network before connecting, because if this was the last connection before 
      // a disconnect(), this will not reconnect. 
      wifiManager.disableNetwork(networkIdToConnect); 
      wifiManager.enableNetwork(networkIdToConnect, true); 


      WifiInfo wifiInfo = wifiManager.getConnectionInfo(); 
      supState = wifiInfo.getSupplicantState(); 
      logThis("WifiWizard: Done connect to network : status = " + supState.toString()); 
     } else { 
      logThis("WifiWizard: cannot connect to network"); 
     }