Update oauth-provider to use new OSGi APIs
[ccsdk/features.git] / sdnr / wt / oauth-provider / provider-jar / src / main / java / org / onap / ccsdk / features / sdnr / wt / oauthprovider / Helper.java
1 package org.onap.ccsdk.features.sdnr.wt.oauthprovider;
2
3 import org.jolokia.osgi.security.Authenticator;
4 import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.InvalidConfigurationException;
5 import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.UnableToConfigureOAuthService;
6 import org.onap.ccsdk.features.sdnr.wt.oauthprovider.http.AuthHttpServlet;
7 import org.opendaylight.aaa.api.IdMService;
8 import org.opendaylight.mdsal.binding.api.DataBroker;
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.aaa.app.config.rev170619.ShiroConfiguration;
10 import org.osgi.service.http.HttpService;
11 import org.osgi.service.http.NamespaceException;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14
15 import javax.servlet.ServletException;
16 import java.io.IOException;
17
18 public class Helper {
19
20     private static final Logger LOG = LoggerFactory.getLogger(Helper.class);
21     private AuthHttpServlet authServlet;
22
23     public Helper() throws UnableToConfigureOAuthService, IOException, InvalidConfigurationException {
24         this.authServlet = new AuthHttpServlet();
25
26     }
27
28     public void onUnbindService(HttpService httpService) {
29         httpService.unregister(AuthHttpServlet.BASEURI);
30         this.authServlet = null;
31     }
32
33     public void onBindService(HttpService httpService)
34             throws ServletException, NamespaceException {
35         if (httpService == null) {
36             LOG.warn("Unable to inject HttpService into loader.");
37         } else {
38             httpService.registerServlet(AuthHttpServlet.BASEURI, authServlet, null, null);
39             LOG.info("auth servlet registered.");
40         }
41     }
42
43     public void setOdlAuthenticator(Authenticator odlAuthenticator) {
44         authServlet.setOdlAuthenticator(odlAuthenticator);
45     }
46
47     public void setOdlIdentityService(IdMService odlIdentityService) {
48         this.authServlet.setOdlIdentityService(odlIdentityService);
49     }
50
51     public void setShiroConfiguration(ShiroConfiguration shiroConfiguration) {
52         this.authServlet.setShiroConfiguration(shiroConfiguration);
53     }
54
55     public void setDataBroker(DataBroker dataBroker) {
56         this.authServlet.setDataBroker(dataBroker);
57     }
58
59     public void init() {
60
61     }
62
63     public void close() {
64
65     }
66 }