Bug 8153: Enforce check-style rules for netconf - aaa-authn-odl-plugin 87/54987/5
authormatus.kubica <matus.kubica@pantheon.tech>
Thu, 13 Apr 2017 14:14:36 +0000 (16:14 +0200)
committerTomas Cere <tcere@cisco.com>
Thu, 27 Apr 2017 11:40:03 +0000 (11:40 +0000)
    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 <matus.kubica@pantheon.tech>
netconf/aaa-authn-odl-plugin/pom.xml
netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/CredentialServiceAuthProvider.java
netconf/aaa-authn-odl-plugin/src/test/java/org/opendaylight/aaa/odl/CredentialServiceAuthProviderTest.java

index 6dc5676e9df7adb5800b383537678dea4a64a3c2..115e048ff8fdb3e35b4554b367b8ad400047e573 100644 (file)
             <scope>test</scope>
         </dependency>
     </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>
index 67ad6ebc572475dce506bc4aee96bdbf6b00254d..19e72dfe08bf9aec4d1397b085a3271e8e1de2df 100644 (file)
@@ -25,10 +25,10 @@ import org.slf4j.LoggerFactory;
  * AuthProvider implementation delegating to AAA CredentialAuth&lt;PasswordCredentials&gt; 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<BundleContext, CredentialServiceAuthProvider> INSTANCE;
 
@@ -39,23 +39,26 @@ public final class CredentialServiceAuthProvider implements AuthProvider, AutoCl
 
     public CredentialServiceAuthProvider(final BundleContext bundleContext) {
 
-        final ServiceTrackerCustomizer<CredentialAuth, CredentialAuth> customizer = new ServiceTrackerCustomizer<CredentialAuth, CredentialAuth>() {
+        final ServiceTrackerCustomizer<CredentialAuth, CredentialAuth> customizer =
+                new ServiceTrackerCustomizer<CredentialAuth, CredentialAuth>() {
             @Override
             public CredentialAuth addingService(final ServiceReference<CredentialAuth> 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<CredentialAuth> reference, final CredentialAuth service) {
-                logger.trace("Replacing modified Credential service {}", reference);
+            public void modifiedService(final ServiceReference<CredentialAuth> reference,
+                                        final CredentialAuth service) {
+                LOG.trace("Replacing modified Credential service {}", reference);
                 nullableCredService = service;
             }
 
             @Override
             public void removedService(final ServiceReference<CredentialAuth> 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&lt;PasswordCredentials&gt; and delegates the decision to it. If the service is not
-     * available, IllegalStateException is thrown.
+     * Authenticate user. This implementation tracks CredentialAuth&lt;PasswordCredentials&gt;
+     * 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;
         }
index 4962256717fb3bc0b7b59fb3a377a4051a465e5f..08456118c3bc2fe95604df3cc161749392c35110 100644 (file)
@@ -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;