/** * New ticket registry cipher executor cipher executor. * * @param registry the registry * @param registryName the registry name * @return the cipher executor */ public static CipherExecutor newTicketRegistryCipherExecutor(final EncryptionRandomizedSigningJwtCryptographyProperties registry, final String registryName) { return newTicketRegistryCipherExecutor(registry, false, registryName); }
@ConditionalOnMissingBean(name = "ticketRegistry") @Bean public TicketRegistry ticketRegistry() { LOGGER.warn("Runtime memory is used as the persistence storage for retrieving and managing tickets. " + "Tickets that are issued during runtime will be LOST when the web server is restarted. This MAY impact SSO functionality."); val mem = casProperties.getTicket().getRegistry().getInMemory(); val cipher = CoreTicketUtils.newTicketRegistryCipherExecutor(mem.getCrypto(), "inMemory"); if (mem.isCache()) { val logoutManager = applicationContext.getBean("logoutManager", LogoutManager.class); return new CachingTicketRegistry(cipher, logoutManager); } return new DefaultTicketRegistry(mem.getInitialCapacity(), mem.getLoadFactor(), mem.getConcurrency(), cipher); }
@Autowired @Bean public TicketRegistry ticketRegistry(@Qualifier("ehcacheTicketCacheManager") final CacheManager manager, @Qualifier("ticketCatalog") final TicketCatalog ticketCatalog) { val crypto = casProperties.getTicket().getRegistry().getEhcache().getCrypto(); val definitions = ticketCatalog.findAll(); definitions.forEach(t -> { val ehcache = buildCache(t); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Created Ehcache cache [{}] for [{}]", ehcache.getName(), t); val config = ehcache.getCacheConfiguration(); LOGGER.debug("TicketCache.maxEntriesLocalHeap=[{}]", config.getMaxEntriesLocalHeap()); LOGGER.debug("TicketCache.maxEntriesLocalDisk=[{}]", config.getMaxEntriesLocalDisk()); LOGGER.debug("TicketCache.maxEntriesInCache=[{}]", config.getMaxEntriesInCache()); LOGGER.debug("TicketCache.persistenceConfiguration=[{}]", config.getPersistenceConfiguration().getStrategy()); LOGGER.debug("TicketCache.synchronousWrites=[{}]", config.getPersistenceConfiguration().getSynchronousWrites()); LOGGER.debug("TicketCache.timeToLive=[{}]", config.getTimeToLiveSeconds()); LOGGER.debug("TicketCache.timeToIdle=[{}]", config.getTimeToIdleSeconds()); LOGGER.debug("TicketCache.cacheManager=[{}]", ehcache.getCacheManager().getName()); } manager.addDecoratedCacheIfAbsent(ehcache); }); if (LOGGER.isDebugEnabled()) { LOGGER.debug("The following caches are available: [{}]", (Object[]) manager.getCacheNames()); } return new EhCacheTicketRegistry(ticketCatalog, manager, CoreTicketUtils.newTicketRegistryCipherExecutor(crypto, "ehcache")); }
@Bean public TicketRegistry ticketRegistry() { val hz = casProperties.getTicket().getRegistry().getHazelcast(); val factory = new HazelcastConfigurationFactory(); ticketCatalog.getIfAvailable().findAll().stream() .map(TicketDefinition::getProperties) .peek(p -> LOGGER.debug("Created Hazelcast map configuration for [{}]", p)) .map(p -> factory.buildMapConfig(hz, p.getStorageName(), p.getStorageTimeout())) .forEach(m -> hazelcastInstance.getIfAvailable().getConfig().addMapConfig(m)); val r = new HazelcastTicketRegistry(hazelcastInstance.getIfAvailable(), ticketCatalog.getIfAvailable(), hz.getPageSize()); r.setCipherExecutor(CoreTicketUtils.newTicketRegistryCipherExecutor(hz.getCrypto(), "hazelcast")); return r; }