From: Robert Varga Date: Wed, 12 May 2021 09:00:14 +0000 (+0200) Subject: Merge OSGiCredentialServiceAuthProvider X-Git-Tag: v1.13.2~11 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=616da074c253305d082cdde0c4376df541dfc8b2;p=netconf.git Merge OSGiCredentialServiceAuthProvider We now have OSGi R7, hence we can safely use constructor injection, eliminating the need for an extra class. Change-Id: I41a1bc06d6aec1be89979327e9b530952cd673ce Signed-off-by: Robert Varga --- diff --git a/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/netconf/authprovider/CredentialServiceAuthProvider.java b/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/netconf/authprovider/CredentialServiceAuthProvider.java index 8e869aca32..eab2c7fb36 100644 --- a/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/netconf/authprovider/CredentialServiceAuthProvider.java +++ b/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/netconf/authprovider/CredentialServiceAuthProvider.java @@ -16,6 +16,9 @@ import org.opendaylight.aaa.api.Claim; import org.opendaylight.aaa.api.PasswordCredentialAuth; import org.opendaylight.aaa.api.PasswordCredentials; 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.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,13 +26,15 @@ import org.slf4j.LoggerFactory; * AuthProvider implementation delegating to a {@link PasswordCredentialAuth} instance. */ @Singleton +@Component(immediate = true, property = "type=netconf-auth-provider") public final class CredentialServiceAuthProvider implements AuthProvider { private static final Logger LOG = LoggerFactory.getLogger(CredentialServiceAuthProvider.class); private final PasswordCredentialAuth credService; @Inject - public CredentialServiceAuthProvider(final PasswordCredentialAuth credService) { + @Activate + public CredentialServiceAuthProvider(final @Reference PasswordCredentialAuth credService) { this.credService = requireNonNull(credService); } 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 deleted file mode 100644 index 8d44faf96b..0000000000 --- a/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/netconf/authprovider/OSGiCredentialServiceAuthProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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; - } -}