private IdentityStore<?> getContextualStoreForFeature(IdentityStoreInvocationContext ctx, Feature feature) { String realm = (ctx.getRealm() != null) ? ctx.getRealm().getName() : Realm.DEFAULT_REALM; if (!realmStores.containsKey(realm)) { throw new SecurityException("The specified realm '" + realm + "' has not been configured."); } IdentityStoreConfiguration config = null; Map<Feature,IdentityStoreConfiguration> featureToStoreMap = realmStores.get(realm); if (featureToStoreMap.containsKey(feature)) { config = featureToStoreMap.get(feature); } else if (featureToStoreMap.containsKey(Feature.all)) { config = featureToStoreMap.get(Feature.all); } else { throw new UnsupportedOperationException("The requested identity management feature [" + feature.toString() + "] has not been configured."); } IdentityStore<?> store = storeFactory.createIdentityStore(config, ctx); getContextFactory().initContextForStore(ctx, store); return store; }