/** * Returns true if legacy XSRF mode is active, otherwise returns false. * * @since 3.0.0 * @deprecated Only provided for legacy reasons, will be removed in 4.0.0 */ @VisibleForTesting @Deprecated boolean inLegacyXsrfMode() { return darkFeatureManager.isFeatureEnabledForAllUsers(LEGACY_FEATURE_KEY); }
/** * This flag decides if we should generate Protobuf derived Plugin modules as well as ModuleDescriptors. This method * allows fallback between the "vertigo ready" and old (deprecated) way of generating module descriptors at installation * time. * @return Whether or not to generate ModulDescriptors using the "vertigo ready" path or not. */ public boolean isVertigoSpiEnabled() { return !darkFeatureManager.isFeatureEnabledForAllUsers(DARKFEATURE_VERTIGO_SPI_DISABLED_KEY); } }
@Override public boolean isInviteToHipChatEnabled() { return !darkFeatureManager.isFeatureEnabledForAllUsers(HIPCHAT_INVITE_DISABLED); } }
@Override protected boolean isConditionTrue() { return darkFeatureManager.isFeatureEnabledForAllUsers(ACJS_VERSION_FEATURE_FLAG); }
public boolean isHipChatSystemUserEnabled() { return darkFeatureManager.isFeatureEnabledForAllUsers(HIPCHAT_SYSTEM_USER_ENABLED); }
/** * This method returns true if Atlasian Connect should start up in a Vertigo way. This includes no database calls * without a tenant and no OSGI registrations. * @return true if vertigo style startup is enabled. */ public boolean isVertigoStartupEnabled() { return isVertigoInstance() || darkFeatureManager.isFeatureEnabledForAllUsers(VERTIGO_STARTUP_ENABLED_KEY); }
private boolean i18nSupportIsEnabled() { return systemPropertyService.isDevMode() || darkFeatureManager.isFeatureEnabledForAllUsers(I18N_DARK_FEATURE); } }
private boolean fetchOnlyPostgres() { return darkFeatureManager.isFeatureEnabledForAllUsers(DARK_FEATURE_FETCH_ONLY_POSTGRES) || vertigoState.isVertigoInstance(); }
@GET @AnonymousAllowed //Not really, we require a valid asap token @Produces("application/json") @Path("client/{clientKey}") public Response getClient(@PathParam("clientKey") String clientKey) { if(this.darkFeatureManager.isFeatureEnabledForAllUsers(ConnectAddonManager.DARK_FEATURE_DISABLE_OAUTH2_IMPERSONATION)) { return notFound; } Optional<ShallowConnectAddon> maybeAddon = this.findConnectAddonByOAuthClientId(clientKey); return maybeAddon.map(this::beanToResponse).orElse(notFound); }
@GET @AnonymousAllowed //Not really, we require a valid asap token @Produces("application/json") @Path("client/{clientKey}") public Response getClient(@PathParam("clientKey") String clientKey) { if(!this.darkFeatureManager.isFeatureEnabledForAllUsers(ConnectAddonManager.DARK_FEATURE_OAUTH2_IMPERSONATION)) { return notFound; } Optional<ConnectAddonBean> maybeAddon = this.findConnectAddonByOAuthClientId(clientKey); return maybeAddon.map(this::beanToResponse).orElse(notFound); }
@Nullable @Override public JwtIssuer getIssuer(@Nonnull final String issuer) { if (!darkFeatureManager.isFeatureEnabledForAllUsers(DelegatingConnectAddonInformationProvider.PLUGIN_SETTINGS_FEATURE_FLAG)) { return null; } return addonRegistry.getSecret(issuer).map((secret) -> new ConnectJwtIssuer(issuer, secret)).orElse(null); } }
public boolean skipDependencies() { final boolean dependenciesEnabledByFeatureFlag = darkFeatureManager.isFeatureEnabledForAllUsers(DARK_FEATURE_ALLOW_DEPENDENCIES); final boolean devMode = systemPropertyService.isDevMode(); final boolean isVertigoMode = vertigoState.isVertigoInstance(); final boolean dependenciesAllowed = dependenciesEnabledByFeatureFlag || devMode || isVertigoMode; final boolean skipDependencies = !dependenciesAllowed; log.debug("skipDependencies: {} ({}: {}; dev mode: {}; vertigo mode: {})", skipDependencies, DARK_FEATURE_ALLOW_DEPENDENCIES, dependenciesEnabledByFeatureFlag, devMode, isVertigoMode); return skipDependencies; }
@Override public boolean isAddonAlreadyInstalled(String addonKey, Optional<ApplicationLink> maybePreviousApplink, AddonSettings previousSettings) { boolean pluginSettingsReturnValue = StringUtils.isNotBlank(previousSettings.getDescriptor()); boolean applinksReturnValue = maybePreviousApplink.isPresent() && StringUtils.isNotBlank(previousSettings.getDescriptor()); boolean featureFlagOn = darkFeatureManager.isFeatureEnabledForAllUsers(PLUGIN_SETTINGS_FEATURE_FLAG); logIfValuesNotEqual(addonKey, pluginSettingsReturnValue, pluginSettingsReturnValue, "isAddonAlreadyInstalled", featureFlagOn); return featureFlagOn ? pluginSettingsReturnValue : applinksReturnValue; }
@Override public ApplicationLinkJwtIssuer getIssuer(@Nonnull String issuer) { if (darkFeatureManager.isFeatureEnabledForAllUsers(CONNECT_PLUGIN_SETTINGS_FEATURE_FLAG)) { return null; } if (issuer == null) { return null; } ApplicationLink link = jwtApplinkFinder.find(issuer); return link == null ? null : new ApplicationLinkJwtIssuer(link); } }
@Test public void systemFeatureDisabledForAllUsers() { assertFeatureDisabled(darkFeatureManager.isFeatureEnabledForAllUsers(DISABLED_FEATURE)); }
@Test public void systemFeatureEnabledForAllUsers() { assertFeatureEnabled(darkFeatureManager.isFeatureEnabledForAllUsers(ENABLED_FEATURE)); }
@Test public void invalidFeatureKeyIsNeverEnabledForAllUsers() { assertInvalidFeatureDisabled(darkFeatureManager.isFeatureEnabledForAllUsers(INVALID_FEATURE_KEY)); }
@Override public Optional<String> getSharedSecret(String addonKey) { Optional<String> pluginSettingsReturnValue = addonRegistry.getSecret(addonKey); Optional<String> applinksReturnValue = applinkManager.getSharedSecretOrPublicKey(applinkManager.getAppLink(addonKey)); boolean featureFlagOn = darkFeatureManager.isFeatureEnabledForAllUsers(PLUGIN_SETTINGS_FEATURE_FLAG); if (featureFlagOn || pluginSettingsReturnValue.isPresent()) { // the shared secret wasn't originally stored in the plugin settings, so only complain if it's going to be // used, or if a different secret has been defined logIfValuesNotEqual(addonKey, pluginSettingsReturnValue, applinksReturnValue, "getSharedSecret", featureFlagOn); } return featureFlagOn ? pluginSettingsReturnValue : applinksReturnValue; }
@Override public Optional<AuthenticationType> getAuthenticationType(String addonKey) { Optional<AuthenticationType> pluginSettingsReturnValue = this.getAuthenticationTypeFromName(addonRegistry.getAddonSettings(addonKey).getAuth()); ApplicationLink appLink = applinkManager.getAppLink(addonKey); Optional<AuthenticationType> applinksReturnValue = ConnectApplinkUtil.getAuthenticationType(appLink); boolean featureFlagOn = darkFeatureManager.isFeatureEnabledForAllUsers(PLUGIN_SETTINGS_FEATURE_FLAG); if (featureFlagOn || pluginSettingsReturnValue.isPresent()) { // add-ons that were installed using an older version of connect did not store the auth type in the // plugin settings, so only complain if the plugin settings version is going to be used, or if a // value has been defined logIfValuesNotEqual(addonKey, pluginSettingsReturnValue, applinksReturnValue, "getAuthenticationType", featureFlagOn); } return featureFlagOn ? pluginSettingsReturnValue : applinksReturnValue; }
@Test public void changeFeatureForAuthenticatedUser() { try { darkFeatureManager.enableFeatureForUser(adminUser(), ADMIN_USER_FEATURE); } catch (UnsupportedOperationException e) { ignoreTest(); } assertTrue("Feature key '" + ADMIN_USER_FEATURE + "' must be enabled for the admin user", darkFeatureManager.isFeatureEnabledForUser(adminUser(), ADMIN_USER_FEATURE)); assertFalse("Feature key '" + ADMIN_USER_FEATURE + "' must be disabled for all users", darkFeatureManager.isFeatureEnabledForAllUsers(ADMIN_USER_FEATURE)); darkFeatureManager.disableFeatureForUser(adminUser(), ADMIN_USER_FEATURE); assertFalse("Feature key '" + ADMIN_USER_FEATURE + "' must be disabled for the admin user", darkFeatureManager.isFeatureEnabledForUser(adminUser(), ADMIN_USER_FEATURE)); }