|
9 | 9 |
|
10 | 10 | import com.here.account.util.Clock; |
11 | 11 | import com.here.account.util.SettableSystemClock; |
12 | | -import org.ini4j.Ini; |
| 12 | +import org.apache.commons.configuration2.INIConfiguration; |
| 13 | +import org.apache.commons.configuration2.ex.ConfigurationException; |
| 14 | +import org.apache.commons.configuration2.HierarchicalConfiguration; |
| 15 | +import org.apache.commons.configuration2.tree.ImmutableNode; |
13 | 16 |
|
14 | 17 | import com.here.account.auth.OAuth1ClientCredentialsProvider; |
15 | 18 | import com.here.account.http.HttpConstants.HttpMethods; |
@@ -64,27 +67,27 @@ protected static ClientAuthorizationRequestProvider getClientCredentialsProvider |
64 | 67 | try { |
65 | 68 | Properties properties = getPropertiesFromIni(inputStream, sectionName); |
66 | 69 | return FromSystemProperties.getClientCredentialsProviderWithDefaultTokenEndpointUrl(clock, properties); |
67 | | - } catch (IOException e) { |
| 70 | + } catch (IOException | ConfigurationException e) { |
68 | 71 | throw new RequestProviderException("trouble FromFile " + e, e); |
69 | 72 | } |
70 | 73 | } |
71 | 74 |
|
72 | 75 | static final String DEFAULT_INI_SECTION_NAME = "default"; |
73 | | - |
74 | | - static Properties getPropertiesFromIni(InputStream inputStream, String sectionName) throws IOException { |
75 | | - Ini ini = new Ini(); |
| 76 | + |
| 77 | + static Properties getPropertiesFromIni(InputStream inputStream, String sectionName) throws IOException, ConfigurationException { |
76 | 78 | try (Reader reader = new InputStreamReader(inputStream, OAuthConstants.UTF_8_CHARSET)) { |
77 | | - ini.load(reader); |
78 | | - Ini.Section section = ini.get(sectionName); |
| 79 | + INIConfiguration ini = new INIConfiguration(); |
| 80 | + ini.read(reader); |
79 | 81 | Properties properties = new Properties(); |
| 82 | + HierarchicalConfiguration<ImmutableNode> section = ini.getSection(sectionName); |
80 | 83 | properties.put(OAuth1ClientCredentialsProvider.FromProperties.TOKEN_ENDPOINT_URL_PROPERTY, |
81 | | - section.get(OAuth1ClientCredentialsProvider.FromProperties.TOKEN_ENDPOINT_URL_PROPERTY)); |
| 84 | + section.getString(OAuth1ClientCredentialsProvider.FromProperties.TOKEN_ENDPOINT_URL_PROPERTY)); |
82 | 85 | properties.put(OAuth1ClientCredentialsProvider.FromProperties.ACCESS_KEY_ID_PROPERTY, |
83 | | - section.get(OAuth1ClientCredentialsProvider.FromProperties.ACCESS_KEY_ID_PROPERTY)); |
| 86 | + section.getString(OAuth1ClientCredentialsProvider.FromProperties.ACCESS_KEY_ID_PROPERTY)); |
84 | 87 | properties.put(OAuth1ClientCredentialsProvider.FromProperties.ACCESS_KEY_SECRET_PROPERTY, |
85 | | - section.get(OAuth1ClientCredentialsProvider.FromProperties.ACCESS_KEY_SECRET_PROPERTY)); |
| 88 | + section.getString(OAuth1ClientCredentialsProvider.FromProperties.ACCESS_KEY_SECRET_PROPERTY)); |
86 | 89 | // scope is optional |
87 | | - String scope = section.get(OAuth1ClientCredentialsProvider.FromProperties.TOKEN_SCOPE_PROPERTY); |
| 90 | + String scope = section.getString(OAuth1ClientCredentialsProvider.FromProperties.TOKEN_SCOPE_PROPERTY); |
88 | 91 | if (null != scope) |
89 | 92 | properties.put(OAuth1ClientCredentialsProvider.FromProperties.TOKEN_SCOPE_PROPERTY, scope); |
90 | 93 |
|
|
0 commit comments