@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.ConditionMessage的实例源码
ResourceServerTokenServicesConfiguration.java 文件源码
项目:spring-security-oauth2-boot
阅读 44
收藏 0
点赞 0
评论 0
EnableOAuth2SsoCondition.java 文件源码
项目:spring-security-oauth2-boot
阅读 41
收藏 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());
}
SwaggerApiAutoDetectCondition.java 文件源码
项目:holon-jaxrs
阅读 42
收藏 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
阅读 44
收藏 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
阅读 37
收藏 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
阅读 26
收藏 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();
}
ZipkinSenderCondition.java 文件源码
项目:spring-cloud-sleuth
阅读 34
收藏 0
点赞 0
评论 0
@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"));
}
OnOperationSystemCondition.java 文件源码
项目:azure-application-insights-spring-boot-starter
阅读 33
收藏 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
阅读 34
收藏 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
阅读 43
收藏 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
阅读 34
收藏 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());
}
OnEnabledDetectorCondition.java 文件源码
项目:cereebro
阅读 33
收藏 0
点赞 0
评论 0
@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"));
}
FlexyPoolConfiguration.java 文件源码
项目:spring-boot-data-source-decorator
阅读 32
收藏 0
点赞 0
评论 0
@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());
}
HttpComponentAutoConfiguration.java 文件源码
项目:syndesis
阅读 33
收藏 0
点赞 0
评论 0
@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"));
}
HttpComponentAutoConfiguration.java 文件源码
项目:connectors
阅读 28
收藏 0
点赞 0
评论 0
@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"));
}
DataSourceAutoConfiguration.java 文件源码
项目:spring-boot-multidatasource
阅读 37
收藏 0
点赞 0
评论 0
@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());
}
LogoutConfiguration.java 文件源码
项目:simple-openid-provider
阅读 25
收藏 0
点赞 0
评论 0
@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"));
}
}
LogoutConfiguration.java 文件源码
项目:simple-openid-provider
阅读 35
收藏 0
点赞 0
评论 0
@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"));
}
}
JuiserSpringSecurityCondition.java 文件源码
项目:juiser
阅读 34
收藏 0
点赞 0
评论 0
@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);
}
FailsafeAutoConfiguration.java 文件源码
项目:failsafe-actuator
阅读 31
收藏 0
点赞 0
评论 0
@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"));
}
OAuth2ResourceServerConfiguration.java 文件源码
项目:spring-security-oauth2-boot
阅读 34
收藏 0
点赞 0
评论 0
@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());
}
OnWorkerCondition.java 文件源码
项目:piper
阅读 39
收藏 0
点赞 0
评论 0
@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));
}
OnCoordinatorCondition.java 文件源码
项目:piper
阅读 30
收藏 0
点赞 0
评论 0
@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));
}