From 3c7776cebdd0313449da8a44e2a9db4491eb434d Mon Sep 17 00:00:00 2001 From: "matus.kubica" Date: Thu, 13 Apr 2017 16:14:36 +0200 Subject: [PATCH] Bug 8153: Enforce check-style rules for netconf - aaa-authn-odl-plugin Organize Imports for Checkstyle compliance. Checkstyle compliance: line length. Checkstyle compliance: various types of small changes. Checkstyle compliant Exception handling. Checkstyle final clean up & enforcement. Add the fail on violation flag into the pom.xml . Change-Id: I91e2642a694f330863ffcc6b3759a4df530001bb Signed-off-by: matus.kubica --- netconf/aaa-authn-odl-plugin/pom.xml | 13 ++++++++ .../odl/CredentialServiceAuthProvider.java | 31 ++++++++++--------- .../CredentialServiceAuthProviderTest.java | 1 - 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/netconf/aaa-authn-odl-plugin/pom.xml b/netconf/aaa-authn-odl-plugin/pom.xml index 6dc5676e9d..115e048ff8 100644 --- a/netconf/aaa-authn-odl-plugin/pom.xml +++ b/netconf/aaa-authn-odl-plugin/pom.xml @@ -64,4 +64,17 @@ test + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + + + + 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 67ad6ebc57..19e72dfe08 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 @@ -25,10 +25,10 @@ import org.slf4j.LoggerFactory; * AuthProvider implementation delegating to AAA CredentialAuth<PasswordCredentials> instance. */ public final class CredentialServiceAuthProvider implements AuthProvider, AutoCloseable { - private static final Logger logger = LoggerFactory.getLogger(CredentialServiceAuthProvider.class); + private static final Logger LOG = LoggerFactory.getLogger(CredentialServiceAuthProvider.class); /** - * Singleton instance with delayed instantiation + * Singleton instance with delayed instantiation. */ public static volatile Map.Entry INSTANCE; @@ -39,23 +39,26 @@ public final class CredentialServiceAuthProvider implements AuthProvider, AutoCl public CredentialServiceAuthProvider(final BundleContext bundleContext) { - final ServiceTrackerCustomizer customizer = new ServiceTrackerCustomizer() { + final ServiceTrackerCustomizer customizer = + new ServiceTrackerCustomizer() { @Override public CredentialAuth addingService(final ServiceReference reference) { - logger.trace("Credential service {} added", reference); + LOG.trace("Credential service {} added", reference); nullableCredService = bundleContext.getService(reference); return nullableCredService; } @Override - public void modifiedService(final ServiceReference reference, final CredentialAuth service) { - logger.trace("Replacing modified Credential service {}", reference); + public void modifiedService(final ServiceReference reference, + final CredentialAuth service) { + LOG.trace("Replacing modified Credential service {}", reference); nullableCredService = service; } @Override public void removedService(final ServiceReference reference, final CredentialAuth service) { - logger.trace("Removing Credential service {}. This AuthProvider will fail to authenticate every time", reference); + LOG.trace("Removing Credential service {}. " + + "This AuthProvider will fail to authenticate every time", reference); synchronized (CredentialServiceAuthProvider.this) { nullableCredService = null; } @@ -66,13 +69,13 @@ public final class CredentialServiceAuthProvider implements AuthProvider, AutoCl } /** - * Authenticate user. This implementation tracks CredentialAuth<PasswordCredentials> and delegates the decision to it. If the service is not - * available, IllegalStateException is thrown. + * Authenticate user. This implementation tracks CredentialAuth<PasswordCredentials> + * and delegates the decision to it. If the service is not available, IllegalStateException is thrown. */ @Override public synchronized boolean authenticated(final String username, final String password) { if (nullableCredService == null) { - logger.warn("Cannot authenticate user '{}', Credential service is missing", username); + LOG.warn("Cannot authenticate user '{}', Credential service is missing", username); throw new IllegalStateException("Credential service is not available"); } @@ -80,16 +83,16 @@ public final class CredentialServiceAuthProvider implements AuthProvider, AutoCl try { claim = nullableCredService.authenticate(new PasswordCredentialsWrapper(username, password)); } catch (AuthenticationException e) { - logger.debug("Authentication failed for user '{}' : {}", username, e); + LOG.debug("Authentication failed for user '{}' : {}", username, e); return false; } - logger.debug("Authentication result for user '{}' : {}", username, claim.domain()); + LOG.debug("Authentication result for user '{}' : {}", username, claim.domain()); return true; } /** - * Invoke by blueprint + * Invoked by blueprint. */ @Override public void close() { @@ -101,7 +104,7 @@ public final class CredentialServiceAuthProvider implements AuthProvider, AutoCl private final String username; private final String password; - public PasswordCredentialsWrapper(final String username, final String password) { + PasswordCredentialsWrapper(final String username, final String password) { this.username = username; this.password = password; } 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..08456118c3 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 @@ -5,7 +5,6 @@ * 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 static org.junit.Assert.assertFalse; -- 2.36.6