本文整理汇总了Java中android.net.wifi.WifiEnterpriseConfig.setIdentity方法的典型用法代码示例。如果您正苦于以下问题:Java WifiEnterpriseConfig.setIdentity方法的具体用法?Java WifiEnterpriseConfig.setIdentity怎么用?Java WifiEnterpriseConfig.setIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.net.wifi.WifiEnterpriseConfig
的用法示例。
在下文中一共展示了WifiEnterpriseConfig.setIdentity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveWifiConfiguration
import android.net.wifi.WifiEnterpriseConfig; //导入方法依赖的package包/类
private boolean saveWifiConfiguration(String ssid, X509Certificate caCert,
PrivateKey privateKey, X509Certificate userCert, String identity) {
mWifiConfiguration.SSID = ssid;
mWifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
mWifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig();
enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS);
enterpriseConfig.setCaCertificate(caCert);
enterpriseConfig.setClientKeyEntry(privateKey, userCert);
if (!TextUtils.isEmpty(identity)) {
enterpriseConfig.setIdentity(identity);
}
mWifiConfiguration.enterpriseConfig = enterpriseConfig;
return WifiConfigUtil.saveWifiConfiguration(getActivity(), mWifiConfiguration);
}
示例2: createNewWifiProfile
import android.net.wifi.WifiEnterpriseConfig; //导入方法依赖的package包/类
public WifiConfiguration createNewWifiProfile() throws EnterpriseConfigurationException {
WifiConfiguration profile = new WifiConfiguration();
// Security Settings for WPA/WPA2
profile.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
profile.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
profile.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
profile.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
profile.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
profile.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
profile.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
profile.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
// Set SSID
profile.SSID = this.ssid;
Log.d("ews-ssid", this.ssid);
// Enterprise Configuration
WifiEnterpriseConfig enterprise = new WifiEnterpriseConfig();
// Set Username
if (username != null && username.length() > 0) {
enterprise.setIdentity(this.username);
} else {
throw new EnterpriseConfigurationMissingUsernameException();
}
// Set Password
if (password != null && password.length() > 0) {
enterprise.setPassword(this.password);
} else {
throw new EnterpriseConfigurationMissingPasswordException();
}
// Set eap method
enterprise.setEapMethod(this.eap_method);
// Set Phase2 methos
enterprise.setPhase2Method(this.phase2_method);
// Set Anonymous Identity
enterprise.setAnonymousIdentity(this.anonymous_ident);
// Set CA_Certificate
enterprise.setCaCertificate(this.ca_certificate);
// Set Subject_match
enterprise.setSubjectMatch(this.subject_match);
// Add enterprise config to profile
profile.enterpriseConfig = enterprise;
Log.d("ews-profile", profile.toString());
// return the new profile
return profile;
}