private OAuth2SpecInfo lookupSpecInfo(final SecurityToken securityToken,
final OAuth2Arguments arguments, final Uri gadgetUri) throws OAuth2RequestException {
log.entering(CLASS, "lookupSpecInfo", new Object[] { securityToken, arguments, gadgetUri });
final GadgetSpec spec = this.findSpec(securityToken, arguments, gadgetUri);
final OAuth2Spec oauthSpec = spec.getModulePrefs().getOAuth2Spec();
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) {