if (oauthSpec == null) {
throw new OAuth2RequestException(OAuth2Error.LOOKUP_SPEC_PROBLEM,
"Failed to retrieve OAuth URLs, spec for gadget " + securityToken.getAppUrl()
+ " does not contain OAuth element.", null);
}
final OAuth2Service service = oauthSpec.getServices().get(arguments.getServiceName());
if (service == null) {
throw new OAuth2RequestException(OAuth2Error.LOOKUP_SPEC_PROBLEM,
"Failed to retrieve OAuth URLs, spec for gadget does not contain OAuth service "
+ arguments.getServiceName() + ". Known services: "
+ Joiner.on(',').join(oauthSpec.getServices().keySet()) + '.', null);
}
String authorizationUrl = null;
final EndPoint authorizationUrlEndpoint = service.getAuthorizationUrl();
if (authorizationUrlEndpoint != null) {
authorizationUrl = authorizationUrlEndpoint.url.toString();
}
String tokenUrl = null;
final EndPoint tokenUrlEndpoint = service.getTokenUrl();
if (tokenUrlEndpoint != null) {
tokenUrl = tokenUrlEndpoint.url.toString();
}
final OAuth2SpecInfo ret = new OAuth2SpecInfo(authorizationUrl, tokenUrl, service.getScope());
if (isLogging) {
GadgetOAuth2TokenStore.LOG.exiting(GadgetOAuth2TokenStore.LOG_CLASS, "lookupSpecInfo", ret);
}