Add blueprint wiring for aaa-authn-odl-plugin 99/45599/17
authorAlexis de Talhouët <adetalhouet@inocybe.com>
Wed, 5 Oct 2016 20:00:11 +0000 (16:00 -0400)
committerAlexis de Talhouët <adetalhouet@inocybe.com>
Mon, 31 Oct 2016 15:43:42 +0000 (11:43 -0400)
Change-Id: Ice0fcaf58aae9b9402e9b6e515e57b2157a1be69
Signed-off-by: Alexis de Talhouët <adetalhouet@inocybe.com>
netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/CredentialServiceAuthProvider.java
netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/yang/gen/v1/config/aaa/authn/netconf/plugin/rev150715/AuthProviderModule.java
netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/yang/gen/v1/config/aaa/authn/netconf/plugin/rev150715/AuthProviderModuleFactory.java
netconf/aaa-authn-odl-plugin/src/main/resources/org/opendaylight/blueprint/aaa-authn-netconf.xml [new file with mode: 0644]
netconf/aaa-authn-odl-plugin/src/main/yang/aaa-authn-netconf-plugin.yang
netconf/netconf-auth/src/main/yang/netconf-auth.yang
netconf/netconf-client/src/test/resources/helloMessage1.xml

index fe1f21c064e6cdc6a94463302cccb174ad072f7c..67ad6ebc572475dce506bc4aee96bdbf6b00254d 100644 (file)
@@ -88,8 +88,11 @@ public final class CredentialServiceAuthProvider implements AuthProvider, AutoCl
         return true;
     }
 
+    /**
+     * Invoke by blueprint
+     */
     @Override
-    public void close() throws Exception {
+    public void close() {
         listenerTracker.close();
         nullableCredService = null;
     }
index e264881f6660c7756df2e5b87e72df18bdf4b995..6de5c18b75674cfcec97400df305e8e6c14ca8e3 100644 (file)
@@ -9,11 +9,19 @@
 package org.opendaylight.yang.gen.v1.config.aaa.authn.netconf.plugin.rev150715;
 
 import com.google.common.base.Preconditions;
-import org.opendaylight.aaa.odl.CredentialServiceAuthProvider;
+import com.google.common.reflect.AbstractInvocationHandler;
+import com.google.common.reflect.Reflection;
+import java.lang.reflect.Method;
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.netconf.auth.AuthProvider;
 import org.osgi.framework.BundleContext;
 
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
 public class AuthProviderModule extends org.opendaylight.yang.gen.v1.config.aaa.authn.netconf.plugin.rev150715.AbstractAuthProviderModule {
 
     private BundleContext bundleContext;
@@ -42,8 +50,24 @@ public class AuthProviderModule extends org.opendaylight.yang.gen.v1.config.aaa.
     }
 
     @Override
-    public AutoCloseable createInstance() {
-       return new CredentialServiceAuthProvider(bundleContext);
+    public java.lang.AutoCloseable createInstance() {
+        final WaitingServiceTracker<AuthProvider> tracker =
+                WaitingServiceTracker.create(AuthProvider.class, bundleContext, "(type=netconf-auth-provider)");
+        final AuthProvider service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+        return Reflection.newProxy(AutoCloseableAuthProvider.class, new AbstractInvocationHandler() {
+            @Override
+            protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
+                if (method.getName().equals("close")) {
+                    tracker.close();
+                    return null;
+                } else {
+                    return method.invoke(service, args);
+                }
+            }
+        });
     }
 
+    private static interface AutoCloseableAuthProvider extends AuthProvider, AutoCloseable {
+    }
 }
index 495ac424929e8674da988787b5b1fa29856ea431..1739f859d8fbf2135148f2b72e51a9d4c9e076da 100644 (file)
@@ -24,6 +24,10 @@ import org.opendaylight.controller.config.api.DependencyResolverFactory;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.osgi.framework.BundleContext;
 
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
 public class AuthProviderModuleFactory extends org.opendaylight.yang.gen.v1.config.aaa.authn.netconf.plugin.rev150715.AbstractAuthProviderModuleFactory {
 
     private static final ModuleIdentifier DEFAULT_INSTANCE_ID = new ModuleIdentifier(NAME, "default-auth-provider");
diff --git a/netconf/aaa-authn-odl-plugin/src/main/resources/org/opendaylight/blueprint/aaa-authn-netconf.xml b/netconf/aaa-authn-odl-plugin/src/main/resources/org/opendaylight/blueprint/aaa-authn-netconf.xml
new file mode 100644 (file)
index 0000000..6e55371
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies Inc. and others.  All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           odl:use-default-for-reference-types="true">
+
+    <bean id="credentialServiceAuthProvider"
+          class="org.opendaylight.aaa.odl.CredentialServiceAuthProvider"
+          destroy-method="close">
+        <argument ref="blueprintBundleContext"/>
+    </bean>
+    <service ref="credentialServiceAuthProvider" interface="org.opendaylight.netconf.auth.AuthProvider"
+             odl:type="netconf-auth-provider"/>
+
+</blueprint>
\ No newline at end of file
index ffa6d986070d90df973a5f6cb114abad49f08984..83169c21e545fc6ad44ca447588163cc9fa043ce 100644 (file)
@@ -16,9 +16,11 @@ module aaa-authn-netconf-plugin {
             base config:module-type;
             config:java-name-prefix AuthProvider;
             config:provided-service na:netconf-auth-provider;
+            status deprecated;
     }
 
     augment "/config:modules/config:module/config:configuration" {
+        status deprecated;
         case aaa-authn-netconf-plugin {
             when "/config:modules/config:module/config:type = 'aaa-authn-netconf-plugin'";
             // no config yet
index 8f975ced2be7c491a09d42bbe45320ab1abf7a56..97213b5d466ebb229c6c5a8fffd7e9a45fb7bcf1 100644 (file)
@@ -17,6 +17,8 @@ module netconf-auth {
     identity netconf-auth-provider {
         base "config:service-type";
         config:java-class "org.opendaylight.netconf.auth.AuthProvider";
+        config:disable-osgi-service-registration;
+        status deprecated;
     }
 
 }
\ No newline at end of file
index 9cc3feb8494e30cb3f455119f320de279a87852c..7179c8de25aad4c4efd5afc2b3e15b2a9a7687ce 100644 (file)
@@ -24,7 +24,6 @@
         <capability>urn:ietf:params:xml:ns:yang:ietf-network-topology?module=ietf-network-topology&amp;revision=2015-06-08</capability>
         <capability>urn:ietf:params:xml:ns:yang:ietf-netconf-notifications?module=ietf-netconf-notifications&amp;revision=2012-02-06</capability>
         <capability>urn:TBD:params:xml:ns:yang:ospf-topology?module=ospf-topology&amp;revision=2013-10-21</capability>
-        <capability>config:aaa:authn:netconf:plugin?module=aaa-authn-netconf-plugin&amp;revision=2015-07-15</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:config:netconf:auth?module=netconf-auth&amp;revision=2015-07-15</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store?module=opendaylight-operational-dom-datastore&amp;revision=2014-06-17</capability>
         <capability>urn:ietf:params:xml:ns:yang:ospf-topology?module=ospf-topology&amp;revision=2013-07-12</capability>