use of com.android.hotspot2.pps.HomeSP in project platform_frameworks_base by android.
the class PpsMoParser method parseHomeSP.
/**
* Parse configurations under PerProviderSubscription/HomeSP subtree.
*
* @param node PPSNode representing the root of the PerProviderSubscription/HomeSP subtree
* @return HomeSP
* @throws ParsingException
*/
private static HomeSp parseHomeSP(PPSNode node) throws ParsingException {
if (node.isLeaf()) {
throw new ParsingException("Leaf node not expected for HomeSP");
}
HomeSp homeSp = new HomeSp();
for (PPSNode child : node.getChildren()) {
switch(child.getName()) {
case NODE_FQDN:
homeSp.setFqdn(getPpsNodeValue(child));
break;
case NODE_FRIENDLY_NAME:
homeSp.setFriendlyName(getPpsNodeValue(child));
break;
case NODE_ROAMING_CONSORTIUM_OI:
homeSp.setRoamingConsortiumOis(parseRoamingConsortiumOI(getPpsNodeValue(child)));
break;
case NODE_ICON_URL:
homeSp.setIconUrl(getPpsNodeValue(child));
break;
case NODE_NETWORK_ID:
homeSp.setHomeNetworkIds(parseNetworkIds(child));
break;
case NODE_HOME_OI_LIST:
Pair<List<Long>, List<Long>> homeOIs = parseHomeOIList(child);
homeSp.setMatchAllOis(convertFromLongList(homeOIs.first));
homeSp.setMatchAnyOis(convertFromLongList(homeOIs.second));
break;
case NODE_OTHER_HOME_PARTNERS:
homeSp.setOtherHomePartners(parseOtherHomePartners(child));
break;
default:
throw new ParsingException("Unknown node under HomeSP: " + child.getName());
}
}
return homeSp;
}
use of com.android.hotspot2.pps.HomeSP in project platform_frameworks_base by android.
the class ConfigParserTest method generateConfigurationFromProfile.
/**
* Generate a {@link PasspointConfiguration} that matches the configuration specified in the
* XML file {@link #PASSPOINT_INSTALLATION_FILE_WITH_CA_CERT}.
*
* @return {@link PasspointConfiguration}
*/
private PasspointConfiguration generateConfigurationFromProfile() {
PasspointConfiguration config = new PasspointConfiguration();
// HomeSP configuration.
HomeSp homeSp = new HomeSp();
homeSp.setFriendlyName("Century House");
homeSp.setFqdn("mi6.co.uk");
homeSp.setRoamingConsortiumOis(new long[] { 0x112233L, 0x445566L });
config.setHomeSp(homeSp);
// Credential configuration.
Credential credential = new Credential();
credential.setRealm("shaken.stirred.com");
Credential.UserCredential userCredential = new Credential.UserCredential();
userCredential.setUsername("james");
userCredential.setPassword("Ym9uZDAwNw==");
userCredential.setEapType(21);
userCredential.setNonEapInnerMethod("MS-CHAP-V2");
credential.setUserCredential(userCredential);
Credential.CertificateCredential certCredential = new Credential.CertificateCredential();
certCredential.setCertType("x509v3");
byte[] certSha256Fingerprint = new byte[32];
Arrays.fill(certSha256Fingerprint, (byte) 0x1f);
certCredential.setCertSha256Fingerprint(certSha256Fingerprint);
credential.setCertCredential(certCredential);
Credential.SimCredential simCredential = new Credential.SimCredential();
simCredential.setImsi("imsi");
simCredential.setEapType(24);
credential.setSimCredential(simCredential);
credential.setCaCertificate(FakeKeys.CA_CERT0);
config.setCredential(credential);
return config;
}
use of com.android.hotspot2.pps.HomeSP in project android_frameworks_base by DirtyUnicorns.
the class OSUManager method remediationComplete.
public void remediationComplete(HomeSP homeSP, Collection<MOData> mods, Map<OSUCertType, List<X509Certificate>> certs, PrivateKey privateKey) throws IOException, GeneralSecurityException {
HomeSP altSP = mWifiNetworkAdapter.modifySP(homeSP, mods);
X509Certificate caCert = null;
List<X509Certificate> clientCerts = null;
if (certs != null) {
List<X509Certificate> certList = certs.get(OSUCertType.AAA);
caCert = certList != null && !certList.isEmpty() ? certList.iterator().next() : null;
clientCerts = certs.get(OSUCertType.Client);
}
if (altSP != null || certs != null) {
if (altSP == null) {
// No MO mods, only certs and key
altSP = homeSP;
}
mWifiNetworkAdapter.updateNetwork(altSP, caCert, clientCerts, privateKey);
}
notifyUser(OSUOperationStatus.ProvisioningSuccess, null, homeSP.getFriendlyName());
}
use of com.android.hotspot2.pps.HomeSP in project android_frameworks_base by DirtyUnicorns.
the class OSUManager method provisioningComplete.
public void provisioningComplete(OSUInfo osuInfo, MOData moData, Map<OSUCertType, List<X509Certificate>> certs, PrivateKey privateKey, Network osuNetwork) {
synchronized (mWifiNetworkAdapter) {
mProvisioningThread = null;
}
try {
Log.d("ZXZ", "MOTree.toXML: " + moData.getMOTree().toXml());
HomeSP homeSP = mWifiNetworkAdapter.addSP(moData.getMOTree());
Integer spNwk = mWifiNetworkAdapter.addNetwork(homeSP, certs, privateKey, osuNetwork);
if (spNwk == null) {
notifyUser(OSUOperationStatus.ProvisioningFailure, "Failed to save network configuration", osuInfo.getName(LOCALE));
mWifiNetworkAdapter.removeSP(homeSP.getFQDN());
} else {
Set<X509Certificate> rootCerts = OSUSocketFactory.getRootCerts(mKeyStore);
X509Certificate remCert = getCert(certs, OSUCertType.Remediation);
X509Certificate polCert = getCert(certs, OSUCertType.Policy);
if (privateKey != null) {
X509Certificate cltCert = getCert(certs, OSUCertType.Client);
mKeyStore.setKeyEntry(CERT_CLT_KEY_ALIAS + homeSP, privateKey.getEncoded(), new X509Certificate[] { cltCert });
mKeyStore.setCertificateEntry(CERT_CLT_CERT_ALIAS, cltCert);
}
boolean usingShared = false;
int newCerts = 0;
if (remCert != null) {
if (!rootCerts.contains(remCert)) {
if (remCert.equals(polCert)) {
mKeyStore.setCertificateEntry(CERT_SHARED_ALIAS + homeSP.getFQDN(), remCert);
usingShared = true;
newCerts++;
} else {
mKeyStore.setCertificateEntry(CERT_REM_ALIAS + homeSP.getFQDN(), remCert);
newCerts++;
}
}
}
if (!usingShared && polCert != null) {
if (!rootCerts.contains(polCert)) {
mKeyStore.setCertificateEntry(CERT_POLICY_ALIAS + homeSP.getFQDN(), remCert);
newCerts++;
}
}
if (newCerts > 0) {
try (FileOutputStream out = new FileOutputStream(KEYSTORE_FILE)) {
mKeyStore.store(out, null);
}
}
notifyUser(OSUOperationStatus.ProvisioningSuccess, null, osuInfo.getName(LOCALE));
Log.d(TAG, "Provisioning complete.");
}
} catch (IOException | GeneralSecurityException | SAXException e) {
Log.e(TAG, "Failed to provision: " + e, e);
notifyUser(OSUOperationStatus.ProvisioningFailure, e.toString(), osuInfo.getName(LOCALE));
}
}
use of com.android.hotspot2.pps.HomeSP in project android_frameworks_base by DirtyUnicorns.
the class ConfigBuilder method buildTTLSConfig.
// Retain for debugging purposes
/*
private static void xIterateCerts(KeyStore ks, X509Certificate caCert)
throws GeneralSecurityException {
Enumeration<String> aliases = ks.aliases();
while (aliases.hasMoreElements()) {
String alias = aliases.nextElement();
Certificate cert = ks.getCertificate(alias);
Log.d("HS2J", "Checking " + alias);
if (cert instanceof X509Certificate) {
X509Certificate x509Certificate = (X509Certificate) cert;
boolean sm = x509Certificate.getSubjectX500Principal().equals(
caCert.getSubjectX500Principal());
boolean eq = false;
if (sm) {
eq = Arrays.equals(x509Certificate.getEncoded(), caCert.getEncoded());
}
Log.d("HS2J", "Subject: " + x509Certificate.getSubjectX500Principal() +
": " + sm + "/" + eq);
}
}
}
*/
private static WifiConfiguration buildTTLSConfig(HomeSP homeSP) throws IOException {
Credential credential = homeSP.getCredential();
if (credential.getUserName() == null || credential.getPassword() == null) {
throw new IOException("EAP-TTLS provisioned without user name or password");
}
EAPMethod eapMethod = credential.getEAPMethod();
AuthParam authParam = eapMethod.getAuthParam();
if (authParam == null || authParam.getAuthInfoID() != EAP.AuthInfoID.NonEAPInnerAuthType) {
throw new IOException("Bad auth parameter for EAP-TTLS: " + authParam);
}
WifiConfiguration config = buildBaseConfiguration(homeSP);
NonEAPInnerAuth ttlsParam = (NonEAPInnerAuth) authParam;
WifiEnterpriseConfig enterpriseConfig = config.enterpriseConfig;
enterpriseConfig.setPhase2Method(remapInnerMethod(ttlsParam.getType()));
enterpriseConfig.setIdentity(credential.getUserName());
enterpriseConfig.setPassword(credential.getPassword());
return config;
}
Aggregations