diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-04-04 20:25:14 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-04-04 20:25:15 +0000 |
commit | 140de55c011751c1add7644425d4bd87fa3e0e68 (patch) | |
tree | eb64d9648dac369cc4543af3b7d995f632becd02 | |
parent | e87ca83103d68c0b9d0166069ccbfa52da533d88 (diff) | |
parent | ab83ab09b554e4012af5cf439efe081504a29b88 (diff) |
Merge "hotspot2: fix parsing of IMSI from legacy Passpoint config file" into oc-dev
-rw-r--r-- | service/java/com/android/server/wifi/hotspot2/LegacyPasspointConfigParser.java | 34 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/hotspot2/LegacyPasspointConfigParserTest.java | 12 |
2 files changed, 33 insertions, 13 deletions
diff --git a/service/java/com/android/server/wifi/hotspot2/LegacyPasspointConfigParser.java b/service/java/com/android/server/wifi/hotspot2/LegacyPasspointConfigParser.java index 01607b2bf..31795f126 100644 --- a/service/java/com/android/server/wifi/hotspot2/LegacyPasspointConfigParser.java +++ b/service/java/com/android/server/wifi/hotspot2/LegacyPasspointConfigParser.java @@ -85,6 +85,7 @@ public class LegacyPasspointConfigParser { private static final String TAG_ROAMING_CONSORTIUM_OI = "RoamingConsortiumOI"; private static final String TAG_CREDENTIAL = "Credential"; private static final String TAG_REALM = "Realm"; + private static final String TAG_SIM = "SIM"; private static final String TAG_IMSI = "IMSI"; private static final String LONG_ARRAY_SEPARATOR = ","; @@ -274,7 +275,7 @@ public class LegacyPasspointConfigParser { */ private static LegacyPasspointConfig processPpsNode(Node ppsNode) throws IOException { if (ppsNode.getChildren() == null || ppsNode.getChildren().size() != 1) { - throw new IOException("PerProviderSubscription node should contained " + throw new IOException("PerProviderSubscription node should contain " + "one instance node"); } @@ -319,7 +320,7 @@ public class LegacyPasspointConfigParser { private static void processHomeSPNode(Node homeSpNode, LegacyPasspointConfig config) throws IOException { if (homeSpNode.getChildren() == null) { - throw new IOException("HomeSP node should contained at least one child node"); + throw new IOException("HomeSP node should contain at least one child node"); } for (Node node : homeSpNode.getChildren()) { @@ -351,7 +352,7 @@ public class LegacyPasspointConfigParser { LegacyPasspointConfig config) throws IOException { if (credentialNode.getChildren() == null) { - throw new IOException("Credential node should contained at least one child node"); + throw new IOException("Credential node should contain at least one child node"); } for (Node node : credentialNode.getChildren()) { @@ -359,11 +360,36 @@ public class LegacyPasspointConfigParser { case TAG_REALM: config.mRealm = getValue(node); break; + case TAG_SIM: + processSimNode(node, config); + break; + default: + Log.d(TAG, "Ignore uninterested field under Credential: " + node.getName()); + break; + } + } + } + + /** + * Process a SIM node to retrieve configuration data into the given |config|. + * + * @param simNode The SIM node to process + * @param config The config object to fill in the data + * @throws IOException + */ + private static void processSimNode(Node simNode, LegacyPasspointConfig config) + throws IOException { + if (simNode.getChildren() == null) { + throw new IOException("SIM node should contain at least one child node"); + } + + for (Node node : simNode.getChildren()) { + switch (node.getName()) { case TAG_IMSI: config.mImsi = getValue(node); break; default: - Log.d(TAG, "Ignore uninterested field under Credential: " + node.getName()); + Log.d(TAG, "Ignore uninterested field under SIM: " + node.getName()); break; } } diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/LegacyPasspointConfigParserTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/LegacyPasspointConfigParserTest.java index 932a302b6..10ebceb22 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/LegacyPasspointConfigParserTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/LegacyPasspointConfigParserTest.java @@ -64,17 +64,11 @@ public class LegacyPasspointConfigParserTest { + "4:FQDN=9:test2.net\n" + ".\n" + "a:Credential+\n" - + "10:UsernamePassword+\n" - + "8:Username=5:user2\n" - + "8:Password=5:pass2\n" - + "\n" - + "9:EAPMethod+\n" - + "7:EAPType=2:21\n" - + "b:InnerMethod=a:MS-CHAP-V2\n" - + ".\n" + + "3:SIM+\n" + + "4:IMSI=4:1234\n" + + "7:EAPType=2:18\n" + ".\n" + "5:Realm=9:test2.com\n" - + "4:IMSI=4:1234\n" + ".\n" + ".\n" + ".\n" |