org.zodiac.autoconfigure.web.crypto.ReactiveWebApiCryptoAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.web.crypto;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.context.annotation.Bean;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.web.reactive.accept.RequestedContentTypeResolver;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer;
import org.zodiac.autoconfigure.web.PlatformApiCryptoProperties;
@SpringBootConfiguration
@ConditionalOnWebApplication(type = Type.REACTIVE)
@ConditionalOnClass(value = {org.zodiac.core.web.remote.crypto.config.PlatformApiCryptoInfo.class})
@ConditionalOnProperty(value = org.zodiac.core.web.remote.crypto.constants.ApiCryptoSystemPropertiesConstants.PLATFORM_API_CRYPTO_ENABLED, havingValue = "true")
public class ReactiveWebApiCryptoAutoConfiguration implements WebFluxConfigurer {
private final PlatformApiCryptoProperties platformApiCryptoProperties;
public ReactiveWebApiCryptoAutoConfiguration(PlatformApiCryptoProperties platformApiCryptoProperties) {
this.platformApiCryptoProperties = platformApiCryptoProperties;
}
@Override
public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
configurer.addCustomResolver(new org.zodiac.core.web.remote.crypto.core.reactive.ApiDecryptParamResolver(platformApiCryptoProperties));
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.core.web.remote.crypto.core.reactive.ApiDecryptRequestBodyAdvice apiDecryptRequestBodyAdvice(
ServerCodecConfigurer serverCodecConfigurer) {
return new org.zodiac.core.web.remote.crypto.core.reactive.ApiDecryptRequestBodyAdvice(serverCodecConfigurer.getReaders(),
platformApiCryptoProperties);
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.core.web.remote.crypto.core.reactive.ApiEncryptResponseBodyAdvice apiEncryptResponseBodyAdvice(
RequestedContentTypeResolver resolver, ServerCodecConfigurer serverCodecConfigurer) {
return new org.zodiac.core.web.remote.crypto.core.reactive.ApiEncryptResponseBodyAdvice(serverCodecConfigurer.getWriters(),
resolver, platformApiCryptoProperties);
}
}