@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage .forCondition("OAuth JWT Condition"); Environment environment = context.getEnvironment(); String keyValue = environment .getProperty("security.oauth2.resource.jwt.key-value"); String keyUri = environment .getProperty("security.oauth2.resource.jwt.key-uri"); if (StringUtils.hasText(keyValue) || StringUtils.hasText(keyUri)) { return ConditionOutcome .match(message.foundExactly("provided public key")); } return ConditionOutcome .noMatch(message.didNotFind("provided public key").atAll()); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { String[] enablers = context.getBeanFactory() .getBeanNamesForAnnotation(EnableOAuth2Sso.class); ConditionMessage.Builder message = ConditionMessage .forCondition("@EnableOAuth2Sso Condition"); for (String name : enablers) { if (context.getBeanFactory().isTypeMatch(name, WebSecurityConfigurerAdapter.class)) { return ConditionOutcome.match(message .found("@EnableOAuth2Sso annotation on WebSecurityConfigurerAdapter") .items(name)); } } return ConditionOutcome.noMatch(message.didNotFind( "@EnableOAuth2Sso annotation " + "on any WebSecurityConfigurerAdapter") .atAll()); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { final RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(), "holon.swagger."); if (!resolver.getProperty("holon.swagger.enabled", boolean.class, true)) { return ConditionOutcome.noMatch(ConditionMessage.forCondition("SwaggerApiAutoDetectCondition") .because("holon.swagger.enabled is false")); } if (resolver.containsProperty("resourcePackage")) { return ConditionOutcome.noMatch( ConditionMessage.forCondition("SwaggerApiAutoDetectCondition").available("resourcePackage")); } Map<String, Object> ag = resolver.getSubProperties("apiGroups"); if (ag != null && ag.size() > 0) { return ConditionOutcome .noMatch(ConditionMessage.forCondition("SwaggerApiAutoDetectCondition").available("apiGroups")); } return ConditionOutcome.match(); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage .forCondition("EmbeddedDataSource"); if (anyMatches(context, metadata, this.pooledCondition)) { return ConditionOutcome .noMatch(message.foundExactly("supported pooled data source")); } EmbeddedDatabaseType type = EmbeddedDatabaseConnection .get(context.getClassLoader()).getType(); if (type == null) { return ConditionOutcome .noMatch(message.didNotFind("embedded database").atAll()); } return ConditionOutcome.match(message.found("embedded database").items(type)); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage .forCondition("DataSourceAvailable"); if (hasBean(context, DataSource.class) || hasBean(context, XADataSource.class)) { return ConditionOutcome .match(message.foundExactly("existing data source bean")); } if (anyMatches(context, metadata, this.pooledCondition, this.embeddedCondition)) { return ConditionOutcome.match(message .foundExactly("existing auto-configured data source bean")); } return ConditionOutcome .noMatch(message.didNotFind("any existing data source bean").atAll()); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { Map<String, Object> attributes = metadata.getAnnotationAttributes(ConditionalOnPropertyPrefix.class.getName()); if (attributes.containsKey("value")) { String prefix = (String) attributes.get("value"); if (prefix != null && !prefix.trim().equals("")) { final String propertyPrefix = !prefix.endsWith(".") ? prefix + "." : prefix; ConfigPropertyProvider configPropertyProvider = EnvironmentConfigPropertyProvider .create(context.getEnvironment()); Set<String> names = configPropertyProvider.getPropertyNames() .filter((n) -> n.startsWith(propertyPrefix)).collect(Collectors.toSet()); if (!names.isEmpty()) { return ConditionOutcome.match(); } return ConditionOutcome.noMatch( ConditionMessage.forCondition(ConditionalOnPropertyPrefix.class).notAvailable(propertyPrefix)); } } return ConditionOutcome.match(); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata md) { String sourceClass = ""; if (md instanceof ClassMetadata) { sourceClass = ((ClassMetadata) md).getClassName(); } ConditionMessage.Builder message = ConditionMessage.forCondition("ZipkinSender", sourceClass); String property = context.getEnvironment() .getProperty("spring.zipkin.sender.type"); if (StringUtils.isEmpty(property)) { return ConditionOutcome.match(message.because("automatic sender type")); } String senderType = getType(((AnnotationMetadata) md).getClassName()); if (property.equals(senderType)) { return ConditionOutcome.match(message.because(property + " sender type")); } return ConditionOutcome.noMatch(message.because(property + " sender type")); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { Map<String, Object> attributes = metadata.getAnnotationAttributes(ConditionalOnOperatingSystem.class.getName()); OperatingSystem operatingSystem = (OperatingSystem) attributes.get("value"); ConditionMessage.Builder message = ConditionMessage.forCondition(ConditionalOnOperatingSystem.class); String name = operatingSystem.name(); if (operatingSystem == OperatingSystem.WINDOWS && SystemInformation.INSTANCE.isWindows()) { return ConditionOutcome.match(message.foundExactly(name)); } if (operatingSystem == OperatingSystem.UNIX && SystemInformation.INSTANCE.isUnix()) { return ConditionOutcome.match(message.foundExactly(name)); } return ConditionOutcome.noMatch(message.didNotFind(name).atAll()); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage .forCondition("OAuth TokenInfo Condition"); Environment environment = context.getEnvironment(); Boolean preferTokenInfo = environment.getProperty( "security.oauth2.resource.prefer-token-info", Boolean.class); if (preferTokenInfo == null) { preferTokenInfo = environment .resolvePlaceholders("${OAUTH2_RESOURCE_PREFERTOKENINFO:true}") .equals("true"); } String tokenInfoUri = environment .getProperty("security.oauth2.resource.token-info-uri"); String userInfoUri = environment .getProperty("security.oauth2.resource.user-info-uri"); if (!StringUtils.hasLength(userInfoUri) && !StringUtils.hasLength(tokenInfoUri)) { return ConditionOutcome .match(message.didNotFind("user-info-uri property").atAll()); } if (StringUtils.hasLength(tokenInfoUri) && preferTokenInfo) { return ConditionOutcome .match(message.foundExactly("preferred token-info-uri property")); } return ConditionOutcome.noMatch(message.didNotFind("token info").atAll()); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage .forCondition("OAuth JWK Condition"); Environment environment = context.getEnvironment(); String keyUri = environment .getProperty("security.oauth2.resource.jwk.key-set-uri"); if (StringUtils.hasText(keyUri)) { return ConditionOutcome .match(message.foundExactly("provided jwk key set URI")); } return ConditionOutcome .noMatch(message.didNotFind("key jwk set URI not provided").atAll()); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { String clientId = context.getEnvironment() .getProperty("security.oauth2.client.client-id"); ConditionMessage.Builder message = ConditionMessage .forCondition("OAuth Client ID"); if (StringUtils.hasLength(clientId)) { return ConditionOutcome.match(message .foundExactly("security.oauth2.client.client-id property")); } return ConditionOutcome.noMatch(message .didNotFind("security.oauth2.client.client-id property").atAll()); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { AnnotationAttributes attributes = AnnotationAttributes .fromMap(metadata.getAnnotationAttributes(ConditionalOnEnabledDetector.class.getName())); final String name = attributes.getString("value"); final String prefix = attributes.getString("prefix"); RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(), prefix + "." + name + "."); Boolean enabled = resolver.getProperty("enabled", Boolean.class, true); return new ConditionOutcome(enabled, ConditionMessage.forCondition(ConditionalOnEnabledDetector.class, name) .because(enabled ? "enabled" : "disabled")); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage.forCondition("FlexyPoolConfigurationAvailable"); String propertiesFilePath = System.getProperty(PropertyLoader.PROPERTIES_FILE_PATH); if (propertiesFilePath != null && ClassLoaderUtils.getResource(propertiesFilePath) != null) { return ConditionOutcome.match(message.found("FlexyPool configuration file").items(propertiesFilePath)); } if (ClassLoaderUtils.getResource(PropertyLoader.PROPERTIES_FILE_NAME) != null) { return ConditionOutcome.match(message.found("FlexyPool configuration file").items(PropertyLoader.PROPERTIES_FILE_NAME)); } return ConditionOutcome.noMatch(message.didNotFind("FlexyPool configuration file").atAll()); }
@Override public ConditionOutcome getMatchOutcome( ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) { boolean groupEnabled = isEnabled(conditionContext, "camel.component.", true); ConditionMessage.Builder message = ConditionMessage .forCondition("camel.component.syndesis-http"); if (isEnabled(conditionContext, "camel.component.syndesis-http.", groupEnabled)) { return ConditionOutcome.match(message.because("enabled")); } return ConditionOutcome.noMatch(message.because("not enabled")); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage .forCondition("PooledDataSource"); if (getDataSourceClassLoader(context) != null) { return ConditionOutcome .match(message.foundExactly("supported DataSource")); } return ConditionOutcome .noMatch(message.didNotFind("supported DataSource").atAll()); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage.forCondition("OpenID Session Management Condition"); Environment environment = context.getEnvironment(); boolean enabled = environment.getProperty("op.session-management.enabled", Boolean.class, false); if (enabled) { return ConditionOutcome.match(message.found("property", "properties") .items(ConditionMessage.Style.QUOTE, "op.session-management.enabled")); } else { return ConditionOutcome.noMatch(message.didNotFind("property", "properties") .items(ConditionMessage.Style.QUOTE, "op.session-management.enabled")); } }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage.forCondition("OpenID Front-Channel Logout Condition"); Environment environment = context.getEnvironment(); boolean enabled = environment.getProperty("op.front-channel-logout.enabled", Boolean.class, false); if (enabled) { return ConditionOutcome.match(message.found("property", "properties") .items(ConditionMessage.Style.QUOTE, "op.front-channel-logout.enabled")); } else { return ConditionOutcome.noMatch(message.didNotFind("property", "properties") .items(ConditionMessage.Style.QUOTE, "op.front-channel-logout.enabled")); } }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage matchMessage = ConditionMessage.empty(); boolean enabled = isSpringSecurityEnabled(context); if (metadata.isAnnotated(ConditionalOnJuiserSpringSecurityEnabled.class.getName())) { if (!enabled) { return ConditionOutcome.noMatch( ConditionMessage.forCondition(ConditionalOnJuiserSpringSecurityEnabled.class) .didNotFind("spring security enabled").atAll()); } matchMessage = matchMessage.andCondition(ConditionalOnJuiserSpringSecurityEnabled.class) .foundExactly("spring security enabled"); } if (metadata.isAnnotated(ConditionalOnJuiserSpringSecurityDisabled.class.getName())) { if (enabled) { return ConditionOutcome.noMatch( ConditionMessage.forCondition(ConditionalOnJuiserSpringSecurityDisabled.class) .didNotFind("spring security disabled").atAll()); } matchMessage = matchMessage.andCondition(ConditionalOnJuiserSpringSecurityDisabled.class) .didNotFind("spring security disabled").atAll(); } return ConditionOutcome.match(matchMessage); }
@Override public ConditionOutcome getMatchOutcome( final ConditionContext context, final AnnotatedTypeMetadata metadata) { final boolean endpointsEnabled = isEnabled(context, "endpoints.", true); final ConditionMessage.Builder message = ConditionMessage.forCondition("Failsafe"); if (isEnabled(context, "endpoints.failsafe.", endpointsEnabled)) { return ConditionOutcome.match(message.because("enabled")); } return ConditionOutcome.noMatch(message.because("not enabled")); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage .forCondition("OAuth ResourceServer Condition"); Environment environment = context.getEnvironment(); if (!(environment instanceof ConfigurableEnvironment)) { return ConditionOutcome .noMatch(message.didNotFind("A ConfigurableEnvironment").atAll()); } if (hasOAuthClientId(environment)) { return ConditionOutcome.match(message.foundExactly("client-id property")); } Binder binder = Binder.get(environment); String prefix = "security.oauth2.resource."; if (binder.bind(prefix + "jwt", STRING_OBJECT_MAP).isBound()) { return ConditionOutcome .match(message.foundExactly("JWT resource configuration")); } if (binder.bind(prefix + "jwk", STRING_OBJECT_MAP).isBound()) { return ConditionOutcome .match(message.foundExactly("JWK resource configuration")); } if (StringUtils.hasText(environment.getProperty(prefix + "user-info-uri"))) { return ConditionOutcome .match(message.foundExactly("user-info-uri property")); } if (StringUtils.hasText(environment.getProperty(prefix + "token-info-uri"))) { return ConditionOutcome .match(message.foundExactly("token-info-uri property")); } if (ClassUtils.isPresent(AUTHORIZATION_ANNOTATION, null)) { if (AuthorizationServerEndpointsConfigurationBeanCondition .matches(context)) { return ConditionOutcome.match( message.found("class").items(AUTHORIZATION_ANNOTATION)); } } return ConditionOutcome.noMatch( message.didNotFind("client ID, JWT resource or authorization server") .atAll()); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext aContext, AnnotatedTypeMetadata aMetadata) { String property = aContext.getEnvironment().getProperty("piper.worker.enabled"); boolean result = Boolean.valueOf(property); return new ConditionOutcome(result,ConditionMessage.forCondition(ConditionalOnWorker.class, "(" + getClass().getName() + ")").resultedIn(result)); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext aContext, AnnotatedTypeMetadata aMetadata) { String property = aContext.getEnvironment().getProperty("piper.coordinator.enabled"); boolean result = Boolean.valueOf(property); return new ConditionOutcome(result,ConditionMessage.forCondition(ConditionalOnCoordinator.class, "(" + getClass().getName() + ")").resultedIn(result)); }