@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());
}
java类org.springframework.boot.autoconfigure.condition.ConditionOutcome的实例源码
ResourceServerTokenServicesConfiguration.java 文件源码
项目:spring-security-oauth2-boot
阅读 37
收藏 0
点赞 0
评论 0
EnableOAuth2SsoCondition.java 文件源码
项目:spring-security-oauth2-boot
阅读 32
收藏 0
点赞 0
评论 0
@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());
}
VaultConnectorBootstrapConfiguration.java 文件源码
项目:spring-cloud-vault-connector
阅读 37
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
CloudFactory cloudFactory = new CloudFactory();
try {
Cloud cloud = cloudFactory.getCloud();
List<ServiceInfo> serviceInfos = cloud.getServiceInfos();
for (ServiceInfo serviceInfo : serviceInfos) {
if (serviceInfo instanceof VaultServiceInfo) {
return ConditionOutcome.match(String.format(
"Found Vault service %s", serviceInfo.getId()));
}
}
return ConditionOutcome.noMatch("No Vault service found");
}
catch (CloudException e) {
return ConditionOutcome.noMatch("Not running in a Cloud");
}
}
SwaggerApiAutoDetectCondition.java 文件源码
项目:holon-jaxrs
阅读 29
收藏 0
点赞 0
评论 0
@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();
}
DataSourceAutoConfiguration.java 文件源码
项目:spring-boot-multidatasource
阅读 34
收藏 0
点赞 0
评论 0
@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));
}
DataSourceAutoConfiguration.java 文件源码
项目:spring-boot-multidatasource
阅读 35
收藏 0
点赞 0
评论 0
@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());
}
OnPropertyPrefixCondition.java 文件源码
项目:holon-core
阅读 33
收藏 0
点赞 0
评论 0
@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();
}
PrefixPropertyCondition.java 文件源码
项目:loc-framework
阅读 31
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
String prefix = (String) attribute(metadata, "prefix");
Class<?> value = (Class<?>) attribute(metadata, "value");
ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment();
try {
new Binder(ConfigurationPropertySources.from(environment.getPropertySources()))
.bind(prefix, Bindable.of(value))
.orElseThrow(
() -> new FatalBeanException("Could not bind DataSourceSettings properties"));
return new ConditionOutcome(true, String.format("Map property [%s] is not empty", prefix));
} catch (Exception e) {
//ignore
}
return new ConditionOutcome(false, String.format("Map property [%s] is empty", prefix));
}
EndpointWebMvcManagementContextConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 29
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
Environment environment = context.getEnvironment();
String config = environment.resolvePlaceholders("${logging.file:}");
if (StringUtils.hasText(config)) {
return ConditionOutcome.match("Found logging.file: " + config);
}
config = environment.resolvePlaceholders("${logging.path:}");
if (StringUtils.hasText(config)) {
return ConditionOutcome.match("Found logging.path: " + config);
}
config = new RelaxedPropertyResolver(environment, "endpoints.logfile.")
.getProperty("external-file");
if (StringUtils.hasText(config)) {
return ConditionOutcome
.match("Found endpoints.logfile.external-file: " + config);
}
return ConditionOutcome.noMatch("Found no log file configuration");
}
AutoConfigurationReportEndpointTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 36
收藏 0
点赞 0
评论 0
@PostConstruct
public void setupAutoConfigurationReport() {
ConditionEvaluationReport report = ConditionEvaluationReport
.get(this.context.getBeanFactory());
report.recordConditionEvaluation("a", mock(Condition.class),
mock(ConditionOutcome.class));
report.recordExclusions(Arrays.asList("com.foo.Bar"));
}
OnEnabledResourceChainCondition.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 36
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
ConfigurableEnvironment environment = (ConfigurableEnvironment) context
.getEnvironment();
ResourceProperties properties = new ResourceProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(properties, "spring.resources");
binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
Boolean match = properties.getChain().getEnabled();
if (match == null) {
boolean webJarsLocatorPresent = ClassUtils.isPresent(WEBJAR_ASSERT_LOCATOR,
getClass().getClassLoader());
return new ConditionOutcome(webJarsLocatorPresent,
"Webjars locator (" + WEBJAR_ASSERT_LOCATOR + ") is "
+ (webJarsLocatorPresent ? "present" : "absent"));
}
return new ConditionOutcome(match,
"Resource chain is " + (match ? "enabled" : "disabled"));
}
DispatcherServletAutoConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 65
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
List<String> dispatchServletBeans = Arrays.asList(beanFactory
.getBeanNamesForType(DispatcherServlet.class, false, false));
if (dispatchServletBeans.contains(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)) {
return ConditionOutcome.noMatch("found DispatcherServlet named "
+ DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
}
if (beanFactory.containsBean(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)) {
return ConditionOutcome.noMatch("found non-DispatcherServlet named "
+ DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
}
if (dispatchServletBeans.isEmpty()) {
return ConditionOutcome.match("no DispatcherServlet found");
}
return ConditionOutcome
.match("one or more DispatcherServlets found and none is named "
+ DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
}
ResourceServerTokenServicesConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 40
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
Environment environment = context.getEnvironment();
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
"security.oauth2.resource.");
Boolean preferTokenInfo = resolver.getProperty("prefer-token-info",
Boolean.class);
if (preferTokenInfo == null) {
preferTokenInfo = environment
.resolvePlaceholders("${OAUTH2_RESOURCE_PREFERTOKENINFO:true}")
.equals("true");
}
String tokenInfoUri = resolver.getProperty("token-info-uri");
String userInfoUri = resolver.getProperty("user-info-uri");
if (!StringUtils.hasLength(userInfoUri)) {
return ConditionOutcome.match("No user info provided");
}
if (StringUtils.hasLength(tokenInfoUri) && preferTokenInfo) {
return ConditionOutcome.match(
"Token info endpoint " + "is preferred and user info provided");
}
return ConditionOutcome.noMatch("Token info endpoint is not provided");
}
OAuth2ResourceServerConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 26
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
Environment environment = context.getEnvironment();
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
"security.oauth2.resource.");
if (hasOAuthClientId(environment)) {
return ConditionOutcome.match("found client id");
}
if (!resolver.getSubProperties("jwt").isEmpty()) {
return ConditionOutcome.match("found JWT resource configuration");
}
if (StringUtils.hasText(resolver.getProperty("user-info-uri"))) {
return ConditionOutcome
.match("found UserInfo " + "URI resource configuration");
}
if (ClassUtils.isPresent(AUTHORIZATION_ANNOTATION, null)) {
if (AuthorizationServerEndpointsConfigurationBeanCondition
.matches(context)) {
return ConditionOutcome.match(
"found authorization " + "server endpoints configuration");
}
}
return ConditionOutcome.noMatch("found neither client id nor "
+ "JWT resource nor authorization server");
}
SessionCondition.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 26
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
context.getEnvironment(), "spring.session.");
StoreType sessionStoreType = SessionStoreMappings
.getType(((AnnotationMetadata) metadata).getClassName());
if (!resolver.containsProperty("store-type")) {
if (sessionStoreType == StoreType.REDIS && redisPresent) {
return ConditionOutcome
.match("Session store type default to redis (deprecated)");
}
return ConditionOutcome.noMatch("Session store type not set");
}
String value = resolver.getProperty("store-type").replace("-", "_").toUpperCase();
if (value.equals(sessionStoreType.name())) {
return ConditionOutcome.match("Session store type " + sessionStoreType);
}
return ConditionOutcome.noMatch("Session store type " + value);
}
CacheCondition.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 27
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
context.getEnvironment(), "spring.cache.");
if (!resolver.containsProperty("type")) {
return ConditionOutcome.match("Automatic cache type");
}
CacheType cacheType = CacheConfigurations
.getType(((AnnotationMetadata) metadata).getClassName());
String value = resolver.getProperty("type").replace("-", "_").toUpperCase();
if (value.equals(cacheType.name())) {
return ConditionOutcome.match("Cache type " + cacheType);
}
return ConditionOutcome.noMatch("Cache type " + value);
}
JCacheCacheConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 31
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
context.getEnvironment(), "spring.cache.jcache.");
if (resolver.containsProperty("provider")) {
return ConditionOutcome.match("JCache provider specified");
}
Iterator<CachingProvider> providers = Caching.getCachingProviders()
.iterator();
if (!providers.hasNext()) {
return ConditionOutcome.noMatch("No JSR-107 compliant providers");
}
providers.next();
if (providers.hasNext()) {
return ConditionOutcome.noMatch(
"Multiple default JSR-107 compliant " + "providers found");
}
return ConditionOutcome.match("Default JSR-107 compliant provider found.");
}
ZipkinMessageListener.java 文件源码
项目:Zipkin
阅读 24
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
Environment environment = context.getEnvironment();
if ("true".equals(environment
.resolvePlaceholders("${spring.sleuth.stream.enabled:}"))) {
return ConditionOutcome
.noMatch("Found spring.sleuth.stream.enabled=true");
}
if (environment instanceof ConfigurableEnvironment) {
ConfigurableEnvironment configurable = (ConfigurableEnvironment) environment;
configurable.getPropertySources()
.addLast(
new MapPropertySource("spring.sleuth.stream",
Collections.<String, Object>singletonMap(
"spring.sleuth.stream.enabled",
"false")));
}
return ConditionOutcome.match("Not found: spring.sleuth.stream.enabled");
}
EndpointWebMvcManagementContextConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 39
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
Environment environment = context.getEnvironment();
String config = environment.resolvePlaceholders("${logging.file:}");
if (StringUtils.hasText(config)) {
return ConditionOutcome.match("Found logging.file: " + config);
}
config = environment.resolvePlaceholders("${logging.path:}");
if (StringUtils.hasText(config)) {
return ConditionOutcome.match("Found logging.path: " + config);
}
config = new RelaxedPropertyResolver(environment, "endpoints.logfile.")
.getProperty("external-file");
if (StringUtils.hasText(config)) {
return ConditionOutcome
.match("Found endpoints.logfile.external-file: " + config);
}
return ConditionOutcome.noMatch("Found no log file configuration");
}
OnEnabledResourceChainCondition.java 文件源码
项目:spring-boot-concourse
阅读 31
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
ConfigurableEnvironment environment = (ConfigurableEnvironment) context
.getEnvironment();
ResourceProperties properties = new ResourceProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(properties, "spring.resources");
binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
Boolean match = properties.getChain().getEnabled();
if (match == null) {
boolean webJarsLocatorPresent = ClassUtils.isPresent(WEBJAR_ASSERT_LOCATOR,
getClass().getClassLoader());
return new ConditionOutcome(webJarsLocatorPresent,
"Webjars locator (" + WEBJAR_ASSERT_LOCATOR + ") is "
+ (webJarsLocatorPresent ? "present" : "absent"));
}
return new ConditionOutcome(match,
"Resource chain is " + (match ? "enabled" : "disabled"));
}
DispatcherServletAutoConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 36
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
List<String> dispatchServletBeans = Arrays.asList(beanFactory
.getBeanNamesForType(DispatcherServlet.class, false, false));
if (dispatchServletBeans.contains(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)) {
return ConditionOutcome.noMatch("found DispatcherServlet named "
+ DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
}
if (beanFactory.containsBean(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)) {
return ConditionOutcome.noMatch("found non-DispatcherServlet named "
+ DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
}
if (dispatchServletBeans.isEmpty()) {
return ConditionOutcome.match("no DispatcherServlet found");
}
return ConditionOutcome
.match("one or more DispatcherServlets found and none is named "
+ DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
}
ResourceServerTokenServicesConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 36
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
Environment environment = context.getEnvironment();
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
"security.oauth2.resource.");
Boolean preferTokenInfo = resolver.getProperty("prefer-token-info",
Boolean.class);
if (preferTokenInfo == null) {
preferTokenInfo = environment
.resolvePlaceholders("${OAUTH2_RESOURCE_PREFERTOKENINFO:true}")
.equals("true");
}
String tokenInfoUri = resolver.getProperty("token-info-uri");
String userInfoUri = resolver.getProperty("user-info-uri");
if (!StringUtils.hasLength(userInfoUri)) {
return ConditionOutcome.match("No user info provided");
}
if (StringUtils.hasLength(tokenInfoUri) && preferTokenInfo) {
return ConditionOutcome.match(
"Token info endpoint " + "is preferred and user info provided");
}
return ConditionOutcome.noMatch("Token info endpoint is not provided");
}
OAuth2ResourceServerConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 32
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
Environment environment = context.getEnvironment();
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
"security.oauth2.resource.");
if (hasOAuthClientId(environment)) {
return ConditionOutcome.match("found client id");
}
if (!resolver.getSubProperties("jwt").isEmpty()) {
return ConditionOutcome.match("found JWT resource configuration");
}
if (StringUtils.hasText(resolver.getProperty("user-info-uri"))) {
return ConditionOutcome
.match("found UserInfo " + "URI resource configuration");
}
if (ClassUtils.isPresent(AUTHORIZATION_ANNOTATION, null)) {
if (AuthorizationServerEndpointsConfigurationBeanCondition
.matches(context)) {
return ConditionOutcome.match(
"found authorization " + "server endpoints configuration");
}
}
return ConditionOutcome.noMatch("found neither client id nor "
+ "JWT resource nor authorization server");
}
SessionCondition.java 文件源码
项目:spring-boot-concourse
阅读 28
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
context.getEnvironment(), "spring.session.");
StoreType sessionStoreType = SessionStoreMappings
.getType(((AnnotationMetadata) metadata).getClassName());
if (!resolver.containsProperty("store-type")) {
if (sessionStoreType == StoreType.REDIS && redisPresent) {
return ConditionOutcome
.match("Session store type default to redis (deprecated)");
}
return ConditionOutcome.noMatch("Session store type not set");
}
String value = resolver.getProperty("store-type").replace("-", "_").toUpperCase();
if (value.equals(sessionStoreType.name())) {
return ConditionOutcome.match("Session store type " + sessionStoreType);
}
return ConditionOutcome.noMatch("Session store type " + value);
}
CacheCondition.java 文件源码
项目:spring-boot-concourse
阅读 32
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
context.getEnvironment(), "spring.cache.");
if (!resolver.containsProperty("type")) {
return ConditionOutcome.match("Automatic cache type");
}
CacheType cacheType = CacheConfigurations
.getType(((AnnotationMetadata) metadata).getClassName());
String value = resolver.getProperty("type").replace("-", "_").toUpperCase();
if (value.equals(cacheType.name())) {
return ConditionOutcome.match("Cache type " + cacheType);
}
return ConditionOutcome.noMatch("Cache type " + value);
}
JCacheCacheConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 32
收藏 0
点赞 0
评论 0
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
context.getEnvironment(), "spring.cache.jcache.");
if (resolver.containsProperty("provider")) {
return ConditionOutcome.match("JCache provider specified");
}
Iterator<CachingProvider> providers = Caching.getCachingProviders()
.iterator();
if (!providers.hasNext()) {
return ConditionOutcome.noMatch("No JSR-107 compliant providers");
}
providers.next();
if (providers.hasNext()) {
return ConditionOutcome.noMatch(
"Multiple default JSR-107 compliant " + "providers found");
}
return ConditionOutcome.match("Default JSR-107 compliant provider found.");
}
OnOperationSystemCondition.java 文件源码
项目:azure-application-insights-spring-boot-starter
阅读 27
收藏 0
点赞 0
评论 0
@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());
}
ResourceServerTokenServicesConfiguration.java 文件源码
项目:spring-security-oauth2-boot
阅读 39
收藏 0
点赞 0
评论 0
@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());
}
ResourceServerTokenServicesConfiguration.java 文件源码
项目:spring-security-oauth2-boot
阅读 28
收藏 0
点赞 0
评论 0
@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());
}
OAuth2RestOperationsConfiguration.java 文件源码
项目:spring-security-oauth2-boot
阅读 26
收藏 0
点赞 0
评论 0
@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());
}