712427eb1f6edf4cdd8b97c251f673c2f39a720f
[aaa.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.BrokerService;
14 import org.opendaylight.controller.sal.core.api.RpcImplementation;
15 import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
16 import org.opendaylight.yangtools.concepts.ListenerRegistration;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.common.RpcResult;
19 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
20
21 import java.util.Set;
22 import java.util.concurrent.Future;
23
24 /**
25  * Created by wdec on 28/08/2014.
26  */
27 public class AuthzProviderContextImpl extends AuthzConsumerContextImpl implements Broker.ProviderSession {
28
29   private final Broker.ProviderSession realSession;
30
31   public AuthzProviderContextImpl(Broker.ProviderSession providerSession, AuthzBrokerImpl authzBroker) {
32     super(null, authzBroker);
33     this.realSession = providerSession;
34   }
35   @Override
36   public Broker.RpcRegistration addRpcImplementation(QName qName, RpcImplementation rpcImplementation) throws IllegalArgumentException {
37     return realSession.addRpcImplementation(qName, rpcImplementation);
38   }
39
40   @Override
41   public Broker.RoutedRpcRegistration addRoutedRpcImplementation(QName qName, RpcImplementation rpcImplementation) {
42     return realSession.addRoutedRpcImplementation(qName, rpcImplementation);
43   }
44
45   @Override
46   public Broker.RoutedRpcRegistration addMountedRpcImplementation(QName qName, RpcImplementation rpcImplementation) {
47     return realSession.addMountedRpcImplementation(qName, rpcImplementation);
48   }
49
50   @Override
51   public void close() {
52     realSession.close();
53
54   }
55
56   @Override
57   public Future<RpcResult<CompositeNode>> rpc(QName qName, CompositeNode compositeNode) {
58     return realSession.rpc(qName, compositeNode);
59   }
60
61   @Override
62   public boolean isClosed() {
63     return realSession.isClosed();
64   }
65
66   @Override
67   public <T extends BrokerService> T getService(Class<T> tClass) {
68     T t;
69     //Check for class and return Authz broker only for DOMBroker
70     if (tClass == DOMDataBroker.class) {
71       t = (T) AuthzDomDataBroker.getInstance();
72     }
73    else {
74       t = realSession.getService(tClass);
75     }
76    // AuthzDomDataBroker.getInstance().setDomDataBroker((DOMDataBroker)t);
77     return t;
78   }
79
80   @Override
81   public Set<QName> getSupportedRpcs() {
82     return realSession.getSupportedRpcs();
83   }
84
85   @Override
86   public ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(RpcRegistrationListener rpcRegistrationListener) {
87     return realSession.addRpcRegistrationListener(rpcRegistrationListener);
88   }
89 }