private Set<ScopeName> getScopeReferences(String pluginKey) { Optional<ConnectAddonBean> optionalAddon = addonAccessor.getAddon(pluginKey); if (!optionalAddon.isPresent()) { throw new IllegalStateException(String.format("The Connect Add-on Registry has no descriptor for add-on '%s' and therefore we cannot compute its scopes!", pluginKey)); } return Sets.newHashSet(Iterables.concat(optionalAddon.get().getScopes(), Collections.singleton(ScopeName.NONE))); }
private Response beanToResponse(ConnectAddonBean bean) { String addonKey = bean.getKey(); List<String> scopes = bean.getScopes().stream().map(ScopeName::toString).collect(Collectors.toList()); Optional<String> maybeSecret = this.connectAddonInfoProvider.getSharedSecret(addonKey); return maybeSecret.map(secret -> Response.ok(new RestOAuth2Client(addonKey, secret, scopes)).build()) .orElse(notFound); }
private String provisionAddonUserAndScopes(ConnectAddonBean addon, Optional<String> maybePreviousDescriptor) throws PluginInstallException, ConnectAddonInstallException { final Set<ScopeName> newScopes = addon.getScopes(); final Set<ScopeName> previousScopes = maybePreviousDescriptor .map(desc -> connectAddonBeanFactory.fromJson(desc).getScopes()) .orElse(ImmutableSet.of()); try { return connectUserService.provisionAddonUserWithScopes(addon, previousScopes, newScopes); } catch (ConnectAddonInitException e) { throw new ConnectAddonInstallException(e.getMessage(), e, e.getI18nKey(), addon.getName()); } } }
private String provisionAddonUserAndScopes(ConnectAddonBean addon, String previousDescriptor) throws PluginInstallException, ConnectAddonInstallException { Set<ScopeName> previousScopes = Sets.newHashSet(); Set<ScopeName> newScopes = addon.getScopes(); if (StringUtils.isNotBlank(previousDescriptor)) { ConnectAddonBean previousAddon = connectAddonBeanFactory.fromJson(previousDescriptor); previousScopes = previousAddon.getScopes(); } try { return connectUserService.provisionAddonUserWithScopes(addon, previousScopes, newScopes); } catch (ConnectAddonInitException e) { throw new ConnectAddonInstallException(e.getMessage(), e, e.getI18nKey(), addon.getName()); } } }
newUseSharedSecret, maybePreviousClient); final Optional<OAuthClient> scopeFilteredOAuthClient = stripOAuthClientIdForAddonWithoutScope(addon.getScopes(), newOAuthClient);