Fix issues related to checkstyle enforcement for module 02/53102/4
authorDavid <david.suarez.fuentes@ericsson.com>
Thu, 9 Mar 2017 22:17:26 +0000 (23:17 +0100)
committerRyan Goulding <ryandgoulding@gmail.com>
Wed, 22 Mar 2017 00:17:44 +0000 (00:17 +0000)
aaa-authn-sssd

- Copyright sections
- Line lengths
- Formatting
- Move variable declaration closer to its use
- Change variable names
- Exception catching
- JavaDoc
- Enforcement in pom.xml

Change-Id: I4082eced4907409b20be18cf2cd348e3f59096f6
Signed-off-by: David <david.suarez.fuentes@ericsson.com>
aaa-authn-sssd/pom.xml
aaa-authn-sssd/src/main/java/org/opendaylight/aaa/sssd/SssdClaimAuth.java

index fed6c595afde4936570bdccac9388d54b922607d..d22c181ae0d85003503c6df38bb7dd56bdd0e139 100644 (file)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.opendaylight.aaa</groupId>
           </instructions>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>
index 33f9861cca736fa8b8d77649ddd86807e721b881..7c4999a9db58a918b99649ad603a300d62640370 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
+ * Copyright (c) 2014, 2017 Hewlett-Packard Development Company, L.P. 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,
@@ -8,6 +8,7 @@
 
 package org.opendaylight.aaa.sssd;
 
+import java.io.IOException;
 import java.io.StringWriter;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -41,9 +42,9 @@ public class SssdClaimAuth implements ClaimAuth {
     private RuleProcessor ruleProcessor = null;
 
     // Called by DM when all required dependencies are satisfied.
-    void init(Component c) {
+    void init(Component componet) {
         LOG.info("Initializing SSSD Plugin");
-        Map<String, Object> properties = new HashMap<String, Object>(1);
+        Map<String, Object> properties = new HashMap<>(1);
         properties.put(JsonGenerator.PRETTY_PRINTING, true);
         generatorFactory = Json.createGeneratorFactory(properties);
 
@@ -56,16 +57,16 @@ public class SssdClaimAuth implements ClaimAuth {
         Path mappingRulesPath = Paths.get(mappingRulesFile);
 
         if (!Files.exists(mappingRulesPath)) {
-            LOG.warn(String.format("mapping rules file (%s) "
-                    + "does not exist, SssdClaimAuth will be disabled", mappingRulesFile));
+            LOG.warn(String.format("mapping rules file (%s) " + "does not exist, SssdClaimAuth will be disabled",
+                    mappingRulesFile));
             return;
         }
 
         try {
             ruleProcessor = new RuleProcessor(mappingRulesPath, null);
-        } catch (Exception e) {
-            LOG.error(String.format("mapping rules file (%s) "
-                    + "could not be loaded, SssdClaimAuth will be disabled. " + "error = %s",
+        } catch (IOException e) {
+            LOG.error(String.format(
+                    "mapping rules file (%s) " + "could not be loaded, SssdClaimAuth will be disabled. " + "error = %s",
                     mappingRulesFile, e));
         }
     }
@@ -74,43 +75,39 @@ public class SssdClaimAuth implements ClaimAuth {
      * Transform a Map of assertions into a {@link Claim} via a set of mapping
      * rules.
      *
+     * <p>
      * A set of mapping rules have been previously loaded. the incoming
      * assertion is converted to a JSON document and presented to the
      * {@link RuleProcessor}. If the RuleProcessor can successfully transform
      * the assertion given the site specific set of rules it will return a Map
      * of values which will then be used to build a {@link Claim}. The rule
-     * should return one or more of the following which will be used to populate
-     * the Claim.
+     * should return one or more of the following which will be used to
+     * populate.
      *
-     * <dl>
-     * <dt>ClientId</dt>
-     * <dd>A string.
+     * <p>
+     * ClientId:a string.
      *
-     * @see org.opendaylight.aaa.api.Claim#clientId() </dd>
+     * @see org.opendaylight.aaa.api.Claim#clientId()
      *
-     *      <dt>UserId</dt> <dd>A string.
-     * @see org.opendaylight.aaa.api.Claim#userId() </dd>
+     *      UserId: a string
+     * @see org.opendaylight.aaa.api.Claim#userId()
      *
-     *      <dt>User</dt> <dd>A string.
-     * @see org.opendaylight.aaa.api.Claim#user() </dd>
+     *      User: a string.
+     * @see org.opendaylight.aaa.api.Claim#user()
      *
-     *      <dt>Domain</dt> <dd>A string.
-     * @see org.opendaylight.aaa.api.Claim#domain() </dd>
+     *      Domain: a string.
+     * @see org.opendaylight.aaa.api.Claim#domain()
      *
-     *      <dt>Roles</dt> <dd>An array of strings.
-     * @see org.opendaylight.aaa.api.Claim#roles() </dd>
-     *
-     *      </dl>
+     *      Roles: an array of strings.
+     * @see org.opendaylight.aaa.api.Claim#roles()
      *
      * @param assertion
      *            A Map of name/value assertions provided by an external IdP
      * @return A {@link Claim} if successful, null otherwise.
      */
-
     @Override
     public Claim transform(Map<String, Object> assertion) {
         String assertionJson;
-        Map<String, Object> mapped;
         assertionJson = claimToJson(assertion);
 
         if (ruleProcessor == null) {
@@ -121,7 +118,7 @@ public class SssdClaimAuth implements ClaimAuth {
         if (LOG.isDebugEnabled()) {
             LOG.debug("assertionJson=\n{}", assertionJson);
         }
-
+        Map<String, Object> mapped;
         mapped = ruleProcessor.process(assertionJson);
         if (mapped == null) {
             if (LOG.isDebugEnabled()) {
@@ -166,6 +163,7 @@ public class SssdClaimAuth implements ClaimAuth {
     /**
      * Convert a Claim Map into a JSON object.
      *
+     * <p>
      * Given a Map of name/value pairs convert it into a JSON object and return
      * it as a string. This is not a general purpose routine used to convert any
      * Map into JSON because a claim has the restriction that each value must be
@@ -179,7 +177,6 @@ public class SssdClaimAuth implements ClaimAuth {
      * <li>Boolean</li>
      * <li>null</li>
      * </ul>
-     *
      * See also {@link ClaimAuth}.
      *
      * @param claim
@@ -210,8 +207,8 @@ public class SssdClaimAuth implements ClaimAuth {
             } else if (value == null) {
                 generator.write(name, JsonValue.NULL);
             } else {
-                LOG.warn(String.format("ignoring claim unsupported value type "
-                        + "entry %s has type %s", name, value.getClass().getSimpleName()));
+                LOG.warn(String.format("ignoring claim unsupported value type " + "entry %s has type %s", name,
+                        value.getClass().getSimpleName()));
             }
         }
         generator.writeEnd();