dbfea6ede7269dec57384356eb02464f0128f88f
[moon.git] /
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.authz.srv;
10
11 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
12 import org.opendaylight.controller.sal.core.api.Broker;
13 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
14 import org.opendaylight.controller.sal.core.api.BrokerService;
15 import org.opendaylight.controller.sal.core.spi.ForwardingProviderSession;
16
17 /**
18  * Created by wdec on 28/08/2014.
19  */
20 public class AuthzProviderContextImpl extends ForwardingProviderSession {
21
22     private final Broker.ProviderSession realSession;
23
24     public AuthzProviderContextImpl(Broker.ProviderSession providerSession,
25             AuthzBrokerImpl authzBroker) {
26         this.realSession = providerSession;
27     }
28
29     @Override
30     protected ProviderSession delegate() {
31         // TODO Auto-generated method stub
32         return realSession;
33     }
34
35     @Override
36     public <T extends BrokerService> T getService(Class<T> tClass) {
37         T t;
38         // Check for class and return Authz broker only for DOMBroker
39         if (tClass == DOMDataBroker.class) {
40             t = (T) AuthzDomDataBroker.getInstance();
41         } else {
42             t = realSession.getService(tClass);
43         }
44         // AuthzDomDataBroker.getInstance().setDomDataBroker((DOMDataBroker)t);
45         return t;
46     }
47 }