commit
d59b385304
|
@ -163,22 +163,20 @@ public class Neo4jAutoConfiguration {
|
||||||
|
|
||||||
private TrustStrategy createTrustStrategy(Neo4jProperties.Security securityProperties, String propertyName,
|
private TrustStrategy createTrustStrategy(Neo4jProperties.Security securityProperties, String propertyName,
|
||||||
Security.TrustStrategy strategy) {
|
Security.TrustStrategy strategy) {
|
||||||
switch (strategy) {
|
return switch (strategy) {
|
||||||
case TRUST_ALL_CERTIFICATES:
|
case TRUST_ALL_CERTIFICATES -> TrustStrategy.trustAllCertificates();
|
||||||
return TrustStrategy.trustAllCertificates();
|
case TRUST_SYSTEM_CA_SIGNED_CERTIFICATES -> TrustStrategy.trustSystemCertificates();
|
||||||
case TRUST_SYSTEM_CA_SIGNED_CERTIFICATES:
|
case TRUST_CUSTOM_CA_SIGNED_CERTIFICATES -> {
|
||||||
return TrustStrategy.trustSystemCertificates();
|
|
||||||
case TRUST_CUSTOM_CA_SIGNED_CERTIFICATES:
|
|
||||||
File certFile = securityProperties.getCertFile();
|
File certFile = securityProperties.getCertFile();
|
||||||
if (certFile == null || !certFile.isFile()) {
|
if (certFile == null || !certFile.isFile()) {
|
||||||
throw new InvalidConfigurationPropertyValueException(propertyName, strategy.name(),
|
throw new InvalidConfigurationPropertyValueException(propertyName, strategy.name(),
|
||||||
"Configured trust strategy requires a certificate file.");
|
"Configured trust strategy requires a certificate file.");
|
||||||
}
|
}
|
||||||
return TrustStrategy.trustCustomCertificateSignedBy(certFile);
|
yield TrustStrategy.trustCustomCertificateSignedBy(certFile);
|
||||||
default:
|
}
|
||||||
throw new InvalidConfigurationPropertyValueException(propertyName, strategy.name(),
|
default -> throw new InvalidConfigurationPropertyValueException(propertyName, strategy.name(),
|
||||||
"Unknown strategy.");
|
"Unknown strategy.");
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,12 +27,12 @@ public class MyReadinessStateExporter {
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onStateChange(AvailabilityChangeEvent<ReadinessState> event) {
|
public void onStateChange(AvailabilityChangeEvent<ReadinessState> event) {
|
||||||
switch (event.getState()) {
|
switch (event.getState()) {
|
||||||
case ACCEPTING_TRAFFIC:
|
case ACCEPTING_TRAFFIC -> {
|
||||||
// create file /tmp/healthy
|
// create file /tmp/healthy
|
||||||
break;
|
}
|
||||||
case REFUSING_TRAFFIC:
|
case REFUSING_TRAFFIC -> {
|
||||||
// remove file /tmp/healthy
|
// remove file /tmp/healthy
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,19 +69,20 @@ public class FilterAnnotations implements Iterable<TypeFilter> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private TypeFilter createTypeFilter(FilterType filterType, Class<?> filterClass) {
|
private TypeFilter createTypeFilter(FilterType filterType, Class<?> filterClass) {
|
||||||
switch (filterType) {
|
return switch (filterType) {
|
||||||
case ANNOTATION:
|
case ANNOTATION -> {
|
||||||
Assert.isAssignable(Annotation.class, filterClass,
|
Assert.isAssignable(Annotation.class, filterClass,
|
||||||
"An error occurred while processing an ANNOTATION type filter: ");
|
"An error occurred while processing an ANNOTATION type filter: ");
|
||||||
return new AnnotationTypeFilter((Class<Annotation>) filterClass);
|
yield new AnnotationTypeFilter((Class<Annotation>) filterClass);
|
||||||
case ASSIGNABLE_TYPE:
|
}
|
||||||
return new AssignableTypeFilter(filterClass);
|
case ASSIGNABLE_TYPE -> new AssignableTypeFilter(filterClass);
|
||||||
case CUSTOM:
|
case CUSTOM -> {
|
||||||
Assert.isAssignable(TypeFilter.class, filterClass,
|
Assert.isAssignable(TypeFilter.class, filterClass,
|
||||||
"An error occurred while processing a CUSTOM type filter: ");
|
"An error occurred while processing a CUSTOM type filter: ");
|
||||||
return BeanUtils.instantiateClass(filterClass, TypeFilter.class);
|
yield BeanUtils.instantiateClass(filterClass, TypeFilter.class);
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Filter type not supported with Class value: " + filterType);
|
default -> throw new IllegalArgumentException("Filter type not supported with Class value: " + filterType);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeFilter createTypeFilter(FilterType filterType, String pattern) {
|
private TypeFilter createTypeFilter(FilterType filterType, String pattern) {
|
||||||
|
|
Loading…
Reference in New Issue