当前位置: 首页>>代码示例>>Java>>正文


Java WifiEnterpriseConfig类代码示例

本文整理汇总了Java中android.net.wifi.WifiEnterpriseConfig的典型用法代码示例。如果您正苦于以下问题:Java WifiEnterpriseConfig类的具体用法?Java WifiEnterpriseConfig怎么用?Java WifiEnterpriseConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WifiEnterpriseConfig类属于android.net.wifi包,在下文中一共展示了WifiEnterpriseConfig类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:googlesamples,项目名称:android-testdpc,代码行数:16,代码来源:WifiEapTlsCreateDialogFragment.java

示例2: buttonPressed

import android.net.wifi.WifiEnterpriseConfig; //导入依赖的package包/类
/**
 * Initiate wifi setup if button has been pressed
 */
public void buttonPressed() {
	Log.d("ews-debug", "Button has pressed");
	// Select eap Mehod
	final int eap;
	String seap = feap.getSelectedItem().toString();
	if (seap.equals("PEAP")) {
		eap = WifiEnterpriseConfig.Eap.PEAP;
	} else if (seap.equals("PWD")) {
		eap = WifiEnterpriseConfig.Eap.PWD;
	} else if (seap.equals("TLS")) {
		eap = WifiEnterpriseConfig.Eap.TLS;
	} else if (seap.equals("TTLS")) {
		eap = WifiEnterpriseConfig.Eap.TTLS;
	} else {
		eap = -1;
	}
	Log.d("ews-debug", seap + eap);
	// Select Phase2 Method
	final String sphase2 = fPhase2.getSelectedItem().toString();
	final int phase2;
	if (sphase2.equals("MSCHAP")) {
		phase2 = WifiEnterpriseConfig.Phase2.MSCHAP;
	} else if (sphase2.equals("MSCHAPV2")) {
		phase2 = WifiEnterpriseConfig.Phase2.MSCHAPV2;
	} else if (sphase2.equals("PAP")) {
		phase2 = WifiEnterpriseConfig.Phase2.PAP;
	} else {
		phase2 = -1;
	}
	Log.d("ews-debug", sphase2 + phase2);
       //create wifi configuration and save it
	final WifiSetup setup = new WifiSetup(this.getApplicationContext());
	boolean error = setup.createConnection("\"" + fssid.getText().toString() + "\"", fuser.getText().toString(),
			fpass.getText().toString(), fanonymous.getText().toString(), fCn.getText().toString(), eap, phase2,
			fcert.getSelectedItem().toString());
	if (error) {
		feedback.setText("Could not Save Network");
	} else {
		feedback.setText("Network setup finished!");
	}
}
 
开发者ID:enterpriseWifiSafeguard,项目名称:EnterpriseWifiSafeguard,代码行数:45,代码来源:MainActivity.java

示例3: 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;
}
 
开发者ID:enterpriseWifiSafeguard,项目名称:EnterpriseWifiSafeguard,代码行数:49,代码来源:WifiConfig.java

示例4: setup802xWifiConfig

import android.net.wifi.WifiEnterpriseConfig; //导入依赖的package包/类
@TargetApi(18)
    private static void setup802xWifiConfig(WifiConfiguration config, String ssid, String password)
    {
        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
        config.enterpriseConfig = new WifiEnterpriseConfig();

        int eapMethod = WifiEnterpriseConfig.Eap.PEAP;
        int phase2Method = WifiEnterpriseConfig.Phase2.GTC;

        config.enterpriseConfig.setEapMethod(eapMethod);

        switch (eapMethod)
        {
            case WifiEnterpriseConfig.Eap.PEAP:
                // PEAP supports limited phase2 values
                // Map the index from the PHASE2_PEAP_ADAPTER to the one used
                // by the API which has the full list of PEAP methods.
                switch (phase2Method)
                {
                    case APLReflectionConstants.WIFI_PEAP_PHASE2_NONE:
                        config.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.NONE);
                        break;
                    case APLReflectionConstants.WIFI_PEAP_PHASE2_MSCHAPV2:
                        config.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.MSCHAPV2);
                        break;
                    case APLReflectionConstants.WIFI_PEAP_PHASE2_GTC:
                        config.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.GTC);
                        break;
                    default:
                        Timber.e("Unknown phase2 method" + phase2Method);
                        break;
                }
                break;
            default:
                // The default index from PHASE2_FULL_ADAPTER maps to the API
                config.enterpriseConfig.setPhase2Method(phase2Method);
                break;
        }

        String caCert = "";
//        config.enterpriseConfig.setCaCertificateAlias(caCert);
//        String clientCert = (String) mEapUserCertSpinner.getSelectedItem();
//        if (clientCert.equals(unspecifiedCert)) clientCert = "";
//        config.enterpriseConfig.setClientCertificateAlias(clientCert);
//        config.enterpriseConfig.setIdentity(mEapIdentityView.getText().toString());
//        config.enterpriseConfig.setAnonymousIdentity(mEapAnonymousView.getText().toString());

//         if (mPasswordView.isShown())
//         {
//             // For security reasons, a previous password is not displayed to user.
//             // Update only if it has been changed.
//             if (mPasswordView.length() > 0)
//             {
        config.enterpriseConfig.setPassword(password.toString());
//             }
//         }
//         else
//         {
//             // clear password
//             config.enterpriseConfig.setPassword(mPasswordView.getText().toString());
//         }
    }
 
开发者ID:shouldit,项目名称:android-proxy,代码行数:64,代码来源:TestUtils.java

示例5: setupEnterpriseConfigAPI18

import android.net.wifi.WifiEnterpriseConfig; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void setupEnterpriseConfigAPI18(WifiConfiguration conf, String lrzId, String networkPass) {
    conf.enterpriseConfig.setIdentity(lrzId + "@eduroam.mwn.de");
    conf.enterpriseConfig.setPassword(networkPass);
    conf.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.PWD);
}
 
开发者ID:TCA-Team,项目名称:TumCampusApp,代码行数:7,代码来源:EduroamManager.java

示例6: isConfigValid

import android.net.wifi.WifiEnterpriseConfig; //导入依赖的package包/类
private boolean isConfigValid() {
    errors.clear();
    eduroam = EduroamManager.getEduroamConfig(mContext);

    //If it is not configured then the config valid
    if (eduroam == null) {
        return true;
    }

    // Eduroam was configured by other university
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2
            && !isTumEduroam(eduroam.enterpriseConfig.getIdentity())) {
        Utils.log("Eduroam wasn't configured at TUM");
        return true;
    }

    // Check attributes - Android 23+: check newer match for the radius server
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {

        // for all configurations
        // Check that the full quantifier is used (we already know it's a tum config)
        if (!eduroam.enterpriseConfig.getIdentity().contains(atSign)) {
            errors.add(mContext.getString(R.string.wifi_identity_zone));
        }

        int eapMethod = eduroam.enterpriseConfig.getEapMethod();
        int phase2 = eduroam.enterpriseConfig.getPhase2Method();

        if ((eapMethod == WifiEnterpriseConfig.Eap.TTLS
             && (phase2 == WifiEnterpriseConfig.Phase2.MSCHAPV2 || phase2 == WifiEnterpriseConfig.Phase2.PAP)
             || (eapMethod == WifiEnterpriseConfig.Eap.PEAP
                 && phase2 == WifiEnterpriseConfig.Phase2.MSCHAPV2))) {

            checkDNSName();
            checkAnonymousIdentity();

            // note: checking the certificate does not seem possible
        } else {
            // PWD or unknown authentication method (we don't know if that method is safe or not -> ignore)
        }
    }
    return errors.isEmpty();
}
 
开发者ID:TCA-Team,项目名称:TumCampusApp,代码行数:44,代码来源:EduroamFixCard.java


注:本文中的android.net.wifi.WifiEnterpriseConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。