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 realmName = initParams.getValueParam(REALM_NAME_OPTION);
ValueParam apiCacheConfig = initParams.getValueParam(CACHE_CONFIG_API_OPTION);
ValueParam storeCacheConfig = initParams.getValueParam(CACHE_CONFIG_STORE_OPTION);
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();
}
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());
JBossCacheAPICacheProviderImpl apiCacheProvider = new JBossCacheAPICacheProviderImpl();
apiCacheProvider.initialize(configStream);
picketLinkIDMCache.register(apiCacheProvider);
identityConfiguration.getIdentityConfigurationRegistry().register(apiCacheProvider, "apiCacheProvider");
configStream.close();
}
if (storeCacheConfig != null)
{
InputStream configStream = confManager.getInputStream(storeCacheConfig.getValue());
JBossCacheIdentityStoreCacheProviderImpl storeCacheProvider = new JBossCacheIdentityStoreCacheProviderImpl();
storeCacheProvider.initialize(configStream);
picketLinkIDMCache.register(storeCacheProvider);
identityConfiguration.getIdentityConfigurationRegistry().register(storeCacheProvider, "storeCacheProvider");