Search in sources :

Example 41 with HomeSP

use of com.android.hotspot2.pps.HomeSP in project android_frameworks_base by AOSPA.

the class ConfigBuilder method buildConfig.

public static WifiConfiguration buildConfig(HomeSP homeSP, X509Certificate caCert, List<X509Certificate> clientChain, PrivateKey key) throws IOException, GeneralSecurityException {
    Credential credential = homeSP.getCredential();
    WifiConfiguration config;
    EAP.EAPMethodID eapMethodID = credential.getEAPMethod().getEAPMethodID();
    switch(eapMethodID) {
        case EAP_TTLS:
            if (key != null || clientChain != null) {
                Log.w(TAG, "Client cert and/or key included with EAP-TTLS profile");
            }
            config = buildTTLSConfig(homeSP);
            break;
        case EAP_TLS:
            config = buildTLSConfig(homeSP, clientChain, key);
            break;
        case EAP_AKA:
        case EAP_AKAPrim:
        case EAP_SIM:
            if (key != null || clientChain != null || caCert != null) {
                Log.i(TAG, "Client/CA cert and/or key included with " + eapMethodID + " profile");
            }
            config = buildSIMConfig(homeSP);
            break;
        default:
            throw new IOException("Unsupported EAP Method: " + eapMethodID);
    }
    WifiEnterpriseConfig enterpriseConfig = config.enterpriseConfig;
    enterpriseConfig.setCaCertificate(caCert);
    enterpriseConfig.setAnonymousIdentity("anonymous@" + credential.getRealm());
    return config;
}
Also used : WifiEnterpriseConfig(android.net.wifi.WifiEnterpriseConfig) Credential(com.android.hotspot2.pps.Credential) WifiConfiguration(android.net.wifi.WifiConfiguration) EAP(com.android.anqp.eap.EAP) IOException(java.io.IOException)

Example 42 with HomeSP

use of com.android.hotspot2.pps.HomeSP in project android_frameworks_base by AOSPA.

the class ConfigBuilder method buildSIMConfig.

private static WifiConfiguration buildSIMConfig(HomeSP homeSP) throws IOException {
    Credential credential = homeSP.getCredential();
    IMSIParameter credImsi = credential.getImsi();
    /*
         * Uncomment to enforce strict IMSI matching with currently installed SIM cards.
         *
        TelephonyManager tm = TelephonyManager.from(context);
        SubscriptionManager sub = SubscriptionManager.from(context);
        boolean match = false;

        for (int subId : sub.getActiveSubscriptionIdList()) {
            String imsi = tm.getSubscriberId(subId);
            if (credImsi.matches(imsi)) {
                match = true;
                break;
            }
        }
        if (!match) {
            throw new IOException("Supplied IMSI does not match any SIM card");
        }
        */
    WifiConfiguration config = buildBaseConfiguration(homeSP);
    config.enterpriseConfig.setPlmn(credImsi.toString());
    return config;
}
Also used : Credential(com.android.hotspot2.pps.Credential) WifiConfiguration(android.net.wifi.WifiConfiguration) IMSIParameter(com.android.hotspot2.IMSIParameter)

Example 43 with HomeSP

use of com.android.hotspot2.pps.HomeSP in project platform_frameworks_base by android.

the class PasspointConfigurationTest method createHomeSp.

/**
     * Utility function for creating a {@link android.net.wifi.hotspot2.pps.HomeSP}.
     *
     * @return {@link android.net.wifi.hotspot2.pps.HomeSP}
     */
private static HomeSp createHomeSp() {
    HomeSp homeSp = new HomeSp();
    homeSp.setFqdn("fqdn");
    homeSp.setFriendlyName("friendly name");
    homeSp.setRoamingConsortiumOis(new long[] { 0x55, 0x66 });
    return homeSp;
}
Also used : HomeSp(android.net.wifi.hotspot2.pps.HomeSp)

Example 44 with HomeSP

use of com.android.hotspot2.pps.HomeSP in project platform_frameworks_base by android.

the class PpsMoParserTest method generateConfigurationFromPPSMOTree.

/**
     * Generate a {@link PasspointConfiguration} that matches the configuration specified in the
     * XML file {@link #VALID_PPS_MO_XML_FILE}.
     *
     * @return {@link PasspointConfiguration}
     */
private PasspointConfiguration generateConfigurationFromPPSMOTree() throws Exception {
    DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    byte[] certFingerprint = new byte[32];
    Arrays.fill(certFingerprint, (byte) 0x1f);
    PasspointConfiguration config = new PasspointConfiguration();
    config.setUpdateIdentifier(12);
    config.setCredentialPriority(99);
    // AAA Server trust root.
    Map<String, byte[]> trustRootCertList = new HashMap<>();
    trustRootCertList.put("server1.trust.root.com", certFingerprint);
    config.setTrustRootCertList(trustRootCertList);
    // Subscription update.
    UpdateParameter subscriptionUpdate = new UpdateParameter();
    subscriptionUpdate.setUpdateIntervalInMinutes(120);
    subscriptionUpdate.setUpdateMethod(UpdateParameter.UPDATE_METHOD_SSP);
    subscriptionUpdate.setRestriction(UpdateParameter.UPDATE_RESTRICTION_ROAMING_PARTNER);
    subscriptionUpdate.setServerUri("subscription.update.com");
    subscriptionUpdate.setUsername("subscriptionUser");
    subscriptionUpdate.setBase64EncodedPassword("subscriptionPass");
    subscriptionUpdate.setTrustRootCertUrl("subscription.update.cert.com");
    subscriptionUpdate.setTrustRootCertSha256Fingerprint(certFingerprint);
    config.setSubscriptionUpdate(subscriptionUpdate);
    // Subscription parameters.
    config.setSubscriptionCreationTimeInMs(format.parse("2016-02-01T10:00:00Z").getTime());
    config.setSubscriptionExpirationTimeInMs(format.parse("2016-03-01T10:00:00Z").getTime());
    config.setSubscriptionType("Gold");
    config.setUsageLimitDataLimit(921890);
    config.setUsageLimitStartTimeInMs(format.parse("2016-12-01T10:00:00Z").getTime());
    config.setUsageLimitTimeLimitInMinutes(120);
    config.setUsageLimitUsageTimePeriodInMinutes(99910);
    // HomeSP configuration.
    HomeSp homeSp = new HomeSp();
    homeSp.setFriendlyName("Century House");
    homeSp.setFqdn("mi6.co.uk");
    homeSp.setRoamingConsortiumOis(new long[] { 0x112233L, 0x445566L });
    homeSp.setIconUrl("icon.test.com");
    Map<String, Long> homeNetworkIds = new HashMap<>();
    homeNetworkIds.put("TestSSID", 0x12345678L);
    homeNetworkIds.put("NullHESSID", null);
    homeSp.setHomeNetworkIds(homeNetworkIds);
    homeSp.setMatchAllOis(new long[] { 0x11223344 });
    homeSp.setMatchAnyOis(new long[] { 0x55667788 });
    homeSp.setOtherHomePartners(new String[] { "other.fqdn.com" });
    config.setHomeSp(homeSp);
    // Credential configuration.
    Credential credential = new Credential();
    credential.setCreationTimeInMs(format.parse("2016-01-01T10:00:00Z").getTime());
    credential.setExpirationTimeInMs(format.parse("2016-02-01T10:00:00Z").getTime());
    credential.setRealm("shaken.stirred.com");
    credential.setCheckAaaServerCertStatus(true);
    Credential.UserCredential userCredential = new Credential.UserCredential();
    userCredential.setUsername("james");
    userCredential.setPassword("Ym9uZDAwNw==");
    userCredential.setMachineManaged(true);
    userCredential.setSoftTokenApp("TestApp");
    userCredential.setAbleToShare(true);
    userCredential.setEapType(21);
    userCredential.setNonEapInnerMethod("MS-CHAP-V2");
    credential.setUserCredential(userCredential);
    Credential.CertificateCredential certCredential = new Credential.CertificateCredential();
    certCredential.setCertType("x509v3");
    certCredential.setCertSha256Fingerprint(certFingerprint);
    credential.setCertCredential(certCredential);
    Credential.SimCredential simCredential = new Credential.SimCredential();
    simCredential.setImsi("imsi");
    simCredential.setEapType(24);
    credential.setSimCredential(simCredential);
    config.setCredential(credential);
    // Policy configuration.
    Policy policy = new Policy();
    List<Policy.RoamingPartner> preferredRoamingPartnerList = new ArrayList<>();
    Policy.RoamingPartner partner1 = new Policy.RoamingPartner();
    partner1.setFqdn("test1.fqdn.com");
    partner1.setFqdnExactMatch(true);
    partner1.setPriority(127);
    partner1.setCountries("us,fr");
    Policy.RoamingPartner partner2 = new Policy.RoamingPartner();
    partner2.setFqdn("test2.fqdn.com");
    partner2.setFqdnExactMatch(false);
    partner2.setPriority(200);
    partner2.setCountries("*");
    preferredRoamingPartnerList.add(partner1);
    preferredRoamingPartnerList.add(partner2);
    policy.setPreferredRoamingPartnerList(preferredRoamingPartnerList);
    policy.setMinHomeDownlinkBandwidth(23412);
    policy.setMinHomeUplinkBandwidth(9823);
    policy.setMinRoamingDownlinkBandwidth(9271);
    policy.setMinRoamingUplinkBandwidth(2315);
    policy.setExcludedSsidList(new String[] { "excludeSSID" });
    Map<Integer, String> requiredProtoPortMap = new HashMap<>();
    requiredProtoPortMap.put(12, "34,92,234");
    policy.setRequiredProtoPortMap(requiredProtoPortMap);
    policy.setMaximumBssLoadValue(23);
    UpdateParameter policyUpdate = new UpdateParameter();
    policyUpdate.setUpdateIntervalInMinutes(120);
    policyUpdate.setUpdateMethod(UpdateParameter.UPDATE_METHOD_OMADM);
    policyUpdate.setRestriction(UpdateParameter.UPDATE_RESTRICTION_HOMESP);
    policyUpdate.setServerUri("policy.update.com");
    policyUpdate.setUsername("updateUser");
    policyUpdate.setBase64EncodedPassword("updatePass");
    policyUpdate.setTrustRootCertUrl("update.cert.com");
    policyUpdate.setTrustRootCertSha256Fingerprint(certFingerprint);
    policy.setPolicyUpdate(policyUpdate);
    config.setPolicy(policy);
    return config;
}
Also used : Policy(android.net.wifi.hotspot2.pps.Policy) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HomeSp(android.net.wifi.hotspot2.pps.HomeSp) PasspointConfiguration(android.net.wifi.hotspot2.PasspointConfiguration) Credential(android.net.wifi.hotspot2.pps.Credential) UpdateParameter(android.net.wifi.hotspot2.pps.UpdateParameter) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat)

Example 45 with HomeSP

use of com.android.hotspot2.pps.HomeSP in project android_frameworks_base by crdroidandroid.

the class MOManager method addSP.

public HomeSP addSP(MOTree instanceTree, OSUManager osuManager) throws IOException {
    List<HomeSP> spList = buildSPs(instanceTree);
    if (spList.size() != 1) {
        throw new OMAException("Expected exactly one HomeSP, got " + spList.size());
    }
    HomeSP sp = spList.iterator().next();
    String fqdn = sp.getFQDN();
    if (mSPs.put(fqdn, sp) != null) {
        throw new OMAException("SP " + fqdn + " already exists");
    }
    OMAConstructed pps = (OMAConstructed) instanceTree.getRoot().getChild(TAG_PerProviderSubscription);
    try {
        addSP(pps, osuManager);
    } catch (FileNotFoundException fnfe) {
        MOTree tree = new MOTree(instanceTree.getUrn(), instanceTree.getDtdRev(), instanceTree.getRoot());
        writeMO(tree, mPpsFile, osuManager);
    }
    return sp;
}
Also used : HomeSP(com.android.hotspot2.pps.HomeSP) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

HomeSP (com.android.hotspot2.pps.HomeSP)50 IOException (java.io.IOException)45 Credential (com.android.hotspot2.pps.Credential)35 WifiConfiguration (android.net.wifi.WifiConfiguration)25 HashMap (java.util.HashMap)16 WifiEnterpriseConfig (android.net.wifi.WifiEnterpriseConfig)15 X509Certificate (java.security.cert.X509Certificate)15 ArrayList (java.util.ArrayList)12 EAPMethod (com.android.anqp.eap.EAPMethod)10 NonEAPInnerAuth (com.android.anqp.eap.NonEAPInnerAuth)10 MOData (com.android.hotspot2.osu.commands.MOData)10 UpdateInfo (com.android.hotspot2.pps.UpdateInfo)10 BufferedInputStream (java.io.BufferedInputStream)10 FileInputStream (java.io.FileInputStream)10 GeneralSecurityException (java.security.GeneralSecurityException)10 SAXException (org.xml.sax.SAXException)10 List (java.util.List)6 Network (android.net.Network)5 WifiInfo (android.net.wifi.WifiInfo)5 AuthParam (com.android.anqp.eap.AuthParam)5