2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.config.yang.config.aaa_authz.srv;
11 import org.opendaylight.aaa.api.AuthenticationService;
12 import org.opendaylight.aaa.authz.srv.AuthzBrokerImpl;
13 import org.opendaylight.aaa.authz.srv.AuthzServiceImpl;
14 import org.osgi.framework.BundleContext;
15 import org.osgi.framework.ServiceReference;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 public class AuthzSrvModule extends
20 org.opendaylight.controller.config.yang.config.aaa_authz.srv.AbstractAuthzSrvModule {
21 private static final Logger LOG = LoggerFactory.getLogger(AuthzSrvModule.class);
22 private static boolean simple_config_switch;
23 private BundleContext bundleContext;
25 public AuthzSrvModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
26 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
27 super(identifier, dependencyResolver);
30 public AuthzSrvModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
31 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
32 org.opendaylight.controller.config.yang.config.aaa_authz.srv.AuthzSrvModule oldModule,
33 java.lang.AutoCloseable oldInstance) {
34 super(identifier, dependencyResolver, oldModule, oldInstance);
38 public void customValidation() {
39 // checkNotNull(getDomBroker(), domBrokerJmxAttribute);
43 public java.lang.AutoCloseable createInstance() {
45 // Get new AuthZ Broker
46 final AuthzBrokerImpl authzBrokerImpl = new AuthzBrokerImpl();
48 // Provide real broker to the new Authz broker
49 authzBrokerImpl.setBroker(getDomBrokerDependency());
51 // Get AuthN service reference and register it with the authzBroker
52 ServiceReference<AuthenticationService> authServiceReference = bundleContext
53 .getServiceReference(AuthenticationService.class);
54 AuthenticationService as = bundleContext.getService(authServiceReference);
55 authzBrokerImpl.setAuthenticationService(as);
57 // Set the policies list to authz serviceimpl
58 AuthzServiceImpl.setPolicies(getPolicies());
60 // Register AuthZ broker with the real Broker as a provider; triggers
61 // "onSessionInitiated" in AuthzBrokerImpl
62 getDomBrokerDependency().registerProvider(authzBrokerImpl);
63 // TODO ActionType is of type string, not ENUM due to improper
64 // serialization of ENUMs by config/netconf subsystem. This needs to be
65 // fixed as soon as config/netconf fixes the problem.
68 LOG.info("AuthZ Service Initialized from Config subsystem");
69 return authzBrokerImpl;
73 public void setBundleContext(BundleContext bundleContext) {
74 this.bundleContext = bundleContext;