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;
*/
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();
}
--- /dev/null
+/*
+ * 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> {
+}
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;
public class CredentialServiceAuthProviderTest {
@Mock
- private CredentialAuth<PasswordCredentials> credAuth;
+ private PasswordCredentialAuth credAuth;
@Mock
private BundleContext ctx;