jmspring requested changes on this pull request.
Need to be more flexible in handling the oauth endpoint.
>
@ConfiguresHttpApi
public class AzureComputeHttpApiModule extends HttpApiModule<AzureComputeApi> {
+ private static final Pattern OAUTH_TENANT_PATTERN = Pattern
+ .compile("https://login.microsoftonline.com/([^/]+)/oauth2/token");
+
```
private static final Pattern OAUTH_TENANT_PATTERN_MICROSOFT_ONLINE = Pattern
.compile("https://login.microsoftonline.com/([^/]+)/oauth2/token");
private static final Pattern OAUTH_TENANT_PATTERN_MICROSOFT = Pattern
.compile("https://login.microsoft.com/([^/]+)/oauth2/token");
```
> bind(OAuthScopes.class).toInstance(OAuthScopes.NoScopes.create());
+
bind(OAuthConfigFactory.class).to(AzureOAuthConfigFactory.class).in(Scopes.SINGLETON);
+ }
+
+ @Provides
+ @Singleton
+ @Tenant
+ protected String provideTenant(@Named("oauth.endpoint") final String
oauthEndpoint) {
+ Matcher m = OAUTH_TENANT_PATTERN.matcher(oauthEndpoint);
+ if (!m.matches()) {
+ throw new IllegalArgumentException("Could not parse tenantId from: "
+ oauthEndpoint);
+ }
+ return m.group(1);
+ }
+
```
protected String provideTenant(@Named("oauth.endpoint") final String
oauthEndpoint) {
Matcher m = OAUTH_TENANT_PATTERN_MICROSOFT_ONLINE.matcher(oauthEndpoint);
if (!m.matches()) {
m = OAUTH_TENANT_PATTERN_MICROSOFT.matcher(oauthEndpoint);
if(!m.matches()) {
throw new IllegalArgumentException("Could not parse tenantId from:
" + oauthEndpoint);
}
}
return m.group(1);
}
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/424#pullrequestreview-80632767