}
public PicketLinkIDMServiceImpl(ExoContainerContext exoContainerContext, InitParams initParams,
HibernateService hibernateService, ConfigurationManager confManager, PicketLinkIDMCacheService picketLinkIDMCache,
InitialContextInitializer dependency) throws Exception {
ValueParam config = initParams.getValueParam(PARAM_CONFIG_OPTION);
ValueParam jndiName = initParams.getValueParam(PARAM_JNDI_NAME_OPTION);
ValueParam canExpireStructureCacheEntriesParam = initParams
.getValueParam(PARAM_SKIP_EXPIRATION_STRUCTURE_CACHE_ENTRIES);
ValueParam staleCacheNodesLinksCleanerDelayParam = initParams
.getValueParam(PARAM_STALE_CACHE_NODES_LINKS_CLEANER_DELAY);
ValueParam realmName = initParams.getValueParam(REALM_NAME_OPTION);
ValueParam apiCacheConfig = initParams.getValueParam(CACHE_CONFIG_API_OPTION);
ValueParam storeCacheConfig = initParams.getValueParam(CACHE_CONFIG_STORE_OPTION);
this.hibernateService = hibernateService;
if (config == null && jndiName == null) {
throw new IllegalStateException("Either '" + PARAM_CONFIG_OPTION + "' or '" + PARAM_JNDI_NAME_OPTION
+ "' parameter must " + "be specified");
}
if (realmName != null) {
this.realmName = realmName.getValue();
}
long staleCacheNodesLinksCleanerDelay = staleCacheNodesLinksCleanerDelayParam == null ? DEFAULT_STALE_CACHE_NODES_LINKS_CLEANER_DELAY
: Long.parseLong(staleCacheNodesLinksCleanerDelayParam.getValue());
boolean skipExpirationOfStructureCacheEntries = canExpireStructureCacheEntriesParam != null
&& "true".equals(canExpireStructureCacheEntriesParam.getValue());
// Not ideal, as we are changing field of singleton (could be changed more time with different values for different
// portal containers)
infinispanCacheFactory.setSkipExpirationOfStructureCacheEntries(skipExpirationOfStructureCacheEntries);
if (config != null) {
this.config = config.getValue();
URL configURL = confManager.getURL(this.config);
if (configURL == null) {
throw new IllegalStateException("Cannot fine resource: " + this.config);
}
IdentityConfigurationMetaData configMD = JAXB2IdentityConfiguration.createConfigurationMetaData(confManager
.getInputStream(this.config));
identityConfiguration = new IdentityConfigurationImpl().configure(configMD);
identityConfiguration.getIdentityConfigurationRegistry().register(hibernateService.getSessionFactory(),
"hibernateSessionFactory");
if (apiCacheConfig != null) {
InputStream configStream = confManager.getInputStream(apiCacheConfig.getValue());
if (configStream == null) {
throw new IllegalArgumentException("Infinispan configuration InputStream is null");
}
Cache cache = infinispanCacheFactory.createInfinispanCache(configStream,
exoContainerContext.getPortalContainerName(), "api");
configStream.close();
// PLIDM API cache
APICacheProvider apiCacheProvider = infinispanCacheFactory.createAPICacheProvider(
staleCacheNodesLinksCleanerDelay, cache);
picketLinkIDMCache.register(apiCacheProvider);
identityConfiguration.getIdentityConfigurationRegistry().register(apiCacheProvider, "apiCacheProvider");
// Integration cache
integrationCache = infinispanCacheFactory.createIntegrationCache(cache);
picketLinkIDMCache.register(integrationCache);
}
if (storeCacheConfig != null) {
InputStream configStream = confManager.getInputStream(storeCacheConfig.getValue());
if (configStream == null) {
throw new IllegalArgumentException("Infinispan configuration InputStream is null");
}