private boolean hasGrant(ConnectAddonBean addonBean) { return AUTHORISED_ADD_ON_KEYS.contains(addonBean.getKey()); } }
private RemotablePluginAccessor get(ConnectAddonBean addon) { // this will potentially create multiple instances if called quickly, but we don't really // care as they shouldn't be cached final RemotablePluginAccessor accessor; if (accessors.containsKey(addon.getKey())) { accessor = accessors.get(addon.getKey()); } else { accessor = create(addon, getDisplayUrl(addon)); accessors.put(addon.getKey(), accessor); } return accessor; }
public ConnectAddonSerializeFailedEvent(ConnectAddonBean addon, ConnectModuleMeta meta, Collection<?> beans, boolean isEventExpected) { super(addon.getKey()); descriptorKey = meta.getDescriptorKey(); moduleBeanCount = beans.size(); isExpectedException = isEventExpected; }
public String getKey(ConnectAddonBean addon) { checkState(!Strings.isNullOrEmpty(key), "Modules cannot contain empty or null keys."); if (Strings.isNullOrEmpty(calculatedKey)) { this.calculatedKey = addonAndModuleKey(addon.getKey(), key); } return calculatedKey; }
@Override public void deleteAppLink(final ConnectAddonBean addon) throws NotConnectAddonException { final String key = addon.getKey(); deleteAppLink(key); }
public ConnectAddonDeserializeFailedEvent(ConnectAddonBean addon, ConnectModuleMeta meta, Collection<?> beans, boolean isExpectedException, String deserializerIdentifier) { super(addon.getKey()); descriptorKey = meta.getDescriptorKey(); moduleBeanCount = beans.size(); this.isExpectedException = isExpectedException; this.deserializerIdentifier = deserializerIdentifier; }
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); }
@Override public void acceptModuleValidationCause(ConnectModuleValidationException cause) { super.acceptModuleValidationCause(cause); String message = String.format("Descriptor validation failed while enabling add-on %s, skipping", addon.getKey()); throw new ConnectModuleRegistrationException(message, cause); } }
@Override public void acceptModuleValidationCause(ConnectModuleValidationException cause) { super.acceptModuleValidationCause(cause); String message = String.format("Descriptor validation failed while enabling add-on %s, skipping", addon.getKey()); throw new ConnectModuleRegistrationException(message, cause); } }
private void addPluginInfoParameterForPageIfDeclared(PluginInformation pluginInfo, String parameterKey, ConnectAddonBean addon, String moduleType) { Optional<List<ModuleBean>> optionalPages = addon.getModules().getValidModuleListOfType( moduleType, moduleValidationExceptionHandler); optionalPages.ifPresent(moduleBeans -> { ConnectPageModuleBean page = (ConnectPageModuleBean) moduleBeans.get(0); if (null != page && !Strings.isNullOrEmpty(page.getUrl())) { pluginInfo.addParameter(parameterKey, ConnectIFrameServletPath.forModule(addon.getKey(), page.getRawKey())); } }); } }
private Collection<TypedPluginModule> serializeConnectIframes(ConnectPageModuleBean module, ConnectAddonBean addon) { String pageIframePluginModuleKey = ConnectIFrameModuleDescriptorGenerator.getModuleKey(addon.getKey(), module.getRawKey(), Optional.empty()); TypedPluginModule pageIframePluginModule = TypedPluginModule.of(ConnectIFrame.IFRAME_PLUGIN_MODULE_DESERIALIZER_IDENTIFIER, pageIframePluginModuleKey, createPageIFrame(module, addon).serialize()); String rawIframepluginModuleKey = ConnectIFrameModuleDescriptorGenerator.getModuleKey(addon.getKey(), module.getRawKey(), Optional.of(RAW_CLASSIFIER)); TypedPluginModule rawIframePluginModule = TypedPluginModule.of(ConnectIFrame.IFRAME_PLUGIN_MODULE_DESERIALIZER_IDENTIFIER, rawIframepluginModuleKey, createRawIFrame(module, addon).serialize()); return ImmutableList.of(pageIframePluginModule, rawIframePluginModule); }
private static TenantPluginModuleProtos.PluginModule toStorage(ConnectModuleProvider.TypedPluginModule typedPluginModule, ConnectAddonBean addon) { return TenantPluginModuleProtos.PluginModule.newBuilder() .setAddonKey(addon.getKey()) .setPluginModuleKey(typedPluginModule.getPluginModuleKey()) .setData(ByteString.copyFrom(typedPluginModule.getStoredData())) .build(); }
private static TenantPluginModuleProtos.PluginModule toStorage(TypedPluginModule typedPluginModule, ConnectAddonBean addon) { return TenantPluginModuleProtos.PluginModule.newBuilder() .setAddonKey(addon.getKey()) .setPluginModuleKey(typedPluginModule.getPluginModuleKey()) .setData(ByteString.copyFrom(typedPluginModule.getStoredData())) .build(); }
private void requestInstallCallback(ConnectAddonBean addon, Optional<OAuthClient> oauthClient, final boolean sign) throws ConnectAddonInstallException { final URI callbackUri = getURI(addon.getBaseUrl(), addon.getLifecycle().getInstalled()); final Optional<String> authHeader = sign ? getAuthHeader(callbackUri, remotablePluginAccessorFactory.get(addon.getKey()).getAuthorizationGenerator()) : Optional.<String>empty(); requestInstallCallback(addon, oauthClient, callbackUri, authHeader); }
@Override public ModuleDescriptor<RedirectData> createModuleDescriptor(RedirectDataBean bean, ConnectAddonBean addon) { Element redirectDataModule = new DOMElement("redirect-data"); redirectDataModule.addAttribute("key", RedirectDataModuleDescriptor.getModuleKey(addon.getKey(), bean.getModuleKey())); RedirectDataModuleDescriptor redirectDataModuleDescriptor = new RedirectDataModuleDescriptor(moduleFactory, bean.getRedirectData()); redirectDataModuleDescriptor.init(pluginRetrievalService.getPlugin(), redirectDataModule); return redirectDataModuleDescriptor; } }
@Override public ModuleDescriptor<RedirectData> createModuleDescriptor(RedirectDataBean bean, ConnectAddonBean addon) { Element redirectDataModule = new DOMElement("redirect-data"); redirectDataModule.addAttribute("key", RedirectDataModuleDescriptor.getModuleKey(addon.getKey(), bean.getModuleKey())); RedirectDataModuleDescriptor redirectDataModuleDescriptor = new RedirectDataModuleDescriptor(moduleFactory, bean.getRedirectData()); redirectDataModuleDescriptor.init(pluginRetrievalService.getPlugin(), redirectDataModule); return redirectDataModuleDescriptor; } }
@Override public ModuleDescriptor<ConnectIFrame> createModuleDescriptor(ConnectIFrameBean bean, ConnectAddonBean addon) { ConnectIFrameModuleDescriptor iFrameModuleDescriptor = new ConnectIFrameModuleDescriptor(moduleFactory, bean.getconnectIFrame()); Element iFrameModule = new DOMElement("connect-iframe"); iFrameModule.addAttribute("key", ConnectIFrameModuleDescriptor.getModuleKey(addon.getKey(), bean.getModuleKey(), bean.getClassifier())); iFrameModuleDescriptor.init(pluginRetrievalService.getPlugin(), iFrameModule); return iFrameModuleDescriptor; } }
private ConnectIFrame createRawIFrame(ConnectPageModuleBean page, ConnectAddonBean connectAddonBean) { return connectIFrameBuilderFactory.builder() .addon(connectAddonBean.getKey()) .module(page.getRawKey()) .genericBodyTemplate() .urlTemplate(page.getUrl()) .title(page.getDisplayName()) .conditions(getPageAndAdditionalConditions(page)) .dimensions("100%", "100%") // the client (js) will size the parent of the iframe .build(); }
private ConnectIFrame createPageIFrame(ConnectPageModuleBean page, ConnectAddonBean connectAddonBean) { return connectIFrameBuilderFactory.builder() .addon(connectAddonBean.getKey()) .module(page.getRawKey()) .pageTemplate() .urlTemplate(page.getUrl()) .decorator(getDecorator()) .conditions(getPageAndAdditionalConditions(page)) .title(page.getDisplayName()) .resizeToParent(true) .build(); }