From 57bfaf2a0146d33a9a504b5a48c5525916a44b79 Mon Sep 17 00:00:00 2001 From: "miroslav.kovac" Date: Thu, 3 Mar 2016 14:38:55 +0100 Subject: [PATCH] Add PasswordCredentialAuth interface Prevents warnings during compilation since CredentialAuth is generic. Change-Id: I368ecf4d03dca65da331c5fd81f2ac7c94d5972e Signed-off-by: miroslav.kovac --- .../odl/CredentialServiceAuthProvider.java | 19 ++++++++----------- .../aaa/odl/PasswordCredentialAuth.java | 15 +++++++++++++++ .../CredentialServiceAuthProviderTest.java | 3 +-- 3 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/PasswordCredentialAuth.java diff --git a/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/CredentialServiceAuthProvider.java b/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/CredentialServiceAuthProvider.java index fe1f21c064..2fb22dbe56 100644 --- a/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/CredentialServiceAuthProvider.java +++ b/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/CredentialServiceAuthProvider.java @@ -10,7 +10,6 @@ package org.opendaylight.aaa.odl; import java.util.Map; import org.opendaylight.aaa.api.AuthenticationException; import org.opendaylight.aaa.api.Claim; -import org.opendaylight.aaa.api.CredentialAuth; import org.opendaylight.aaa.api.PasswordCredentials; import org.opendaylight.netconf.auth.AuthProvider; import org.osgi.framework.BundleContext; @@ -32,36 +31,34 @@ public final class CredentialServiceAuthProvider implements AuthProvider, AutoCl */ public static volatile Map.Entry INSTANCE; - // FIXME CredentialAuth is generic and it causes warnings during compilation - // Maybe there should be a PasswordCredentialAuth implements CredentialAuth - private volatile CredentialAuth nullableCredService; - private final ServiceTracker listenerTracker; + private volatile PasswordCredentialAuth nullableCredService; + private final ServiceTracker listenerTracker; public CredentialServiceAuthProvider(final BundleContext bundleContext) { - final ServiceTrackerCustomizer customizer = new ServiceTrackerCustomizer() { + final ServiceTrackerCustomizer customizer = new ServiceTrackerCustomizer() { @Override - public CredentialAuth addingService(final ServiceReference reference) { + public PasswordCredentialAuth addingService(final ServiceReference reference) { logger.trace("Credential service {} added", reference); - nullableCredService = bundleContext.getService(reference); + nullableCredService = bundleContext.getService(reference); return nullableCredService; } @Override - public void modifiedService(final ServiceReference reference, final CredentialAuth service) { + public void modifiedService(final ServiceReference reference, final PasswordCredentialAuth service) { logger.trace("Replacing modified Credential service {}", reference); nullableCredService = service; } @Override - public void removedService(final ServiceReference reference, final CredentialAuth service) { + public void removedService(final ServiceReference reference, final PasswordCredentialAuth service) { logger.trace("Removing Credential service {}. This AuthProvider will fail to authenticate every time", reference); synchronized (CredentialServiceAuthProvider.this) { nullableCredService = null; } } }; - listenerTracker = new ServiceTracker<>(bundleContext, CredentialAuth.class, customizer); + listenerTracker = new ServiceTracker<>(bundleContext, PasswordCredentialAuth.class, customizer); listenerTracker.open(); } diff --git a/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/PasswordCredentialAuth.java b/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/PasswordCredentialAuth.java new file mode 100644 index 0000000000..0fc2024b23 --- /dev/null +++ b/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/PasswordCredentialAuth.java @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2016 Cisco Systems, 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 + */ + +package org.opendaylight.aaa.odl; + +import org.opendaylight.aaa.api.CredentialAuth; +import org.opendaylight.aaa.api.PasswordCredentials; + +public interface PasswordCredentialAuth extends CredentialAuth { +} diff --git a/netconf/aaa-authn-odl-plugin/src/test/java/org/opendaylight/aaa/odl/CredentialServiceAuthProviderTest.java b/netconf/aaa-authn-odl-plugin/src/test/java/org/opendaylight/aaa/odl/CredentialServiceAuthProviderTest.java index 4962256717..0a025e32b1 100644 --- a/netconf/aaa-authn-odl-plugin/src/test/java/org/opendaylight/aaa/odl/CredentialServiceAuthProviderTest.java +++ b/netconf/aaa-authn-odl-plugin/src/test/java/org/opendaylight/aaa/odl/CredentialServiceAuthProviderTest.java @@ -26,7 +26,6 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.opendaylight.aaa.api.AuthenticationException; import org.opendaylight.aaa.api.Claim; -import org.opendaylight.aaa.api.CredentialAuth; import org.opendaylight.aaa.api.PasswordCredentials; import org.osgi.framework.BundleContext; import org.osgi.framework.Filter; @@ -37,7 +36,7 @@ import org.osgi.framework.ServiceReference; public class CredentialServiceAuthProviderTest { @Mock - private CredentialAuth credAuth; + private PasswordCredentialAuth credAuth; @Mock private BundleContext ctx; -- 2.36.6