Convert aaa-authn-odl-plugin to OSGi DS 04/93704/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 9 Nov 2020 17:30:34 +0000 (18:30 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 16 Nov 2020 11:51:18 +0000 (12:51 +0100)
There is no point in keeping blueprint here, remove it.

Change-Id: I3819739d7042cd3d2fdee06b3457dc8bd3cd7ce5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/aaa-authn-odl-plugin/pom.xml
netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/netconf/authprovider/OSGiCredentialServiceAuthProvider.java [new file with mode: 0644]
netconf/aaa-authn-odl-plugin/src/main/resources/OSGI-INF/blueprint/aaa-authn-netconf.xml [deleted file]

index d28c069f1e1bf359187a38d0b1aec3cb46752745..48cdd62d2a8ad562f98dd3d1522a2d2ec3488f8c 100644 (file)
@@ -36,7 +36,7 @@
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
+            <artifactId>osgi.cmpn</artifactId>
         </dependency>
         <dependency>
             <groupId>javax.inject</groupId>
diff --git a/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/netconf/authprovider/OSGiCredentialServiceAuthProvider.java b/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/netconf/authprovider/OSGiCredentialServiceAuthProvider.java
new file mode 100644 (file)
index 0000000..8d44faf
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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
+ */
+package org.opendaylight.netconf.authprovider;
+
+import org.opendaylight.aaa.api.PasswordCredentialAuth;
+import org.opendaylight.netconf.auth.AuthProvider;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(immediate = true, property = "type=netconf-auth-provider")
+// FIXME: merge with CredentialServiceAuthProvider once we have OSGi R7
+public final class OSGiCredentialServiceAuthProvider implements AuthProvider {
+    @Reference
+    PasswordCredentialAuth credService;
+
+    private CredentialServiceAuthProvider delegate = null;
+
+    @Override
+    public boolean authenticated(final String username, final String password) {
+        return delegate.authenticated(username, password);
+    }
+
+    @Activate
+    void activate() {
+        delegate = new CredentialServiceAuthProvider(credService);
+    }
+
+    @Deactivate
+    void deactivate() {
+        delegate = null;
+    }
+}
diff --git a/netconf/aaa-authn-odl-plugin/src/main/resources/OSGI-INF/blueprint/aaa-authn-netconf.xml b/netconf/aaa-authn-odl-plugin/src/main/resources/OSGI-INF/blueprint/aaa-authn-netconf.xml
deleted file mode 100644 (file)
index e04462b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?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">
-
-    <reference id="credentialAuth" interface="org.opendaylight.aaa.api.PasswordCredentialAuth" odl:type="default" />
-
-    <bean id="credentialServiceAuthProvider" class="org.opendaylight.netconf.authprovider.CredentialServiceAuthProvider">
-        <argument ref="credentialAuth"/>
-    </bean>
-    <service ref="credentialServiceAuthProvider" interface="org.opendaylight.netconf.auth.AuthProvider"
-             odl:type="netconf-auth-provider"/>
-
-</blueprint>