Search in sources :

Example 1 with IgniteProperties

use of org.apereo.cas.configuration.model.support.ignite.IgniteProperties in project cas by apereo.

the class IgniteTicketRegistryConfiguration method igniteConfiguration.

/**
     * Ignite configuration ignite configuration.
     *
     * @return the ignite configuration
     */
@RefreshScope
@Bean
public IgniteConfiguration igniteConfiguration() {
    final IgniteProperties ignite = casProperties.getTicket().getRegistry().getIgnite();
    final IgniteConfiguration config = new IgniteConfiguration();
    final TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setHeartbeatFrequency(ignite.getHeartbeatFrequency());
    spi.setJoinTimeout(ignite.getJoinTimeout());
    if (!StringUtils.isEmpty(ignite.getLocalAddress())) {
        spi.setLocalAddress(ignite.getLocalAddress());
    }
    if (ignite.getLocalPort() != -1) {
        spi.setLocalPort(ignite.getLocalPort());
    }
    spi.setNetworkTimeout(ignite.getNetworkTimeout());
    spi.setSocketTimeout(ignite.getSocketTimeout());
    spi.setThreadPriority(ignite.getThreadPriority());
    spi.setForceServerMode(ignite.isForceServerMode());
    final TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder();
    finder.setAddresses(StringUtils.commaDelimitedListToSet(ignite.getIgniteAddresses()));
    spi.setIpFinder(finder);
    config.setDiscoverySpi(spi);
    final List<CacheConfiguration> configurations = new ArrayList<>();
    final CacheConfiguration ticketsCache = new CacheConfiguration();
    ticketsCache.setName(ignite.getTicketsCache().getCacheName());
    ticketsCache.setCacheMode(CacheMode.valueOf(ignite.getTicketsCache().getCacheMode()));
    ticketsCache.setAtomicityMode(CacheAtomicityMode.valueOf(ignite.getTicketsCache().getAtomicityMode()));
    ticketsCache.setWriteSynchronizationMode(CacheWriteSynchronizationMode.valueOf(ignite.getTicketsCache().getWriteSynchronizationMode()));
    ticketsCache.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, casProperties.getTicket().getTgt().getMaxTimeToLiveInSeconds())));
    configurations.add(ticketsCache);
    config.setCacheConfiguration(configurations.toArray(new CacheConfiguration[] {}));
    return config;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) ArrayList(java.util.ArrayList) Duration(javax.cache.expiry.Duration) IgniteProperties(org.apereo.cas.configuration.model.support.ignite.IgniteProperties) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Example 2 with IgniteProperties

use of org.apereo.cas.configuration.model.support.ignite.IgniteProperties in project cas by apereo.

the class IgniteTicketRegistryConfiguration method ticketRegistry.

@Bean
@RefreshScope
public TicketRegistry ticketRegistry() {
    final IgniteProperties igniteProperties = casProperties.getTicket().getRegistry().getIgnite();
    final IgniteTicketRegistry r = new IgniteTicketRegistry(igniteConfiguration(), igniteProperties);
    r.setCipherExecutor(Beans.newTicketRegistryCipherExecutor(igniteProperties.getCrypto()));
    return r;
}
Also used : IgniteTicketRegistry(org.apereo.cas.ticket.registry.IgniteTicketRegistry) IgniteProperties(org.apereo.cas.configuration.model.support.ignite.IgniteProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Example 3 with IgniteProperties

use of org.apereo.cas.configuration.model.support.ignite.IgniteProperties in project cas by apereo.

the class IgniteTicketRegistryConfiguration method ticketRegistry.

@Bean
@RefreshScope
public TicketRegistry ticketRegistry(@Qualifier("ticketCatalog") final TicketCatalog ticketCatalog) {
    final IgniteProperties igniteProperties = casProperties.getTicket().getRegistry().getIgnite();
    final IgniteTicketRegistry r = new IgniteTicketRegistry(ticketCatalog, igniteConfiguration(ticketCatalog), igniteProperties);
    r.setCipherExecutor(CoreTicketUtils.newTicketRegistryCipherExecutor(igniteProperties.getCrypto(), "ignite"));
    return r;
}
Also used : IgniteTicketRegistry(org.apereo.cas.ticket.registry.IgniteTicketRegistry) IgniteProperties(org.apereo.cas.configuration.model.support.ignite.IgniteProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Example 4 with IgniteProperties

use of org.apereo.cas.configuration.model.support.ignite.IgniteProperties in project cas by apereo.

the class IgniteTicketRegistryConfiguration method igniteConfiguration.

/**
 * Ignite configuration ignite configuration.
 *
 * @param ticketCatalog the ticket catalog
 * @return the ignite configuration
 */
@RefreshScope
@Bean
public IgniteConfiguration igniteConfiguration(@Qualifier("ticketCatalog") final TicketCatalog ticketCatalog) {
    final IgniteProperties ignite = casProperties.getTicket().getRegistry().getIgnite();
    final IgniteConfiguration config = new IgniteConfiguration();
    final TcpDiscoverySpi spi = new TcpDiscoverySpi();
    if (!StringUtils.isEmpty(ignite.getLocalAddress())) {
        spi.setLocalAddress(ignite.getLocalAddress());
    }
    if (ignite.getLocalPort() != -1) {
        spi.setLocalPort(ignite.getLocalPort());
    }
    spi.setJoinTimeout(Beans.newDuration(ignite.getJoinTimeout()).toMillis());
    spi.setAckTimeout(Beans.newDuration(ignite.getAckTimeout()).toMillis());
    spi.setNetworkTimeout(Beans.newDuration(ignite.getNetworkTimeout()).toMillis());
    spi.setSocketTimeout(Beans.newDuration(ignite.getSocketTimeout()).toMillis());
    spi.setThreadPriority(ignite.getThreadPriority());
    spi.setForceServerMode(ignite.isForceServerMode());
    final TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder();
    finder.setAddresses(ignite.getIgniteAddress());
    spi.setIpFinder(finder);
    config.setDiscoverySpi(spi);
    final Collection<CacheConfiguration> cacheConfigurations = buildIgniteTicketCaches(ignite, ticketCatalog);
    config.setCacheConfiguration(cacheConfigurations.toArray(new CacheConfiguration[] {}));
    config.setClientMode(ignite.isClientMode());
    return config;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) IgniteProperties(org.apereo.cas.configuration.model.support.ignite.IgniteProperties) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Aggregations

IgniteProperties (org.apereo.cas.configuration.model.support.ignite.IgniteProperties)4 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)4 Bean (org.springframework.context.annotation.Bean)4 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)2 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)2 IgniteTicketRegistry (org.apereo.cas.ticket.registry.IgniteTicketRegistry)2 ArrayList (java.util.ArrayList)1 Duration (javax.cache.expiry.Duration)1