protected void throwUnknownModuleType(String moduleTypeKey) throws ConnectModuleValidationException { throw new ConnectModuleValidationException( addon, new ConnectModuleMeta<ModuleBean>(moduleTypeKey, ModuleBean.class) { }, "No provider found for module type " + moduleTypeKey + " referenced in the descriptor", "connect.install.error.unknown.module", moduleTypeKey, addon.getKey()); }
public String getKey(ShallowConnectAddonBean 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 validate(ShallowConnectAddonBean addonBean) throws InvalidDescriptorException { // if the baseUrl does not exist or is not a valid URI then schema validation fails and the code never gets here, // so there's no need to check for null, empty-string or not-a-URI URI baseUrl = URI.create(addonBean.getBaseUrl()); if (null == baseUrl.getScheme()) { String message = String.format("Add-on '%s' specifies a 'baseUrl' without a HTTP scheme: please add a scheme (e.g. 'https').", addonBean.getKey()); throw new InvalidDescriptorException(message, "connect.install.error.base_url.no_scheme"); } if (!baseUrl.getScheme().equalsIgnoreCase("https")) { if (!systemPropertyService.isDevMode() && !systemPropertyService.isHttpAllowedMode()) { String message = String.format("Add-on '%s' specifies a 'baseUrl' with the scheme 'http'. Add-ons running " + "in production must be hosted on a domain protected with 'https'", addonBean.getKey()); throw new InvalidDescriptorException(message, "connect.install.error.base_url.no_tls"); } } } }
@Override public void validate(ShallowConnectAddonBean addonBean) throws InvalidDescriptorException { // if the baseUrl does not exist or is not a valid URI then schema validation fails and the code never gets here, // so there's no need to check for null, empty-string or not-a-URI URI baseUrl = URI.create(addonBean.getBaseUrl()); if (null == baseUrl.getScheme()) { String message = String.format("Add-on '%s' specifies a 'baseUrl' without a HTTP scheme: please add a scheme (e.g. 'https').", addonBean.getKey()); throw new InvalidDescriptorException(message, "connect.install.error.base_url.no_scheme"); } if (!baseUrl.getScheme().equalsIgnoreCase("https")) { if (!systemPropertyService.isDevMode() && !systemPropertyService.isHttpAllowedMode()) { String message = String.format("Add-on '%s' specifies a 'baseUrl' with the scheme 'http'. Add-ons running " + "in production must be hosted on a domain protected with 'https'", addonBean.getKey()); throw new InvalidDescriptorException(message, "connect.install.error.base_url.no_tls"); } } } }
@Override public void validate(ShallowConnectAddonBean addonBean) throws InvalidDescriptorException { if (!addonBean.getAddonDependencies().isEmpty() && !dependenciesAreEnabled(addonBean.getKey())) { throw new InvalidDescriptorException( "Add-on dependencies are not enabled, hence the 'dependencies' property is not allowed!", "connect.install.error.dependencies.disabled"); } }
private void validateJsonModuleListEntryAgainstSchema(ConnectModuleProvider<ModuleBean> moduleProvider, ConnectModuleMeta<ModuleBean> moduleMeta, String jsonModuleListEntry) throws ConnectModuleSchemaValidationException { Optional<URL> optionalJsonSchemaResource = moduleProvider.getJsonSchemaResource(); if (optionalJsonSchemaResource.isPresent()) { String modules = String.format("{\"%s\": %s}", moduleMeta.getDescriptorKey(), jsonModuleListEntry); try { descriptorSchemaValidator.assertValidDescriptor(Optional.of(addon.getKey()), modules, optionalJsonSchemaResource.get()); } catch (ConnectJsonSchemaValidationException e) { throw new ConnectModuleSchemaValidationException(addon, moduleMeta, e); } } } }
public ConnectAddonModuleValidationFailedAfterInstallEvent(ConnectModuleValidationException e) { addonKey = e.getAddon().getKey(); moduleType = e.getModuleMeta().getDescriptorKey(); message = e.getMessage(); }
public ConnectAddonModuleValidationFailedAfterInstallEvent(ConnectModuleValidationException e) { addonKey = e.getAddon().getKey(); moduleType = e.getModuleMeta().getDescriptorKey(); message = e.getMessage(); }
@Override public void validate(final ShallowConnectAddonBean addon) throws InvalidDescriptorException { if (addon.getAuthentication().getType() == JWT && !hasInstalledCallback(addon)) { throw new InvalidDescriptorException("The add-on (" + addon.getKey() + ") requested authentication " + "but did not specify an installed lifecycle callback in its descriptor.", "connect.install.error.auth.with.no.installed.callback"); } }
@Override public void validate(final ShallowConnectAddonBean addon) throws InvalidDescriptorException { if (addon.getAuthentication().getType() == JWT && !hasInstalledCallback(addon)) { throw new InvalidDescriptorException("The add-on (" + addon.getKey() + ") requested authentication " + "but did not specify an installed lifecycle callback in its descriptor.", "connect.install.error.auth.with.no.installed.callback"); } }
public String getAbsoluteUrl(ShallowConnectAddonBean addon, String url) { try { URI uri = new URI(url); if (!uri.isAbsolute()) { URI baseUrl = remotablePluginAccessorFactory.get(addon).getBaseUrl(); return new UriBuilder() .setScheme(baseUrl.getScheme()) .setAuthority(baseUrl.getAuthority()) .setPath(uri.getPath()) .setQuery(uri.getQuery()) .setFragment(uri.getFragment()) .toString(); } return url; } catch (URISyntaxException e) { throw new PluginParseException("Malformed url declared by " + addon.getKey() + ": " + url, e); } } }
private void validateCondition(Plugin plugin, ShallowConnectAddonBean addon, ConnectModuleMeta<?> moduleMeta, SingleConditionBean singleCondition) throws ConnectModuleValidationException { Optional<Class<? extends Condition>> optionalConditionClass = conditionClassAccessor.getConditionClassForHostContext(singleCondition); if (optionalConditionClass.isPresent()) { Class<? extends Condition> conditionClass = optionalConditionClass.get(); Condition condition = null; try { condition = webInterfaceManager.getWebFragmentHelper().loadCondition(conditionClass.getName(), plugin); } catch (ConditionLoadingException e) { String message = String.format("The condition %s (%s) could not be loaded", singleCondition.getCondition(), conditionClass.getSimpleName()); rethrowAsModuleValidationException(e, addon, moduleMeta, message, null); } Map<String, String> parameters = conditionModuleFragmentFactory.getFragmentParameters(addon.getKey(), singleCondition); try { condition.init(parameters); } catch (PluginParseException e) { String message = String.format("Invalid parameters provided for condition %s (%s)", singleCondition.getCondition(), conditionClass.getSimpleName()); rethrowAsModuleValidationException(e, addon, moduleMeta, message, "connect.install.error.invalid.condition.parameters", singleCondition.getCondition(), e.getLocalizedMessage()); } catch (Throwable e) { String message = String.format("An error occurred when initializing condition %s (%s)", singleCondition.getCondition(), conditionClass.getSimpleName()); rethrowAsModuleValidationException(e, addon, moduleMeta, message, null); } } }
private void validateCondition(Plugin plugin, ShallowConnectAddonBean addon, ConnectModuleMeta<?> moduleMeta, SingleConditionBean singleCondition) throws ConnectModuleValidationException { Optional<Class<? extends Condition>> optionalConditionClass = conditionClassAccessor.getConditionClassForHostContext(singleCondition); if (optionalConditionClass.isPresent()) { Class<? extends Condition> conditionClass = optionalConditionClass.get(); Condition condition = null; try { condition = webInterfaceManager.getWebFragmentHelper().loadCondition(conditionClass.getName(), plugin); } catch (ConditionLoadingException e) { String message = String.format("The condition %s (%s) could not be loaded", singleCondition.getCondition(), conditionClass.getSimpleName()); rethrowAsModuleValidationException(e, addon, moduleMeta, message, null); } Map<String, String> parameters = conditionModuleFragmentFactory.getFragmentParameters(addon.getKey(), singleCondition); try { condition.init(parameters); } catch (PluginParseException e) { String message = String.format("Invalid parameters provided for condition %s (%s)", singleCondition.getCondition(), conditionClass.getSimpleName()); rethrowAsModuleValidationException(e, addon, moduleMeta, message, "connect.install.error.invalid.condition.parameters", singleCondition.getCondition(), e.getLocalizedMessage()); } catch (Throwable e) { String message = String.format("An error occurred when initializing condition %s (%s)", singleCondition.getCondition(), conditionClass.getSimpleName()); rethrowAsModuleValidationException(e, addon, moduleMeta, message, null); } } }
try { final URI callbackUri = getURI(addon.getBaseUrl(), addon.getLifecycle().getUninstalled()); callSyncHandler(addon.getKey(), addonUsesJwtAuthentication(addon), callbackUri,
public ConnectAddonBeanBuilder(ShallowConnectAddonBean defaultBean) { this.key = defaultBean.getKey(); this.name = defaultBean.getName(); this.version = defaultBean.getVersion(); this.apiVersion = defaultBean.getApiVersion(); this.description = defaultBean.getDescription(); this.vendor = defaultBean.getVendor(); this.links = defaultBean.getLinks(); this.lifecycle = defaultBean.getLifecycle(); this.baseUrl = defaultBean.getBaseUrl(); this.authentication = defaultBean.getAuthentication(); this.scopes = defaultBean.getScopes(); this.enableLicensing = defaultBean.getEnableLicensing(); }
public ConnectAddonBeanBuilder(ShallowConnectAddonBean defaultBean) { this.key = defaultBean.getKey(); this.dependencies = defaultBean.getDependencies(); this.name = defaultBean.getName(); this.version = defaultBean.getVersion(); this.apiVersion = defaultBean.getApiVersion(); this.description = defaultBean.getDescription(); this.vendor = defaultBean.getVendor(); this.links = defaultBean.getLinks(); this.lifecycle = defaultBean.getLifecycle(); this.baseUrl = defaultBean.getBaseUrl(); this.authentication = defaultBean.getAuthentication(); this.scopes = defaultBean.getScopes(); this.enableLicensing = defaultBean.getEnableLicensing(); this.translations = defaultBean.getTranslations(); }