मैं अपने एंड्रॉइड डिवाइस को बिना किसी सफलता के पिछले कुछ दिनों में एक एंटरप्राइज़ नेटवर्क से प्रोग्राम करने की कोशिश कर रहा हूं, मैं कई उदाहरण ऑनलाइन का पालन कर रहा हूं, लेकिन उनमें से अधिकांश I ईएपी (टीएलएस) नेटवर्क के लिए खोजें और जहां मैं काम करता हूं वह ईएपी (पीईएपी) है, यहां नेटवर्क का प्रकार है।वाईफाई एंटरप्राइज़ नेटवर्क से एंड्रॉइड कनेक्ट करें ईएपी (पीईएपी)
802.1x EAP
EAP विधि: PEAP
चरण 2 प्रमाणीकरण: MSCHAPV2
प्रमाणीकरण हमेशा विफल रहता है और logcat मुझे संकेत नहीं है जहां समस्या मैं सिर्फ यह विफल रहता है जब पता है प्रमाणीकरण किया जा रहा है।
यहाँ मेरे वर्तमान कोड की एक प्रति और logcat से लॉग जहां यह विफल रहता है:
/****************** कोड ***** *************************/
public class WPAActivity extends LauncherActivity
{
private static final String TAG = "WPAActivity";
/************* Definitions to find variables ***************************/
private static final String INT_PRIVATE_KEY = "private_key";
private static final String INT_PHASE2 = "phase2";
private static final String INT_PASSWORD = "password";
private static final String INT_IDENTITY = "identity";
private static final String INT_EAP = "eap";
private static final String INT_CLIENT_CERT = "client_cert";
private static final String INT_CA_CERT = "ca_cert";
private static final String INT_ANONYMOUS_IDENTITY = "anonymous_identity";
final String INT_ENTERPRISEFIELD_NAME ="android.net.wifi.WifiConfiguration$EnterpriseField";
/************************************************************************/
/********************************Configuration Strings*********************/
final String ENTERPRISE_EAP = "PEAP";
final String ENTERPRISE_CLIENT_CERT = "";
final String ENTERPRISE_PRIV_KEY = "";
final String ENTERPRISE_PHASE2 = "\"MSCHAPV2\"";
final String ENTERPRISE_ANON_IDENT = "";
final String ENTERPRISE_CA_CERT = "";
final String userName = "\"my Username";
final String passString = "\"my Password\"";
/**************************************************************************/
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiConfiguration wc = new WifiConfiguration();
wc.SSID = "\"mySSID\"";
wc.preSharedKey = "\"my Password\"";
wc.hiddenSSID = true;
wc.status = WifiConfiguration.Status.ENABLED;
wc.allowedKeyManagement.clear();
wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
/*Group Ciphers*/
wc.allowedGroupCiphers.clear();
wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
/*Protocols*/
wc.allowedProtocols.clear();
wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
wc.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
Class[] enterpriseFieldArray = WifiConfiguration.class.getClasses();
Class<?> enterpriseFieldClass = null;
for(Class<?> myClass : enterpriseFieldArray)
{
if(myClass.getName().equals(INT_ENTERPRISEFIELD_NAME))
{
enterpriseFieldClass = myClass;
break;
}
}
Log.d(TAG, "class chosen " + enterpriseFieldClass.getName());
Field anonymousId = null, caCert = null, clientCert = null,
eap = null, identity = null, password = null,
phase2 = null, privateKey = null;
Field[] fields = WifiConfiguration.class.getFields();
for (Field tempField : fields)
{
if (tempField.getName().trim().equals(INT_ANONYMOUS_IDENTITY))
{
anonymousId = tempField;
Log.d(TAG, "field " + anonymousId.getName());
}
else if (tempField.getName().trim().equals(INT_CA_CERT))
{
caCert = tempField;
}
else if (tempField.getName().trim().equals(INT_CA_CERT))
{
}
else if (tempField.getName().trim().equals(INT_CLIENT_CERT))
{
clientCert = tempField;
Log.d(TAG, "field " + clientCert.getName());
}
else if (tempField.getName().trim().equals(INT_EAP))
{
eap = tempField;
Log.d(TAG, "field " + eap.getName());
}
else if (tempField.getName().trim().equals(INT_IDENTITY))
{
identity = tempField;
Log.d(TAG, "field " + identity.getName());
}
else if (tempField.getName().trim().equals(INT_PASSWORD))
{
password = tempField;
Log.d(TAG, "field " + password.getName());
}
else if (tempField.getName().trim().equals(INT_PHASE2))
{
phase2 = tempField;
Log.d(TAG, "field " + phase2.getName());
}
else if (tempField.getName().trim().equals(INT_PRIVATE_KEY))
{
privateKey = tempField;
}
}
Method setValue = null;
for(Method m: enterpriseFieldClass.getMethods())
{
if(m.getName().trim().equals("setValue"))
{
Log.d(TAG, "method " + m.getName());
setValue = m;
break;
}
}
try
{
// EAP
setValue.invoke(eap.get(wc), ENTERPRISE_EAP);
// EAP Phase 2
setValue.invoke(phase2.get(wc), ENTERPRISE_PHASE2);
// EAP Anonymous Id
setValue.invoke(anonymousId.get(wc), ENTERPRISE_ANON_IDENT);
// EAP CA Certificate
setValue.invoke(caCert.get(wc), ENTERPRISE_CA_CERT);
// Private Key
setValue.invoke(privateKey.get(wc), ENTERPRISE_PRIV_KEY);
// EAP Identity
setValue.invoke(identity.get(wc), userName);
// EAP Password
setValue.invoke(password.get(wc), passString);
// EAP Client certificate
setValue.invoke(clientCert.get(wc), ENTERPRISE_CLIENT_CERT);
}
catch (Exception e)
{
}
Log.d("WifiPreference", "2");
int res = wifi.addNetwork(wc);
Log.d("WifiPreference", "add Network returned " + res);
boolean b = wifi.enableNetwork(res, true);
Log.d("WifiPreference", "enableNetwork returned " + b);
}
}
और इन लॉग का संकेत जहां कनेक्शन का प्रयास विफल रहता हैं
/* *********************** और यहां लॉग हैं ********************/
02-09 09:23:30.514: I/ActivityManager(2084): Displayed activity com.test.wpa/.WPAActivity: 445 ms (total 445 ms)
02-09 09:23:31.514: I/wpa_supplicant(27633): CTRL-EVENT-SCAN-RESULTS Ready
02-09 09:23:31.514: I/wpa_supplicant(27633): Trying to associate with 00:1c:0f:82:04:e0 (SSID='*****' freq=2437 MHz)
02-09 09:23:31.514: I/wpa_supplicant(27633): CTRL-EVENT-STATE-CHANGE id=-1 state=3
02-09 09:23:31.649: V/WifiMonitor(2084): Event [Trying to associate with 00:1c:0f:82:04:e0 (SSID='*****' freq=2437 MHz)]
02-09 09:23:31.649: V/WifiMonitor(2084): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=3]
02-09 09:23:31.654: V/WifiStateTracker(2084): Changing supplicant state: SCANNING ==> ASSOCIATING
02-09 09:23:31.654: D/NetworkStateTracker(2084): setDetailed state, old =SCANNING and new state=CONNECTING
02-09 09:23:31.659: D/ConnectivityService(2084): ConnectivityChange for WIFI: CONNECTING/CONNECTING
02-09 09:23:32.621: I/wpa_supplicant(27633): CTRL-EVENT-STATE-CHANGE id=0 state=4
02-09 09:23:32.621: V/WifiMonitor(2084): Event [CTRL-EVENT-STATE-CHANGE id=0 state=4]
02-09 09:23:32.624: I/wpa_supplicant(27633): Associated with 00:1c:0f:82:04:e0
02-09 09:23:32.624: I/wpa_supplicant(27633): CTRL-EVENT-EAP-STARTED EAP authentication started
02-09 09:23:32.629: V/WifiMonitor(2084): Event [Associated with 00:1c:0f:82:04:e0]
**02-09 09:23:32.629: V/WifiMonitor(2084): Event [CTRL-EVENT-EAP-STARTED EAP authentication started]**
02-09 09:23:32.629: V/WifiStateTracker(2084): Changing supplicant state: ASSOCIATING ==> ASSOCIATED
**02-09 09:23:32.629: D/NetworkStateTracker(2084): setDetailed state, old =CONNECTING and new state=CONNECTING**
**02-09 09:23:32.634: I/wpa_supplicant(27633): CTRL-EVENT-DISCONNECTED - Disconnect event - remove keys**
02-09 09:23:32.644: I/wpa_supplicant(27633): CTRL-EVENT-STATE-CHANGE id=0 state=0
**02-09 09:23:32.644: V/WifiMonitor(2084): Event [CTRL-EVENT-DISCONNECTED - Disconnect event - remove keys]**
02-09 09:23:32.644: V/WifiMonitor(2084): Event [CTRL-EVENT-STATE-CHANGE id=0 state=0]
मुझे प्रोग्रामिंग के लिए ईएपी (पीईएपी) प्रमाणीकरण के बारे में ऑनलाइन उदाहरण नहीं मिल सका, मैंने वाईफाई कॉन्फ़िगरेशन को सफलतापूर्वक बदलने की कोशिश की है। एंटरप्राइज़ नेटवर्क ईएपी (पीईएपी) से कनेक्ट करने के तरीके पर कोई विचार या सहायक साइट/उदाहरण, या क्या कोई मुझे सही दिशा में इंगित कर सकता है?
मैं इस समझ नहीं सकता है, तो मैं बस उपयोगकर्ता बताने के लिए मैन्युअल रूप से कनेक्ट करने के लिए करता है, तो कोई संबंध नहीं पाया जाता है या यदि एक अपवाद फेंका जाता है, यह बेहतर काम करने लगता है फैसला किया। –