From: David Date: Thu, 9 Mar 2017 22:17:26 +0000 (+0100) Subject: Fix issues related to checkstyle enforcement for module X-Git-Tag: release/carbon~22 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=c8b4446a1feeca1cdea77989251bfaf871134c11;p=aaa.git Fix issues related to checkstyle enforcement for module 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 --- diff --git a/aaa-authn-sssd/pom.xml b/aaa-authn-sssd/pom.xml index fed6c595a..d22c181ae 100644 --- a/aaa-authn-sssd/pom.xml +++ b/aaa-authn-sssd/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.opendaylight.aaa @@ -74,6 +75,13 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + diff --git a/aaa-authn-sssd/src/main/java/org/opendaylight/aaa/sssd/SssdClaimAuth.java b/aaa-authn-sssd/src/main/java/org/opendaylight/aaa/sssd/SssdClaimAuth.java index 33f9861cc..7c4999a9d 100644 --- a/aaa-authn-sssd/src/main/java/org/opendaylight/aaa/sssd/SssdClaimAuth.java +++ b/aaa-authn-sssd/src/main/java/org/opendaylight/aaa/sssd/SssdClaimAuth.java @@ -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 properties = new HashMap(1); + Map 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. * + *

* 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. * - *

- *
ClientId
- *
A string. + *

+ * ClientId:a string. * - * @see org.opendaylight.aaa.api.Claim#clientId()

+ * @see org.opendaylight.aaa.api.Claim#clientId() * - *
UserId
A string. - * @see org.opendaylight.aaa.api.Claim#userId()
+ * UserId: a string + * @see org.opendaylight.aaa.api.Claim#userId() * - *
User
A string. - * @see org.opendaylight.aaa.api.Claim#user()
+ * User: a string. + * @see org.opendaylight.aaa.api.Claim#user() * - *
Domain
A string. - * @see org.opendaylight.aaa.api.Claim#domain()
+ * Domain: a string. + * @see org.opendaylight.aaa.api.Claim#domain() * - *
Roles
An array of strings. - * @see org.opendaylight.aaa.api.Claim#roles()
- * - *
+ * 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 assertion) { String assertionJson; - Map 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 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. * + *

* 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 { *

  • Boolean
  • *
  • null
  • * - * * 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();