Map<String, IdentityStore> bootstrappedIdentityStores,
Map<String, AttributeStore> bootstrappedAttributeStores) throws IdentityException
{
this.configurationContext = configurationContext;
IdentityRepositoryConfigurationMetaData configurationMD = configurationContext.getRepositoryConfigurationMetaData();
String asId = configurationMD.getDefaultAttributeStoreId();
String isId = configurationMD.getDefaultIdentityStoreId();
if (asId != null && bootstrappedAttributeStores.keySet().contains(asId))
{
defaultAttributeStore = bootstrappedAttributeStores.get(asId);
//TODO: cache wrap support
}
String allowNotDefinedIOT = configurationMD.getOptionSingleValue(ALLOW_NOT_DEFINED_IDENTITY_OBJECT_TYPES_OPTION);
if (allowNotDefinedIOT != null && allowNotDefinedIOT.equalsIgnoreCase("true"))
{
this.allowNotDefinedIdentityObjectTypes = true;
}
if (isId != null && bootstrappedIdentityStores.keySet().contains(isId))
{
defaultIdentityStore = bootstrappedIdentityStores.get(isId);
String cacheOption = configurationMD.getOptionSingleValue(CACHE_OPTION);
if (cacheOption != null && cacheOption.equalsIgnoreCase("true"))
{
String cacheConfig = configurationMD.getOptionSingleValue(CACHE_CONFIG_FILE_OPTION);
String cacheSupportClass = configurationMD.getOptionSingleValue(CACHE_PROVIDER_CLASS_OPTION);
if (cacheConfig == null)
{
throw new IdentityException(CACHE_CONFIG_FILE_OPTION + " is missing in the repository configuration");
}
if (cacheSupportClass == null)
{
throw new IdentityException(CACHE_PROVIDER_CLASS_OPTION + " is missing in the repository configuration");
}
ClassLoader classLoader = SecurityActions.getContextClassLoader();
InputStream cacheConfigInputStream = classLoader.getResourceAsStream(cacheConfig);
if (cacheConfigInputStream == null)
{
throw new IdentityException("JBoss Cache config file specified in option \"" + CACHE_CONFIG_FILE_OPTION +
"\" doesn't exist: " + cacheConfig);
}
try
{
Class cacheClass = null;
cacheClass = Class.forName(cacheSupportClass);
Class partypes[] = new Class[1];
partypes[0] = InputStream.class;
Constructor ct = cacheClass.getConstructor(partypes);
Object argList[] = new Object[1];
argList[0] = cacheConfigInputStream;
IdentityStoreCacheProvider cacheSupport = (IdentityStoreCacheProvider)ct.newInstance(argList);
defaultIdentityStore = new JBossCacheIdentityStoreWrapper(defaultIdentityStore, cacheSupport);
}
catch (Exception e)
{
throw new IdentityException("Cannot instantiate cache provider:" + cacheSupportClass, e);
}
}
}
for (IdentityStoreMappingMetaData identityStoreMappingMetaData : configurationMD.getIdentityStoreToIdentityObjectTypeMappings())
{
String storeId = identityStoreMappingMetaData.getIdentityStoreId();
List<String> identityObjectTypeMappings = identityStoreMappingMetaData.getIdentityObjectTypeMappings();
IdentityStore store = bootstrappedIdentityStores.get(storeId);