Add PasswordCredentialAuth interface 68/35768/4
authormiroslav.kovac <miroslav.kovac@pantheon.tech>
Thu, 3 Mar 2016 13:38:55 +0000 (14:38 +0100)
committermiroslav.kovac <miroslav.kovac@pantheon.tech>
Thu, 17 Mar 2016 11:14:52 +0000 (12:14 +0100)
Prevents warnings during compilation since CredentialAuth is generic.

Change-Id: I368ecf4d03dca65da331c5fd81f2ac7c94d5972e
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/CredentialServiceAuthProvider.java
netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/PasswordCredentialAuth.java [new file with mode: 0644]
netconf/aaa-authn-odl-plugin/src/test/java/org/opendaylight/aaa/odl/CredentialServiceAuthProviderTest.java

index fe1f21c064e6cdc6a94463302cccb174ad072f7c..2fb22dbe56b9586aacfae67c007961514fa808eb 100644 (file)
@@ -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<BundleContext, CredentialServiceAuthProvider> INSTANCE;
 
-    // FIXME CredentialAuth is generic and it causes warnings during compilation
-    // Maybe there should be a PasswordCredentialAuth implements CredentialAuth<PasswordCredentials>
-    private volatile CredentialAuth<PasswordCredentials> nullableCredService;
-    private final ServiceTracker<CredentialAuth, CredentialAuth> listenerTracker;
+    private volatile PasswordCredentialAuth nullableCredService;
+    private final ServiceTracker<PasswordCredentialAuth, PasswordCredentialAuth> listenerTracker;
 
     public CredentialServiceAuthProvider(final BundleContext bundleContext) {
 
-        final ServiceTrackerCustomizer<CredentialAuth, CredentialAuth> customizer = new ServiceTrackerCustomizer<CredentialAuth, CredentialAuth>() {
+        final ServiceTrackerCustomizer<PasswordCredentialAuth, PasswordCredentialAuth> customizer = new ServiceTrackerCustomizer<PasswordCredentialAuth, PasswordCredentialAuth>() {
             @Override
-            public CredentialAuth addingService(final ServiceReference<CredentialAuth> reference) {
+            public PasswordCredentialAuth addingService(final ServiceReference<PasswordCredentialAuth> reference) {
                 logger.trace("Credential service {} added", reference);
-                nullableCredService = bundleContext.getService(reference);
+                nullableCredService =  bundleContext.getService(reference);
                 return nullableCredService;
             }
 
             @Override
-            public void modifiedService(final ServiceReference<CredentialAuth> reference, final CredentialAuth service) {
+            public void modifiedService(final ServiceReference<PasswordCredentialAuth> reference, final PasswordCredentialAuth service) {
                 logger.trace("Replacing modified Credential service {}", reference);
                 nullableCredService = service;
             }
 
             @Override
-            public void removedService(final ServiceReference<CredentialAuth> reference, final CredentialAuth service) {
+            public void removedService(final ServiceReference<PasswordCredentialAuth> 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 (file)
index 0000000..0fc2024
--- /dev/null
@@ -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<PasswordCredentials> {
+}
index 4962256717fb3bc0b7b59fb3a377a4051a465e5f..0a025e32b17a0d095f97761f231ba6b774469e09 100644 (file)
@@ -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<PasswordCredentials> credAuth;
+    private PasswordCredentialAuth credAuth;
     @Mock
     private BundleContext ctx;