Merge "Bug 4054 Federation RuleProcessor utilizes System.out which interferes with...
[aaa.git] / aaa-authn-odl-plugin / src / main / java / org / opendaylight / aaa / odl / AuthProviderActivator.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.aaa.odl;
10
11 import java.util.Hashtable;
12
13 import org.opendaylight.controller.netconf.auth.AuthConstants;
14 import org.opendaylight.controller.netconf.auth.AuthProvider;
15 import org.osgi.framework.BundleActivator;
16 import org.osgi.framework.BundleContext;
17 import org.osgi.framework.ServiceRegistration;
18
19 public class AuthProviderActivator implements BundleActivator {
20
21     public static final int PREFERENCE = 10;
22     private ServiceRegistration<AuthProvider> authProviderServiceRegistration;
23
24     @Override
25     public void start(final BundleContext context) throws Exception {
26         final AuthProvider authProvider = new CredentialServiceAuthProvider(context);
27         // Set preference of this service to 0
28         final Hashtable<String, Object> properties = new Hashtable<>(1);
29         properties.put(AuthConstants.SERVICE_PREFERENCE_KEY, PREFERENCE);
30
31         authProviderServiceRegistration = context.registerService(AuthProvider.class, authProvider, properties);
32     }
33
34     @Override
35     public void stop(final BundleContext context) throws Exception {
36         if(authProviderServiceRegistration != null) {
37             authProviderServiceRegistration.unregister();
38         }
39     }
40 }