1 package org.opendaylight.yang.gen.v1.config.aaa.authn.idmlight.rev151204;
3 import org.opendaylight.aaa.api.CredentialAuth;
4 import org.opendaylight.aaa.api.IDMStoreException;
5 import org.opendaylight.aaa.api.IIDMStore;
6 import org.opendaylight.aaa.api.IdMService;
7 import org.opendaylight.aaa.idm.IdmLightProxy;
8 import org.opendaylight.aaa.idm.StoreBuilder;
9 import org.osgi.framework.BundleContext;
10 import org.osgi.framework.ServiceReference;
11 import org.osgi.framework.ServiceRegistration;
12 import org.osgi.util.tracker.ServiceTracker;
13 import org.osgi.util.tracker.ServiceTrackerCustomizer;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
17 public class AAAIDMLightModule extends org.opendaylight.yang.gen.v1.config.aaa.authn.idmlight.rev151204.AbstractAAAIDMLightModule {
19 private static final Logger LOG = LoggerFactory.getLogger(AAAIDMLightModule.class);
20 private BundleContext bundleContext = null;
21 private static volatile IIDMStore store = null;
23 public AAAIDMLightModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
24 super(identifier, dependencyResolver);
27 public AAAIDMLightModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.config.aaa.authn.idmlight.rev151204.AAAIDMLightModule oldModule, java.lang.AutoCloseable oldInstance) {
28 super(identifier, dependencyResolver, oldModule, oldInstance);
32 public void customValidation() {
33 // add custom validation form module attributes here.
37 public java.lang.AutoCloseable createInstance() {
38 final IdmLightProxy proxy = new IdmLightProxy();
39 final ServiceRegistration<?> idmService = bundleContext.registerService(IdMService.class.getName(), proxy, null);
40 final ServiceRegistration<?> clientAuthService = bundleContext.registerService(CredentialAuth.class.getName(), proxy, null);
42 final ServiceTracker<IIDMStore, IIDMStore> storeServiceTracker = new ServiceTracker<>(bundleContext, IIDMStore.class,
43 new ServiceTrackerCustomizer<IIDMStore, IIDMStore>() {
45 public IIDMStore addingService(ServiceReference<IIDMStore> reference) {
46 store = reference.getBundle().getBundleContext().getService(reference);
47 LOG.info("IIDMStore service {} was found", store.getClass());
49 StoreBuilder.init(store);
50 } catch (IDMStoreException e) {
51 LOG.error("Failed to initialize data in store", e);
58 public void modifiedService(ServiceReference<IIDMStore> reference, IIDMStore service) {
62 public void removedService(ServiceReference<IIDMStore> reference, IIDMStore service) {
66 storeServiceTracker.open();
68 LOG.info("AAA IDM Light Module Initialized");
69 return new AutoCloseable() {
71 public void close() throws Exception {
72 idmService.unregister();
73 clientAuthService.unregister();
74 storeServiceTracker.close();
79 public void setBundleContext(BundleContext b){
80 this.bundleContext = b;
83 public static final IIDMStore getStore(){
87 public static final void setStore(IIDMStore s){