@Test public void testGetConfigProvider() { assertNull("Existing Registration", authConfigFactory.getConfigProvider(LAYER, APP_CONTEXT, null)); String fullId = authConfigFactory.registerConfigProvider(new TestAuthConfigProvider("One"), LAYER, APP_CONTEXT, DESCRIPTION); String layerId = authConfigFactory.registerConfigProvider(new TestAuthConfigProvider("Two"), LAYER, null, DESCRIPTION); String appContextId = authConfigFactory.registerConfigProvider(new TestAuthConfigProvider("Three"), null, APP_CONTEXT, DESCRIPTION); String defaultId = authConfigFactory.registerConfigProvider(new TestAuthConfigProvider("Four"), null, null, DESCRIPTION); assertEquals("Incorrect AuthConfigProvider", "One", ((TestAuthConfigProvider) authConfigFactory.getConfigProvider(LAYER, APP_CONTEXT, null)).getId()); authConfigFactory.removeRegistration(fullId); assertEquals("Incorrect AuthConfigProvider", "Three", ((TestAuthConfigProvider) authConfigFactory.getConfigProvider(LAYER, APP_CONTEXT, null)).getId()); authConfigFactory.removeRegistration(appContextId); assertEquals("Incorrect AuthConfigProvider", "Two", ((TestAuthConfigProvider) authConfigFactory.getConfigProvider(LAYER, APP_CONTEXT, null)).getId()); authConfigFactory.removeRegistration(layerId); assertEquals("Incorrect AuthConfigProvider", "Four", ((TestAuthConfigProvider) authConfigFactory.getConfigProvider(LAYER, APP_CONTEXT, null)).getId()); authConfigFactory.removeRegistration(defaultId); assertNull("Existing Registration", authConfigFactory.getConfigProvider(LAYER, APP_CONTEXT, null)); }
@Override public AuthConfigProvider getConfigProvider(String layer, String appContext, RegistrationListener listener) { synchronized(layerContextRegistration) { LayerContextKey fullKey = new LayerContextKey(layer, appContext); Registration registration = layerContextRegistration.get(fullKey); if (registration != null) { if (listener != null) { registration.addListener(listener); } if (registration.activeRegistration()) { return registration.authConfigProvider; } } else if (listener != null) { Registration listenerRegistration = new Registration(layer, appContext); listenerRegistration.addListener(listener); layerContextRegistration.put(fullKey, listenerRegistration); } if (layer != null) { registration = layerContextRegistration.get(new LayerContextKey(null, appContext)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } if (appContext != null) { registration = layerContextRegistration.get(new LayerContextKey(layer, null)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } if (layer != null && appContext != null) { registration = layerContextRegistration.get(new LayerContextKey(null, null)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } } return null; }
ElytronAuthConfigFactory extends AuthConfigFactory { @Override public AuthConfigProvider getConfigProvider(String layer, String appContext, RegistrationListener listener) { synchronized(layerContextRegistration) { LayerContextKey fullKey = new LayerContextKey(layer, appContext); Registration registration = layerContextRegistration.get(fullKey); if (registration != null) { if (listener != null) { registration.addListener(listener); } if (registration.activeRegistration()) { return registration.authConfigProvider; } } else if (listener != null) { Registration listenerRegistration = new Registration(layer, appContext); listenerRegistration.addListener(listener); layerContextRegistration.put(fullKey, listenerRegistration); } if (layer != null) { registration = layerContextRegistration.get(new LayerContextKey(null, appContext)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } if (appContext != null) { registration = layerContextRegistration.get(new LayerContextKey(layer, null)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } if (layer != null && appContext != null) { registration = layerContextRegistration.get(new LayerContextKey(null, null)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } } return null; } }
ElytronAuthConfigFactory extends AuthConfigFactory { @Override public AuthConfigProvider getConfigProvider(String layer, String appContext, RegistrationListener listener) { synchronized(layerContextRegistration) { LayerContextKey fullKey = new LayerContextKey(layer, appContext); Registration registration = layerContextRegistration.get(fullKey); if (registration != null) { if (listener != null) { registration.addListener(listener); } if (registration.activeRegistration()) { return registration.authConfigProvider; } } else if (listener != null) { Registration listenerRegistration = new Registration(layer, appContext); listenerRegistration.addListener(listener); layerContextRegistration.put(fullKey, listenerRegistration); } if (layer != null) { registration = layerContextRegistration.get(new LayerContextKey(null, appContext)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } if (appContext != null) { registration = layerContextRegistration.get(new LayerContextKey(layer, null)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } if (layer != null && appContext != null) { registration = layerContextRegistration.get(new LayerContextKey(null, null)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } } return null; }  }
ElytronAuthConfigFactory extends AuthConfigFactory { @Override public AuthConfigProvider getConfigProvider(String layer, String appContext, RegistrationListener listener) { synchronized(layerContextRegistration) { LayerContextKey fullKey = new LayerContextKey(layer, appContext); Registration registration = layerContextRegistration.get(fullKey); if (registration != null) { if (listener != null) { registration.addListener(listener); } if (registration.activeRegistration()) { return registration.authConfigProvider; } } else if (listener != null) { Registration listenerRegistration = new Registration(layer, appContext); listenerRegistration.addListener(listener); layerContextRegistration.put(fullKey, listenerRegistration); } if (layer != null) { registration = layerContextRegistration.get(new LayerContextKey(null, appContext)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } if (appContext != null) { registration = layerContextRegistration.get(new LayerContextKey(layer, null)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } if (layer != null && appContext != null) { registration = layerContextRegistration.get(new LayerContextKey(null, null)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } } return null; }  @Override AuthConfigProvider getConfigProvider(String layer, String appContext, RegistrationListener listener); @Override String registerConfigProvider(AuthConfigProvider provider, String layer, String appContext, String description); @Override String registerConfigProvider(String className, Map properties, String layer, String appContext, String description); @Override boolean removeRegistration(String registrationId); @Override String[] detachListener(RegistrationListener listener, String layer, String appContext); @Override RegistrationContext getRegistrationContext(String registrationID); @Override String[] getRegistrationIDs(AuthConfigProvider provider); @Override void refresh(); }
ElytronAuthConfigFactory extends AuthConfigFactory { @Override public AuthConfigProvider getConfigProvider(String layer, String appContext, RegistrationListener listener) { synchronized(layerContextRegistration) { LayerContextKey fullKey = new LayerContextKey(layer, appContext); Registration registration = layerContextRegistration.get(fullKey); if (registration != null) { if (listener != null) { registration.addListener(listener); } if (registration.activeRegistration()) { return registration.authConfigProvider; } } else if (listener != null) { Registration listenerRegistration = new Registration(layer, appContext); listenerRegistration.addListener(listener); layerContextRegistration.put(fullKey, listenerRegistration); } if (layer != null) { registration = layerContextRegistration.get(new LayerContextKey(null, appContext)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } if (appContext != null) { registration = layerContextRegistration.get(new LayerContextKey(layer, null)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } if (layer != null && appContext != null) { registration = layerContextRegistration.get(new LayerContextKey(null, null)); if (registration != null && registration.activeRegistration()) { return registration.authConfigProvider; } } } return null; }  @Override AuthConfigProvider getConfigProvider(String layer, String appContext, RegistrationListener listener); @Override String registerConfigProvider(AuthConfigProvider provider, String layer, String appContext, String description); @Override String registerConfigProvider(String className, Map properties, String layer, String appContext, String description); @Override boolean removeRegistration(String registrationId); @Override String[] detachListener(RegistrationListener listener, String layer, String appContext); @Override RegistrationContext getRegistrationContext(String registrationID); @Override String[] getRegistrationIDs(AuthConfigProvider provider); @Override void refresh();  }