All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.autoconfigure.web.crypto.ReactiveWebApiCryptoAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
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);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy