Merge "hotspot2: update PasspointConfiguration APIs" am: 59da9b24ca am: 4ed5fe8191

am: 28630218cc

Change-Id: I264d4664bc9e69d9c70dce7ffcf75e3ae2e2e430
This commit is contained in:
Peter Qiu
2017-02-01 03:30:58 +00:00
committed by android-build-merger
14 changed files with 1304 additions and 1023 deletions

View File

@@ -175,7 +175,7 @@ public final class ConfigBuilder {
} }
// Credential is needed for storing the certificates and private client key. // Credential is needed for storing the certificates and private client key.
if (config.credential == null) { if (config.getCredential() == null) {
throw new IOException("Passpoint profile missing credential"); throw new IOException("Passpoint profile missing credential");
} }
@@ -183,7 +183,7 @@ public final class ConfigBuilder {
byte[] caCertData = mimeParts.get(TYPE_CA_CERT); byte[] caCertData = mimeParts.get(TYPE_CA_CERT);
if (caCertData != null) { if (caCertData != null) {
try { try {
config.credential.caCertificate = parseCACert(caCertData); config.getCredential().setCaCertificate(parseCACert(caCertData));
} catch (CertificateException e) { } catch (CertificateException e) {
throw new IOException("Failed to parse CA Certificate"); throw new IOException("Failed to parse CA Certificate");
} }
@@ -194,9 +194,9 @@ public final class ConfigBuilder {
if (pkcs12Data != null) { if (pkcs12Data != null) {
try { try {
Pair<PrivateKey, List<X509Certificate>> clientKey = parsePkcs12(pkcs12Data); Pair<PrivateKey, List<X509Certificate>> clientKey = parsePkcs12(pkcs12Data);
config.credential.clientPrivateKey = clientKey.first; config.getCredential().setClientPrivateKey(clientKey.first);
config.credential.clientCertificateChain = config.getCredential().setClientCertificateChain(
clientKey.second.toArray(new X509Certificate[clientKey.second.size()]); clientKey.second.toArray(new X509Certificate[clientKey.second.size()]));
} catch(GeneralSecurityException | IOException e) { } catch(GeneralSecurityException | IOException e) {
throw new IOException("Failed to parse PCKS12 string"); throw new IOException("Failed to parse PCKS12 string");
} }

View File

@@ -58,21 +58,58 @@ public final class PasspointConfiguration implements Parcelable {
*/ */
private static final int NULL_VALUE = -1; private static final int NULL_VALUE = -1;
public HomeSP homeSp = null; /**
public Credential credential = null; * Configurations under HomeSP subtree.
public Policy policy = null; */
private HomeSP mHomeSp = null;
public void setHomeSp(HomeSP homeSp) { mHomeSp = homeSp; }
public HomeSP getHomeSp() { return mHomeSp; }
/**
* Configurations under Credential subtree.
*/
private Credential mCredential = null;
public void setCredential(Credential credential) {
mCredential = credential;
}
public Credential getCredential() {
return mCredential;
}
/**
* Configurations under Policy subtree.
*/
private Policy mPolicy = null;
public void setPolicy(Policy policy) {
mPolicy = policy;
}
public Policy getPolicy() {
return mPolicy;
}
/** /**
* Meta data for performing subscription update. * Meta data for performing subscription update.
*/ */
public UpdateParameter subscriptionUpdate = null; private UpdateParameter mSubscriptionUpdate = null;
public void setSubscriptionUpdate(UpdateParameter subscriptionUpdate) {
mSubscriptionUpdate = subscriptionUpdate;
}
public UpdateParameter getSubscriptionUpdate() {
return mSubscriptionUpdate;
}
/** /**
* List of HTTPS URL for retrieving trust root certificate and the corresponding SHA-256 * List of HTTPS URL for retrieving trust root certificate and the corresponding SHA-256
* fingerprint of the certificate. The certificates are used for verifying AAA server's * fingerprint of the certificate. The certificates are used for verifying AAA server's
* identity during EAP authentication. * identity during EAP authentication.
*/ */
public Map<String, byte[]> trustRootCertList = null; private Map<String, byte[]> mTrustRootCertList = null;
public void setTrustRootCertList(Map<String, byte[]> trustRootCertList) {
mTrustRootCertList = trustRootCertList;
}
public Map<String, byte[]> getTrustRootCertList() {
return mTrustRootCertList;
}
/** /**
* Set by the subscription server, updated every time the configuration is updated by * Set by the subscription server, updated every time the configuration is updated by
@@ -80,14 +117,26 @@ public final class PasspointConfiguration implements Parcelable {
* *
* Use Integer.MIN_VALUE to indicate unset value. * Use Integer.MIN_VALUE to indicate unset value.
*/ */
public int updateIdentifier = Integer.MIN_VALUE; private int mUpdateIdentifier = Integer.MIN_VALUE;
public void setUpdateIdentifier(int updateIdentifier) {
mUpdateIdentifier = updateIdentifier;
}
public int getUpdateIdentififer() {
return mUpdateIdentifier;
}
/** /**
* The priority of the credential. * The priority of the credential.
* *
* Use Integer.MIN_VALUE to indicate unset value. * Use Integer.MIN_VALUE to indicate unset value.
*/ */
public int credentialPriority = Integer.MIN_VALUE; private int mCredentialPriority = Integer.MIN_VALUE;
public void setCredentialPriority(int credentialPriority) {
mCredentialPriority = credentialPriority;
}
public int getCredentialPriority() {
return mCredentialPriority;
}
/** /**
* The time this subscription is created. It is in the format of number * The time this subscription is created. It is in the format of number
@@ -95,7 +144,13 @@ public final class PasspointConfiguration implements Parcelable {
* *
* Use Long.MIN_VALUE to indicate unset value. * Use Long.MIN_VALUE to indicate unset value.
*/ */
public long subscriptionCreationTimeInMs = Long.MIN_VALUE; private long mSubscriptionCreationTimeInMs = Long.MIN_VALUE;
public void setSubscriptionCreationTimeInMs(long subscriptionCreationTimeInMs) {
mSubscriptionCreationTimeInMs = subscriptionCreationTimeInMs;
}
public long getSubscriptionCreationTimeInMs() {
return mSubscriptionCreationTimeInMs;
}
/** /**
* The time this subscription will expire. It is in the format of number * The time this subscription will expire. It is in the format of number
@@ -103,20 +158,38 @@ public final class PasspointConfiguration implements Parcelable {
* *
* Use Long.MIN_VALUE to indicate unset value. * Use Long.MIN_VALUE to indicate unset value.
*/ */
public long subscriptionExpirationTimeInMs = Long.MIN_VALUE; private long mSubscriptionExpirationTimeInMs = Long.MIN_VALUE;
public void setSubscriptionExpirationTimeInMs(long subscriptionExpirationTimeInMs) {
mSubscriptionExpirationTimeInMs = subscriptionExpirationTimeInMs;
}
public long getSubscriptionExpirationTimeInMs() {
return mSubscriptionExpirationTimeInMs;
}
/** /**
* The type of the subscription. This is defined by the provider and the value is provider * The type of the subscription. This is defined by the provider and the value is provider
* specific. * specific.
*/ */
public String subscriptionType = null; private String mSubscriptionType = null;
public void setSubscriptionType(String subscriptionType) {
mSubscriptionType = subscriptionType;
}
public String getSubscriptionType() {
return mSubscriptionType;
}
/** /**
* The time period for usage statistics accumulation. A value of zero means that usage * The time period for usage statistics accumulation. A value of zero means that usage
* statistics are not accumulated on a periodic basis (e.g., a one-time limit for * statistics are not accumulated on a periodic basis (e.g., a one-time limit for
* “pay as you go” - PAYG service). A non-zero value specifies the usage interval in minutes. * “pay as you go” - PAYG service). A non-zero value specifies the usage interval in minutes.
*/ */
public long usageLimitUsageTimePeriodInMinutes = Long.MIN_VALUE; private long mUsageLimitUsageTimePeriodInMinutes = Long.MIN_VALUE;
public void setUsageLimitUsageTimePeriodInMinutes(long usageLimitUsageTimePeriodInMinutes) {
mUsageLimitUsageTimePeriodInMinutes = usageLimitUsageTimePeriodInMinutes;
}
public long getUsageLimitUsageTimePeriodInMinutes() {
return mUsageLimitUsageTimePeriodInMinutes;
}
/** /**
* The time at which usage statistic accumulation begins. It is in the format of number * The time at which usage statistic accumulation begins. It is in the format of number
@@ -124,7 +197,13 @@ public final class PasspointConfiguration implements Parcelable {
* *
* Use Long.MIN_VALUE to indicate unset value. * Use Long.MIN_VALUE to indicate unset value.
*/ */
public long usageLimitStartTimeInMs = Long.MIN_VALUE; private long mUsageLimitStartTimeInMs = Long.MIN_VALUE;
public void setUsageLimitStartTimeInMs(long usageLimitStartTimeInMs) {
mUsageLimitStartTimeInMs = usageLimitStartTimeInMs;
}
public long getUsageLimitStartTimeInMs() {
return mUsageLimitStartTimeInMs;
}
/** /**
* The cumulative data limit in megabytes for the {@link #usageLimitUsageTimePeriodInMinutes}. * The cumulative data limit in megabytes for the {@link #usageLimitUsageTimePeriodInMinutes}.
@@ -132,14 +211,25 @@ public final class PasspointConfiguration implements Parcelable {
* *
* Use Long.MIN_VALUE to indicate unset value. * Use Long.MIN_VALUE to indicate unset value.
*/ */
public long usageLimitDataLimit = Long.MIN_VALUE; private long mUsageLimitDataLimit = Long.MIN_VALUE;
public void setUsageLimitDataLimit(long usageLimitDataLimit) {
mUsageLimitDataLimit = usageLimitDataLimit;
}
public long getUsageLimitDataLimit() {
return mUsageLimitDataLimit;
}
/** /**
* The cumulative time limit in minutes for the {@link #usageLimitUsageTimePeriodInMinutes}. * The cumulative time limit in minutes for the {@link #usageLimitUsageTimePeriodInMinutes}.
* A value of zero indicate unlimited time usage. * A value of zero indicate unlimited time usage.
*/ */
public long usageLimitTimeLimitInMinutes = Long.MIN_VALUE; private long mUsageLimitTimeLimitInMinutes = Long.MIN_VALUE;
public void setUsageLimitTimeLimitInMinutes(long usageLimitTimeLimitInMinutes) {
mUsageLimitTimeLimitInMinutes = usageLimitTimeLimitInMinutes;
}
public long getUsageLimitTimeLimitInMinutes() {
return mUsageLimitTimeLimitInMinutes;
}
/** /**
* Constructor for creating PasspointConfiguration with default values. * Constructor for creating PasspointConfiguration with default values.
@@ -156,30 +246,30 @@ public final class PasspointConfiguration implements Parcelable {
return; return;
} }
if (source.homeSp != null) { if (source.mHomeSp != null) {
homeSp = new HomeSP(source.homeSp); mHomeSp = new HomeSP(source.mHomeSp);
} }
if (source.credential != null) { if (source.mCredential != null) {
credential = new Credential(source.credential); mCredential = new Credential(source.mCredential);
} }
if (source.policy != null) { if (source.mPolicy != null) {
policy = new Policy(source.policy); mPolicy = new Policy(source.mPolicy);
} }
if (source.trustRootCertList != null) { if (source.mTrustRootCertList != null) {
trustRootCertList = Collections.unmodifiableMap(source.trustRootCertList); mTrustRootCertList = Collections.unmodifiableMap(source.mTrustRootCertList);
} }
if (source.subscriptionUpdate != null) { if (source.mSubscriptionUpdate != null) {
subscriptionUpdate = new UpdateParameter(source.subscriptionUpdate); mSubscriptionUpdate = new UpdateParameter(source.mSubscriptionUpdate);
} }
updateIdentifier = source.updateIdentifier; mUpdateIdentifier = source.mUpdateIdentifier;
credentialPriority = source.credentialPriority; mCredentialPriority = source.mCredentialPriority;
subscriptionCreationTimeInMs = source.subscriptionCreationTimeInMs; mSubscriptionCreationTimeInMs = source.mSubscriptionCreationTimeInMs;
subscriptionExpirationTimeInMs = source.subscriptionExpirationTimeInMs; mSubscriptionExpirationTimeInMs = source.mSubscriptionExpirationTimeInMs;
subscriptionType = source.subscriptionType; mSubscriptionType = source.mSubscriptionType;
usageLimitDataLimit = source.usageLimitDataLimit; mUsageLimitDataLimit = source.mUsageLimitDataLimit;
usageLimitStartTimeInMs = source.usageLimitStartTimeInMs; mUsageLimitStartTimeInMs = source.mUsageLimitStartTimeInMs;
usageLimitTimeLimitInMinutes = source.usageLimitTimeLimitInMinutes; mUsageLimitTimeLimitInMinutes = source.mUsageLimitTimeLimitInMinutes;
usageLimitUsageTimePeriodInMinutes = source.usageLimitUsageTimePeriodInMinutes; mUsageLimitUsageTimePeriodInMinutes = source.mUsageLimitUsageTimePeriodInMinutes;
} }
@Override @Override
@@ -189,20 +279,20 @@ public final class PasspointConfiguration implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(homeSp, flags); dest.writeParcelable(mHomeSp, flags);
dest.writeParcelable(credential, flags); dest.writeParcelable(mCredential, flags);
dest.writeParcelable(policy, flags); dest.writeParcelable(mPolicy, flags);
dest.writeParcelable(subscriptionUpdate, flags); dest.writeParcelable(mSubscriptionUpdate, flags);
writeTrustRootCerts(dest, trustRootCertList); writeTrustRootCerts(dest, mTrustRootCertList);
dest.writeInt(updateIdentifier); dest.writeInt(mUpdateIdentifier);
dest.writeInt(credentialPriority); dest.writeInt(mCredentialPriority);
dest.writeLong(subscriptionCreationTimeInMs); dest.writeLong(mSubscriptionCreationTimeInMs);
dest.writeLong(subscriptionExpirationTimeInMs); dest.writeLong(mSubscriptionExpirationTimeInMs);
dest.writeString(subscriptionType); dest.writeString(mSubscriptionType);
dest.writeLong(usageLimitUsageTimePeriodInMinutes); dest.writeLong(mUsageLimitUsageTimePeriodInMinutes);
dest.writeLong(usageLimitStartTimeInMs); dest.writeLong(mUsageLimitStartTimeInMs);
dest.writeLong(usageLimitDataLimit); dest.writeLong(mUsageLimitDataLimit);
dest.writeLong(usageLimitTimeLimitInMinutes); dest.writeLong(mUsageLimitTimeLimitInMinutes);
} }
@Override @Override
@@ -214,22 +304,22 @@ public final class PasspointConfiguration implements Parcelable {
return false; return false;
} }
PasspointConfiguration that = (PasspointConfiguration) thatObject; PasspointConfiguration that = (PasspointConfiguration) thatObject;
return (homeSp == null ? that.homeSp == null : homeSp.equals(that.homeSp)) return (mHomeSp == null ? that.mHomeSp == null : mHomeSp.equals(that.mHomeSp))
&& (credential == null ? that.credential == null && (mCredential == null ? that.mCredential == null
: credential.equals(that.credential)) : mCredential.equals(that.mCredential))
&& (policy == null ? that.policy == null : policy.equals(that.policy)) && (mPolicy == null ? that.mPolicy == null : mPolicy.equals(that.mPolicy))
&& (subscriptionUpdate == null ? that.subscriptionUpdate == null && (mSubscriptionUpdate == null ? that.mSubscriptionUpdate == null
: subscriptionUpdate.equals(that.subscriptionUpdate)) : mSubscriptionUpdate.equals(that.mSubscriptionUpdate))
&& isTrustRootCertListEquals(trustRootCertList, that.trustRootCertList) && isTrustRootCertListEquals(mTrustRootCertList, that.mTrustRootCertList)
&& updateIdentifier == that.updateIdentifier && mUpdateIdentifier == that.mUpdateIdentifier
&& credentialPriority == that.credentialPriority && mCredentialPriority == that.mCredentialPriority
&& subscriptionCreationTimeInMs == that.subscriptionCreationTimeInMs && mSubscriptionCreationTimeInMs == that.mSubscriptionCreationTimeInMs
&& subscriptionExpirationTimeInMs == that.subscriptionExpirationTimeInMs && mSubscriptionExpirationTimeInMs == that.mSubscriptionExpirationTimeInMs
&& TextUtils.equals(subscriptionType, that.subscriptionType) && TextUtils.equals(mSubscriptionType, that.mSubscriptionType)
&& usageLimitUsageTimePeriodInMinutes == that.usageLimitUsageTimePeriodInMinutes && mUsageLimitUsageTimePeriodInMinutes == that.mUsageLimitUsageTimePeriodInMinutes
&& usageLimitStartTimeInMs == that.usageLimitStartTimeInMs && mUsageLimitStartTimeInMs == that.mUsageLimitStartTimeInMs
&& usageLimitDataLimit == that.usageLimitDataLimit && mUsageLimitDataLimit == that.mUsageLimitDataLimit
&& usageLimitTimeLimitInMinutes == that .usageLimitTimeLimitInMinutes; && mUsageLimitTimeLimitInMinutes == that.mUsageLimitTimeLimitInMinutes;
} }
/** /**
@@ -238,20 +328,20 @@ public final class PasspointConfiguration implements Parcelable {
* @return true on success or false on failure * @return true on success or false on failure
*/ */
public boolean validate() { public boolean validate() {
if (homeSp == null || !homeSp.validate()) { if (mHomeSp == null || !mHomeSp.validate()) {
return false; return false;
} }
if (credential == null || !credential.validate()) { if (mCredential == null || !mCredential.validate()) {
return false; return false;
} }
if (policy != null && !policy.validate()) { if (mPolicy != null && !mPolicy.validate()) {
return false; return false;
} }
if (subscriptionUpdate != null && !subscriptionUpdate.validate()) { if (mSubscriptionUpdate != null && !mSubscriptionUpdate.validate()) {
return false; return false;
} }
if (trustRootCertList != null) { if (mTrustRootCertList != null) {
for (Map.Entry<String, byte[]> entry : trustRootCertList.entrySet()) { for (Map.Entry<String, byte[]> entry : mTrustRootCertList.entrySet()) {
String url = entry.getKey(); String url = entry.getKey();
byte[] certFingerprint = entry.getValue(); byte[] certFingerprint = entry.getValue();
if (TextUtils.isEmpty(url)) { if (TextUtils.isEmpty(url)) {
@@ -283,20 +373,20 @@ public final class PasspointConfiguration implements Parcelable {
@Override @Override
public PasspointConfiguration createFromParcel(Parcel in) { public PasspointConfiguration createFromParcel(Parcel in) {
PasspointConfiguration config = new PasspointConfiguration(); PasspointConfiguration config = new PasspointConfiguration();
config.homeSp = in.readParcelable(null); config.setHomeSp(in.readParcelable(null));
config.credential = in.readParcelable(null); config.setCredential(in.readParcelable(null));
config.policy = in.readParcelable(null); config.setPolicy(in.readParcelable(null));
config.subscriptionUpdate = in.readParcelable(null); config.setSubscriptionUpdate(in.readParcelable(null));
config.trustRootCertList = readTrustRootCerts(in); config.setTrustRootCertList(readTrustRootCerts(in));
config.updateIdentifier = in.readInt(); config.setUpdateIdentifier(in.readInt());
config.credentialPriority = in.readInt(); config.setCredentialPriority(in.readInt());
config.subscriptionCreationTimeInMs = in.readLong(); config.setSubscriptionCreationTimeInMs(in.readLong());
config.subscriptionExpirationTimeInMs = in.readLong(); config.setSubscriptionExpirationTimeInMs(in.readLong());
config.subscriptionType = in.readString(); config.setSubscriptionType(in.readString());
config.usageLimitUsageTimePeriodInMinutes = in.readLong(); config.setUsageLimitUsageTimePeriodInMinutes(in.readLong());
config.usageLimitStartTimeInMs = in.readLong(); config.setUsageLimitStartTimeInMs(in.readLong());
config.usageLimitDataLimit = in.readLong(); config.setUsageLimitDataLimit(in.readLong());
config.usageLimitTimeLimitInMinutes = in.readLong(); config.setUsageLimitTimeLimitInMinutes(in.readLong());
return config; return config;
} }

View File

@@ -450,7 +450,7 @@ public final class PPSMOParser {
} }
} }
if (config != null && updateIdentifier != Integer.MIN_VALUE) { if (config != null && updateIdentifier != Integer.MIN_VALUE) {
config.updateIdentifier = updateIdentifier; config.setUpdateIdentifier(updateIdentifier);
} }
return config; return config;
} }
@@ -606,25 +606,25 @@ public final class PPSMOParser {
for (PPSNode child : root.getChildren()) { for (PPSNode child : root.getChildren()) {
switch(child.getName()) { switch(child.getName()) {
case NODE_HOMESP: case NODE_HOMESP:
config.homeSp = parseHomeSP(child); config.setHomeSp(parseHomeSP(child));
break; break;
case NODE_CREDENTIAL: case NODE_CREDENTIAL:
config.credential = parseCredential(child); config.setCredential(parseCredential(child));
break; break;
case NODE_POLICY: case NODE_POLICY:
config.policy = parsePolicy(child); config.setPolicy(parsePolicy(child));
break; break;
case NODE_AAA_SERVER_TRUST_ROOT: case NODE_AAA_SERVER_TRUST_ROOT:
config.trustRootCertList = parseAAAServerTrustRootList(child); config.setTrustRootCertList(parseAAAServerTrustRootList(child));
break; break;
case NODE_SUBSCRIPTION_UPDATE: case NODE_SUBSCRIPTION_UPDATE:
config.subscriptionUpdate = parseUpdateParameter(child); config.setSubscriptionUpdate(parseUpdateParameter(child));
break; break;
case NODE_SUBSCRIPTION_PARAMETER: case NODE_SUBSCRIPTION_PARAMETER:
parseSubscriptionParameter(child, config); parseSubscriptionParameter(child, config);
break; break;
case NODE_CREDENTIAL_PRIORITY: case NODE_CREDENTIAL_PRIORITY:
config.credentialPriority = parseInteger(getPpsNodeValue(child)); config.setCredentialPriority(parseInteger(getPpsNodeValue(child)));
break; break;
default: default:
throw new ParsingException("Unknown node: " + child.getName()); throw new ParsingException("Unknown node: " + child.getName());
@@ -649,28 +649,28 @@ public final class PPSMOParser {
for (PPSNode child : node.getChildren()) { for (PPSNode child : node.getChildren()) {
switch (child.getName()) { switch (child.getName()) {
case NODE_FQDN: case NODE_FQDN:
homeSp.fqdn = getPpsNodeValue(child); homeSp.setFqdn(getPpsNodeValue(child));
break; break;
case NODE_FRIENDLY_NAME: case NODE_FRIENDLY_NAME:
homeSp.friendlyName = getPpsNodeValue(child); homeSp.setFriendlyName(getPpsNodeValue(child));
break; break;
case NODE_ROAMING_CONSORTIUM_OI: case NODE_ROAMING_CONSORTIUM_OI:
homeSp.roamingConsortiumOIs = homeSp.setRoamingConsortiumOIs(
parseRoamingConsortiumOI(getPpsNodeValue(child)); parseRoamingConsortiumOI(getPpsNodeValue(child)));
break; break;
case NODE_ICON_URL: case NODE_ICON_URL:
homeSp.iconUrl = getPpsNodeValue(child); homeSp.setIconUrl(getPpsNodeValue(child));
break; break;
case NODE_NETWORK_ID: case NODE_NETWORK_ID:
homeSp.homeNetworkIds = parseNetworkIds(child); homeSp.setHomeNetworkIds(parseNetworkIds(child));
break; break;
case NODE_HOME_OI_LIST: case NODE_HOME_OI_LIST:
Pair<List<Long>, List<Long>> homeOIs = parseHomeOIList(child); Pair<List<Long>, List<Long>> homeOIs = parseHomeOIList(child);
homeSp.matchAllOIs = convertFromLongList(homeOIs.first); homeSp.setMatchAllOIs(convertFromLongList(homeOIs.first));
homeSp.matchAnyOIs = convertFromLongList(homeOIs.second); homeSp.setMatchAnyOIs(convertFromLongList(homeOIs.second));
break; break;
case NODE_OTHER_HOME_PARTNERS: case NODE_OTHER_HOME_PARTNERS:
homeSp.otherHomePartners = parseOtherHomePartners(child); homeSp.setOtherHomePartners(parseOtherHomePartners(child));
break; break;
default: default:
throw new ParsingException("Unknown node under HomeSP: " + child.getName()); throw new ParsingException("Unknown node under HomeSP: " + child.getName());
@@ -894,26 +894,26 @@ public final class PPSMOParser {
for (PPSNode child: node.getChildren()) { for (PPSNode child: node.getChildren()) {
switch (child.getName()) { switch (child.getName()) {
case NODE_CREATION_DATE: case NODE_CREATION_DATE:
credential.creationTimeInMs = parseDate(getPpsNodeValue(child)); credential.setCreationTimeInMs(parseDate(getPpsNodeValue(child)));
break; break;
case NODE_EXPIRATION_DATE: case NODE_EXPIRATION_DATE:
credential.expirationTimeInMs = parseDate(getPpsNodeValue(child)); credential.setExpirationTimeInMs(parseDate(getPpsNodeValue(child)));
break; break;
case NODE_USERNAME_PASSWORD: case NODE_USERNAME_PASSWORD:
credential.userCredential = parseUserCredential(child); credential.setUserCredential(parseUserCredential(child));
break; break;
case NODE_DIGITAL_CERTIFICATE: case NODE_DIGITAL_CERTIFICATE:
credential.certCredential = parseCertificateCredential(child); credential.setCertCredential(parseCertificateCredential(child));
break; break;
case NODE_REALM: case NODE_REALM:
credential.realm = getPpsNodeValue(child); credential.setRealm(getPpsNodeValue(child));
break; break;
case NODE_CHECK_AAA_SERVER_CERT_STATUS: case NODE_CHECK_AAA_SERVER_CERT_STATUS:
credential.checkAAAServerCertStatus = credential.setCheckAAAServerCertStatus(
Boolean.parseBoolean(getPpsNodeValue(child)); Boolean.parseBoolean(getPpsNodeValue(child)));
break; break;
case NODE_SIM: case NODE_SIM:
credential.simCredential = parseSimCredential(child); credential.setSimCredential(parseSimCredential(child));
break; break;
default: default:
throw new ParsingException("Unknown node under Credential: " + throw new ParsingException("Unknown node under Credential: " +
@@ -941,19 +941,19 @@ public final class PPSMOParser {
for (PPSNode child : node.getChildren()) { for (PPSNode child : node.getChildren()) {
switch (child.getName()) { switch (child.getName()) {
case NODE_USERNAME: case NODE_USERNAME:
userCred.username = getPpsNodeValue(child); userCred.setUsername(getPpsNodeValue(child));
break; break;
case NODE_PASSWORD: case NODE_PASSWORD:
userCred.password = getPpsNodeValue(child); userCred.setPassword(getPpsNodeValue(child));
break; break;
case NODE_MACHINE_MANAGED: case NODE_MACHINE_MANAGED:
userCred.machineManaged = Boolean.parseBoolean(getPpsNodeValue(child)); userCred.setMachineManaged(Boolean.parseBoolean(getPpsNodeValue(child)));
break; break;
case NODE_SOFT_TOKEN_APP: case NODE_SOFT_TOKEN_APP:
userCred.softTokenApp = getPpsNodeValue(child); userCred.setSoftTokenApp(getPpsNodeValue(child));
break; break;
case NODE_ABLE_TO_SHARE: case NODE_ABLE_TO_SHARE:
userCred.ableToShare = Boolean.parseBoolean(getPpsNodeValue(child)); userCred.setAbleToShare(Boolean.parseBoolean(getPpsNodeValue(child)));
break; break;
case NODE_EAP_METHOD: case NODE_EAP_METHOD:
parseEAPMethod(child, userCred); parseEAPMethod(child, userCred);
@@ -984,10 +984,10 @@ public final class PPSMOParser {
for (PPSNode child : node.getChildren()) { for (PPSNode child : node.getChildren()) {
switch(child.getName()) { switch(child.getName()) {
case NODE_EAP_TYPE: case NODE_EAP_TYPE:
userCred.eapType = parseInteger(getPpsNodeValue(child)); userCred.setEapType(parseInteger(getPpsNodeValue(child)));
break; break;
case NODE_INNER_METHOD: case NODE_INNER_METHOD:
userCred.nonEapInnerMethod = getPpsNodeValue(child); userCred.setNonEapInnerMethod(getPpsNodeValue(child));
break; break;
case NODE_VENDOR_ID: case NODE_VENDOR_ID:
case NODE_VENDOR_TYPE: case NODE_VENDOR_TYPE:
@@ -1022,10 +1022,10 @@ public final class PPSMOParser {
for (PPSNode child : node.getChildren()) { for (PPSNode child : node.getChildren()) {
switch (child.getName()) { switch (child.getName()) {
case NODE_CERTIFICATE_TYPE: case NODE_CERTIFICATE_TYPE:
certCred.certType = getPpsNodeValue(child); certCred.setCertType(getPpsNodeValue(child));
break; break;
case NODE_CERT_SHA256_FINGERPRINT: case NODE_CERT_SHA256_FINGERPRINT:
certCred.certSha256FingerPrint = parseHexString(getPpsNodeValue(child)); certCred.setCertSha256Fingerprint(parseHexString(getPpsNodeValue(child)));
break; break;
default: default:
throw new ParsingException("Unknown node under DigitalCertificate: " + throw new ParsingException("Unknown node under DigitalCertificate: " +
@@ -1053,10 +1053,10 @@ public final class PPSMOParser {
for (PPSNode child : node.getChildren()) { for (PPSNode child : node.getChildren()) {
switch (child.getName()) { switch (child.getName()) {
case NODE_SIM_IMSI: case NODE_SIM_IMSI:
simCred.imsi = getPpsNodeValue(child); simCred.setImsi(getPpsNodeValue(child));
break; break;
case NODE_EAP_TYPE: case NODE_EAP_TYPE:
simCred.eapType = parseInteger(getPpsNodeValue(child)); simCred.setEapType(parseInteger(getPpsNodeValue(child)));
break; break;
default: default:
throw new ParsingException("Unknown node under SIM: " + child.getName()); throw new ParsingException("Unknown node under SIM: " + child.getName());
@@ -1081,22 +1081,22 @@ public final class PPSMOParser {
for (PPSNode child : node.getChildren()) { for (PPSNode child : node.getChildren()) {
switch (child.getName()) { switch (child.getName()) {
case NODE_PREFERRED_ROAMING_PARTNER_LIST: case NODE_PREFERRED_ROAMING_PARTNER_LIST:
policy.preferredRoamingPartnerList = parsePreferredRoamingPartnerList(child); policy.setPreferredRoamingPartnerList(parsePreferredRoamingPartnerList(child));
break; break;
case NODE_MIN_BACKHAUL_THRESHOLD: case NODE_MIN_BACKHAUL_THRESHOLD:
parseMinBackhaulThreshold(child, policy); parseMinBackhaulThreshold(child, policy);
break; break;
case NODE_POLICY_UPDATE: case NODE_POLICY_UPDATE:
policy.policyUpdate = parseUpdateParameter(child); policy.setPolicyUpdate(parseUpdateParameter(child));
break; break;
case NODE_SP_EXCLUSION_LIST: case NODE_SP_EXCLUSION_LIST:
policy.excludedSsidList = parseSpExclusionList(child); policy.setExcludedSsidList(parseSpExclusionList(child));
break; break;
case NODE_REQUIRED_PROTO_PORT_TUPLE: case NODE_REQUIRED_PROTO_PORT_TUPLE:
policy.requiredProtoPortMap = parseRequiredProtoPortTuple(child); policy.setRequiredProtoPortMap(parseRequiredProtoPortTuple(child));
break; break;
case NODE_MAXIMUM_BSS_LOAD_VALUE: case NODE_MAXIMUM_BSS_LOAD_VALUE:
policy.maximumBssLoadValue = parseInteger(getPpsNodeValue(child)); policy.setMaximumBssLoadValue(parseInteger(getPpsNodeValue(child)));
break; break;
default: default:
throw new ParsingException("Unknown node under Policy: " + child.getName()); throw new ParsingException("Unknown node under Policy: " + child.getName());
@@ -1154,20 +1154,20 @@ public final class PPSMOParser {
if (fqdnMatchArray.length != 2) { if (fqdnMatchArray.length != 2) {
throw new ParsingException("Invalid FQDN_Match: " + fqdnMatch); throw new ParsingException("Invalid FQDN_Match: " + fqdnMatch);
} }
roamingPartner.fqdn = fqdnMatchArray[0]; roamingPartner.setFqdn(fqdnMatchArray[0]);
if (TextUtils.equals(fqdnMatchArray[1], "exactMatch")) { if (TextUtils.equals(fqdnMatchArray[1], "exactMatch")) {
roamingPartner.fqdnExactMatch = true; roamingPartner.setFqdnExactMatch(true);
} else if (TextUtils.equals(fqdnMatchArray[1], "includeSubdomains")) { } else if (TextUtils.equals(fqdnMatchArray[1], "includeSubdomains")) {
roamingPartner.fqdnExactMatch = false; roamingPartner.setFqdnExactMatch(false);
} else { } else {
throw new ParsingException("Invalid FQDN_Match: " + fqdnMatch); throw new ParsingException("Invalid FQDN_Match: " + fqdnMatch);
} }
break; break;
case NODE_PRIORITY: case NODE_PRIORITY:
roamingPartner.priority = parseInteger(getPpsNodeValue(child)); roamingPartner.setPriority(parseInteger(getPpsNodeValue(child)));
break; break;
case NODE_COUNTRY: case NODE_COUNTRY:
roamingPartner.countries = getPpsNodeValue(child); roamingPartner.setCountries(getPpsNodeValue(child));
break; break;
default: default:
throw new ParsingException("Unknown node under PreferredRoamingPartnerList " throw new ParsingException("Unknown node under PreferredRoamingPartnerList "
@@ -1234,11 +1234,11 @@ public final class PPSMOParser {
} }
if (TextUtils.equals(networkType, "home")) { if (TextUtils.equals(networkType, "home")) {
policy.minHomeDownlinkBandwidth = downlinkBandwidth; policy.setMinHomeDownlinkBandwidth(downlinkBandwidth);
policy.minHomeUplinkBandwidth = uplinkBandwidth; policy.setMinHomeUplinkBandwidth(uplinkBandwidth);
} else if (TextUtils.equals(networkType, "roaming")) { } else if (TextUtils.equals(networkType, "roaming")) {
policy.minRoamingDownlinkBandwidth = downlinkBandwidth; policy.setMinRoamingDownlinkBandwidth(downlinkBandwidth);
policy.minRoamingUplinkBandwidth = uplinkBandwidth; policy.setMinRoamingUplinkBandwidth(uplinkBandwidth);
} else { } else {
throw new ParsingException("Invalid network type: " + networkType); throw new ParsingException("Invalid network type: " + networkType);
} }
@@ -1264,26 +1264,26 @@ public final class PPSMOParser {
for (PPSNode child : node.getChildren()) { for (PPSNode child : node.getChildren()) {
switch(child.getName()) { switch(child.getName()) {
case NODE_UPDATE_INTERVAL: case NODE_UPDATE_INTERVAL:
updateParam.updateIntervalInMinutes = parseLong(getPpsNodeValue(child), 10); updateParam.setUpdateIntervalInMinutes(parseLong(getPpsNodeValue(child), 10));
break; break;
case NODE_UPDATE_METHOD: case NODE_UPDATE_METHOD:
updateParam.updateMethod = getPpsNodeValue(child); updateParam.setUpdateMethod(getPpsNodeValue(child));
break; break;
case NODE_RESTRICTION: case NODE_RESTRICTION:
updateParam.restriction = getPpsNodeValue(child); updateParam.setRestriction(getPpsNodeValue(child));
break; break;
case NODE_URI: case NODE_URI:
updateParam.serverUri = getPpsNodeValue(child); updateParam.setServerUri(getPpsNodeValue(child));
break; break;
case NODE_USERNAME_PASSWORD: case NODE_USERNAME_PASSWORD:
Pair<String, String> usernamePassword = parseUpdateUserCredential(child); Pair<String, String> usernamePassword = parseUpdateUserCredential(child);
updateParam.username = usernamePassword.first; updateParam.setUsername(usernamePassword.first);
updateParam.base64EncodedPassword = usernamePassword.second; updateParam.setBase64EncodedPassword(usernamePassword.second);
break; break;
case NODE_TRUST_ROOT: case NODE_TRUST_ROOT:
Pair<String, byte[]> trustRoot = parseTrustRoot(child); Pair<String, byte[]> trustRoot = parseTrustRoot(child);
updateParam.trustRootCertUrl = trustRoot.first; updateParam.setTrustRootCertUrl(trustRoot.first);
updateParam.trustRootCertSha256Fingerprint = trustRoot.second; updateParam.setTrustRootCertSha256Fingerprint(trustRoot.second);
break; break;
case NODE_OTHER: case NODE_OTHER:
Log.d(TAG, "Ignore unsupported paramter: " + child.getName()); Log.d(TAG, "Ignore unsupported paramter: " + child.getName());
@@ -1508,13 +1508,13 @@ public final class PPSMOParser {
for (PPSNode child : node.getChildren()) { for (PPSNode child : node.getChildren()) {
switch (child.getName()) { switch (child.getName()) {
case NODE_CREATION_DATE: case NODE_CREATION_DATE:
config.subscriptionCreationTimeInMs = parseDate(getPpsNodeValue(child)); config.setSubscriptionCreationTimeInMs(parseDate(getPpsNodeValue(child)));
break; break;
case NODE_EXPIRATION_DATE: case NODE_EXPIRATION_DATE:
config.subscriptionExpirationTimeInMs = parseDate(getPpsNodeValue(child)); config.setSubscriptionExpirationTimeInMs(parseDate(getPpsNodeValue(child)));
break; break;
case NODE_TYPE_OF_SUBSCRIPTION: case NODE_TYPE_OF_SUBSCRIPTION:
config.subscriptionType = getPpsNodeValue(child); config.setSubscriptionType(getPpsNodeValue(child));
break; break;
case NODE_USAGE_LIMITS: case NODE_USAGE_LIMITS:
parseUsageLimits(child, config); parseUsageLimits(child, config);
@@ -1543,17 +1543,17 @@ public final class PPSMOParser {
for (PPSNode child : node.getChildren()) { for (PPSNode child : node.getChildren()) {
switch (child.getName()) { switch (child.getName()) {
case NODE_DATA_LIMIT: case NODE_DATA_LIMIT:
config.usageLimitDataLimit = parseLong(getPpsNodeValue(child), 10); config.setUsageLimitDataLimit(parseLong(getPpsNodeValue(child), 10));
break; break;
case NODE_START_DATE: case NODE_START_DATE:
config.usageLimitStartTimeInMs = parseDate(getPpsNodeValue(child)); config.setUsageLimitStartTimeInMs(parseDate(getPpsNodeValue(child)));
break; break;
case NODE_TIME_LIMIT: case NODE_TIME_LIMIT:
config.usageLimitTimeLimitInMinutes = parseLong(getPpsNodeValue(child), 10); config.setUsageLimitTimeLimitInMinutes(parseLong(getPpsNodeValue(child), 10));
break; break;
case NODE_USAGE_TIME_PERIOD: case NODE_USAGE_TIME_PERIOD:
config.usageLimitUsageTimePeriodInMinutes = config.setUsageLimitUsageTimePeriodInMinutes(
parseLong(getPpsNodeValue(child), 10); parseLong(getPpsNodeValue(child), 10));
break; break;
default: default:
throw new ParsingException("Unknown node under UsageLimits" throw new ParsingException("Unknown node under UsageLimits"

View File

@@ -58,28 +58,52 @@ public final class Credential implements Parcelable {
* of milliseconds since January 1, 1970, 00:00:00 GMT. * of milliseconds since January 1, 1970, 00:00:00 GMT.
* Using Long.MIN_VALUE to indicate unset value. * Using Long.MIN_VALUE to indicate unset value.
*/ */
public long creationTimeInMs = Long.MIN_VALUE; private long mCreationTimeInMs = Long.MIN_VALUE;
public void setCreationTimeInMs(long creationTimeInMs) {
mCreationTimeInMs = creationTimeInMs;
}
public long getCreationTimeInMs() {
return mCreationTimeInMs;
}
/** /**
* The time this credential will expire. It is in the format of number * The time this credential will expire. It is in the format of number
* of milliseconds since January 1, 1970, 00:00:00 GMT. * of milliseconds since January 1, 1970, 00:00:00 GMT.
* Using Long.MIN_VALUE to indicate unset value. * Using Long.MIN_VALUE to indicate unset value.
*/ */
public long expirationTimeInMs = Long.MIN_VALUE; private long mExpirationTimeInMs = Long.MIN_VALUE;
public void setExpirationTimeInMs(long expirationTimeInMs) {
mExpirationTimeInMs = expirationTimeInMs;
}
public long getExpirationTimeInMs() {
return mExpirationTimeInMs;
}
/** /**
* The realm associated with this credential. It will be used to determine * The realm associated with this credential. It will be used to determine
* if this credential can be used to authenticate with a given hotspot by * if this credential can be used to authenticate with a given hotspot by
* comparing the realm specified in that hotspot's ANQP element. * comparing the realm specified in that hotspot's ANQP element.
*/ */
public String realm = null; private String mRealm = null;
public void setRealm(String realm) {
mRealm = realm;
}
public String getRealm() {
return mRealm;
}
/** /**
* When set to true, the device should check AAA (Authentication, Authorization, * When set to true, the device should check AAA (Authentication, Authorization,
* and Accounting) server's certificate during EAP (Extensible Authentication * and Accounting) server's certificate during EAP (Extensible Authentication
* Protocol) authentication. * Protocol) authentication.
*/ */
public boolean checkAAAServerCertStatus = false; private boolean mCheckAAAServerCertStatus = false;
public void setCheckAAAServerCertStatus(boolean checkAAAServerCertStatus) {
mCheckAAAServerCertStatus = checkAAAServerCertStatus;
}
public boolean getCheckAAAServerStatus() {
return mCheckAAAServerCertStatus;
}
/** /**
* Username-password based credential. * Username-password based credential.
@@ -109,27 +133,57 @@ public final class Credential implements Parcelable {
/** /**
* Username of the credential. * Username of the credential.
*/ */
public String username = null; private String mUsername = null;
public void setUsername(String username) {
mUsername = username;
}
public String getUsername() {
return mUsername;
}
/** /**
* Base64-encoded password. * Base64-encoded password.
*/ */
public String password = null; private String mPassword = null;
public void setPassword(String password) {
mPassword = password;
}
public String getPassword() {
return mPassword;
}
/** /**
* Flag indicating if the password is machine managed. * Flag indicating if the password is machine managed.
*/ */
public boolean machineManaged = false; private boolean mMachineManaged = false;
public void setMachineManaged(boolean machineManaged) {
mMachineManaged = machineManaged;
}
public boolean getMachineManaged() {
return mMachineManaged;
}
/** /**
* The name of the application used to generate the password. * The name of the application used to generate the password.
*/ */
public String softTokenApp = null; private String mSoftTokenApp = null;
public void setSoftTokenApp(String softTokenApp) {
mSoftTokenApp = softTokenApp;
}
public String getSoftTokenApp() {
return mSoftTokenApp;
}
/** /**
* Flag indicating if this credential is usable on other mobile devices as well. * Flag indicating if this credential is usable on other mobile devices as well.
*/ */
public boolean ableToShare = false; private boolean mAbleToShare = false;
public void setAbleToShare(boolean ableToShare) {
mAbleToShare = ableToShare;
}
public boolean getAbleToShare() {
return mAbleToShare;
}
/** /**
* EAP (Extensible Authentication Protocol) method type. * EAP (Extensible Authentication Protocol) method type.
@@ -137,12 +191,24 @@ public final class Credential implements Parcelable {
* for valid values. * for valid values.
* Using Integer.MIN_VALUE to indicate unset value. * Using Integer.MIN_VALUE to indicate unset value.
*/ */
public int eapType = Integer.MIN_VALUE; private int mEapType = Integer.MIN_VALUE;
public void setEapType(int eapType) {
mEapType = eapType;
}
public int getEapType() {
return mEapType;
}
/** /**
* Non-EAP inner authentication method. * Non-EAP inner authentication method.
*/ */
public String nonEapInnerMethod = null; private String mNonEapInnerMethod = null;
public void setNonEapInnerMethod(String nonEapInnerMethod) {
mNonEapInnerMethod = nonEapInnerMethod;
}
public String getNonEapInnerMethod() {
return mNonEapInnerMethod;
}
/** /**
* Constructor for creating UserCredential with default values. * Constructor for creating UserCredential with default values.
@@ -156,13 +222,13 @@ public final class Credential implements Parcelable {
*/ */
public UserCredential(UserCredential source) { public UserCredential(UserCredential source) {
if (source != null) { if (source != null) {
username = source.username; mUsername = source.mUsername;
password = source.password; mPassword = source.mPassword;
machineManaged = source.machineManaged; mMachineManaged = source.mMachineManaged;
softTokenApp = source.softTokenApp; mSoftTokenApp = source.mSoftTokenApp;
ableToShare = source.ableToShare; mAbleToShare = source.mAbleToShare;
eapType = source.eapType; mEapType = source.mEapType;
nonEapInnerMethod = source.nonEapInnerMethod; mNonEapInnerMethod = source.mNonEapInnerMethod;
} }
} }
@@ -173,13 +239,13 @@ public final class Credential implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeString(username); dest.writeString(mUsername);
dest.writeString(password); dest.writeString(mPassword);
dest.writeInt(machineManaged ? 1 : 0); dest.writeInt(mMachineManaged ? 1 : 0);
dest.writeString(softTokenApp); dest.writeString(mSoftTokenApp);
dest.writeInt(ableToShare ? 1 : 0); dest.writeInt(mAbleToShare ? 1 : 0);
dest.writeInt(eapType); dest.writeInt(mEapType);
dest.writeString(nonEapInnerMethod); dest.writeString(mNonEapInnerMethod);
} }
@Override @Override
@@ -192,13 +258,13 @@ public final class Credential implements Parcelable {
} }
UserCredential that = (UserCredential) thatObject; UserCredential that = (UserCredential) thatObject;
return TextUtils.equals(username, that.username) return TextUtils.equals(mUsername, that.mUsername)
&& TextUtils.equals(password, that.password) && TextUtils.equals(mPassword, that.mPassword)
&& machineManaged == that.machineManaged && mMachineManaged == that.mMachineManaged
&& TextUtils.equals(softTokenApp, that.softTokenApp) && TextUtils.equals(mSoftTokenApp, that.mSoftTokenApp)
&& ableToShare == that.ableToShare && mAbleToShare == that.mAbleToShare
&& eapType == that.eapType && mEapType == that.mEapType
&& TextUtils.equals(nonEapInnerMethod, that.nonEapInnerMethod); && TextUtils.equals(mNonEapInnerMethod, that.mNonEapInnerMethod);
} }
/** /**
@@ -207,35 +273,35 @@ public final class Credential implements Parcelable {
* @return true on success or false on failure * @return true on success or false on failure
*/ */
public boolean validate() { public boolean validate() {
if (TextUtils.isEmpty(username)) { if (TextUtils.isEmpty(mUsername)) {
Log.d(TAG, "Missing username"); Log.d(TAG, "Missing username");
return false; return false;
} }
if (username.getBytes(StandardCharsets.UTF_8).length > MAX_USERNAME_BYTES) { if (mUsername.getBytes(StandardCharsets.UTF_8).length > MAX_USERNAME_BYTES) {
Log.d(TAG, "username exceeding maximum length: " Log.d(TAG, "username exceeding maximum length: "
+ username.getBytes(StandardCharsets.UTF_8).length); + mUsername.getBytes(StandardCharsets.UTF_8).length);
return false; return false;
} }
if (TextUtils.isEmpty(password)) { if (TextUtils.isEmpty(mPassword)) {
Log.d(TAG, "Missing password"); Log.d(TAG, "Missing password");
return false; return false;
} }
if (password.getBytes(StandardCharsets.UTF_8).length > MAX_PASSWORD_BYTES) { if (mPassword.getBytes(StandardCharsets.UTF_8).length > MAX_PASSWORD_BYTES) {
Log.d(TAG, "password exceeding maximum length: " Log.d(TAG, "password exceeding maximum length: "
+ password.getBytes(StandardCharsets.UTF_8).length); + mPassword.getBytes(StandardCharsets.UTF_8).length);
return false; return false;
} }
// Only supports EAP-TTLS for user credential. // Only supports EAP-TTLS for user credential.
if (eapType != EAPConstants.EAP_TTLS) { if (mEapType != EAPConstants.EAP_TTLS) {
Log.d(TAG, "Invalid EAP Type for user credential: " + eapType); Log.d(TAG, "Invalid EAP Type for user credential: " + mEapType);
return false; return false;
} }
// Verify Non-EAP inner method for EAP-TTLS. // Verify Non-EAP inner method for EAP-TTLS.
if (!SUPPORTED_AUTH.contains(nonEapInnerMethod)) { if (!SUPPORTED_AUTH.contains(mNonEapInnerMethod)) {
Log.d(TAG, "Invalid non-EAP inner method for EAP-TTLS: " + nonEapInnerMethod); Log.d(TAG, "Invalid non-EAP inner method for EAP-TTLS: " + mNonEapInnerMethod);
return false; return false;
} }
return true; return true;
@@ -246,13 +312,13 @@ public final class Credential implements Parcelable {
@Override @Override
public UserCredential createFromParcel(Parcel in) { public UserCredential createFromParcel(Parcel in) {
UserCredential userCredential = new UserCredential(); UserCredential userCredential = new UserCredential();
userCredential.username = in.readString(); userCredential.setUsername(in.readString());
userCredential.password = in.readString(); userCredential.setPassword(in.readString());
userCredential.machineManaged = in.readInt() != 0; userCredential.setMachineManaged(in.readInt() != 0);
userCredential.softTokenApp = in.readString(); userCredential.setSoftTokenApp(in.readString());
userCredential.ableToShare = in.readInt() != 0; userCredential.setAbleToShare(in.readInt() != 0);
userCredential.eapType = in.readInt(); userCredential.setEapType(in.readInt());
userCredential.nonEapInnerMethod = in.readString(); userCredential.setNonEapInnerMethod(in.readString());
return userCredential; return userCredential;
} }
@@ -262,7 +328,13 @@ public final class Credential implements Parcelable {
} }
}; };
} }
public UserCredential userCredential = null; private UserCredential mUserCredential = null;
public void setUserCredential(UserCredential userCredential) {
mUserCredential = userCredential;
}
public UserCredential getUserCredential() {
return mUserCredential;
}
/** /**
* Certificate based credential. This is used for EAP-TLS. * Certificate based credential. This is used for EAP-TLS.
@@ -282,12 +354,24 @@ public final class Credential implements Parcelable {
/** /**
* Certificate type. * Certificate type.
*/ */
public String certType = null; private String mCertType = null;
public void setCertType(String certType) {
mCertType = certType;
}
public String getCertType() {
return mCertType;
}
/** /**
* The SHA-256 fingerprint of the certificate. * The SHA-256 fingerprint of the certificate.
*/ */
public byte[] certSha256FingerPrint = null; private byte[] mCertSha256Fingerprint = null;
public void setCertSha256Fingerprint(byte[] certSha256Fingerprint) {
mCertSha256Fingerprint = certSha256Fingerprint;
}
public byte[] getCertSha256Fingerprint() {
return mCertSha256Fingerprint;
}
/** /**
* Constructor for creating CertificateCredential with default values. * Constructor for creating CertificateCredential with default values.
@@ -301,10 +385,10 @@ public final class Credential implements Parcelable {
*/ */
public CertificateCredential(CertificateCredential source) { public CertificateCredential(CertificateCredential source) {
if (source != null) { if (source != null) {
certType = source.certType; mCertType = source.mCertType;
if (source.certSha256FingerPrint != null) { if (source.mCertSha256Fingerprint != null) {
certSha256FingerPrint = Arrays.copyOf(source.certSha256FingerPrint, mCertSha256Fingerprint = Arrays.copyOf(source.mCertSha256Fingerprint,
source.certSha256FingerPrint.length); source.mCertSha256Fingerprint.length);
} }
} }
} }
@@ -316,8 +400,8 @@ public final class Credential implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeString(certType); dest.writeString(mCertType);
dest.writeByteArray(certSha256FingerPrint); dest.writeByteArray(mCertSha256Fingerprint);
} }
@Override @Override
@@ -330,8 +414,8 @@ public final class Credential implements Parcelable {
} }
CertificateCredential that = (CertificateCredential) thatObject; CertificateCredential that = (CertificateCredential) thatObject;
return TextUtils.equals(certType, that.certType) return TextUtils.equals(mCertType, that.mCertType)
&& Arrays.equals(certSha256FingerPrint, that.certSha256FingerPrint); && Arrays.equals(mCertSha256Fingerprint, that.mCertSha256Fingerprint);
} }
/** /**
@@ -340,12 +424,12 @@ public final class Credential implements Parcelable {
* @return true on success or false on failure * @return true on success or false on failure
*/ */
public boolean validate() { public boolean validate() {
if (!TextUtils.equals(CERT_TYPE_X509V3, certType)) { if (!TextUtils.equals(CERT_TYPE_X509V3, mCertType)) {
Log.d(TAG, "Unsupported certificate type: " + certType); Log.d(TAG, "Unsupported certificate type: " + mCertType);
return false; return false;
} }
if (certSha256FingerPrint == null if (mCertSha256Fingerprint == null
|| certSha256FingerPrint.length != CERT_SHA256_FINGER_PRINT_LENGTH) { || mCertSha256Fingerprint.length != CERT_SHA256_FINGER_PRINT_LENGTH) {
Log.d(TAG, "Invalid SHA-256 fingerprint"); Log.d(TAG, "Invalid SHA-256 fingerprint");
return false; return false;
} }
@@ -357,8 +441,8 @@ public final class Credential implements Parcelable {
@Override @Override
public CertificateCredential createFromParcel(Parcel in) { public CertificateCredential createFromParcel(Parcel in) {
CertificateCredential certCredential = new CertificateCredential(); CertificateCredential certCredential = new CertificateCredential();
certCredential.certType = in.readString(); certCredential.setCertType(in.readString());
certCredential.certSha256FingerPrint = in.createByteArray(); certCredential.setCertSha256Fingerprint(in.createByteArray());
return certCredential; return certCredential;
} }
@@ -368,7 +452,13 @@ public final class Credential implements Parcelable {
} }
}; };
} }
public CertificateCredential certCredential = null; private CertificateCredential mCertCredential = null;
public void setCertCredential(CertificateCredential certCredential) {
mCertCredential = certCredential;
}
public CertificateCredential getCertCredential() {
return mCertCredential;
}
/** /**
* SIM (Subscriber Identify Module) based credential. * SIM (Subscriber Identify Module) based credential.
@@ -378,14 +468,20 @@ public final class Credential implements Parcelable {
/** /**
* Maximum string length for IMSI. * Maximum string length for IMSI.
*/ */
public static final int MAX_IMSI_LENGTH = 15; private static final int MAX_IMSI_LENGTH = 15;
/** /**
* International Mobile Subscriber Identity, is used to identify the user * International Mobile Subscriber Identity, is used to identify the user
* of a cellular network and is a unique identification associated with all * of a cellular network and is a unique identification associated with all
* cellular networks * cellular networks
*/ */
public String imsi = null; private String mImsi = null;
public void setImsi(String imsi) {
mImsi = imsi;
}
public String getImsi() {
return mImsi;
}
/** /**
* EAP (Extensible Authentication Protocol) method type for using SIM credential. * EAP (Extensible Authentication Protocol) method type for using SIM credential.
@@ -393,7 +489,13 @@ public final class Credential implements Parcelable {
* for valid values. * for valid values.
* Using Integer.MIN_VALUE to indicate unset value. * Using Integer.MIN_VALUE to indicate unset value.
*/ */
public int eapType = Integer.MIN_VALUE; private int mEapType = Integer.MIN_VALUE;
public void setEapType(int eapType) {
mEapType = eapType;
}
public int getEapType() {
return mEapType;
}
/** /**
* Constructor for creating SimCredential with default values. * Constructor for creating SimCredential with default values.
@@ -407,8 +509,8 @@ public final class Credential implements Parcelable {
*/ */
public SimCredential(SimCredential source) { public SimCredential(SimCredential source) {
if (source != null) { if (source != null) {
imsi = source.imsi; mImsi = source.mImsi;
eapType = source.eapType; mEapType = source.mEapType;
} }
} }
@@ -427,14 +529,14 @@ public final class Credential implements Parcelable {
} }
SimCredential that = (SimCredential) thatObject; SimCredential that = (SimCredential) thatObject;
return TextUtils.equals(imsi, that.imsi) return TextUtils.equals(mImsi, that.mImsi)
&& eapType == that.eapType; && mEapType == that.mEapType;
} }
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeString(imsi); dest.writeString(mImsi);
dest.writeInt(eapType); dest.writeInt(mEapType);
} }
/** /**
@@ -449,9 +551,9 @@ public final class Credential implements Parcelable {
if (!verifyImsi()) { if (!verifyImsi()) {
return false; return false;
} }
if (eapType != EAPConstants.EAP_SIM && eapType != EAPConstants.EAP_AKA if (mEapType != EAPConstants.EAP_SIM && mEapType != EAPConstants.EAP_AKA
&& eapType != EAPConstants.EAP_AKA_PRIME) { && mEapType != EAPConstants.EAP_AKA_PRIME) {
Log.d(TAG, "Invalid EAP Type for SIM credential: " + eapType); Log.d(TAG, "Invalid EAP Type for SIM credential: " + mEapType);
return false; return false;
} }
return true; return true;
@@ -462,8 +564,8 @@ public final class Credential implements Parcelable {
@Override @Override
public SimCredential createFromParcel(Parcel in) { public SimCredential createFromParcel(Parcel in) {
SimCredential simCredential = new SimCredential(); SimCredential simCredential = new SimCredential();
simCredential.imsi = in.readString(); simCredential.setImsi(in.readString());
simCredential.eapType = in.readInt(); simCredential.setEapType(in.readInt());
return simCredential; return simCredential;
} }
@@ -481,51 +583,75 @@ public final class Credential implements Parcelable {
* @return true if IMSI is valid, false otherwise. * @return true if IMSI is valid, false otherwise.
*/ */
private boolean verifyImsi() { private boolean verifyImsi() {
if (TextUtils.isEmpty(imsi)) { if (TextUtils.isEmpty(mImsi)) {
Log.d(TAG, "Missing IMSI"); Log.d(TAG, "Missing IMSI");
return false; return false;
} }
if (imsi.length() > MAX_IMSI_LENGTH) { if (mImsi.length() > MAX_IMSI_LENGTH) {
Log.d(TAG, "IMSI exceeding maximum length: " + imsi.length()); Log.d(TAG, "IMSI exceeding maximum length: " + mImsi.length());
return false; return false;
} }
// Locate the first non-digit character. // Locate the first non-digit character.
int nonDigit; int nonDigit;
char stopChar = '\0'; char stopChar = '\0';
for (nonDigit = 0; nonDigit < imsi.length(); nonDigit++) { for (nonDigit = 0; nonDigit < mImsi.length(); nonDigit++) {
stopChar = imsi.charAt(nonDigit); stopChar = mImsi.charAt(nonDigit);
if (stopChar < '0' || stopChar > '9') { if (stopChar < '0' || stopChar > '9') {
break; break;
} }
} }
if (nonDigit == imsi.length()) { if (nonDigit == mImsi.length()) {
return true; return true;
} }
else if (nonDigit == imsi.length()-1 && stopChar == '*') { else if (nonDigit == mImsi.length()-1 && stopChar == '*') {
// Prefix matching. // Prefix matching.
return true; return true;
} }
return false; return false;
} }
} }
public SimCredential simCredential = null; private SimCredential mSimCredential = null;
public void setSimCredential(SimCredential simCredential) {
mSimCredential = simCredential;
}
public SimCredential getSimCredential() {
return mSimCredential;
}
/** /**
* CA (Certificate Authority) X509 certificate. * CA (Certificate Authority) X509 certificate.
*/ */
public X509Certificate caCertificate = null; private X509Certificate mCaCertificate = null;
public void setCaCertificate(X509Certificate caCertificate) {
mCaCertificate = caCertificate;
}
public X509Certificate getCaCertificate() {
return mCaCertificate;
}
/** /**
* Client side X509 certificate chain. * Client side X509 certificate chain.
*/ */
public X509Certificate[] clientCertificateChain = null; private X509Certificate[] mClientCertificateChain = null;
public void setClientCertificateChain(X509Certificate[] certificateChain) {
mClientCertificateChain = certificateChain;
}
public X509Certificate[] getClientCertificateChain() {
return mClientCertificateChain;
}
/** /**
* Client side private key. * Client side private key.
*/ */
public PrivateKey clientPrivateKey = null; private PrivateKey mClientPrivateKey = null;
public void setClientPrivateKey(PrivateKey clientPrivateKey) {
mClientPrivateKey = clientPrivateKey;
}
public PrivateKey getClientPrivateKey() {
return mClientPrivateKey;
}
/** /**
* Constructor for creating Credential with default values. * Constructor for creating Credential with default values.
@@ -539,25 +665,25 @@ public final class Credential implements Parcelable {
*/ */
public Credential(Credential source) { public Credential(Credential source) {
if (source != null) { if (source != null) {
creationTimeInMs = source.creationTimeInMs; mCreationTimeInMs = source.mCreationTimeInMs;
expirationTimeInMs = source.expirationTimeInMs; mExpirationTimeInMs = source.mExpirationTimeInMs;
realm = source.realm; mRealm = source.mRealm;
checkAAAServerCertStatus = source.checkAAAServerCertStatus; mCheckAAAServerCertStatus = source.mCheckAAAServerCertStatus;
if (source.userCredential != null) { if (source.mUserCredential != null) {
userCredential = new UserCredential(source.userCredential); mUserCredential = new UserCredential(source.mUserCredential);
} }
if (source.certCredential != null) { if (source.mCertCredential != null) {
certCredential = new CertificateCredential(source.certCredential); mCertCredential = new CertificateCredential(source.mCertCredential);
} }
if (source.simCredential != null) { if (source.mSimCredential != null) {
simCredential = new SimCredential(source.simCredential); mSimCredential = new SimCredential(source.mSimCredential);
} }
if (source.clientCertificateChain != null) { if (source.mClientCertificateChain != null) {
clientCertificateChain = Arrays.copyOf(source.clientCertificateChain, mClientCertificateChain = Arrays.copyOf(source.mClientCertificateChain,
source.clientCertificateChain.length); source.mClientCertificateChain.length);
} }
caCertificate = source.caCertificate; mCaCertificate = source.mCaCertificate;
clientPrivateKey = source.clientPrivateKey; mClientPrivateKey = source.mClientPrivateKey;
} }
} }
@@ -568,16 +694,16 @@ public final class Credential implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(creationTimeInMs); dest.writeLong(mCreationTimeInMs);
dest.writeLong(expirationTimeInMs); dest.writeLong(mExpirationTimeInMs);
dest.writeString(realm); dest.writeString(mRealm);
dest.writeInt(checkAAAServerCertStatus ? 1 : 0); dest.writeInt(mCheckAAAServerCertStatus ? 1 : 0);
dest.writeParcelable(userCredential, flags); dest.writeParcelable(mUserCredential, flags);
dest.writeParcelable(certCredential, flags); dest.writeParcelable(mCertCredential, flags);
dest.writeParcelable(simCredential, flags); dest.writeParcelable(mSimCredential, flags);
ParcelUtil.writeCertificate(dest, caCertificate); ParcelUtil.writeCertificate(dest, mCaCertificate);
ParcelUtil.writeCertificates(dest, clientCertificateChain); ParcelUtil.writeCertificates(dest, mClientCertificateChain);
ParcelUtil.writePrivateKey(dest, clientPrivateKey); ParcelUtil.writePrivateKey(dest, mClientPrivateKey);
} }
@Override @Override
@@ -590,19 +716,19 @@ public final class Credential implements Parcelable {
} }
Credential that = (Credential) thatObject; Credential that = (Credential) thatObject;
return TextUtils.equals(realm, that.realm) return TextUtils.equals(mRealm, that.mRealm)
&& creationTimeInMs == that.creationTimeInMs && mCreationTimeInMs == that.mCreationTimeInMs
&& expirationTimeInMs == that.expirationTimeInMs && mExpirationTimeInMs == that.mExpirationTimeInMs
&& checkAAAServerCertStatus == that.checkAAAServerCertStatus && mCheckAAAServerCertStatus == that.mCheckAAAServerCertStatus
&& (userCredential == null ? that.userCredential == null && (mUserCredential == null ? that.mUserCredential == null
: userCredential.equals(that.userCredential)) : mUserCredential.equals(that.mUserCredential))
&& (certCredential == null ? that.certCredential == null && (mCertCredential == null ? that.mCertCredential == null
: certCredential.equals(that.certCredential)) : mCertCredential.equals(that.mCertCredential))
&& (simCredential == null ? that.simCredential == null && (mSimCredential == null ? that.mSimCredential == null
: simCredential.equals(that.simCredential)) : mSimCredential.equals(that.mSimCredential))
&& isX509CertificateEquals(caCertificate, that.caCertificate) && isX509CertificateEquals(mCaCertificate, that.mCaCertificate)
&& isX509CertificatesEquals(clientCertificateChain, that.clientCertificateChain) && isX509CertificatesEquals(mClientCertificateChain, that.mClientCertificateChain)
&& isPrivateKeyEquals(clientPrivateKey, that.clientPrivateKey); && isPrivateKeyEquals(mClientPrivateKey, that.mClientPrivateKey);
} }
/** /**
@@ -611,26 +737,26 @@ public final class Credential implements Parcelable {
* @return true on success or false on failure * @return true on success or false on failure
*/ */
public boolean validate() { public boolean validate() {
if (TextUtils.isEmpty(realm)) { if (TextUtils.isEmpty(mRealm)) {
Log.d(TAG, "Missing realm"); Log.d(TAG, "Missing realm");
return false; return false;
} }
if (realm.getBytes(StandardCharsets.UTF_8).length > MAX_REALM_BYTES) { if (mRealm.getBytes(StandardCharsets.UTF_8).length > MAX_REALM_BYTES) {
Log.d(TAG, "realm exceeding maximum length: " Log.d(TAG, "realm exceeding maximum length: "
+ realm.getBytes(StandardCharsets.UTF_8).length); + mRealm.getBytes(StandardCharsets.UTF_8).length);
return false; return false;
} }
// Verify the credential. // Verify the credential.
if (userCredential != null) { if (mUserCredential != null) {
if (!verifyUserCredential()) { if (!verifyUserCredential()) {
return false; return false;
} }
} else if (certCredential != null) { } else if (mCertCredential != null) {
if (!verifyCertCredential()) { if (!verifyCertCredential()) {
return false; return false;
} }
} else if (simCredential != null) { } else if (mSimCredential != null) {
if (!verifySimCredential()) { if (!verifySimCredential()) {
return false; return false;
} }
@@ -647,16 +773,16 @@ public final class Credential implements Parcelable {
@Override @Override
public Credential createFromParcel(Parcel in) { public Credential createFromParcel(Parcel in) {
Credential credential = new Credential(); Credential credential = new Credential();
credential.creationTimeInMs = in.readLong(); credential.setCreationTimeInMs(in.readLong());
credential.expirationTimeInMs = in.readLong(); credential.setExpirationTimeInMs(in.readLong());
credential.realm = in.readString(); credential.setRealm(in.readString());
credential.checkAAAServerCertStatus = in.readInt() != 0; credential.setCheckAAAServerCertStatus(in.readInt() != 0);
credential.userCredential = in.readParcelable(null); credential.setUserCredential(in.readParcelable(null));
credential.certCredential = in.readParcelable(null); credential.setCertCredential(in.readParcelable(null));
credential.simCredential = in.readParcelable(null); credential.setSimCredential(in.readParcelable(null));
credential.caCertificate = ParcelUtil.readCertificate(in); credential.setCaCertificate(ParcelUtil.readCertificate(in));
credential.clientCertificateChain = ParcelUtil.readCertificates(in); credential.setClientCertificateChain(ParcelUtil.readCertificates(in));
credential.clientPrivateKey = ParcelUtil.readPrivateKey(in); credential.setClientPrivateKey(ParcelUtil.readPrivateKey(in));
return credential; return credential;
} }
@@ -672,18 +798,18 @@ public final class Credential implements Parcelable {
* @return true if user credential is valid, false otherwise. * @return true if user credential is valid, false otherwise.
*/ */
private boolean verifyUserCredential() { private boolean verifyUserCredential() {
if (userCredential == null) { if (mUserCredential == null) {
Log.d(TAG, "Missing user credential"); Log.d(TAG, "Missing user credential");
return false; return false;
} }
if (certCredential != null || simCredential != null) { if (mCertCredential != null || mSimCredential != null) {
Log.d(TAG, "Contained more than one type of credential"); Log.d(TAG, "Contained more than one type of credential");
return false; return false;
} }
if (!userCredential.validate()) { if (!mUserCredential.validate()) {
return false; return false;
} }
if (caCertificate == null) { if (mCaCertificate == null) {
Log.d(TAG, "Missing CA Certificate for user credential"); Log.d(TAG, "Missing CA Certificate for user credential");
return false; return false;
} }
@@ -697,32 +823,32 @@ public final class Credential implements Parcelable {
* @return true if certificate credential is valid, false otherwise. * @return true if certificate credential is valid, false otherwise.
*/ */
private boolean verifyCertCredential() { private boolean verifyCertCredential() {
if (certCredential == null) { if (mCertCredential == null) {
Log.d(TAG, "Missing certificate credential"); Log.d(TAG, "Missing certificate credential");
return false; return false;
} }
if (userCredential != null || simCredential != null) { if (mUserCredential != null || mSimCredential != null) {
Log.d(TAG, "Contained more than one type of credential"); Log.d(TAG, "Contained more than one type of credential");
return false; return false;
} }
if (!certCredential.validate()) { if (!mCertCredential.validate()) {
return false; return false;
} }
// Verify required key and certificates for certificate credential. // Verify required key and certificates for certificate credential.
if (caCertificate == null) { if (mCaCertificate == null) {
Log.d(TAG, "Missing CA Certificate for certificate credential"); Log.d(TAG, "Missing CA Certificate for certificate credential");
return false; return false;
} }
if (clientPrivateKey == null) { if (mClientPrivateKey == null) {
Log.d(TAG, "Missing client private key for certificate credential"); Log.d(TAG, "Missing client private key for certificate credential");
return false; return false;
} }
try { try {
// Verify SHA-256 fingerprint for client certificate. // Verify SHA-256 fingerprint for client certificate.
if (!verifySha256Fingerprint(clientCertificateChain, if (!verifySha256Fingerprint(mClientCertificateChain,
certCredential.certSha256FingerPrint)) { mCertCredential.getCertSha256Fingerprint())) {
Log.d(TAG, "SHA-256 fingerprint mismatch"); Log.d(TAG, "SHA-256 fingerprint mismatch");
return false; return false;
} }
@@ -740,15 +866,15 @@ public final class Credential implements Parcelable {
* @return true if SIM credential is valid, false otherwise. * @return true if SIM credential is valid, false otherwise.
*/ */
private boolean verifySimCredential() { private boolean verifySimCredential() {
if (simCredential == null) { if (mSimCredential == null) {
Log.d(TAG, "Missing SIM credential"); Log.d(TAG, "Missing SIM credential");
return false; return false;
} }
if (userCredential != null || certCredential != null) { if (mUserCredential != null || mCertCredential != null) {
Log.d(TAG, "Contained more than one type of credential"); Log.d(TAG, "Contained more than one type of credential");
return false; return false;
} }
return simCredential.validate(); return mSimCredential.validate();
} }
private static boolean isPrivateKeyEquals(PrivateKey key1, PrivateKey key2) { private static boolean isPrivateKeyEquals(PrivateKey key1, PrivateKey key2) {

View File

@@ -52,17 +52,35 @@ public final class HomeSP implements Parcelable {
/** /**
* FQDN (Fully Qualified Domain Name) of this home service provider. * FQDN (Fully Qualified Domain Name) of this home service provider.
*/ */
public String fqdn = null; private String mFqdn = null;
public void setFqdn(String fqdn) {
mFqdn = fqdn;
}
public String getFqdn() {
return mFqdn;
}
/** /**
* Friendly name of this home service provider. * Friendly name of this home service provider.
*/ */
public String friendlyName = null; private String mFriendlyName = null;
public void setFriendlyName(String friendlyName) {
mFriendlyName = friendlyName;
}
public String getFriendlyName() {
return mFriendlyName;
}
/** /**
* Icon URL of this home service provider. * Icon URL of this home service provider.
*/ */
public String iconUrl = null; private String mIconUrl = null;
public void setIconUrl(String iconUrl) {
mIconUrl = iconUrl;
}
public String getIconUrl() {
return mIconUrl;
}
/** /**
* <SSID, HESSID> duple of the networks that are consider home networks. * <SSID, HESSID> duple of the networks that are consider home networks.
@@ -71,7 +89,13 @@ public final class HomeSP implements Parcelable {
* all nodes in the PSS MO are encoded using UTF-8 unless stated otherwise. Thus, the SSID * all nodes in the PSS MO are encoded using UTF-8 unless stated otherwise. Thus, the SSID
* string is assumed to be encoded using UTF-8. * string is assumed to be encoded using UTF-8.
*/ */
public Map<String, Long> homeNetworkIds = null; private Map<String, Long> mHomeNetworkIds = null;
public void setHomeNetworkIds(Map<String, Long> homeNetworkIds) {
mHomeNetworkIds = homeNetworkIds;
}
public Map<String, Long> getHomeNetworkIds() {
return mHomeNetworkIds;
}
/** /**
* Used for determining if this provider is a member of a given Hotspot provider. * Used for determining if this provider is a member of a given Hotspot provider.
@@ -83,7 +107,13 @@ public final class HomeSP implements Parcelable {
* Refer to HomeSP/HomeOIList subtree in PerProviderSubscription (PPS) Management Object * Refer to HomeSP/HomeOIList subtree in PerProviderSubscription (PPS) Management Object
* (MO) tree for more detail. * (MO) tree for more detail.
*/ */
public long[] matchAllOIs = null; private long[] mMatchAllOIs = null;
public void setMatchAllOIs(long[] matchAllOIs) {
mMatchAllOIs = matchAllOIs;
}
public long[] getMatchAllOIs() {
return mMatchAllOIs;
}
/** /**
* Used for determining if this provider is a member of a given Hotspot provider. * Used for determining if this provider is a member of a given Hotspot provider.
@@ -92,13 +122,19 @@ public final class HomeSP implements Parcelable {
* of that Hotspot provider (e.g. successful authentication with such Hotspot * of that Hotspot provider (e.g. successful authentication with such Hotspot
* is possible). * is possible).
* *
* {@link #matchAllOIs} will have precedence over this one, meaning this list will * {@link #mMatchAllOIs} will have precedence over this one, meaning this list will
* only be used for matching if {@link #matchAllOIs} is null or empty. * only be used for matching if {@link #mMatchAllOIs} is null or empty.
* *
* Refer to HomeSP/HomeOIList subtree in PerProviderSubscription (PPS) Management Object * Refer to HomeSP/HomeOIList subtree in PerProviderSubscription (PPS) Management Object
* (MO) tree for more detail. * (MO) tree for more detail.
*/ */
public long[] matchAnyOIs = null; private long[] mMatchAnyOIs = null;
public void setMatchAnyOIs(long[] matchAnyOIs) {
mMatchAnyOIs = matchAnyOIs;
}
public long[] getMatchAnysOIs() {
return mMatchAnyOIs;
}
/** /**
* List of FQDN (Fully Qualified Domain Name) of partner providers. * List of FQDN (Fully Qualified Domain Name) of partner providers.
@@ -106,13 +142,25 @@ public final class HomeSP implements Parcelable {
* This relationship is most likely achieved via a commercial agreement or * This relationship is most likely achieved via a commercial agreement or
* operator merges between the providers. * operator merges between the providers.
*/ */
public String[] otherHomePartners = null; private String[] mOtherHomePartners = null;
public void setOtherHomePartners(String[] otherHomePartners) {
mOtherHomePartners = otherHomePartners;
}
public String[] getOtherHomePartners() {
return mOtherHomePartners;
}
/** /**
* List of Organization Identifiers (OIs) identifying a roaming consortium of * List of Organization Identifiers (OIs) identifying a roaming consortium of
* which this provider is a member. * which this provider is a member.
*/ */
public long[] roamingConsortiumOIs = null; private long[] mRoamingConsortiumOIs = null;
public void setRoamingConsortiumOIs(long[] roamingConsortiumOIs) {
mRoamingConsortiumOIs = roamingConsortiumOIs;
}
public long[] getRoamingConsortiumOIs() {
return mRoamingConsortiumOIs;
}
/** /**
* Constructor for creating HomeSP with default values. * Constructor for creating HomeSP with default values.
@@ -128,25 +176,25 @@ public final class HomeSP implements Parcelable {
if (source == null) { if (source == null) {
return; return;
} }
fqdn = source.fqdn; mFqdn = source.mFqdn;
friendlyName = source.friendlyName; mFriendlyName = source.mFriendlyName;
iconUrl = source.iconUrl; mIconUrl = source.mIconUrl;
if (source.homeNetworkIds != null) { if (source.mHomeNetworkIds != null) {
homeNetworkIds = Collections.unmodifiableMap(source.homeNetworkIds); mHomeNetworkIds = Collections.unmodifiableMap(source.mHomeNetworkIds);
} }
if (source.matchAllOIs != null) { if (source.mMatchAllOIs != null) {
matchAllOIs = Arrays.copyOf(source.matchAllOIs, source.matchAllOIs.length); mMatchAllOIs = Arrays.copyOf(source.mMatchAllOIs, source.mMatchAllOIs.length);
} }
if (source.matchAnyOIs != null) { if (source.mMatchAnyOIs != null) {
matchAnyOIs = Arrays.copyOf(source.matchAnyOIs, source.matchAnyOIs.length); mMatchAnyOIs = Arrays.copyOf(source.mMatchAnyOIs, source.mMatchAnyOIs.length);
} }
if (source.otherHomePartners != null) { if (source.mOtherHomePartners != null) {
otherHomePartners = Arrays.copyOf(source.otherHomePartners, mOtherHomePartners = Arrays.copyOf(source.mOtherHomePartners,
source.otherHomePartners.length); source.mOtherHomePartners.length);
} }
if (source.roamingConsortiumOIs != null) { if (source.mRoamingConsortiumOIs != null) {
roamingConsortiumOIs = Arrays.copyOf(source.roamingConsortiumOIs, mRoamingConsortiumOIs = Arrays.copyOf(source.mRoamingConsortiumOIs,
source.roamingConsortiumOIs.length); source.mRoamingConsortiumOIs.length);
} }
} }
@@ -157,14 +205,14 @@ public final class HomeSP implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeString(fqdn); dest.writeString(mFqdn);
dest.writeString(friendlyName); dest.writeString(mFriendlyName);
dest.writeString(iconUrl); dest.writeString(mIconUrl);
writeHomeNetworkIds(dest, homeNetworkIds); writeHomeNetworkIds(dest, mHomeNetworkIds);
dest.writeLongArray(matchAllOIs); dest.writeLongArray(mMatchAllOIs);
dest.writeLongArray(matchAnyOIs); dest.writeLongArray(mMatchAnyOIs);
dest.writeStringArray(otherHomePartners); dest.writeStringArray(mOtherHomePartners);
dest.writeLongArray(roamingConsortiumOIs); dest.writeLongArray(mRoamingConsortiumOIs);
} }
@Override @Override
@@ -177,15 +225,15 @@ public final class HomeSP implements Parcelable {
} }
HomeSP that = (HomeSP) thatObject; HomeSP that = (HomeSP) thatObject;
return TextUtils.equals(fqdn, that.fqdn) return TextUtils.equals(mFqdn, that.mFqdn)
&& TextUtils.equals(friendlyName, that.friendlyName) && TextUtils.equals(mFriendlyName, that.mFriendlyName)
&& TextUtils.equals(iconUrl, that.iconUrl) && TextUtils.equals(mIconUrl, that.mIconUrl)
&& (homeNetworkIds == null ? that.homeNetworkIds == null && (mHomeNetworkIds == null ? that.mHomeNetworkIds == null
: homeNetworkIds.equals(that.homeNetworkIds)) : mHomeNetworkIds.equals(that.mHomeNetworkIds))
&& Arrays.equals(matchAllOIs, that.matchAllOIs) && Arrays.equals(mMatchAllOIs, that.mMatchAllOIs)
&& Arrays.equals(matchAnyOIs, that.matchAnyOIs) && Arrays.equals(mMatchAnyOIs, that.mMatchAnyOIs)
&& Arrays.equals(otherHomePartners, that.otherHomePartners) && Arrays.equals(mOtherHomePartners, that.mOtherHomePartners)
&& Arrays.equals(roamingConsortiumOIs, that.roamingConsortiumOIs); && Arrays.equals(mRoamingConsortiumOIs, that.mRoamingConsortiumOIs);
} }
/** /**
@@ -194,17 +242,17 @@ public final class HomeSP implements Parcelable {
* @return true on success or false on failure * @return true on success or false on failure
*/ */
public boolean validate() { public boolean validate() {
if (TextUtils.isEmpty(fqdn)) { if (TextUtils.isEmpty(mFqdn)) {
Log.d(TAG, "Missing FQDN"); Log.d(TAG, "Missing FQDN");
return false; return false;
} }
if (TextUtils.isEmpty(friendlyName)) { if (TextUtils.isEmpty(mFriendlyName)) {
Log.d(TAG, "Missing friendly name"); Log.d(TAG, "Missing friendly name");
return false; return false;
} }
// Verify SSIDs specified in the NetworkID // Verify SSIDs specified in the NetworkID
if (homeNetworkIds != null) { if (mHomeNetworkIds != null) {
for (Map.Entry<String, Long> entry : homeNetworkIds.entrySet()) { for (Map.Entry<String, Long> entry : mHomeNetworkIds.entrySet()) {
if (entry.getKey() == null || if (entry.getKey() == null ||
entry.getKey().getBytes(StandardCharsets.UTF_8).length > MAX_SSID_BYTES) { entry.getKey().getBytes(StandardCharsets.UTF_8).length > MAX_SSID_BYTES) {
Log.d(TAG, "Invalid SSID in HomeNetworkIDs"); Log.d(TAG, "Invalid SSID in HomeNetworkIDs");
@@ -220,14 +268,14 @@ public final class HomeSP implements Parcelable {
@Override @Override
public HomeSP createFromParcel(Parcel in) { public HomeSP createFromParcel(Parcel in) {
HomeSP homeSp = new HomeSP(); HomeSP homeSp = new HomeSP();
homeSp.fqdn = in.readString(); homeSp.setFqdn(in.readString());
homeSp.friendlyName = in.readString(); homeSp.setFriendlyName(in.readString());
homeSp.iconUrl = in.readString(); homeSp.setIconUrl(in.readString());
homeSp.homeNetworkIds = readHomeNetworkIds(in); homeSp.setHomeNetworkIds(readHomeNetworkIds(in));
homeSp.matchAllOIs = in.createLongArray(); homeSp.setMatchAllOIs(in.createLongArray());
homeSp.matchAnyOIs = in.createLongArray(); homeSp.setMatchAnyOIs(in.createLongArray());
homeSp.otherHomePartners = in.createStringArray(); homeSp.setOtherHomePartners(in.createStringArray());
homeSp.roamingConsortiumOIs = in.createLongArray(); homeSp.setRoamingConsortiumOIs(in.createLongArray());
return homeSp; return homeSp;
} }

View File

@@ -79,8 +79,20 @@ public final class Policy implements Parcelable {
* *
* Using Long.MIN_VALUE to indicate unset value. * Using Long.MIN_VALUE to indicate unset value.
*/ */
public long minHomeDownlinkBandwidth = Long.MIN_VALUE; private long mMinHomeDownlinkBandwidth = Long.MIN_VALUE;
public long minHomeUplinkBandwidth = Long.MIN_VALUE; public void setMinHomeDownlinkBandwidth(long minHomeDownlinkBandwidth) {
mMinHomeDownlinkBandwidth = minHomeDownlinkBandwidth;
}
public long getMinHomeDownlinkBandWidht() {
return mMinHomeDownlinkBandwidth;
}
private long mMinHomeUplinkBandwidth = Long.MIN_VALUE;
public void setMinHomeUplinkBandwidth(long minHomeUplinkBandwidth) {
mMinHomeUplinkBandwidth = minHomeUplinkBandwidth;
}
public long getMinHomeUplinkBandwidth() {
return mMinHomeUplinkBandwidth;
}
/** /**
* Minimum available downlink/uplink bandwidth (in kilobits per second) required when * Minimum available downlink/uplink bandwidth (in kilobits per second) required when
@@ -91,26 +103,56 @@ public final class Policy implements Parcelable {
* *
* Using Long.MIN_VALUE to indicate unset value. * Using Long.MIN_VALUE to indicate unset value.
*/ */
public long minRoamingDownlinkBandwidth = Long.MIN_VALUE; private long mMinRoamingDownlinkBandwidth = Long.MIN_VALUE;
public long minRoamingUplinkBandwidth = Long.MIN_VALUE; public void setMinRoamingDownlinkBandwidth(long minRoamingDownlinkBandwidth) {
mMinRoamingDownlinkBandwidth = minRoamingDownlinkBandwidth;
}
public long getMinRoamingDownlinkBandwidth() {
return mMinRoamingDownlinkBandwidth;
}
private long mMinRoamingUplinkBandwidth = Long.MIN_VALUE;
public void setMinRoamingUplinkBandwidth(long minRoamingUplinkBandwidth) {
mMinRoamingUplinkBandwidth = minRoamingUplinkBandwidth;
}
public long getMinRoamingUplinkBandwidth() {
return mMinRoamingUplinkBandwidth;
}
/** /**
* List of SSIDs that are not preferred by the Home SP. * List of SSIDs that are not preferred by the Home SP.
*/ */
public String[] excludedSsidList = null; private String[] mExcludedSsidList = null;
public void setExcludedSsidList(String[] excludedSsidList) {
mExcludedSsidList = excludedSsidList;
}
public String[] getExcludedSsidList() {
return mExcludedSsidList;
}
/** /**
* List of IP protocol and port number required by one or more operator supported application. * List of IP protocol and port number required by one or more operator supported application.
* The port string contained one or more port numbers delimited by ",". * The port string contained one or more port numbers delimited by ",".
*/ */
public Map<Integer, String> requiredProtoPortMap = null; private Map<Integer, String> mRequiredProtoPortMap = null;
public void setRequiredProtoPortMap(Map<Integer, String> requiredProtoPortMap) {
mRequiredProtoPortMap = requiredProtoPortMap;
}
public Map<Integer, String> getRequiredProtoPortMap() {
return mRequiredProtoPortMap;
}
/** /**
* This specifies the maximum acceptable BSS load policy. This is used to prevent device * This specifies the maximum acceptable BSS load policy. This is used to prevent device
* from joining an AP whose channel is overly congested with traffic. * from joining an AP whose channel is overly congested with traffic.
* Using Integer.MIN_VALUE to indicate unset value. * Using Integer.MIN_VALUE to indicate unset value.
*/ */
public int maximumBssLoadValue = Integer.MIN_VALUE; private int mMaximumBssLoadValue = Integer.MIN_VALUE;
public void setMaximumBssLoadValue(int maximumBssLoadValue) {
mMaximumBssLoadValue = maximumBssLoadValue;
}
public int getMaximumBssLoadValue() {
return mMaximumBssLoadValue;
}
/** /**
* Policy associated with a roaming provider. This specifies a priority associated * Policy associated with a roaming provider. This specifies a priority associated
@@ -122,7 +164,13 @@ public final class Policy implements Parcelable {
/** /**
* FQDN of the roaming partner. * FQDN of the roaming partner.
*/ */
public String fqdn = null; private String mFqdn = null;
public void setFqdn(String fqdn) {
mFqdn = fqdn;
}
public String getFqdn() {
return mFqdn;
}
/** /**
* Flag indicating the exact match of FQDN is required for FQDN matching. * Flag indicating the exact match of FQDN is required for FQDN matching.
@@ -130,27 +178,45 @@ public final class Policy implements Parcelable {
* When this flag is set to false, sub-domain matching is used. For example, when * When this flag is set to false, sub-domain matching is used. For example, when
* {@link #fqdn} s set to "example.com", "host.example.com" would be a match. * {@link #fqdn} s set to "example.com", "host.example.com" would be a match.
*/ */
public boolean fqdnExactMatch = false; private boolean mFqdnExactMatch = false;
public void setFqdnExactMatch(boolean fqdnExactMatch) {
mFqdnExactMatch = fqdnExactMatch;
}
public boolean getFqdnExactMatch() {
return mFqdnExactMatch;
}
/** /**
* Priority associated with this roaming partner policy. * Priority associated with this roaming partner policy.
*/ */
public int priority = PREFERRED_ROAMING_PARTNER_DEFAULT_PRIORITY; private int mPriority = PREFERRED_ROAMING_PARTNER_DEFAULT_PRIORITY;
public void setPriority(int priority) {
mPriority = priority;
}
public int getPriority() {
return mPriority;
}
/** /**
* A string contained One or more, comma delimited (i.e., ",") ISO/IEC 3166-1 two * A string contained One or more, comma delimited (i.e., ",") ISO/IEC 3166-1 two
* character country strings or the country-independent value, "*". * character country strings or the country-independent value, "*".
*/ */
public String countries = null; private String mCountries = null;
public void setCountries(String countries) {
mCountries = countries;
}
public String getCountries() {
return mCountries;
}
public RoamingPartner() {} public RoamingPartner() {}
public RoamingPartner(RoamingPartner source) { public RoamingPartner(RoamingPartner source) {
if (source != null) { if (source != null) {
fqdn = source.fqdn; mFqdn = source.mFqdn;
fqdnExactMatch = source.fqdnExactMatch; mFqdnExactMatch = source.mFqdnExactMatch;
priority = source.priority; mPriority = source.mPriority;
countries = source.countries; mCountries = source.mCountries;
} }
} }
@@ -161,10 +227,10 @@ public final class Policy implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeString(fqdn); dest.writeString(mFqdn);
dest.writeInt(fqdnExactMatch ? 1 : 0); dest.writeInt(mFqdnExactMatch ? 1 : 0);
dest.writeInt(priority); dest.writeInt(mPriority);
dest.writeString(countries); dest.writeString(mCountries);
} }
@Override @Override
@@ -177,10 +243,10 @@ public final class Policy implements Parcelable {
} }
RoamingPartner that = (RoamingPartner) thatObject; RoamingPartner that = (RoamingPartner) thatObject;
return TextUtils.equals(fqdn, that.fqdn) return TextUtils.equals(mFqdn, that.mFqdn)
&& fqdnExactMatch == that.fqdnExactMatch && mFqdnExactMatch == that.mFqdnExactMatch
&& priority == that.priority && mPriority == that.mPriority
&& TextUtils.equals(countries, that.countries); && TextUtils.equals(mCountries, that.mCountries);
} }
/** /**
@@ -189,11 +255,11 @@ public final class Policy implements Parcelable {
* @return true on success * @return true on success
*/ */
public boolean validate() { public boolean validate() {
if (TextUtils.isEmpty(fqdn)) { if (TextUtils.isEmpty(mFqdn)) {
Log.d(TAG, "Missing FQDN"); Log.d(TAG, "Missing FQDN");
return false; return false;
} }
if (TextUtils.isEmpty(countries)) { if (TextUtils.isEmpty(mCountries)) {
Log.d(TAG, "Missing countries"); Log.d(TAG, "Missing countries");
return false; return false;
} }
@@ -205,10 +271,10 @@ public final class Policy implements Parcelable {
@Override @Override
public RoamingPartner createFromParcel(Parcel in) { public RoamingPartner createFromParcel(Parcel in) {
RoamingPartner roamingPartner = new RoamingPartner(); RoamingPartner roamingPartner = new RoamingPartner();
roamingPartner.fqdn = in.readString(); roamingPartner.setFqdn(in.readString());
roamingPartner.fqdnExactMatch = in.readInt() != 0; roamingPartner.setFqdnExactMatch(in.readInt() != 0);
roamingPartner.priority = in.readInt(); roamingPartner.setPriority(in.readInt());
roamingPartner.countries = in.readString(); roamingPartner.setCountries(in.readString());
return roamingPartner; return roamingPartner;
} }
@@ -218,12 +284,24 @@ public final class Policy implements Parcelable {
} }
}; };
} }
public List<RoamingPartner> preferredRoamingPartnerList = null; private List<RoamingPartner> mPreferredRoamingPartnerList = null;
public void setPreferredRoamingPartnerList(List<RoamingPartner> partnerList) {
mPreferredRoamingPartnerList = partnerList;
}
public List<RoamingPartner> getPreferredRoamingPartnerList() {
return mPreferredRoamingPartnerList;
}
/** /**
* Meta data used for policy update. * Meta data used for policy update.
*/ */
public UpdateParameter policyUpdate = null; private UpdateParameter mPolicyUpdate = null;
public void setPolicyUpdate(UpdateParameter policyUpdate) {
mPolicyUpdate = policyUpdate;
}
public UpdateParameter getPolicyUpdate() {
return mPolicyUpdate;
}
/** /**
* Constructor for creating Policy with default values. * Constructor for creating Policy with default values.
@@ -239,24 +317,24 @@ public final class Policy implements Parcelable {
if (source == null) { if (source == null) {
return; return;
} }
minHomeDownlinkBandwidth = source.minHomeDownlinkBandwidth; mMinHomeDownlinkBandwidth = source.mMinHomeDownlinkBandwidth;
minHomeUplinkBandwidth = source.minHomeUplinkBandwidth; mMinHomeUplinkBandwidth = source.mMinHomeUplinkBandwidth;
minRoamingDownlinkBandwidth = source.minRoamingDownlinkBandwidth; mMinRoamingDownlinkBandwidth = source.mMinRoamingDownlinkBandwidth;
minRoamingUplinkBandwidth = source.minRoamingUplinkBandwidth; mMinRoamingUplinkBandwidth = source.mMinRoamingUplinkBandwidth;
maximumBssLoadValue = source.maximumBssLoadValue; mMaximumBssLoadValue = source.mMaximumBssLoadValue;
if (source.excludedSsidList != null) { if (source.mExcludedSsidList != null) {
excludedSsidList = Arrays.copyOf(source.excludedSsidList, mExcludedSsidList = Arrays.copyOf(source.mExcludedSsidList,
source.excludedSsidList.length); source.mExcludedSsidList.length);
} }
if (source.requiredProtoPortMap != null) { if (source.mRequiredProtoPortMap != null) {
requiredProtoPortMap = Collections.unmodifiableMap(source.requiredProtoPortMap); mRequiredProtoPortMap = Collections.unmodifiableMap(source.mRequiredProtoPortMap);
} }
if (source.preferredRoamingPartnerList != null) { if (source.mPreferredRoamingPartnerList != null) {
preferredRoamingPartnerList = Collections.unmodifiableList( mPreferredRoamingPartnerList = Collections.unmodifiableList(
source.preferredRoamingPartnerList); source.mPreferredRoamingPartnerList);
} }
if (source.policyUpdate != null) { if (source.mPolicyUpdate != null) {
policyUpdate = new UpdateParameter(source.policyUpdate); mPolicyUpdate = new UpdateParameter(source.mPolicyUpdate);
} }
} }
@@ -267,15 +345,15 @@ public final class Policy implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(minHomeDownlinkBandwidth); dest.writeLong(mMinHomeDownlinkBandwidth);
dest.writeLong(minHomeUplinkBandwidth); dest.writeLong(mMinHomeUplinkBandwidth);
dest.writeLong(minRoamingDownlinkBandwidth); dest.writeLong(mMinRoamingDownlinkBandwidth);
dest.writeLong(minRoamingUplinkBandwidth); dest.writeLong(mMinRoamingUplinkBandwidth);
dest.writeStringArray(excludedSsidList); dest.writeStringArray(mExcludedSsidList);
writeProtoPortMap(dest, requiredProtoPortMap); writeProtoPortMap(dest, mRequiredProtoPortMap);
dest.writeInt(maximumBssLoadValue); dest.writeInt(mMaximumBssLoadValue);
writeRoamingPartnerList(dest, flags, preferredRoamingPartnerList); writeRoamingPartnerList(dest, flags, mPreferredRoamingPartnerList);
dest.writeParcelable(policyUpdate, flags); dest.writeParcelable(mPolicyUpdate, flags);
} }
@Override @Override
@@ -288,18 +366,19 @@ public final class Policy implements Parcelable {
} }
Policy that = (Policy) thatObject; Policy that = (Policy) thatObject;
return minHomeDownlinkBandwidth == that.minHomeDownlinkBandwidth return mMinHomeDownlinkBandwidth == that.mMinHomeDownlinkBandwidth
&& minHomeUplinkBandwidth == that.minHomeUplinkBandwidth && mMinHomeUplinkBandwidth == that.mMinHomeUplinkBandwidth
&& minRoamingDownlinkBandwidth == that.minRoamingDownlinkBandwidth && mMinRoamingDownlinkBandwidth == that.mMinRoamingDownlinkBandwidth
&& minRoamingUplinkBandwidth == that.minRoamingUplinkBandwidth && mMinRoamingUplinkBandwidth == that.mMinRoamingUplinkBandwidth
&& Arrays.equals(excludedSsidList, that.excludedSsidList) && Arrays.equals(mExcludedSsidList, that.mExcludedSsidList)
&& (requiredProtoPortMap == null ? that.requiredProtoPortMap == null && (mRequiredProtoPortMap == null ? that.mRequiredProtoPortMap == null
: requiredProtoPortMap.equals(that.requiredProtoPortMap)) : mRequiredProtoPortMap.equals(that.mRequiredProtoPortMap))
&& maximumBssLoadValue == that.maximumBssLoadValue && mMaximumBssLoadValue == that.mMaximumBssLoadValue
&& (preferredRoamingPartnerList == null ? that.preferredRoamingPartnerList == null && (mPreferredRoamingPartnerList == null
: preferredRoamingPartnerList.equals(that.preferredRoamingPartnerList)) ? that.mPreferredRoamingPartnerList == null
&& (policyUpdate == null ? that.policyUpdate == null : mPreferredRoamingPartnerList.equals(that.mPreferredRoamingPartnerList))
: policyUpdate.equals(that.policyUpdate)); && (mPolicyUpdate == null ? that.mPolicyUpdate == null
: mPolicyUpdate.equals(that.mPolicyUpdate));
} }
/** /**
@@ -308,22 +387,22 @@ public final class Policy implements Parcelable {
* @return true on success * @return true on success
*/ */
public boolean validate() { public boolean validate() {
if (policyUpdate == null) { if (mPolicyUpdate == null) {
Log.d(TAG, "PolicyUpdate not specified"); Log.d(TAG, "PolicyUpdate not specified");
return false; return false;
} }
if (!policyUpdate.validate()) { if (!mPolicyUpdate.validate()) {
return false; return false;
} }
// Validate SSID exclusion list. // Validate SSID exclusion list.
if (excludedSsidList != null) { if (mExcludedSsidList != null) {
if (excludedSsidList.length > MAX_EXCLUSION_SSIDS) { if (mExcludedSsidList.length > MAX_EXCLUSION_SSIDS) {
Log.d(TAG, "SSID exclusion list size exceeded the max: " Log.d(TAG, "SSID exclusion list size exceeded the max: "
+ excludedSsidList.length); + mExcludedSsidList.length);
return false; return false;
} }
for (String ssid : excludedSsidList) { for (String ssid : mExcludedSsidList) {
if (ssid.getBytes(StandardCharsets.UTF_8).length > MAX_SSID_BYTES) { if (ssid.getBytes(StandardCharsets.UTF_8).length > MAX_SSID_BYTES) {
Log.d(TAG, "Invalid SSID: " + ssid); Log.d(TAG, "Invalid SSID: " + ssid);
return false; return false;
@@ -331,8 +410,8 @@ public final class Policy implements Parcelable {
} }
} }
// Validate required protocol to port map. // Validate required protocol to port map.
if (requiredProtoPortMap != null) { if (mRequiredProtoPortMap != null) {
for (Map.Entry<Integer, String> entry : requiredProtoPortMap.entrySet()) { for (Map.Entry<Integer, String> entry : mRequiredProtoPortMap.entrySet()) {
String portNumber = entry.getValue(); String portNumber = entry.getValue();
if (portNumber.getBytes(StandardCharsets.UTF_8).length > MAX_PORT_STRING_BYTES) { if (portNumber.getBytes(StandardCharsets.UTF_8).length > MAX_PORT_STRING_BYTES) {
Log.d(TAG, "PortNumber string bytes exceeded the max: " + portNumber); Log.d(TAG, "PortNumber string bytes exceeded the max: " + portNumber);
@@ -341,8 +420,8 @@ public final class Policy implements Parcelable {
} }
} }
// Validate preferred roaming partner list. // Validate preferred roaming partner list.
if (preferredRoamingPartnerList != null) { if (mPreferredRoamingPartnerList != null) {
for (RoamingPartner partner : preferredRoamingPartnerList) { for (RoamingPartner partner : mPreferredRoamingPartnerList) {
if (!partner.validate()) { if (!partner.validate()) {
return false; return false;
} }
@@ -356,15 +435,15 @@ public final class Policy implements Parcelable {
@Override @Override
public Policy createFromParcel(Parcel in) { public Policy createFromParcel(Parcel in) {
Policy policy = new Policy(); Policy policy = new Policy();
policy.minHomeDownlinkBandwidth = in.readLong(); policy.setMinHomeDownlinkBandwidth(in.readLong());
policy.minHomeUplinkBandwidth = in.readLong(); policy.setMinHomeUplinkBandwidth(in.readLong());
policy.minRoamingDownlinkBandwidth = in.readLong(); policy.setMinRoamingDownlinkBandwidth(in.readLong());
policy.minRoamingUplinkBandwidth = in.readLong(); policy.setMinRoamingUplinkBandwidth(in.readLong());
policy.excludedSsidList = in.createStringArray(); policy.setExcludedSsidList(in.createStringArray());
policy.requiredProtoPortMap = readProtoPortMap(in); policy.setRequiredProtoPortMap(readProtoPortMap(in));
policy.maximumBssLoadValue = in.readInt(); policy.setMaximumBssLoadValue(in.readInt());
policy.preferredRoamingPartnerList = readRoamingPartnerList(in); policy.setPreferredRoamingPartnerList(readRoamingPartnerList(in));
policy.policyUpdate = in.readParcelable(null); policy.setPolicyUpdate(in.readParcelable(null));
return policy; return policy;
} }

View File

@@ -88,45 +88,93 @@ public final class UpdateParameter implements Parcelable {
* *
* Using Long.MIN_VALUE to indicate unset value. * Using Long.MIN_VALUE to indicate unset value.
*/ */
public long updateIntervalInMinutes = Long.MIN_VALUE; private long mUpdateIntervalInMinutes = Long.MIN_VALUE;
public void setUpdateIntervalInMinutes(long updateIntervalInMinutes) {
mUpdateIntervalInMinutes = updateIntervalInMinutes;
}
public long getUpdateIntervalInMinutes() {
return mUpdateIntervalInMinutes;
}
/** /**
* The method used to update the policy. Permitted values are "OMA-DM-ClientInitiated" * The method used to update the policy. Permitted values are "OMA-DM-ClientInitiated"
* and "SPP-ClientInitiated". * and "SPP-ClientInitiated".
*/ */
public String updateMethod = null; private String mUpdateMethod = null;
public void setUpdateMethod(String updateMethod) {
mUpdateMethod = updateMethod;
}
public String getUpdateMethod() {
return mUpdateMethod;
}
/** /**
* This specifies the hotspots at which the subscription update is permitted. Permitted * This specifies the hotspots at which the subscription update is permitted. Permitted
* values are "HomeSP", "RoamingPartner", or "Unrestricted"; * values are "HomeSP", "RoamingPartner", or "Unrestricted";
*/ */
public String restriction = null; private String mRestriction = null;
public void setRestriction(String restriction) {
mRestriction = restriction;
}
public String getRestriction() {
return mRestriction;
}
/** /**
* The URI of the update server. * The URI of the update server.
*/ */
public String serverUri = null; private String mServerUri = null;
public void setServerUri(String serverUri) {
mServerUri = serverUri;
}
public String getServerUri() {
return mServerUri;
}
/** /**
* Username used to authenticate with the policy server. * Username used to authenticate with the policy server.
*/ */
public String username = null; private String mUsername = null;
public void setUsername(String username) {
mUsername = username;
}
public String getUsername() {
return mUsername;
}
/** /**
* Base64 encoded password used to authenticate with the policy server. * Base64 encoded password used to authenticate with the policy server.
*/ */
public String base64EncodedPassword = null; private String mBase64EncodedPassword = null;
public void setBase64EncodedPassword(String password) {
mBase64EncodedPassword = password;
}
public String getBase64EncodedPassword() {
return mBase64EncodedPassword;
}
/** /**
* HTTPS URL for retrieving certificate for trust root. The trust root is used to validate * HTTPS URL for retrieving certificate for trust root. The trust root is used to validate
* policy server's identity. * policy server's identity.
*/ */
public String trustRootCertUrl = null; private String mTrustRootCertUrl = null;
public void setTrustRootCertUrl(String trustRootCertUrl) {
mTrustRootCertUrl = trustRootCertUrl;
}
public String getTrustRootCertUrl() {
return mTrustRootCertUrl;
}
/** /**
* SHA-256 fingerprint of the certificate located at {@link #trustRootCertUrl} * SHA-256 fingerprint of the certificate located at {@link #trustRootCertUrl}
*/ */
public byte[] trustRootCertSha256Fingerprint = null; private byte[] mTrustRootCertSha256Fingerprint = null;
public void setTrustRootCertSha256Fingerprint(byte[] fingerprint) {
mTrustRootCertSha256Fingerprint = fingerprint;
}
public byte[] getTrustRootCertSha256Fingerprint() {
return mTrustRootCertSha256Fingerprint;
}
/** /**
* Constructor for creating Policy with default values. * Constructor for creating Policy with default values.
@@ -142,16 +190,16 @@ public final class UpdateParameter implements Parcelable {
if (source == null) { if (source == null) {
return; return;
} }
updateIntervalInMinutes = source.updateIntervalInMinutes; mUpdateIntervalInMinutes = source.mUpdateIntervalInMinutes;
updateMethod = source.updateMethod; mUpdateMethod = source.mUpdateMethod;
restriction = source.restriction; mRestriction = source.mRestriction;
serverUri = source.serverUri; mServerUri = source.mServerUri;
username = source.username; mUsername = source.mUsername;
base64EncodedPassword = source.base64EncodedPassword; mBase64EncodedPassword = source.mBase64EncodedPassword;
trustRootCertUrl = source.trustRootCertUrl; mTrustRootCertUrl = source.mTrustRootCertUrl;
if (source.trustRootCertSha256Fingerprint != null) { if (source.mTrustRootCertSha256Fingerprint != null) {
trustRootCertSha256Fingerprint = Arrays.copyOf(source.trustRootCertSha256Fingerprint, mTrustRootCertSha256Fingerprint = Arrays.copyOf(source.mTrustRootCertSha256Fingerprint,
source.trustRootCertSha256Fingerprint.length); source.mTrustRootCertSha256Fingerprint.length);
} }
} }
@@ -162,14 +210,14 @@ public final class UpdateParameter implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(updateIntervalInMinutes); dest.writeLong(mUpdateIntervalInMinutes);
dest.writeString(updateMethod); dest.writeString(mUpdateMethod);
dest.writeString(restriction); dest.writeString(mRestriction);
dest.writeString(serverUri); dest.writeString(mServerUri);
dest.writeString(username); dest.writeString(mUsername);
dest.writeString(base64EncodedPassword); dest.writeString(mBase64EncodedPassword);
dest.writeString(trustRootCertUrl); dest.writeString(mTrustRootCertUrl);
dest.writeByteArray(trustRootCertSha256Fingerprint); dest.writeByteArray(mTrustRootCertSha256Fingerprint);
} }
@Override @Override
@@ -182,15 +230,15 @@ public final class UpdateParameter implements Parcelable {
} }
UpdateParameter that = (UpdateParameter) thatObject; UpdateParameter that = (UpdateParameter) thatObject;
return updateIntervalInMinutes == that.updateIntervalInMinutes return mUpdateIntervalInMinutes == that.mUpdateIntervalInMinutes
&& TextUtils.equals(updateMethod, that.updateMethod) && TextUtils.equals(mUpdateMethod, that.mUpdateMethod)
&& TextUtils.equals(restriction, that.restriction) && TextUtils.equals(mRestriction, that.mRestriction)
&& TextUtils.equals(serverUri, that.serverUri) && TextUtils.equals(mServerUri, that.mServerUri)
&& TextUtils.equals(username, that.username) && TextUtils.equals(mUsername, that.mUsername)
&& TextUtils.equals(base64EncodedPassword, that.base64EncodedPassword) && TextUtils.equals(mBase64EncodedPassword, that.mBase64EncodedPassword)
&& TextUtils.equals(trustRootCertUrl, that.trustRootCertUrl) && TextUtils.equals(mTrustRootCertUrl, that.mTrustRootCertUrl)
&& Arrays.equals(trustRootCertSha256Fingerprint, && Arrays.equals(mTrustRootCertSha256Fingerprint,
that.trustRootCertSha256Fingerprint); that.mTrustRootCertSha256Fingerprint);
} }
/** /**
@@ -199,81 +247,81 @@ public final class UpdateParameter implements Parcelable {
* @return true on success * @return true on success
*/ */
public boolean validate() { public boolean validate() {
if (updateIntervalInMinutes == Long.MIN_VALUE) { if (mUpdateIntervalInMinutes == Long.MIN_VALUE) {
Log.d(TAG, "Update interval not specified"); Log.d(TAG, "Update interval not specified");
return false; return false;
} }
// Update not applicable. // Update not applicable.
if (updateIntervalInMinutes == UPDATE_CHECK_INTERVAL_NEVER) { if (mUpdateIntervalInMinutes == UPDATE_CHECK_INTERVAL_NEVER) {
return true; return true;
} }
if (!TextUtils.equals(updateMethod, UPDATE_METHOD_OMADM) if (!TextUtils.equals(mUpdateMethod, UPDATE_METHOD_OMADM)
&& !TextUtils.equals(updateMethod, UPDATE_METHOD_SSP)) { && !TextUtils.equals(mUpdateMethod, UPDATE_METHOD_SSP)) {
Log.d(TAG, "Unknown update method: " + updateMethod); Log.d(TAG, "Unknown update method: " + mUpdateMethod);
return false; return false;
} }
if (!TextUtils.equals(restriction, UPDATE_RESTRICTION_HOMESP) if (!TextUtils.equals(mRestriction, UPDATE_RESTRICTION_HOMESP)
&& !TextUtils.equals(restriction, UPDATE_RESTRICTION_ROAMING_PARTNER) && !TextUtils.equals(mRestriction, UPDATE_RESTRICTION_ROAMING_PARTNER)
&& !TextUtils.equals(restriction, UPDATE_RESTRICTION_UNRESTRICTED)) { && !TextUtils.equals(mRestriction, UPDATE_RESTRICTION_UNRESTRICTED)) {
Log.d(TAG, "Unknown restriction: " + restriction); Log.d(TAG, "Unknown restriction: " + mRestriction);
return false; return false;
} }
if (TextUtils.isEmpty(serverUri)) { if (TextUtils.isEmpty(mServerUri)) {
Log.d(TAG, "Missing update server URI"); Log.d(TAG, "Missing update server URI");
return false; return false;
} }
if (serverUri.getBytes(StandardCharsets.UTF_8).length > MAX_URI_BYTES) { if (mServerUri.getBytes(StandardCharsets.UTF_8).length > MAX_URI_BYTES) {
Log.d(TAG, "URI bytes exceeded the max: " Log.d(TAG, "URI bytes exceeded the max: "
+ serverUri.getBytes(StandardCharsets.UTF_8).length); + mServerUri.getBytes(StandardCharsets.UTF_8).length);
return false; return false;
} }
if (TextUtils.isEmpty(username)) { if (TextUtils.isEmpty(mUsername)) {
Log.d(TAG, "Missing username"); Log.d(TAG, "Missing username");
return false; return false;
} }
if (username.getBytes(StandardCharsets.UTF_8).length > MAX_USERNAME_BYTES) { if (mUsername.getBytes(StandardCharsets.UTF_8).length > MAX_USERNAME_BYTES) {
Log.d(TAG, "Username bytes exceeded the max: " Log.d(TAG, "Username bytes exceeded the max: "
+ username.getBytes(StandardCharsets.UTF_8).length); + mUsername.getBytes(StandardCharsets.UTF_8).length);
return false; return false;
} }
if (TextUtils.isEmpty(base64EncodedPassword)) { if (TextUtils.isEmpty(mBase64EncodedPassword)) {
Log.d(TAG, "Missing username"); Log.d(TAG, "Missing username");
return false; return false;
} }
if (base64EncodedPassword.getBytes(StandardCharsets.UTF_8).length > MAX_PASSWORD_BYTES) { if (mBase64EncodedPassword.getBytes(StandardCharsets.UTF_8).length > MAX_PASSWORD_BYTES) {
Log.d(TAG, "Password bytes exceeded the max: " Log.d(TAG, "Password bytes exceeded the max: "
+ base64EncodedPassword.getBytes(StandardCharsets.UTF_8).length); + mBase64EncodedPassword.getBytes(StandardCharsets.UTF_8).length);
return false; return false;
} }
try { try {
Base64.decode(base64EncodedPassword, Base64.DEFAULT); Base64.decode(mBase64EncodedPassword, Base64.DEFAULT);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.d(TAG, "Invalid encoding for password: " + base64EncodedPassword); Log.d(TAG, "Invalid encoding for password: " + mBase64EncodedPassword);
return false; return false;
} }
if (TextUtils.isEmpty(trustRootCertUrl)) { if (TextUtils.isEmpty(mTrustRootCertUrl)) {
Log.d(TAG, "Missing trust root certificate URL"); Log.d(TAG, "Missing trust root certificate URL");
return false; return false;
} }
if (trustRootCertUrl.getBytes(StandardCharsets.UTF_8).length > MAX_URL_BYTES) { if (mTrustRootCertUrl.getBytes(StandardCharsets.UTF_8).length > MAX_URL_BYTES) {
Log.d(TAG, "Trust root cert URL bytes exceeded the max: " Log.d(TAG, "Trust root cert URL bytes exceeded the max: "
+ trustRootCertUrl.getBytes(StandardCharsets.UTF_8).length); + mTrustRootCertUrl.getBytes(StandardCharsets.UTF_8).length);
return false; return false;
} }
if (trustRootCertSha256Fingerprint == null) { if (mTrustRootCertSha256Fingerprint == null) {
Log.d(TAG, "Missing trust root certificate SHA-256 fingerprint"); Log.d(TAG, "Missing trust root certificate SHA-256 fingerprint");
return false; return false;
} }
if (trustRootCertSha256Fingerprint.length != CERTIFICATE_SHA256_BYTES) { if (mTrustRootCertSha256Fingerprint.length != CERTIFICATE_SHA256_BYTES) {
Log.d(TAG, "Incorrect size of trust root certificate SHA-256 fingerprint: " Log.d(TAG, "Incorrect size of trust root certificate SHA-256 fingerprint: "
+ trustRootCertSha256Fingerprint.length); + mTrustRootCertSha256Fingerprint.length);
return false; return false;
} }
return true; return true;
@@ -284,14 +332,14 @@ public final class UpdateParameter implements Parcelable {
@Override @Override
public UpdateParameter createFromParcel(Parcel in) { public UpdateParameter createFromParcel(Parcel in) {
UpdateParameter updateParam = new UpdateParameter(); UpdateParameter updateParam = new UpdateParameter();
updateParam.updateIntervalInMinutes = in.readLong(); updateParam.setUpdateIntervalInMinutes(in.readLong());
updateParam.updateMethod = in.readString(); updateParam.setUpdateMethod(in.readString());
updateParam.restriction = in.readString(); updateParam.setRestriction(in.readString());
updateParam.serverUri = in.readString(); updateParam.setServerUri(in.readString());
updateParam.username = in.readString(); updateParam.setUsername(in.readString());
updateParam.base64EncodedPassword = in.readString(); updateParam.setBase64EncodedPassword(in.readString());
updateParam.trustRootCertUrl = in.readString(); updateParam.setTrustRootCertUrl(in.readString());
updateParam.trustRootCertSha256Fingerprint = in.createByteArray(); updateParam.setTrustRootCertSha256Fingerprint(in.createByteArray());
return updateParam; return updateParam;
} }

View File

@@ -83,27 +83,33 @@ public class ConfigBuilderTest {
PasspointConfiguration config = new PasspointConfiguration(); PasspointConfiguration config = new PasspointConfiguration();
// HomeSP configuration. // HomeSP configuration.
config.homeSp = new HomeSP(); HomeSP homeSp = new HomeSP();
config.homeSp.friendlyName = "Century House"; homeSp.setFriendlyName("Century House");
config.homeSp.fqdn = "mi6.co.uk"; homeSp.setFqdn("mi6.co.uk");
config.homeSp.roamingConsortiumOIs = new long[] {0x112233L, 0x445566L}; homeSp.setRoamingConsortiumOIs(new long[] {0x112233L, 0x445566L});
config.setHomeSp(homeSp);
// Credential configuration. // Credential configuration.
config.credential = new Credential(); Credential credential = new Credential();
config.credential.realm = "shaken.stirred.com"; credential.setRealm("shaken.stirred.com");
config.credential.userCredential = new Credential.UserCredential(); Credential.UserCredential userCredential = new Credential.UserCredential();
config.credential.userCredential.username = "james"; userCredential.setUsername("james");
config.credential.userCredential.password = "Ym9uZDAwNw=="; userCredential.setPassword("Ym9uZDAwNw==");
config.credential.userCredential.eapType = 21; userCredential.setEapType(21);
config.credential.userCredential.nonEapInnerMethod = "MS-CHAP-V2"; userCredential.setNonEapInnerMethod("MS-CHAP-V2");
config.credential.certCredential = new Credential.CertificateCredential(); credential.setUserCredential(userCredential);
config.credential.certCredential.certType = "x509v3"; Credential.CertificateCredential certCredential = new Credential.CertificateCredential();
config.credential.certCredential.certSha256FingerPrint = new byte[32]; certCredential.setCertType("x509v3");
Arrays.fill(config.credential.certCredential.certSha256FingerPrint, (byte)0x1f); byte[] certSha256Fingerprint = new byte[32];
config.credential.simCredential = new Credential.SimCredential(); Arrays.fill(certSha256Fingerprint, (byte)0x1f);
config.credential.simCredential.imsi = "imsi"; certCredential.setCertSha256Fingerprint(certSha256Fingerprint);
config.credential.simCredential.eapType = 24; credential.setCertCredential(certCredential);
config.credential.caCertificate = FakeKeys.CA_CERT0; 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; return config;
} }

View File

@@ -34,6 +34,8 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* Unit tests for {@link android.net.wifi.hotspot2.PasspointConfiguration}. * Unit tests for {@link android.net.wifi.hotspot2.PasspointConfiguration}.
@@ -50,9 +52,9 @@ public class PasspointConfigurationTest {
*/ */
private static HomeSP createHomeSp() { private static HomeSP createHomeSp() {
HomeSP homeSp = new HomeSP(); HomeSP homeSp = new HomeSP();
homeSp.fqdn = "fqdn"; homeSp.setFqdn("fqdn");
homeSp.friendlyName = "friendly name"; homeSp.setFriendlyName("friendly name");
homeSp.roamingConsortiumOIs = new long[] {0x55, 0x66}; homeSp.setRoamingConsortiumOIs(new long[] {0x55, 0x66});
return homeSp; return homeSp;
} }
@@ -63,15 +65,15 @@ public class PasspointConfigurationTest {
*/ */
private static Credential createCredential() { private static Credential createCredential() {
Credential cred = new Credential(); Credential cred = new Credential();
cred.realm = "realm"; cred.setRealm("realm");
cred.userCredential = null; cred.setUserCredential(null);
cred.certCredential = null; cred.setCertCredential(null);
cred.simCredential = new Credential.SimCredential(); cred.setSimCredential(new Credential.SimCredential());
cred.simCredential.imsi = "1234*"; cred.getSimCredential().setImsi("1234*");
cred.simCredential.eapType = EAPConstants.EAP_SIM; cred.getSimCredential().setEapType(EAPConstants.EAP_SIM);
cred.caCertificate = null; cred.setCaCertificate(null);
cred.clientCertificateChain = null; cred.setClientCertificateChain(null);
cred.clientPrivateKey = null; cred.setClientPrivateKey(null);
return cred; return cred;
} }
@@ -82,56 +84,59 @@ public class PasspointConfigurationTest {
*/ */
private static Policy createPolicy() { private static Policy createPolicy() {
Policy policy = new Policy(); Policy policy = new Policy();
policy.minHomeDownlinkBandwidth = 123; policy.setMinHomeDownlinkBandwidth(123);
policy.minHomeUplinkBandwidth = 345; policy.setMinHomeUplinkBandwidth(345);
policy.minRoamingDownlinkBandwidth = 567; policy.setMinRoamingDownlinkBandwidth(567);
policy.minRoamingUplinkBandwidth = 789; policy.setMinRoamingUplinkBandwidth(789);
policy.maximumBssLoadValue = 12; policy.setMaximumBssLoadValue(12);
policy.excludedSsidList = new String[] {"ssid1", "ssid2"}; policy.setExcludedSsidList(new String[] {"ssid1", "ssid2"});
policy.requiredProtoPortMap = new HashMap<>(); HashMap<Integer, String> requiredProtoPortMap = new HashMap<>();
policy.requiredProtoPortMap.put(12, "23,342,123"); requiredProtoPortMap.put(12, "23,342,123");
policy.requiredProtoPortMap.put(23, "789,372,1235"); requiredProtoPortMap.put(23, "789,372,1235");
policy.setRequiredProtoPortMap(requiredProtoPortMap);
policy.preferredRoamingPartnerList = new ArrayList<>(); List<Policy.RoamingPartner> preferredRoamingPartnerList = new ArrayList<>();
Policy.RoamingPartner partner1 = new Policy.RoamingPartner(); Policy.RoamingPartner partner1 = new Policy.RoamingPartner();
partner1.fqdn = "partner1.com"; partner1.setFqdn("partner1.com");
partner1.fqdnExactMatch = true; partner1.setFqdnExactMatch(true);
partner1.priority = 12; partner1.setPriority(12);
partner1.countries = "us,jp"; partner1.setCountries("us,jp");
Policy.RoamingPartner partner2 = new Policy.RoamingPartner(); Policy.RoamingPartner partner2 = new Policy.RoamingPartner();
partner2.fqdn = "partner2.com"; partner2.setFqdn("partner2.com");
partner2.fqdnExactMatch = false; partner2.setFqdnExactMatch(false);
partner2.priority = 42; partner2.setPriority(42);
partner2.countries = "ca,fr"; partner2.setCountries("ca,fr");
policy.preferredRoamingPartnerList.add(partner1); preferredRoamingPartnerList.add(partner1);
policy.preferredRoamingPartnerList.add(partner2); preferredRoamingPartnerList.add(partner2);
policy.setPreferredRoamingPartnerList(preferredRoamingPartnerList);
policy.policyUpdate = new UpdateParameter(); UpdateParameter policyUpdate = new UpdateParameter();
policy.policyUpdate.updateIntervalInMinutes = 1712; policyUpdate.setUpdateIntervalInMinutes(1712);
policy.policyUpdate.updateMethod = UpdateParameter.UPDATE_METHOD_OMADM; policyUpdate.setUpdateMethod(UpdateParameter.UPDATE_METHOD_OMADM);
policy.policyUpdate.restriction = UpdateParameter.UPDATE_RESTRICTION_HOMESP; policyUpdate.setRestriction(UpdateParameter.UPDATE_RESTRICTION_HOMESP);
policy.policyUpdate.serverUri = "policy.update.com"; policyUpdate.setServerUri("policy.update.com");
policy.policyUpdate.username = "username"; policyUpdate.setUsername("username");
policy.policyUpdate.base64EncodedPassword = policyUpdate.setBase64EncodedPassword(
Base64.encodeToString("password".getBytes(), Base64.DEFAULT); Base64.encodeToString("password".getBytes(), Base64.DEFAULT));
policy.policyUpdate.trustRootCertUrl = "trust.cert.com"; policyUpdate.setTrustRootCertUrl("trust.cert.com");
policy.policyUpdate.trustRootCertSha256Fingerprint = policyUpdate.setTrustRootCertSha256Fingerprint(
new byte[CERTIFICATE_FINGERPRINT_BYTES]; new byte[CERTIFICATE_FINGERPRINT_BYTES]);
policy.setPolicyUpdate(policyUpdate);
return policy; return policy;
} }
private static UpdateParameter createSubscriptionUpdate() { private static UpdateParameter createSubscriptionUpdate() {
UpdateParameter subUpdate = new UpdateParameter(); UpdateParameter subUpdate = new UpdateParameter();
subUpdate.updateIntervalInMinutes = 9021; subUpdate.setUpdateIntervalInMinutes(9021);
subUpdate.updateMethod = UpdateParameter.UPDATE_METHOD_SSP; subUpdate.setUpdateMethod(UpdateParameter.UPDATE_METHOD_SSP);
subUpdate.restriction = UpdateParameter.UPDATE_RESTRICTION_ROAMING_PARTNER; subUpdate.setRestriction(UpdateParameter.UPDATE_RESTRICTION_ROAMING_PARTNER);
subUpdate.serverUri = "subscription.update.com"; subUpdate.setServerUri("subscription.update.com");
subUpdate.username = "subUsername"; subUpdate.setUsername("subUsername");
subUpdate.base64EncodedPassword = subUpdate.setBase64EncodedPassword(
Base64.encodeToString("subPassword".getBytes(), Base64.DEFAULT); Base64.encodeToString("subPassword".getBytes(), Base64.DEFAULT));
subUpdate.trustRootCertUrl = "subscription.trust.cert.com"; subUpdate.setTrustRootCertUrl("subscription.trust.cert.com");
subUpdate.trustRootCertSha256Fingerprint = new byte[CERTIFICATE_FINGERPRINT_BYTES]; subUpdate.setTrustRootCertSha256Fingerprint(new byte[CERTIFICATE_FINGERPRINT_BYTES]);
return subUpdate; return subUpdate;
} }
/** /**
@@ -141,24 +146,25 @@ public class PasspointConfigurationTest {
*/ */
private static PasspointConfiguration createConfig() { private static PasspointConfiguration createConfig() {
PasspointConfiguration config = new PasspointConfiguration(); PasspointConfiguration config = new PasspointConfiguration();
config.homeSp = createHomeSp(); config.setHomeSp(createHomeSp());
config.credential = createCredential(); config.setCredential(createCredential());
config.policy = createPolicy(); config.setPolicy(createPolicy());
config.subscriptionUpdate = createSubscriptionUpdate(); config.setSubscriptionUpdate(createSubscriptionUpdate());
config.trustRootCertList = new HashMap<>(); Map<String, byte[]> trustRootCertList = new HashMap<>();
config.trustRootCertList.put("trustRoot.cert1.com", trustRootCertList.put("trustRoot.cert1.com",
new byte[CERTIFICATE_FINGERPRINT_BYTES]); new byte[CERTIFICATE_FINGERPRINT_BYTES]);
config.trustRootCertList.put("trustRoot.cert2.com", trustRootCertList.put("trustRoot.cert2.com",
new byte[CERTIFICATE_FINGERPRINT_BYTES]); new byte[CERTIFICATE_FINGERPRINT_BYTES]);
config.updateIdentifier = 1; config.setTrustRootCertList(trustRootCertList);
config.credentialPriority = 120; config.setUpdateIdentifier(1);
config.subscriptionCreationTimeInMs = 231200; config.setCredentialPriority(120);
config.subscriptionExpirationTimeInMs = 2134232; config.setSubscriptionCreationTimeInMs(231200);
config.subscriptionType = "Gold"; config.setSubscriptionExpirationTimeInMs(2134232);
config.usageLimitUsageTimePeriodInMinutes = 3600; config.setSubscriptionType("Gold");
config.usageLimitStartTimeInMs = 124214213; config.setUsageLimitUsageTimePeriodInMinutes(3600);
config.usageLimitDataLimit = 14121; config.setUsageLimitStartTimeInMs(124214213);
config.usageLimitTimeLimitInMinutes = 78912; config.setUsageLimitDataLimit(14121);
config.setUsageLimitTimeLimitInMinutes(78912);
return config; return config;
} }
@@ -206,7 +212,7 @@ public class PasspointConfigurationTest {
@Test @Test
public void verifyParcelWithoutHomeSP() throws Exception { public void verifyParcelWithoutHomeSP() throws Exception {
PasspointConfiguration config = createConfig(); PasspointConfiguration config = createConfig();
config.homeSp = null; config.setHomeSp(null);
verifyParcel(config); verifyParcel(config);
} }
@@ -218,7 +224,7 @@ public class PasspointConfigurationTest {
@Test @Test
public void verifyParcelWithoutCredential() throws Exception { public void verifyParcelWithoutCredential() throws Exception {
PasspointConfiguration config = createConfig(); PasspointConfiguration config = createConfig();
config.credential = null; config.setCredential(null);
verifyParcel(config); verifyParcel(config);
} }
@@ -230,7 +236,7 @@ public class PasspointConfigurationTest {
@Test @Test
public void verifyParcelWithoutPolicy() throws Exception { public void verifyParcelWithoutPolicy() throws Exception {
PasspointConfiguration config = createConfig(); PasspointConfiguration config = createConfig();
config.policy = null; config.setPolicy(null);
verifyParcel(config); verifyParcel(config);
} }
@@ -242,7 +248,7 @@ public class PasspointConfigurationTest {
@Test @Test
public void verifyParcelWithoutSubscriptionUpdate() throws Exception { public void verifyParcelWithoutSubscriptionUpdate() throws Exception {
PasspointConfiguration config = createConfig(); PasspointConfiguration config = createConfig();
config.subscriptionUpdate = null; config.setSubscriptionUpdate(null);
verifyParcel(config); verifyParcel(config);
} }
@@ -255,7 +261,7 @@ public class PasspointConfigurationTest {
@Test @Test
public void verifyParcelWithoutTrustRootCertList() throws Exception { public void verifyParcelWithoutTrustRootCertList() throws Exception {
PasspointConfiguration config = createConfig(); PasspointConfiguration config = createConfig();
config.trustRootCertList = null; config.setTrustRootCertList(null);
verifyParcel(config); verifyParcel(config);
} }
@@ -289,7 +295,7 @@ public class PasspointConfigurationTest {
@Test @Test
public void validateConfigWithoutCredential() throws Exception { public void validateConfigWithoutCredential() throws Exception {
PasspointConfiguration config = createConfig(); PasspointConfiguration config = createConfig();
config.credential = null; config.setCredential(null);
assertFalse(config.validate()); assertFalse(config.validate());
} }
@@ -301,7 +307,7 @@ public class PasspointConfigurationTest {
@Test @Test
public void validateConfigWithoutHomeSp() throws Exception { public void validateConfigWithoutHomeSp() throws Exception {
PasspointConfiguration config = createConfig(); PasspointConfiguration config = createConfig();
config.homeSp = null; config.setHomeSp(null);
assertFalse(config.validate()); assertFalse(config.validate());
} }
@@ -314,7 +320,7 @@ public class PasspointConfigurationTest {
@Test @Test
public void validateConfigWithoutPolicy() throws Exception { public void validateConfigWithoutPolicy() throws Exception {
PasspointConfiguration config = createConfig(); PasspointConfiguration config = createConfig();
config.policy = null; config.setPolicy(null);
assertTrue(config.validate()); assertTrue(config.validate());
} }
@@ -327,7 +333,7 @@ public class PasspointConfigurationTest {
@Test @Test
public void validateConfigWithoutSubscriptionUpdate() throws Exception { public void validateConfigWithoutSubscriptionUpdate() throws Exception {
PasspointConfiguration config = createConfig(); PasspointConfiguration config = createConfig();
config.subscriptionUpdate = null; config.setSubscriptionUpdate(null);
assertTrue(config.validate()); assertTrue(config.validate());
} }
@@ -341,13 +347,16 @@ public class PasspointConfigurationTest {
public void validateConfigWithInvalidTrustRootCertUrl() throws Exception { public void validateConfigWithInvalidTrustRootCertUrl() throws Exception {
PasspointConfiguration config = createConfig(); PasspointConfiguration config = createConfig();
byte[] rawUrlBytes = new byte[MAX_URL_BYTES + 1]; byte[] rawUrlBytes = new byte[MAX_URL_BYTES + 1];
Map<String, byte[]> trustRootCertList = new HashMap<>();
Arrays.fill(rawUrlBytes, (byte) 'a'); Arrays.fill(rawUrlBytes, (byte) 'a');
config.trustRootCertList.put(new String(rawUrlBytes, StandardCharsets.UTF_8), trustRootCertList.put(new String(rawUrlBytes, StandardCharsets.UTF_8),
new byte[CERTIFICATE_FINGERPRINT_BYTES]); new byte[CERTIFICATE_FINGERPRINT_BYTES]);
config.setTrustRootCertList(trustRootCertList);
assertFalse(config.validate()); assertFalse(config.validate());
config.trustRootCertList = new HashMap<>(); trustRootCertList = new HashMap<>();
config.trustRootCertList.put(null, new byte[CERTIFICATE_FINGERPRINT_BYTES]); trustRootCertList.put(null, new byte[CERTIFICATE_FINGERPRINT_BYTES]);
config.setTrustRootCertList(trustRootCertList);
assertFalse(config.validate()); assertFalse(config.validate());
} }
@@ -359,16 +368,19 @@ public class PasspointConfigurationTest {
@Test @Test
public void validateConfigWithInvalidTrustRootCertFingerprint() throws Exception { public void validateConfigWithInvalidTrustRootCertFingerprint() throws Exception {
PasspointConfiguration config = createConfig(); PasspointConfiguration config = createConfig();
config.trustRootCertList = new HashMap<>(); Map<String, byte[]> trustRootCertList = new HashMap<>();
config.trustRootCertList.put("test.cert.com", new byte[CERTIFICATE_FINGERPRINT_BYTES + 1]); trustRootCertList.put("test.cert.com", new byte[CERTIFICATE_FINGERPRINT_BYTES + 1]);
config.setTrustRootCertList(trustRootCertList);
assertFalse(config.validate()); assertFalse(config.validate());
config.trustRootCertList = new HashMap<>(); trustRootCertList = new HashMap<>();
config.trustRootCertList.put("test.cert.com", new byte[CERTIFICATE_FINGERPRINT_BYTES - 1]); trustRootCertList.put("test.cert.com", new byte[CERTIFICATE_FINGERPRINT_BYTES - 1]);
config.setTrustRootCertList(trustRootCertList);
assertFalse(config.validate()); assertFalse(config.validate());
config.trustRootCertList = new HashMap<>(); trustRootCertList = new HashMap<>();
config.trustRootCertList.put("test.cert.com", null); trustRootCertList.put("test.cert.com", null);
config.setTrustRootCertList(trustRootCertList);
assertFalse(config.validate()); assertFalse(config.validate());
} }

View File

@@ -39,6 +39,8 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* Unit tests for {@link android.net.wifi.hotspot2.omadm.PPSMOParser}. * Unit tests for {@link android.net.wifi.hotspot2.omadm.PPSMOParser}.
@@ -86,107 +88,115 @@ public class PPSMOParserTest {
*/ */
private PasspointConfiguration generateConfigurationFromPPSMOTree() throws Exception { private PasspointConfiguration generateConfigurationFromPPSMOTree() throws Exception {
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
PasspointConfiguration config = new PasspointConfiguration();
config.updateIdentifier = 12;
config.credentialPriority = 99;
// AAA Server trust root.
config.trustRootCertList = new HashMap<>();
byte[] certFingerprint = new byte[32]; byte[] certFingerprint = new byte[32];
Arrays.fill(certFingerprint, (byte) 0x1f); Arrays.fill(certFingerprint, (byte) 0x1f);
config.trustRootCertList.put("server1.trust.root.com", certFingerprint);
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. // Subscription update.
config.subscriptionUpdate = new UpdateParameter(); UpdateParameter subscriptionUpdate = new UpdateParameter();
config.subscriptionUpdate.updateIntervalInMinutes = 120; subscriptionUpdate.setUpdateIntervalInMinutes(120);
config.subscriptionUpdate.updateMethod = UpdateParameter.UPDATE_METHOD_SSP; subscriptionUpdate.setUpdateMethod(UpdateParameter.UPDATE_METHOD_SSP);
config.subscriptionUpdate.restriction = UpdateParameter.UPDATE_RESTRICTION_ROAMING_PARTNER; subscriptionUpdate.setRestriction(UpdateParameter.UPDATE_RESTRICTION_ROAMING_PARTNER);
config.subscriptionUpdate.serverUri = "subscription.update.com"; subscriptionUpdate.setServerUri("subscription.update.com");
config.subscriptionUpdate.username = "subscriptionUser"; subscriptionUpdate.setUsername("subscriptionUser");
config.subscriptionUpdate.base64EncodedPassword = "subscriptionPass"; subscriptionUpdate.setBase64EncodedPassword("subscriptionPass");
config.subscriptionUpdate.trustRootCertUrl = "subscription.update.cert.com"; subscriptionUpdate.setTrustRootCertUrl("subscription.update.cert.com");
config.subscriptionUpdate.trustRootCertSha256Fingerprint = new byte[32]; subscriptionUpdate.setTrustRootCertSha256Fingerprint(certFingerprint);
Arrays.fill(config.subscriptionUpdate.trustRootCertSha256Fingerprint, (byte) 0x1f); config.setSubscriptionUpdate(subscriptionUpdate);
// Subscription parameters. // Subscription parameters.
config.subscriptionCreationTimeInMs = format.parse("2016-02-01T10:00:00Z").getTime(); config.setSubscriptionCreationTimeInMs(format.parse("2016-02-01T10:00:00Z").getTime());
config.subscriptionExpirationTimeInMs = format.parse("2016-03-01T10:00:00Z").getTime(); config.setSubscriptionExpirationTimeInMs(format.parse("2016-03-01T10:00:00Z").getTime());
config.subscriptionType = "Gold"; config.setSubscriptionType("Gold");
config.usageLimitDataLimit = 921890; config.setUsageLimitDataLimit(921890);
config.usageLimitStartTimeInMs = format.parse("2016-12-01T10:00:00Z").getTime(); config.setUsageLimitStartTimeInMs(format.parse("2016-12-01T10:00:00Z").getTime());
config.usageLimitTimeLimitInMinutes = 120; config.setUsageLimitTimeLimitInMinutes(120);
config.usageLimitUsageTimePeriodInMinutes = 99910; config.setUsageLimitUsageTimePeriodInMinutes(99910);
// HomeSP configuration. // HomeSP configuration.
config.homeSp = new HomeSP(); HomeSP homeSp = new HomeSP();
config.homeSp.friendlyName = "Century House"; homeSp.setFriendlyName("Century House");
config.homeSp.fqdn = "mi6.co.uk"; homeSp.setFqdn("mi6.co.uk");
config.homeSp.roamingConsortiumOIs = new long[] {0x112233L, 0x445566L}; homeSp.setRoamingConsortiumOIs(new long[] {0x112233L, 0x445566L});
config.homeSp.iconUrl = "icon.test.com"; homeSp.setIconUrl("icon.test.com");
config.homeSp.homeNetworkIds = new HashMap<>(); Map<String, Long> homeNetworkIds = new HashMap<>();
config.homeSp.homeNetworkIds.put("TestSSID", 0x12345678L); homeNetworkIds.put("TestSSID", 0x12345678L);
config.homeSp.homeNetworkIds.put("NullHESSID", null); homeNetworkIds.put("NullHESSID", null);
config.homeSp.matchAllOIs = new long[] {0x11223344}; homeSp.setHomeNetworkIds(homeNetworkIds);
config.homeSp.matchAnyOIs = new long[] {0x55667788}; homeSp.setMatchAllOIs(new long[] {0x11223344});
config.homeSp.otherHomePartners = new String[] {"other.fqdn.com"}; homeSp.setMatchAnyOIs(new long[] {0x55667788});
homeSp.setOtherHomePartners(new String[] {"other.fqdn.com"});
config.setHomeSp(homeSp);
// Credential configuration. // Credential configuration.
config.credential = new Credential(); Credential credential = new Credential();
config.credential.creationTimeInMs = format.parse("2016-01-01T10:00:00Z").getTime(); credential.setCreationTimeInMs(format.parse("2016-01-01T10:00:00Z").getTime());
config.credential.expirationTimeInMs = format.parse("2016-02-01T10:00:00Z").getTime(); credential.setExpirationTimeInMs(format.parse("2016-02-01T10:00:00Z").getTime());
config.credential.realm = "shaken.stirred.com"; credential.setRealm("shaken.stirred.com");
config.credential.checkAAAServerCertStatus = true; credential.setCheckAAAServerCertStatus(true);
config.credential.userCredential = new Credential.UserCredential(); Credential.UserCredential userCredential = new Credential.UserCredential();
config.credential.userCredential.username = "james"; userCredential.setUsername("james");
config.credential.userCredential.password = "Ym9uZDAwNw=="; userCredential.setPassword("Ym9uZDAwNw==");
config.credential.userCredential.machineManaged = true; userCredential.setMachineManaged(true);
config.credential.userCredential.softTokenApp = "TestApp"; userCredential.setSoftTokenApp("TestApp");
config.credential.userCredential.ableToShare = true; userCredential.setAbleToShare(true);
config.credential.userCredential.eapType = 21; userCredential.setEapType(21);
config.credential.userCredential.nonEapInnerMethod = "MS-CHAP-V2"; userCredential.setNonEapInnerMethod("MS-CHAP-V2");
config.credential.certCredential = new Credential.CertificateCredential(); credential.setUserCredential(userCredential);
config.credential.certCredential.certType = "x509v3"; Credential.CertificateCredential certCredential = new Credential.CertificateCredential();
config.credential.certCredential.certSha256FingerPrint = new byte[32]; certCredential.setCertType("x509v3");
Arrays.fill(config.credential.certCredential.certSha256FingerPrint, (byte)0x1f); certCredential.setCertSha256Fingerprint(certFingerprint);
config.credential.simCredential = new Credential.SimCredential(); credential.setCertCredential(certCredential);
config.credential.simCredential.imsi = "imsi"; Credential.SimCredential simCredential = new Credential.SimCredential();
config.credential.simCredential.eapType = 24; simCredential.setImsi("imsi");
simCredential.setEapType(24);
credential.setSimCredential(simCredential);
config.setCredential(credential);
// Policy configuration. // Policy configuration.
config.policy = new Policy(); Policy policy = new Policy();
config.policy.preferredRoamingPartnerList = new ArrayList<>(); List<Policy.RoamingPartner> preferredRoamingPartnerList = new ArrayList<>();
Policy.RoamingPartner partner1 = new Policy.RoamingPartner(); Policy.RoamingPartner partner1 = new Policy.RoamingPartner();
partner1.fqdn = "test1.fqdn.com"; partner1.setFqdn("test1.fqdn.com");
partner1.fqdnExactMatch = true; partner1.setFqdnExactMatch(true);
partner1.priority = 127; partner1.setPriority(127);
partner1.countries = "us,fr"; partner1.setCountries("us,fr");
Policy.RoamingPartner partner2 = new Policy.RoamingPartner(); Policy.RoamingPartner partner2 = new Policy.RoamingPartner();
partner2.fqdn = "test2.fqdn.com"; partner2.setFqdn("test2.fqdn.com");
partner2.fqdnExactMatch = false; partner2.setFqdnExactMatch(false);
partner2.priority = 200; partner2.setPriority(200);
partner2.countries = "*"; partner2.setCountries("*");
config.policy.preferredRoamingPartnerList.add(partner1); preferredRoamingPartnerList.add(partner1);
config.policy.preferredRoamingPartnerList.add(partner2); preferredRoamingPartnerList.add(partner2);
config.policy.minHomeDownlinkBandwidth = 23412; policy.setPreferredRoamingPartnerList(preferredRoamingPartnerList);
config.policy.minHomeUplinkBandwidth = 9823; policy.setMinHomeDownlinkBandwidth(23412);
config.policy.minRoamingDownlinkBandwidth = 9271; policy.setMinHomeUplinkBandwidth(9823);
config.policy.minRoamingUplinkBandwidth = 2315; policy.setMinRoamingDownlinkBandwidth(9271);
config.policy.excludedSsidList = new String[] {"excludeSSID"}; policy.setMinRoamingUplinkBandwidth(2315);
config.policy.requiredProtoPortMap = new HashMap<>(); policy.setExcludedSsidList(new String[] {"excludeSSID"});
config.policy.requiredProtoPortMap.put(12, "34,92,234"); Map<Integer, String> requiredProtoPortMap = new HashMap<>();
config.policy.maximumBssLoadValue = 23; requiredProtoPortMap.put(12, "34,92,234");
config.policy.policyUpdate = new UpdateParameter(); policy.setRequiredProtoPortMap(requiredProtoPortMap);
config.policy.policyUpdate.updateIntervalInMinutes = 120; policy.setMaximumBssLoadValue(23);
config.policy.policyUpdate.updateMethod = UpdateParameter.UPDATE_METHOD_OMADM; UpdateParameter policyUpdate = new UpdateParameter();
config.policy.policyUpdate.restriction = UpdateParameter.UPDATE_RESTRICTION_HOMESP; policyUpdate.setUpdateIntervalInMinutes(120);
config.policy.policyUpdate.serverUri = "policy.update.com"; policyUpdate.setUpdateMethod(UpdateParameter.UPDATE_METHOD_OMADM);
config.policy.policyUpdate.username = "updateUser"; policyUpdate.setRestriction(UpdateParameter.UPDATE_RESTRICTION_HOMESP);
config.policy.policyUpdate.base64EncodedPassword = "updatePass"; policyUpdate.setServerUri("policy.update.com");
config.policy.policyUpdate.trustRootCertUrl = "update.cert.com"; policyUpdate.setUsername("updateUser");
config.policy.policyUpdate.trustRootCertSha256Fingerprint = new byte[32]; policyUpdate.setBase64EncodedPassword("updatePass");
Arrays.fill(config.policy.policyUpdate.trustRootCertSha256Fingerprint, (byte) 0x1f); policyUpdate.setTrustRootCertUrl("update.cert.com");
policyUpdate.setTrustRootCertSha256Fingerprint(certFingerprint);
policy.setPolicyUpdate(policyUpdate);
config.setPolicy(policy);
return config; return config;
} }
@@ -249,10 +259,3 @@ public class PPSMOParserTest {
loadResourceFile(PPS_MO_XML_FILE_INVALID_NAME))); loadResourceFile(PPS_MO_XML_FILE_INVALID_NAME)));
} }
} }

View File

@@ -23,10 +23,11 @@ import android.net.wifi.EAPConstants;
import android.net.wifi.FakeKeys; import android.net.wifi.FakeKeys;
import android.os.Parcel; import android.os.Parcel;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.Arrays; import java.util.Arrays;
@@ -55,16 +56,16 @@ public class CredentialTest {
X509Certificate[] clientCertificateChain, X509Certificate[] clientCertificateChain,
PrivateKey clientPrivateKey) { PrivateKey clientPrivateKey) {
Credential cred = new Credential(); Credential cred = new Credential();
cred.creationTimeInMs = 123455L; cred.setCreationTimeInMs(123455L);
cred.expirationTimeInMs = 2310093L; cred.setExpirationTimeInMs(2310093L);
cred.realm = "realm"; cred.setRealm("realm");
cred.checkAAAServerCertStatus = true; cred.setCheckAAAServerCertStatus(true);
cred.userCredential = userCred; cred.setUserCredential(userCred);
cred.certCredential = certCred; cred.setCertCredential(certCred);
cred.simCredential = simCred; cred.setSimCredential(simCred);
cred.caCertificate = caCert; cred.setCaCertificate(caCert);
cred.clientCertificateChain = clientCertificateChain; cred.setClientCertificateChain(clientCertificateChain);
cred.clientPrivateKey = clientPrivateKey; cred.setClientPrivateKey(clientPrivateKey);
return cred; return cred;
} }
@@ -73,10 +74,12 @@ public class CredentialTest {
* *
* @return {@link Credential} * @return {@link Credential}
*/ */
private static Credential createCredentialWithCertificateCredential() { private static Credential createCredentialWithCertificateCredential()
throws NoSuchAlgorithmException, CertificateEncodingException {
Credential.CertificateCredential certCred = new Credential.CertificateCredential(); Credential.CertificateCredential certCred = new Credential.CertificateCredential();
certCred.certType = "x509v3"; certCred.setCertType("x509v3");
certCred.certSha256FingerPrint = new byte[32]; certCred.setCertSha256Fingerprint(
MessageDigest.getInstance("SHA-256").digest(FakeKeys.CLIENT_CERT.getEncoded()));
return createCredential(null, certCred, null, FakeKeys.CA_CERT0, return createCredential(null, certCred, null, FakeKeys.CA_CERT0,
new X509Certificate[] {FakeKeys.CLIENT_CERT}, FakeKeys.RSA_KEY1); new X509Certificate[] {FakeKeys.CLIENT_CERT}, FakeKeys.RSA_KEY1);
} }
@@ -88,8 +91,8 @@ public class CredentialTest {
*/ */
private static Credential createCredentialWithSimCredential() { private static Credential createCredentialWithSimCredential() {
Credential.SimCredential simCred = new Credential.SimCredential(); Credential.SimCredential simCred = new Credential.SimCredential();
simCred.imsi = "1234*"; simCred.setImsi("1234*");
simCred.eapType = EAPConstants.EAP_SIM; simCred.setEapType(EAPConstants.EAP_SIM);
return createCredential(null, null, simCred, null, null, null); return createCredential(null, null, simCred, null, null, null);
} }
@@ -100,15 +103,14 @@ public class CredentialTest {
*/ */
private static Credential createCredentialWithUserCredential() { private static Credential createCredentialWithUserCredential() {
Credential.UserCredential userCred = new Credential.UserCredential(); Credential.UserCredential userCred = new Credential.UserCredential();
userCred.username = "username"; userCred.setUsername("username");
userCred.password = "password"; userCred.setPassword("password");
userCred.machineManaged = true; userCred.setMachineManaged(true);
userCred.ableToShare = true; userCred.setAbleToShare(true);
userCred.softTokenApp = "TestApp"; userCred.setSoftTokenApp("TestApp");
userCred.eapType = EAPConstants.EAP_TTLS; userCred.setEapType(EAPConstants.EAP_TTLS);
userCred.nonEapInnerMethod = "MS-CHAP"; userCred.setNonEapInnerMethod("MS-CHAP");
return createCredential(userCred, null, null, FakeKeys.CA_CERT0, return createCredential(userCred, null, null, FakeKeys.CA_CERT0, null, null);
new X509Certificate[] {FakeKeys.CLIENT_CERT}, FakeKeys.RSA_KEY1);
} }
private static void verifyParcel(Credential writeCred) { private static void verifyParcel(Credential writeCred) {
@@ -166,14 +168,7 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateUserCredential() throws Exception { public void validateUserCredential() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithUserCredential();
cred.realm = "realm";
cred.userCredential = new Credential.UserCredential();
cred.userCredential.username = "username";
cred.userCredential.password = "password";
cred.userCredential.eapType = EAPConstants.EAP_TTLS;
cred.userCredential.nonEapInnerMethod = "MS-CHAP";
cred.caCertificate = FakeKeys.CA_CERT0;
assertTrue(cred.validate()); assertTrue(cred.validate());
} }
@@ -184,13 +179,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateUserCredentialWithoutCaCert() throws Exception { public void validateUserCredentialWithoutCaCert() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithUserCredential();
cred.realm = "realm"; cred.setCaCertificate(null);
cred.userCredential = new Credential.UserCredential();
cred.userCredential.username = "username";
cred.userCredential.password = "password";
cred.userCredential.eapType = EAPConstants.EAP_TTLS;
cred.userCredential.nonEapInnerMethod = "MS-CHAP";
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -201,14 +191,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateUserCredentialWithEapTls() throws Exception { public void validateUserCredentialWithEapTls() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithUserCredential();
cred.realm = "realm"; cred.getUserCredential().setEapType(EAPConstants.EAP_TLS);
cred.userCredential = new Credential.UserCredential();
cred.userCredential.username = "username";
cred.userCredential.password = "password";
cred.userCredential.eapType = EAPConstants.EAP_TLS;
cred.userCredential.nonEapInnerMethod = "MS-CHAP";
cred.caCertificate = FakeKeys.CA_CERT0;
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -220,13 +204,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateUserCredentialWithoutRealm() throws Exception { public void validateUserCredentialWithoutRealm() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithUserCredential();
cred.userCredential = new Credential.UserCredential(); cred.setRealm(null);
cred.userCredential.username = "username";
cred.userCredential.password = "password";
cred.userCredential.eapType = EAPConstants.EAP_TTLS;
cred.userCredential.nonEapInnerMethod = "MS-CHAP";
cred.caCertificate = FakeKeys.CA_CERT0;
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -237,13 +216,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateUserCredentialWithoutUsername() throws Exception { public void validateUserCredentialWithoutUsername() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithUserCredential();
cred.realm = "realm"; cred.getUserCredential().setUsername(null);
cred.userCredential = new Credential.UserCredential();
cred.userCredential.password = "password";
cred.userCredential.eapType = EAPConstants.EAP_TTLS;
cred.userCredential.nonEapInnerMethod = "MS-CHAP";
cred.caCertificate = FakeKeys.CA_CERT0;
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -254,13 +228,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateUserCredentialWithoutPassword() throws Exception { public void validateUserCredentialWithoutPassword() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithUserCredential();
cred.realm = "realm"; cred.getUserCredential().setPassword(null);
cred.userCredential = new Credential.UserCredential();
cred.userCredential.username = "username";
cred.userCredential.eapType = EAPConstants.EAP_TTLS;
cred.userCredential.nonEapInnerMethod = "MS-CHAP";
cred.caCertificate = FakeKeys.CA_CERT0;
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -271,13 +240,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateUserCredentialWithoutAuthMethod() throws Exception { public void validateUserCredentialWithoutAuthMethod() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithUserCredential();
cred.realm = "realm"; cred.getUserCredential().setNonEapInnerMethod(null);
cred.userCredential = new Credential.UserCredential();
cred.userCredential.username = "username";
cred.userCredential.password = "password";
cred.userCredential.eapType = EAPConstants.EAP_TTLS;
cred.caCertificate = FakeKeys.CA_CERT0;
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -290,17 +254,7 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateCertCredential() throws Exception { public void validateCertCredential() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithCertificateCredential();
cred.realm = "realm";
// Setup certificate credential.
cred.certCredential = new Credential.CertificateCredential();
cred.certCredential.certType = "x509v3";
cred.certCredential.certSha256FingerPrint =
MessageDigest.getInstance("SHA-256").digest(FakeKeys.CLIENT_CERT.getEncoded());
// Setup certificates and private key.
cred.caCertificate = FakeKeys.CA_CERT0;
cred.clientCertificateChain = new X509Certificate[] {FakeKeys.CLIENT_CERT};
cred.clientPrivateKey = FakeKeys.RSA_KEY1;
assertTrue(cred.validate()); assertTrue(cred.validate());
} }
@@ -310,16 +264,8 @@ public class CredentialTest {
* @throws Exception * @throws Exception
*/ */
public void validateCertCredentialWithoutCaCert() throws Exception { public void validateCertCredentialWithoutCaCert() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithCertificateCredential();
cred.realm = "realm"; cred.setCaCertificate(null);
// Setup certificate credential.
cred.certCredential = new Credential.CertificateCredential();
cred.certCredential.certType = "x509v3";
cred.certCredential.certSha256FingerPrint =
MessageDigest.getInstance("SHA-256").digest(FakeKeys.CLIENT_CERT.getEncoded());
// Setup certificates and private key.
cred.clientCertificateChain = new X509Certificate[] {FakeKeys.CLIENT_CERT};
cred.clientPrivateKey = FakeKeys.RSA_KEY1;
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -330,16 +276,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateCertCredentialWithoutClientCertChain() throws Exception { public void validateCertCredentialWithoutClientCertChain() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithCertificateCredential();
cred.realm = "realm"; cred.setClientCertificateChain(null);
// Setup certificate credential.
cred.certCredential = new Credential.CertificateCredential();
cred.certCredential.certType = "x509v3";
cred.certCredential.certSha256FingerPrint =
MessageDigest.getInstance("SHA-256").digest(FakeKeys.CLIENT_CERT.getEncoded());
// Setup certificates and private key.
cred.caCertificate = FakeKeys.CA_CERT0;
cred.clientPrivateKey = FakeKeys.RSA_KEY1;
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -350,16 +288,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateCertCredentialWithoutClientPrivateKey() throws Exception { public void validateCertCredentialWithoutClientPrivateKey() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithCertificateCredential();
cred.realm = "realm"; cred.setClientPrivateKey(null);
// Setup certificate credential.
cred.certCredential = new Credential.CertificateCredential();
cred.certCredential.certType = "x509v3";
cred.certCredential.certSha256FingerPrint =
MessageDigest.getInstance("SHA-256").digest(FakeKeys.CLIENT_CERT.getEncoded());
// Setup certificates and private key.
cred.caCertificate = FakeKeys.CA_CERT0;
cred.clientCertificateChain = new X509Certificate[] {FakeKeys.CLIENT_CERT};
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -371,17 +301,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateCertCredentialWithMismatchFingerprint() throws Exception { public void validateCertCredentialWithMismatchFingerprint() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithCertificateCredential();
cred.realm = "realm"; cred.getCertCredential().setCertSha256Fingerprint(new byte[32]);
// Setup certificate credential.
cred.certCredential = new Credential.CertificateCredential();
cred.certCredential.certType = "x509v3";
cred.certCredential.certSha256FingerPrint = new byte[32];
Arrays.fill(cred.certCredential.certSha256FingerPrint, (byte)0);
// Setup certificates and private key.
cred.caCertificate = FakeKeys.CA_CERT0;
cred.clientCertificateChain = new X509Certificate[] {FakeKeys.CLIENT_CERT};
cred.clientPrivateKey = FakeKeys.RSA_KEY1;
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -392,12 +313,7 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateSimCredentialWithEapSim() throws Exception { public void validateSimCredentialWithEapSim() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithSimCredential();
cred.realm = "realm";
// Setup SIM credential.
cred.simCredential = new Credential.SimCredential();
cred.simCredential.imsi = "1234*";
cred.simCredential.eapType = EAPConstants.EAP_SIM;
assertTrue(cred.validate()); assertTrue(cred.validate());
} }
@@ -408,12 +324,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateSimCredentialWithEapAka() throws Exception { public void validateSimCredentialWithEapAka() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithSimCredential();
cred.realm = "realm"; cred.getSimCredential().setEapType(EAPConstants.EAP_AKA);
// Setup SIM credential.
cred.simCredential = new Credential.SimCredential();
cred.simCredential.imsi = "1234*";
cred.simCredential.eapType = EAPConstants.EAP_AKA;
assertTrue(cred.validate()); assertTrue(cred.validate());
} }
@@ -424,12 +336,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateSimCredentialWithEapAkaPrime() throws Exception { public void validateSimCredentialWithEapAkaPrime() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithSimCredential();
cred.realm = "realm"; cred.getSimCredential().setEapType(EAPConstants.EAP_AKA_PRIME);
// Setup SIM credential.
cred.simCredential = new Credential.SimCredential();
cred.simCredential.imsi = "1234*";
cred.simCredential.eapType = EAPConstants.EAP_AKA_PRIME;
assertTrue(cred.validate()); assertTrue(cred.validate());
} }
@@ -440,11 +348,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateSimCredentialWithoutIMSI() throws Exception { public void validateSimCredentialWithoutIMSI() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithSimCredential();
cred.realm = "realm"; cred.getSimCredential().setImsi(null);
// Setup SIM credential.
cred.simCredential = new Credential.SimCredential();
cred.simCredential.eapType = EAPConstants.EAP_SIM;
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -455,12 +360,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateSimCredentialWithInvalidIMSI() throws Exception { public void validateSimCredentialWithInvalidIMSI() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithSimCredential();
cred.realm = "realm"; cred.getSimCredential().setImsi("dummy");
// Setup SIM credential.
cred.simCredential = new Credential.SimCredential();
cred.simCredential.imsi = "dummy";
cred.simCredential.eapType = EAPConstants.EAP_SIM;
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -471,12 +372,8 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateSimCredentialWithEapTls() throws Exception { public void validateSimCredentialWithEapTls() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithSimCredential();
cred.realm = "realm"; cred.getSimCredential().setEapType(EAPConstants.EAP_TLS);
// Setup SIM credential.
cred.simCredential = new Credential.SimCredential();
cred.simCredential.imsi = "1234*";
cred.simCredential.eapType = EAPConstants.EAP_TLS;
assertFalse(cred.validate()); assertFalse(cred.validate());
} }
@@ -487,19 +384,12 @@ public class CredentialTest {
*/ */
@Test @Test
public void validateCredentialWithUserAndSimCredential() throws Exception { public void validateCredentialWithUserAndSimCredential() throws Exception {
Credential cred = new Credential(); Credential cred = createCredentialWithUserCredential();
cred.realm = "realm";
// Setup user credential with EAP-TTLS.
cred.userCredential = new Credential.UserCredential();
cred.userCredential.username = "username";
cred.userCredential.password = "password";
cred.userCredential.eapType = EAPConstants.EAP_TTLS;
cred.userCredential.nonEapInnerMethod = "MS-CHAP";
cred.caCertificate = FakeKeys.CA_CERT0;
// Setup SIM credential. // Setup SIM credential.
cred.simCredential = new Credential.SimCredential(); Credential.SimCredential simCredential = new Credential.SimCredential();
cred.simCredential.imsi = "1234*"; simCredential.setImsi("1234*");
cred.simCredential.eapType = EAPConstants.EAP_SIM; simCredential.setEapType(EAPConstants.EAP_SIM);
cred.setSimCredential(simCredential);
assertFalse(cred.validate()); assertFalse(cred.validate());
} }

View File

@@ -55,14 +55,14 @@ public class HomeSPTest {
*/ */
private static HomeSP createHomeSp(Map<String, Long> homeNetworkIds) { private static HomeSP createHomeSp(Map<String, Long> homeNetworkIds) {
HomeSP homeSp = new HomeSP(); HomeSP homeSp = new HomeSP();
homeSp.fqdn = "fqdn"; homeSp.setFqdn("fqdn");
homeSp.friendlyName = "friendly name"; homeSp.setFriendlyName("friendly name");
homeSp.iconUrl = "icon.url"; homeSp.setIconUrl("icon.url");
homeSp.homeNetworkIds = homeNetworkIds; homeSp.setHomeNetworkIds(homeNetworkIds);
homeSp.matchAllOIs = new long[] {0x11L, 0x22L}; homeSp.setMatchAllOIs(new long[] {0x11L, 0x22L});
homeSp.matchAnyOIs = new long[] {0x33L, 0x44L}; homeSp.setMatchAnyOIs(new long[] {0x33L, 0x44L});
homeSp.otherHomePartners = new String[] {"partner1", "partner2"}; homeSp.setOtherHomePartners(new String[] {"partner1", "partner2"});
homeSp.roamingConsortiumOIs = new long[] {0x55, 0x66}; homeSp.setRoamingConsortiumOIs(new long[] {0x55, 0x66});
return homeSp; return homeSp;
} }
@@ -136,9 +136,7 @@ public class HomeSPTest {
*/ */
@Test @Test
public void validateValidHomeSP() throws Exception { public void validateValidHomeSP() throws Exception {
HomeSP homeSp = new HomeSP(); HomeSP homeSp = createHomeSpWithHomeNetworkIds();
homeSp.fqdn = "fqdn";
homeSp.friendlyName = "friendly name";
assertTrue(homeSp.validate()); assertTrue(homeSp.validate());
} }
@@ -149,8 +147,8 @@ public class HomeSPTest {
*/ */
@Test @Test
public void validateHomeSpWithoutFqdn() throws Exception { public void validateHomeSpWithoutFqdn() throws Exception {
HomeSP homeSp = new HomeSP(); HomeSP homeSp = createHomeSpWithHomeNetworkIds();
homeSp.friendlyName = "friendly name"; homeSp.setFqdn(null);
assertFalse(homeSp.validate()); assertFalse(homeSp.validate());
} }
@@ -161,36 +159,9 @@ public class HomeSPTest {
*/ */
@Test @Test
public void validateHomeSpWithoutFriendlyName() throws Exception { public void validateHomeSpWithoutFriendlyName() throws Exception {
HomeSP homeSp = new HomeSP();
homeSp.fqdn = "fqdn";
assertFalse(homeSp.validate());
}
/**
* Verify that a HomeSP is valid when the optional Roaming Consortium OIs are
* provided.
*
* @throws Exception
*/
@Test
public void validateHomeSpWithRoamingConsoritums() throws Exception {
HomeSP homeSp = new HomeSP();
homeSp.fqdn = "fqdn";
homeSp.friendlyName = "friendly name";
homeSp.roamingConsortiumOIs = new long[] {0x55, 0x66};
assertTrue(homeSp.validate());
}
/**
* Verify that a HomeSP is valid when the optional Home Network IDs are
* provided.
*
* @throws Exception
*/
@Test
public void validateHomeSpWithHomeNetworkIds() throws Exception {
HomeSP homeSp = createHomeSpWithHomeNetworkIds(); HomeSP homeSp = createHomeSpWithHomeNetworkIds();
assertTrue(homeSp.validate()); homeSp.setFriendlyName(null);
assertFalse(homeSp.validate());
} }
/** /**
@@ -213,14 +184,14 @@ public class HomeSPTest {
*/ */
@Test @Test
public void validateHomeSpWithInvalidHomeNetworkIds() throws Exception { public void validateHomeSpWithInvalidHomeNetworkIds() throws Exception {
HomeSP homeSp = new HomeSP(); HomeSP homeSp = createHomeSpWithoutHomeNetworkIds();
homeSp.fqdn = "fqdn"; // HomeNetworkID with SSID exceeding the maximum length.
homeSp.friendlyName = "friendly name"; Map<String, Long> homeNetworkIds = new HashMap<>();
homeSp.homeNetworkIds = new HashMap<>();
byte[] rawSsidBytes = new byte[33]; byte[] rawSsidBytes = new byte[33];
Arrays.fill(rawSsidBytes, (byte) 'a'); Arrays.fill(rawSsidBytes, (byte) 'a');
homeSp.homeNetworkIds.put( homeNetworkIds.put(
StringFactory.newStringFromBytes(rawSsidBytes, StandardCharsets.UTF_8), 0x1234L); StringFactory.newStringFromBytes(rawSsidBytes, StandardCharsets.UTF_8), 0x1234L);
homeSp.setHomeNetworkIds(homeNetworkIds);
assertFalse(homeSp.validate()); assertFalse(homeSp.validate());
} }

View File

@@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@@ -48,40 +49,43 @@ public class PolicyTest {
*/ */
private static Policy createPolicy() { private static Policy createPolicy() {
Policy policy = new Policy(); Policy policy = new Policy();
policy.minHomeDownlinkBandwidth = 123; policy.setMinHomeDownlinkBandwidth(123);
policy.minHomeUplinkBandwidth = 345; policy.setMinHomeUplinkBandwidth(345);
policy.minRoamingDownlinkBandwidth = 567; policy.setMinRoamingDownlinkBandwidth(567);
policy.minRoamingUplinkBandwidth = 789; policy.setMinRoamingUplinkBandwidth(789);
policy.excludedSsidList = new String[] {"ssid1", "ssid2"}; policy.setExcludedSsidList(new String[] {"ssid1", "ssid2"});
policy.requiredProtoPortMap = new HashMap<>(); Map<Integer, String> requiredProtoPortMap = new HashMap<>();
policy.requiredProtoPortMap.put(12, "23,342,123"); requiredProtoPortMap.put(12, "23,342,123");
policy.requiredProtoPortMap.put(23, "789,372,1235"); requiredProtoPortMap.put(23, "789,372,1235");
policy.maximumBssLoadValue = 12; policy.setRequiredProtoPortMap(requiredProtoPortMap);
policy.setMaximumBssLoadValue(12);
policy.preferredRoamingPartnerList = new ArrayList<>(); List<Policy.RoamingPartner> preferredRoamingPartnerList = new ArrayList<>();
Policy.RoamingPartner partner1 = new Policy.RoamingPartner(); Policy.RoamingPartner partner1 = new Policy.RoamingPartner();
partner1.fqdn = "partner1.com"; partner1.setFqdn("partner1.com");
partner1.fqdnExactMatch = true; partner1.setFqdnExactMatch(true);
partner1.priority = 12; partner1.setPriority(12);
partner1.countries = "us,jp"; partner1.setCountries("us,jp");
Policy.RoamingPartner partner2 = new Policy.RoamingPartner(); Policy.RoamingPartner partner2 = new Policy.RoamingPartner();
partner2.fqdn = "partner2.com"; partner2.setFqdn("partner2.com");
partner2.fqdnExactMatch = false; partner2.setFqdnExactMatch(false);
partner2.priority = 42; partner2.setPriority(42);
partner2.countries = "ca,fr"; partner2.setCountries("ca,fr");
policy.preferredRoamingPartnerList.add(partner1); preferredRoamingPartnerList.add(partner1);
policy.preferredRoamingPartnerList.add(partner2); preferredRoamingPartnerList.add(partner2);
policy.setPreferredRoamingPartnerList(preferredRoamingPartnerList);
policy.policyUpdate = new UpdateParameter(); UpdateParameter policyUpdate = new UpdateParameter();
policy.policyUpdate.updateIntervalInMinutes = 1712; policyUpdate.setUpdateIntervalInMinutes(1712);
policy.policyUpdate.updateMethod = UpdateParameter.UPDATE_METHOD_OMADM; policyUpdate.setUpdateMethod(UpdateParameter.UPDATE_METHOD_OMADM);
policy.policyUpdate.restriction = UpdateParameter.UPDATE_RESTRICTION_HOMESP; policyUpdate.setRestriction(UpdateParameter.UPDATE_RESTRICTION_HOMESP);
policy.policyUpdate.serverUri = "policy.update.com"; policyUpdate.setServerUri("policy.update.com");
policy.policyUpdate.username = "username"; policyUpdate.setUsername("username");
policy.policyUpdate.base64EncodedPassword = policyUpdate.setBase64EncodedPassword(
Base64.encodeToString("password".getBytes(), Base64.DEFAULT); Base64.encodeToString("password".getBytes(), Base64.DEFAULT));
policy.policyUpdate.trustRootCertUrl = "trust.cert.com"; policyUpdate.setTrustRootCertUrl("trust.cert.com");
policy.policyUpdate.trustRootCertSha256Fingerprint = new byte[32]; policyUpdate.setTrustRootCertSha256Fingerprint(new byte[32]);
policy.setPolicyUpdate(policyUpdate);
return policy; return policy;
} }
@@ -128,7 +132,7 @@ public class PolicyTest {
@Test @Test
public void verifyParcelWithoutProtoPortMap() throws Exception { public void verifyParcelWithoutProtoPortMap() throws Exception {
Policy policy = createPolicy(); Policy policy = createPolicy();
policy.requiredProtoPortMap = null; policy.setRequiredProtoPortMap(null);
verifyParcel(policy); verifyParcel(policy);
} }
@@ -140,7 +144,7 @@ public class PolicyTest {
@Test @Test
public void verifyParcelWithoutPreferredRoamingPartnerList() throws Exception { public void verifyParcelWithoutPreferredRoamingPartnerList() throws Exception {
Policy policy = createPolicy(); Policy policy = createPolicy();
policy.preferredRoamingPartnerList = null; policy.setPreferredRoamingPartnerList(null);
verifyParcel(policy); verifyParcel(policy);
} }
@@ -152,7 +156,7 @@ public class PolicyTest {
@Test @Test
public void verifyParcelWithoutPolicyUpdate() throws Exception { public void verifyParcelWithoutPolicyUpdate() throws Exception {
Policy policy = createPolicy(); Policy policy = createPolicy();
policy.policyUpdate = null; policy.setPolicyUpdate(null);
verifyParcel(policy); verifyParcel(policy);
} }
@@ -212,7 +216,7 @@ public class PolicyTest {
@Test @Test
public void validatePolicyWithoutPolicyUpdate() throws Exception { public void validatePolicyWithoutPolicyUpdate() throws Exception {
Policy policy = createPolicy(); Policy policy = createPolicy();
policy.policyUpdate = null; policy.setPolicyUpdate(null);
assertFalse(policy.validate()); assertFalse(policy.validate());
} }
@@ -224,7 +228,7 @@ public class PolicyTest {
@Test @Test
public void validatePolicyWithInvalidPolicyUpdate() throws Exception { public void validatePolicyWithInvalidPolicyUpdate() throws Exception {
Policy policy = createPolicy(); Policy policy = createPolicy();
policy.policyUpdate = new UpdateParameter(); policy.setPolicyUpdate(new UpdateParameter());
assertFalse(policy.validate()); assertFalse(policy.validate());
} }
@@ -237,10 +241,10 @@ public class PolicyTest {
public void validatePolicyWithRoamingPartnerWithoutFQDN() throws Exception { public void validatePolicyWithRoamingPartnerWithoutFQDN() throws Exception {
Policy policy = createPolicy(); Policy policy = createPolicy();
Policy.RoamingPartner partner = new Policy.RoamingPartner(); Policy.RoamingPartner partner = new Policy.RoamingPartner();
partner.fqdnExactMatch = true; partner.setFqdnExactMatch(true);
partner.priority = 12; partner.setPriority(12);
partner.countries = "us,jp"; partner.setCountries("us,jp");
policy.preferredRoamingPartnerList.add(partner); policy.getPreferredRoamingPartnerList().add(partner);
assertFalse(policy.validate()); assertFalse(policy.validate());
} }
@@ -254,10 +258,10 @@ public class PolicyTest {
public void validatePolicyWithRoamingPartnerWithoutCountries() throws Exception { public void validatePolicyWithRoamingPartnerWithoutCountries() throws Exception {
Policy policy = createPolicy(); Policy policy = createPolicy();
Policy.RoamingPartner partner = new Policy.RoamingPartner(); Policy.RoamingPartner partner = new Policy.RoamingPartner();
partner.fqdn = "test.com"; partner.setFqdn("test.com");
partner.fqdnExactMatch = true; partner.setFqdnExactMatch(true);
partner.priority = 12; partner.setPriority(12);
policy.preferredRoamingPartnerList.add(partner); policy.getPreferredRoamingPartnerList().add(partner);
assertFalse(policy.validate()); assertFalse(policy.validate());
} }
@@ -271,7 +275,8 @@ public class PolicyTest {
public void validatePolicyWithInvalidPortStringInProtoPortMap() throws Exception { public void validatePolicyWithInvalidPortStringInProtoPortMap() throws Exception {
Policy policy = createPolicy(); Policy policy = createPolicy();
byte[] rawPortBytes = new byte[MAX_PORT_STRING_BYTES + 1]; byte[] rawPortBytes = new byte[MAX_PORT_STRING_BYTES + 1];
policy.requiredProtoPortMap.put(324, new String(rawPortBytes, StandardCharsets.UTF_8)); policy.getRequiredProtoPortMap().put(
324, new String(rawPortBytes, StandardCharsets.UTF_8));
assertFalse(policy.validate()); assertFalse(policy.validate());
} }
@@ -283,8 +288,9 @@ public class PolicyTest {
@Test @Test
public void validatePolicyWithSsidExclusionListSizeExceededMax() throws Exception { public void validatePolicyWithSsidExclusionListSizeExceededMax() throws Exception {
Policy policy = createPolicy(); Policy policy = createPolicy();
policy.excludedSsidList = new String[MAX_NUMBER_OF_EXCLUDED_SSIDS + 1]; String[] excludedSsidList = new String[MAX_NUMBER_OF_EXCLUDED_SSIDS + 1];
Arrays.fill(policy.excludedSsidList, "ssid"); Arrays.fill(excludedSsidList, "ssid");
policy.setExcludedSsidList(excludedSsidList);
assertFalse(policy.validate()); assertFalse(policy.validate());
} }
@@ -298,7 +304,9 @@ public class PolicyTest {
Policy policy = createPolicy(); Policy policy = createPolicy();
byte[] rawSsidBytes = new byte[MAX_SSID_BYTES + 1]; byte[] rawSsidBytes = new byte[MAX_SSID_BYTES + 1];
Arrays.fill(rawSsidBytes, (byte) 'a'); Arrays.fill(rawSsidBytes, (byte) 'a');
policy.excludedSsidList = new String[] {new String(rawSsidBytes, StandardCharsets.UTF_8)}; String[] excludedSsidList = new String[] {
new String(rawSsidBytes, StandardCharsets.UTF_8)};
policy.setExcludedSsidList(excludedSsidList);
assertFalse(policy.validate()); assertFalse(policy.validate());
} }
} }

View File

@@ -50,15 +50,15 @@ public class UpdateParameterTest {
*/ */
private static UpdateParameter createUpdateParameter() { private static UpdateParameter createUpdateParameter() {
UpdateParameter updateParam = new UpdateParameter(); UpdateParameter updateParam = new UpdateParameter();
updateParam.updateIntervalInMinutes = 1712; updateParam.setUpdateIntervalInMinutes(1712);
updateParam.updateMethod = UpdateParameter.UPDATE_METHOD_OMADM; updateParam.setUpdateMethod(UpdateParameter.UPDATE_METHOD_OMADM);
updateParam.restriction = UpdateParameter.UPDATE_RESTRICTION_HOMESP; updateParam.setRestriction(UpdateParameter.UPDATE_RESTRICTION_HOMESP);
updateParam.serverUri = "server.pdate.com"; updateParam.setServerUri("server.pdate.com");
updateParam.username = "username"; updateParam.setUsername("username");
updateParam.base64EncodedPassword = updateParam.setBase64EncodedPassword(
Base64.encodeToString("password".getBytes(), Base64.DEFAULT); Base64.encodeToString("password".getBytes(), Base64.DEFAULT));
updateParam.trustRootCertUrl = "trust.cert.com"; updateParam.setTrustRootCertUrl("trust.cert.com");
updateParam.trustRootCertSha256Fingerprint = new byte[32]; updateParam.setTrustRootCertSha256Fingerprint(new byte[32]);
return updateParam; return updateParam;
} }
@@ -152,7 +152,7 @@ public class UpdateParameterTest {
@Test @Test
public void validateUpdateParameterWithUnknowMethod() throws Exception { public void validateUpdateParameterWithUnknowMethod() throws Exception {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
updateParam.updateMethod = "adsfasd"; updateParam.setUpdateMethod("adsfasd");
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -164,7 +164,7 @@ public class UpdateParameterTest {
@Test @Test
public void validateUpdateParameterWithUnknowRestriction() throws Exception { public void validateUpdateParameterWithUnknowRestriction() throws Exception {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
updateParam.restriction = "adsfasd"; updateParam.setRestriction("adsfasd");
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -178,7 +178,7 @@ public class UpdateParameterTest {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
byte[] rawUsernameBytes = new byte[MAX_USERNAME_BYTES + 1]; byte[] rawUsernameBytes = new byte[MAX_USERNAME_BYTES + 1];
Arrays.fill(rawUsernameBytes, (byte) 'a'); Arrays.fill(rawUsernameBytes, (byte) 'a');
updateParam.username = new String(rawUsernameBytes, StandardCharsets.UTF_8); updateParam.setUsername(new String(rawUsernameBytes, StandardCharsets.UTF_8));
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -190,7 +190,7 @@ public class UpdateParameterTest {
@Test @Test
public void validateUpdateParameterWithEmptyUsername() throws Exception { public void validateUpdateParameterWithEmptyUsername() throws Exception {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
updateParam.username = null; updateParam.setUsername(null);
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -204,7 +204,7 @@ public class UpdateParameterTest {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
byte[] rawPasswordBytes = new byte[MAX_PASSWORD_BYTES + 1]; byte[] rawPasswordBytes = new byte[MAX_PASSWORD_BYTES + 1];
Arrays.fill(rawPasswordBytes, (byte) 'a'); Arrays.fill(rawPasswordBytes, (byte) 'a');
updateParam.base64EncodedPassword = new String(rawPasswordBytes, StandardCharsets.UTF_8); updateParam.setBase64EncodedPassword(new String(rawPasswordBytes, StandardCharsets.UTF_8));
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -216,7 +216,7 @@ public class UpdateParameterTest {
@Test @Test
public void validateUpdateParameterWithEmptyPassword() throws Exception { public void validateUpdateParameterWithEmptyPassword() throws Exception {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
updateParam.base64EncodedPassword = null; updateParam.setBase64EncodedPassword(null);
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -229,7 +229,7 @@ public class UpdateParameterTest {
@Test @Test
public void validateUpdateParameterWithPasswordContainedInvalidPadding() throws Exception { public void validateUpdateParameterWithPasswordContainedInvalidPadding() throws Exception {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
updateParam.base64EncodedPassword = updateParam.base64EncodedPassword + "="; updateParam.setBase64EncodedPassword(updateParam.getBase64EncodedPassword() + "=");
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -241,7 +241,7 @@ public class UpdateParameterTest {
@Test @Test
public void validateUpdateParameterWithoutTrustRootCertUrl() throws Exception { public void validateUpdateParameterWithoutTrustRootCertUrl() throws Exception {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
updateParam.trustRootCertUrl = null; updateParam.setTrustRootCertUrl(null);
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -255,7 +255,7 @@ public class UpdateParameterTest {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
byte[] rawUrlBytes = new byte[MAX_URL_BYTES + 1]; byte[] rawUrlBytes = new byte[MAX_URL_BYTES + 1];
Arrays.fill(rawUrlBytes, (byte) 'a'); Arrays.fill(rawUrlBytes, (byte) 'a');
updateParam.trustRootCertUrl = new String(rawUrlBytes, StandardCharsets.UTF_8); updateParam.setTrustRootCertUrl(new String(rawUrlBytes, StandardCharsets.UTF_8));
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -268,7 +268,7 @@ public class UpdateParameterTest {
@Test @Test
public void validateUpdateParameterWithouttrustRootCertSha256Fingerprint() throws Exception { public void validateUpdateParameterWithouttrustRootCertSha256Fingerprint() throws Exception {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
updateParam.trustRootCertSha256Fingerprint = null; updateParam.setTrustRootCertSha256Fingerprint(null);
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -281,10 +281,10 @@ public class UpdateParameterTest {
@Test @Test
public void validateUpdateParameterWithInvalidtrustRootCertSha256Fingerprint() throws Exception { public void validateUpdateParameterWithInvalidtrustRootCertSha256Fingerprint() throws Exception {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
updateParam.trustRootCertSha256Fingerprint = new byte[CERTIFICATE_SHA256_BYTES + 1]; updateParam.setTrustRootCertSha256Fingerprint(new byte[CERTIFICATE_SHA256_BYTES + 1]);
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
updateParam.trustRootCertSha256Fingerprint = new byte[CERTIFICATE_SHA256_BYTES - 1]; updateParam.setTrustRootCertSha256Fingerprint(new byte[CERTIFICATE_SHA256_BYTES - 1]);
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -296,7 +296,7 @@ public class UpdateParameterTest {
@Test @Test
public void validateUpdateParameterWithoutServerUri() throws Exception { public void validateUpdateParameterWithoutServerUri() throws Exception {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
updateParam.serverUri = null; updateParam.setServerUri(null);
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -310,7 +310,7 @@ public class UpdateParameterTest {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
byte[] rawUriBytes = new byte[MAX_URI_BYTES + 1]; byte[] rawUriBytes = new byte[MAX_URI_BYTES + 1];
Arrays.fill(rawUriBytes, (byte) 'a'); Arrays.fill(rawUriBytes, (byte) 'a');
updateParam.serverUri = new String(rawUriBytes, StandardCharsets.UTF_8); updateParam.setServerUri(new String(rawUriBytes, StandardCharsets.UTF_8));
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
@@ -323,14 +323,14 @@ public class UpdateParameterTest {
@Test @Test
public void validateUpdateParameterWithNoServerCheck() throws Exception { public void validateUpdateParameterWithNoServerCheck() throws Exception {
UpdateParameter updateParam = new UpdateParameter(); UpdateParameter updateParam = new UpdateParameter();
updateParam.updateIntervalInMinutes = UpdateParameter.UPDATE_CHECK_INTERVAL_NEVER; updateParam.setUpdateIntervalInMinutes(UpdateParameter.UPDATE_CHECK_INTERVAL_NEVER);
updateParam.username = null; updateParam.setUsername(null);
updateParam.base64EncodedPassword = null; updateParam.setBase64EncodedPassword(null);
updateParam.updateMethod = null; updateParam.setUpdateMethod(null);
updateParam.restriction = null; updateParam.setRestriction(null);
updateParam.serverUri = null; updateParam.setServerUri(null);
updateParam.trustRootCertUrl = null; updateParam.setTrustRootCertUrl(null);
updateParam.trustRootCertSha256Fingerprint = null; updateParam.setTrustRootCertSha256Fingerprint(null);
assertTrue(updateParam.validate()); assertTrue(updateParam.validate());
} }
@@ -342,7 +342,7 @@ public class UpdateParameterTest {
@Test @Test
public void validateUpdateParameterWithoutUpdateInterval() throws Exception { public void validateUpdateParameterWithoutUpdateInterval() throws Exception {
UpdateParameter updateParam = createUpdateParameter(); UpdateParameter updateParam = createUpdateParameter();
updateParam.updateIntervalInMinutes = Long.MIN_VALUE; updateParam.setUpdateIntervalInMinutes(Long.MIN_VALUE);
assertFalse(updateParam.validate()); assertFalse(updateParam.validate());
} }
} }