uk.gov.gchq.palisade.example.library.config.ApplicationConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of example-library Show documentation
Show all versions of example-library Show documentation
The users, resources and policies to be used in the example, as well as pre-population configuration for services.
The newest version!
/*
* Copyright 2018-2021 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.gov.gchq.palisade.example.library.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import uk.gov.gchq.palisade.service.user.config.UserConfiguration;
import uk.gov.gchq.palisade.service.user.config.UserPrepopulationFactory;
/**
* Configuration class for example specific data that is added to service caches
*/
@Configuration
@ConditionalOnClass(UserConfiguration.class)
public class ApplicationConfiguration {
/**
* Overrides the {@link UserConfiguration} Spring bean for the example user pre-population
*
* @return an {@link ExampleUserConfiguration}
*/
@Bean
@ConditionalOnProperty(prefix = "population", name = "userProvider", havingValue = "example")
@ConfigurationProperties(prefix = "population")
public UserConfiguration userConfiguration() {
return new ExampleUserConfiguration();
}
/**
* Overrides the {@link UserPrepopulationFactory} Spring bean for the example user pre-population
*
* @return an {@link ExampleUserPrepopulationFactory}
*/
@Bean
@ConditionalOnProperty(prefix = "population", name = "userProvider", havingValue = "example")
public UserPrepopulationFactory userPrepopulationFactory() {
return new ExampleUserPrepopulationFactory();
}
}