Search in sources :

Example 16 with Profile

use of org.springframework.context.annotation.Profile in project webanno by webanno.

the class WebAnnoSecurity method externalAuthenticationProvider.

@Bean(name = "authenticationProvider")
@Profile("auto-mode-preauth")
public PreAuthenticatedAuthenticationProvider externalAuthenticationProvider(UserDetailsManager aUserDetailsService) {
    PreAuthenticatedAuthenticationProvider authProvider = new PreAuthenticatedAuthenticationProvider();
    authProvider.setPreAuthenticatedUserDetailsService(new UserDetailsByNameServiceWrapper<PreAuthenticatedAuthenticationToken>(aUserDetailsService));
    return authProvider;
}
Also used : PreAuthenticatedAuthenticationProvider(org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider) PreAuthenticatedAuthenticationToken(org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken) Profile(org.springframework.context.annotation.Profile) Bean(org.springframework.context.annotation.Bean)

Example 17 with Profile

use of org.springframework.context.annotation.Profile in project commons-dao by reportportal.

the class MongodbConfiguration method mongoDbFactory.

@Bean
@Profile("!unittest")
MongoDbFactory mongoDbFactory() throws UnknownHostException {
    SimpleMongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(mongo(), mongoProperties.getDatabase());
    mongoDbFactory.setWriteConcern(WriteConcern.ACKNOWLEDGED);
    return mongoDbFactory;
}
Also used : SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) Profile(org.springframework.context.annotation.Profile) ReportPortalRepositoryFactoryBean(com.epam.ta.reportportal.database.dao.ReportPortalRepositoryFactoryBean) RepositoriesFactoryBean(com.epam.ta.reportportal.database.support.RepositoriesFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 18 with Profile

use of org.springframework.context.annotation.Profile in project hello-world by haoziapple.

the class DatabaseConfiguration method h2TCPServer.

/**
 * Open the TCP port for the H2 database, so it is available remotely.
 *
 * @return the H2 database TCP server
 * @throws SQLException if the server failed to start
 */
@Bean(initMethod = "start", destroyMethod = "stop")
@Profile(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)
public Object h2TCPServer() throws SQLException {
    try {
        // We don't want to include H2 when we are packaging for the "prod" profile and won't
        // actually need it, so we have to load / invoke things at runtime through reflection.
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        Class<?> serverClass = Class.forName("org.h2.tools.Server", true, loader);
        Method createServer = serverClass.getMethod("createTcpServer", String[].class);
        return createServer.invoke(null, new Object[] { new String[] { "-tcp", "-tcpAllowOthers" } });
    } catch (ClassNotFoundException | LinkageError e) {
        throw new RuntimeException("Failed to load and initialize org.h2.tools.Server", e);
    } catch (SecurityException | NoSuchMethodException e) {
        throw new RuntimeException("Failed to get method org.h2.tools.Server.createTcpServer()", e);
    } catch (IllegalAccessException | IllegalArgumentException e) {
        throw new RuntimeException("Failed to invoke org.h2.tools.Server.createTcpServer()", e);
    } catch (InvocationTargetException e) {
        Throwable t = e.getTargetException();
        if (t instanceof SQLException) {
            throw (SQLException) t;
        }
        throw new RuntimeException("Unchecked exception in org.h2.tools.Server.createTcpServer()", t);
    }
}
Also used : SQLException(java.sql.SQLException) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) Profile(org.springframework.context.annotation.Profile) Bean(org.springframework.context.annotation.Bean)

Example 19 with Profile

use of org.springframework.context.annotation.Profile in project hono by eclipse.

the class ApplicationConfig method amqpServer.

/**
 * Creates a new server for exposing the device registry's AMQP 1.0 based
 * endpoints.
 *
 * @param tenantService The tenant service instance.
 * @param registrationService The device registration service instance.
 * @param credentialsService The credentials service instance.
 * @param tenantManagementService The tenant management service instance.
 * @param deviceManagementService The device management service instance.
 * @param credentialsManagementService The credentials management service instance.
 * @return The server.
 */
@Bean(name = BEAN_NAME_AMQP_SERVER)
@Scope("prototype")
@Profile(Profiles.PROFILE_REGISTRY_ADAPTER)
public DeviceRegistryAmqpServer amqpServer(@Autowired(required = false) final TenantService tenantService, final RegistrationServiceImpl registrationService, final CredentialsServiceImpl credentialsService, @Autowired(required = false) final TenantManagementService tenantManagementService, @Autowired(required = false) final DeviceManagementService deviceManagementService, @Autowired(required = false) final CredentialsManagementService credentialsManagementService) {
    final DeviceRegistryAmqpServer amqpServer = new DeviceRegistryAmqpServer();
    final TenantInformationService tenantInformationService = createAndApplyTenantInformationService(tenantManagementService, deviceManagementService, credentialsManagementService);
    if (deviceManagementService != null) {
        final var eventSenderProvider = eventSenderProvider();
        final EdgeDeviceAutoProvisioner edgeDeviceAutoProvisioner = new EdgeDeviceAutoProvisioner(vertx(), deviceManagementService, eventSenderProvider, autoProvisionerConfigProperties(), tracer());
        registrationService.setEdgeDeviceAutoProvisioner(edgeDeviceAutoProvisioner);
        if (credentialsManagementService != null) {
            final DeviceAndGatewayAutoProvisioner deviceAndGatewayAutoProvisioner = new DeviceAndGatewayAutoProvisioner(vertx(), deviceManagementService, credentialsManagementService, eventSenderProvider);
            credentialsService.setDeviceAndGatewayAutoProvisioner(deviceAndGatewayAutoProvisioner);
        }
    }
    registrationService.setTenantInformationService(tenantInformationService);
    credentialsService.setTenantInformationService(tenantInformationService);
    // add endpoints
    final List<AbstractAmqpEndpoint<ServiceConfigProperties>> endpoints = new ArrayList<>();
    Optional.ofNullable(tenantService).ifPresent(svc -> endpoints.add(new DelegatingTenantAmqpEndpoint<>(vertx(), svc)));
    endpoints.add(new DelegatingRegistrationAmqpEndpoint<>(vertx(), registrationService));
    endpoints.add(new DelegatingCredentialsAmqpEndpoint<>(vertx(), credentialsService));
    endpoints.forEach(ep -> {
        ep.setTracer(tracer());
        ep.setConfiguration(amqpServerProperties());
        amqpServer.addEndpoint(ep);
    });
    return amqpServer;
}
Also used : EdgeDeviceAutoProvisioner(org.eclipse.hono.deviceregistry.service.device.EdgeDeviceAutoProvisioner) DelegatingTenantAmqpEndpoint(org.eclipse.hono.service.tenant.DelegatingTenantAmqpEndpoint) AbstractAmqpEndpoint(org.eclipse.hono.service.amqp.AbstractAmqpEndpoint) DeviceAndGatewayAutoProvisioner(org.eclipse.hono.service.management.device.DeviceAndGatewayAutoProvisioner) ArrayList(java.util.ArrayList) DeviceRegistryAmqpServer(org.eclipse.hono.deviceregistry.server.DeviceRegistryAmqpServer) NoopTenantInformationService(org.eclipse.hono.deviceregistry.service.tenant.NoopTenantInformationService) TenantInformationService(org.eclipse.hono.deviceregistry.service.tenant.TenantInformationService) DefaultTenantInformationService(org.eclipse.hono.deviceregistry.service.tenant.DefaultTenantInformationService) Scope(org.springframework.context.annotation.Scope) Profile(org.springframework.context.annotation.Profile) ObjectFactoryCreatingFactoryBean(org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 20 with Profile

use of org.springframework.context.annotation.Profile in project hono by eclipse.

the class ApplicationConfig method notificationSender.

/**
 * Exposes a notification sender.
 *
 * @return The bean instance.
 */
@Bean
@Profile(Profiles.PROFILE_REGISTRY_MANAGEMENT)
public NotificationSender notificationSender() {
    final NotificationSender notificationSender;
    final var kafkaProducerConfig = notificationKafkaProducerConfig();
    if (kafkaProducerConfig.isConfigured()) {
        notificationSender = new KafkaBasedNotificationSender(CachingKafkaProducerFactory.sharedFactory(vertx()), kafkaProducerConfig);
    } else {
        notificationSender = new ProtonBasedNotificationSender(HonoConnection.newConnection(vertx(), downstreamSenderConfig(), tracer()));
    }
    if (notificationSender instanceof ServiceClient) {
        healthCheckServer().registerHealthCheckResources(ServiceClientAdapter.forClient((ServiceClient) notificationSender));
    }
    NotificationConstants.DEVICE_REGISTRY_NOTIFICATION_TYPES.forEach(notificationType -> {
        NotificationEventBusSupport.registerConsumer(vertx(), notificationType, notificationSender::publish);
    });
    return notificationSender;
}
Also used : ProtonBasedNotificationSender(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationSender) NotificationSender(org.eclipse.hono.notification.NotificationSender) KafkaBasedNotificationSender(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationSender) KafkaBasedNotificationSender(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationSender) ServiceClient(org.eclipse.hono.client.util.ServiceClient) ProtonBasedNotificationSender(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationSender) Profile(org.springframework.context.annotation.Profile) ObjectFactoryCreatingFactoryBean(org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Bean (org.springframework.context.annotation.Bean)27 Profile (org.springframework.context.annotation.Profile)27 ObjectFactoryCreatingFactoryBean (org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean)5 ArrayList (java.util.ArrayList)2 ConfigurationProperties (org.springframework.boot.context.properties.ConfigurationProperties)2 Scope (org.springframework.context.annotation.Scope)2 DaoAuthenticationProvider (org.springframework.security.authentication.dao.DaoAuthenticationProvider)2 ExternalConfiguration (alfio.manager.system.ExternalConfiguration)1 AWS4Signer (com.amazonaws.auth.AWS4Signer)1 AWSRequestSigningApacheInterceptor (com.amazonaws.http.AWSRequestSigningApacheInterceptor)1 ReportPortalRepositoryFactoryBean (com.epam.ta.reportportal.database.dao.ReportPortalRepositoryFactoryBean)1 RepositoriesFactoryBean (com.epam.ta.reportportal.database.support.RepositoriesFactoryBean)1 JcrIndexService (com.thinkbiganalytics.metadata.modeshape.service.JcrIndexService)1 SimpleServiceLevelAssessor (com.thinkbiganalytics.metadata.sla.spi.core.SimpleServiceLevelAssessor)1 WebAnnoDaoAuthenticationProvider (de.tudarmstadt.ukp.clarin.webanno.security.WebAnnoDaoAuthenticationProvider)1 ShibbolethRequestHeaderAuthenticationFilter (de.tudarmstadt.ukp.clarin.webanno.security.preauth.ShibbolethRequestHeaderAuthenticationFilter)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 SQLException (java.sql.SQLException)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1