private boolean isJsonJwtAddon(ConnectAddonBean addonBean) { return addonBean.getAuthentication() != null && addonBean.getAuthentication().getType() == AuthenticationType.JWT; }
private static boolean addonRequiresAuth(ConnectAddonBean addon) { return addon.getAuthentication() != null && !AuthenticationType.NONE.equals(addon.getAuthentication().getType()); }
private static boolean addonUsesJwtAuthentication(ConnectAddonBean addon) { return null != addon.getAuthentication() && AuthenticationType.JWT.equals(addon.getAuthentication().getType()); }
public String provisionUserIfNecessary(ConnectAddonBean addon, Optional<String> maybePreviousDescriptor) throws ConnectAddonInstallException { return addonRequiresAuth(addon.getAuthentication()) ? provisionAddonUserAndScopes(addon, maybePreviousDescriptor) : null; }
private boolean addonUsesSymmetricSharedSecret(ConnectAddonBean addonBean, SigningAlgorithm jwtAlgorithm) { AuthenticationBean authenticationBean = addonBean.getAuthentication(); return null != authenticationBean && addonUsesSymmetricSharedSecret(authenticationBean.getType(), jwtAlgorithm); }
private void enableSingleConnectAddon(final String pluginKey) throws ConnectAddonInitException, ConnectAddonEnableException, TranslationsDownloadException { long startTime = System.currentTimeMillis(); if (addonRegistry.hasDescriptor(pluginKey)) { ConnectAddonBean addon; try { addon = connectAddonAccessor.getAddon(pluginKey).get(); moduleReconfigurationBatcher.runBatched(() -> beanToModuleRegistrar.registerDescriptorsForBeans(addon)); } catch (InvalidDescriptorException | ConnectModuleRegistrationException e) { addonEventManager.publishEnableFailedEvent(pluginKey, e.getMessage()); throw new ConnectAddonEnableException(pluginKey, "Module registration failed while enabling add-on, skipping.", e); } if (addonRequiresAuth(addon.getAuthentication())) { connectUserService.getOrCreateAddonUserName(addon); } addonRegistry.storeRestartState(pluginKey, PluginState.ENABLED); try { addonEventManager.publishEnabledEvent(pluginKey); } catch (Exception e) { log.warn(String.format("Could not fire enabled webhook event for add-on %s, continuing anyway", pluginKey), e); } long endTime = System.currentTimeMillis(); log.info("Connect addon '" + addon.getKey() + "' enabled in " + (endTime - startTime) + "ms"); } else { String message = "Tried to enable add-on before it was installed."; addonEventManager.publishEnableFailedEvent(pluginKey, message); throw new ConnectAddonEnableException(pluginKey, message); } }
String previousDescriptor = addonRegistry.getDescriptor(pluginKey); AuthenticationType newAuthType = addon.getAuthentication().getType(); final boolean newUseSharedSecret = addonUsesSymmetricSharedSecret(newAuthType, JWT_ALGORITHM); final Optional<OAuthClient> newOAuthClient = getUpdatedOAuthClient(pluginKey, addon.getAuthentication().getPublicKey(); // the key stored on the applink: used to sign outgoing requests and verify incoming requests
final Optional<String> maybePreviousDescriptor = addonRegistry.getDescriptor(pluginKey); final AuthenticationType newAuthType = addon.getAuthentication().getType(); final boolean newUseSharedSecret = addonUsesSymmetricSharedSecret(newAuthType, JWT_ALGORITHM);