Skip to content

Commit

Permalink
Checkstyle errors clean up
Browse files Browse the repository at this point in the history
Altered documents that threw errors for the newly defined checkstyle configuration

Signed-off-by: Jasper Berton <[email protected]>
  • Loading branch information
JasperB-TeamBlue authored and sandrobonazzola committed Dec 6, 2024
1 parent 58c74a4 commit 632e59c
Show file tree
Hide file tree
Showing 1,256 changed files with 3,483 additions and 3,485 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private enum Action {
module.argMap.get("user-name")
).mput(
Authn.InvokeKeys.CREDENTIALS,
getPassword((String)module.argMap.get("password"))
getPassword((String) module.argMap.get("password"))
)
);
log.info(
Expand All @@ -113,13 +113,13 @@ private enum Action {
),
CHANGE_CREDENTIALS(
module -> {
AAAProfile aaaprofile = module.new AAAProfile((String)module.argMap.get("profile"));
AAAProfile aaaprofile = module.new AAAProfile((String) module.argMap.get("profile"));
if ((aaaprofile.getAuthnExtension().getContext().<Long>get(Authn.ContextKeys.CAPABILITIES, 0L) & Authn.Capabilities.CREDENTIALS_CHANGE) == 0 &&
!(Boolean)module.argMap.get("ignore-capabilities")) {
!(Boolean) module.argMap.get("ignore-capabilities")) {
throw new IllegalArgumentException("Unsupported operation: CREDENTIALS_CHANGE");
}

String user = aaaprofile.mapUser((String)module.argMap.get("user-name"));
String user = aaaprofile.mapUser((String) module.argMap.get("user-name"));
log.info("API: -->Authn.InvokeCommands.CREDENTIALS_CHANGES profile='{}' user='{}'", aaaprofile.getProfile(), user);
ExtMap outMap = aaaprofile.getAuthnExtension().invoke(
new ExtMap().mput(
Expand All @@ -130,10 +130,10 @@ private enum Action {
user
).mput(
Authn.InvokeKeys.CREDENTIALS,
getPassword((String)module.argMap.get("password"))
getPassword((String) module.argMap.get("password"))
).mput(
Authn.InvokeKeys.CREDENTIALS_NEW,
getPassword((String)module.argMap.get("password-new"), "New password: ")
getPassword((String) module.argMap.get("password-new"), "New password: ")
)
);
log.info(
Expand All @@ -151,8 +151,8 @@ private enum Action {
),
LOGIN_USER(
module -> {
AAAProfile aaaprofile = module.new AAAProfile((String)module.argMap.get("profile"));
String user = aaaprofile.mapUser((String)module.argMap.get("user-name"));
AAAProfile aaaprofile = module.new AAAProfile((String) module.argMap.get("profile"));
String user = aaaprofile.mapUser((String) module.argMap.get("user-name"));
log.info("API: -->Authn.InvokeCommands.AUTHENTICATE_CREDENTIALS profile='{}' user='{}'", aaaprofile.getProfile(), user);
ExtMap outMap = aaaprofile.getAuthnExtension().invoke(
new ExtMap().mput(
Expand All @@ -163,7 +163,7 @@ private enum Action {
user
).mput(
Authn.InvokeKeys.CREDENTIALS,
getPassword((String)module.argMap.get("password"))
getPassword((String) module.argMap.get("password"))
)
);
log.info(
Expand Down Expand Up @@ -192,7 +192,7 @@ private enum Action {
);
}

if(aaaprofile.getMappingExtension() != null) {
if (aaaprofile.getMappingExtension() != null) {
log.info("API: -->Mapping.InvokeCommands.MAP_AUTH_RECORD");
Dump.AUTH_RECORD.dump(module, authRecord);
authRecord = aaaprofile.getMappingExtension().invoke(
Expand Down Expand Up @@ -302,7 +302,7 @@ private enum Action {
SEARCH(
module -> {
ExtensionProxy authzExtension = module.getExtensionsManager().getExtensionByName((String) module.argMap.get("extension-name"));
ExtUUID entity = getQueryEntity((String)module.argMap.get("entity"));
ExtUUID entity = getQueryEntity((String) module.argMap.get("entity"));
ExtMap filter = createQueryFilter(entity, module.argMap);
Dump.QUERY_FILTER_RECORD.dump(module, filter, "");

Expand All @@ -311,7 +311,7 @@ private enum Action {
Collections.<String>emptyList()
);
if (module.argMap.get("namespace") != null) {
namespaces = (Collection<String>)module.argMap.get("namespace");
namespaces = (Collection<String>) module.argMap.get("namespace");
}

for (String namespace : namespaces) {
Expand All @@ -325,7 +325,7 @@ private enum Action {
entity
).mput(
Authz.InvokeKeys.QUERY_FLAGS,
getAuthzFlags((List<String>)module.argMap.get("authz-flag"))
getAuthzFlags((List<String>) module.argMap.get("authz-flag"))
).mput(
Authz.InvokeKeys.QUERY_FILTER,
filter
Expand Down Expand Up @@ -395,12 +395,12 @@ Map<String, Object> parse(Map<String, String> substitutions, Properties props, L
parser.parse(actionArgs);
Map<String, Object> argMap = parser.getParsedArgs();

if((Boolean)argMap.get("help")) {
if ((Boolean) argMap.get("help")) {
System.out.format("Usage: %s", parser.getUsage());
throw new ExitException("Help", 0);
}
if(!parser.getErrors().isEmpty()) {
for(Throwable t : parser.getErrors()) {
if (!parser.getErrors().isEmpty()) {
for (Throwable t : parser.getErrors()) {
log.error(t.getMessage());
}
throw new ExitException("Parsing error", 1);
Expand Down Expand Up @@ -492,7 +492,7 @@ private static void dumpRecord(AAAServiceImpl module, ExtMap extMap, Set<ExtKey>
Collection<ExtKey> keys = new HashSet<>(extMap.keySet());
if (module.argModuleMap.get("key") != null) {
Collection<ExtKey> k = new HashSet<>();
for (String uuid : (List<String>)module.argModuleMap.get("key")) {
for (String uuid : (List<String>) module.argModuleMap.get("key")) {
k.add(new ExtKey("Unknown", Object.class, uuid));
}
keys.retainAll(k);
Expand All @@ -505,7 +505,7 @@ private static void dumpRecord(AAAServiceImpl module, ExtMap extMap, Set<ExtKey>
continue;
}
module.output(
((String)module.argModuleMap.get("format")).replace(
((String) module.argModuleMap.get("format")).replace(
"{key}",
key.getUuid().getUuid().toString()
).replace(
Expand Down Expand Up @@ -540,7 +540,7 @@ private static <T> List<T> safeList(List<T> list) {
}

private ExtensionsManager getExtensionsManager() {
return (ExtensionsManager)context.get(ContextKeys.EXTENSION_MANAGER);
return (ExtensionsManager) context.get(ContextKeys.EXTENSION_MANAGER);
}

private ExtensionProxy getExtensionByProfile(String name) {
Expand All @@ -554,7 +554,7 @@ private ExtensionProxy getExtensionByProfile(String name) {
private ExtensionProxy getExtensionByConfigKey(String key, String value) {
ExtensionProxy ret = null;

for(ExtensionProxy proxy : getExtensionsManager().getExtensionsByService(Authn.class.getName())) {
for (ExtensionProxy proxy : getExtensionsManager().getExtensionsByService(Authn.class.getName())) {
if (
value.equals(
proxy.getContext().<Properties>get(
Expand Down Expand Up @@ -591,7 +591,7 @@ private static String getPassword(String what, String prompt) {
if ("pass".equals(type)) {
password = value;
} else if ("file".equals(type)) {
try(
try (
InputStream is = new FileInputStream(value);
Reader reader = new InputStreamReader(is, StandardCharsets.UTF_8);
BufferedReader breader = new BufferedReader(reader)
Expand Down Expand Up @@ -652,12 +652,12 @@ public void parseArguments(List<String> args) throws Exception {
parser.parse(args);
argModuleMap = parser.getParsedArgs();

if((Boolean)argModuleMap.get("help")) {
if ((Boolean) argModuleMap.get("help")) {
System.out.format("Usage: %s", parser.getUsage());
throw new ExitException("Help", 0);
}
if(!parser.getErrors().isEmpty()) {
for(Throwable t : parser.getErrors()) {
if (!parser.getErrors().isEmpty()) {
for (Throwable t : parser.getErrors()) {
log.error(t.getMessage());
}
throw new ExitException("Parsing error", 1);
Expand All @@ -670,7 +670,7 @@ public void parseArguments(List<String> args) throws Exception {

try {
action = Action.valueOf(args.get(0).toUpperCase().replace("-", "_"));
} catch(IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
log.error("Invalid action '{}'", args.get(0));
throw new ExitException("Invalid action", 1);
}
Expand All @@ -680,7 +680,7 @@ public void parseArguments(List<String> args) throws Exception {

@Override
public void run() throws Exception {
int iterations = (Integer)argModuleMap.get("iterations");
int iterations = (Integer) argModuleMap.get("iterations");
for (int i = 0; i < iterations; i++) {
log.info("Iteration: {}", i);
action.execute(this);
Expand All @@ -699,7 +699,7 @@ private static ExtMap createQueryFilter(ExtUUID entity, Map<String, Object> argM
);
}

for (String id : safeList((List<String>)argMap.get("entity-id"))) {
for (String id : safeList((List<String>) argMap.get("entity-id"))) {
filter.add(
createQueryFilterElement(
Authz.QueryEntity.GROUP.equals(entity) ? Authz.GroupRecord.ID : Authz.PrincipalRecord.ID,
Expand Down Expand Up @@ -733,7 +733,7 @@ private static ExtMap createQueryFilterElement(ExtKey key, String value) {
);
}

private static ExtUUID getQueryEntity(String entity) {
private static ExtUUID getQueryEntity(String entity) {
try {
return (ExtUUID) Authz.QueryEntity.class.getDeclaredField(
entity.toUpperCase()
Expand All @@ -748,7 +748,7 @@ private static int getAuthzFlags(List<String> flags) {
for (String f : safeList(flags)) {
try {
ret |= Authz.QueryFlags.class.getDeclaredField(f.toUpperCase().replace("-", "_")).getInt(new Authz.QueryFlags());
} catch(NoSuchFieldException | IllegalAccessException ex) {
} catch (NoSuchFieldException | IllegalAccessException ex) {
log.error("Unknown Authz flag '{}' (ignored)", f);
}
}
Expand Down Expand Up @@ -842,7 +842,7 @@ public AAAProfile(String profile) {
this.authnName = this.authnExtension.getContext().get(Base.ContextKeys.INSTANCE_NAME);

this.authzExtension = getExtensionsManager().getExtensionByName(authzName);
if(this.mappingName != null) {
if (this.mappingName != null) {
this.mappingExtension = getExtensionsManager().getExtensionByName(mappingName);
}

Expand All @@ -856,7 +856,7 @@ public AAAProfile(String profile) {
}

public String mapUser(String user) {
if(getMappingExtension()!= null) {
if (getMappingExtension() != null) {
log.info("API: -->Mapping.InvokeCommands.MAP_USER profile='{}' user='{}'", getProfile(), user);
user = getMappingExtension().invoke(
new ExtMap().mput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ public static void main(String... args) {

log.debug("Version: {}-{} ({})", PACKAGE_NAME, PACKAGE_VERSION, PACKAGE_DISPLAY_NAME);

if((Boolean)argMap.get("help")) {
if ((Boolean) argMap.get("help")) {
System.out.format("Usage: %s", parser.getUsage());
throw new ExitException("Help", 0);
} else if((Boolean)argMap.get("version")) {
} else if ((Boolean) argMap.get("version")) {
System.out.format("%s-%s (%s)%n", PACKAGE_NAME, PACKAGE_VERSION, PACKAGE_DISPLAY_NAME);
throw new ExitException("Version", 0);
}
if(!parser.getErrors().isEmpty()) {
for(Throwable t : parser.getErrors()) {
if (!parser.getErrors().isEmpty()) {
for (Throwable t : parser.getErrors()) {
log.error(t.getMessage());
log.debug(t.getMessage(), t);
}
Expand Down Expand Up @@ -120,7 +120,7 @@ public static void main(String... args) {
log.info("========================================================================");
moduleService.run();
exitStatus = 0;
} catch(ExitException e) {
} catch (ExitException e) {
log.debug(e.getMessage(), e);
exitStatus = e.getExitCode();
} catch (Throwable t) {
Expand Down Expand Up @@ -168,7 +168,7 @@ private static Path createTemporaryJAASconfiguration() throws IOException {
principalName = String.format("principal=\"%s\"", AAA_JAAS_PRINCIPAL_NAME);
}

String debug= "";
String debug = "";
if (StringUtils.isNotEmpty(AAA_JAAS_ENABLE_DEBUG)) {
debug = String.format("debug=\"%s\"", AAA_JAAS_ENABLE_DEBUG);
}
Expand Down Expand Up @@ -207,16 +207,16 @@ private static void loadExtensions(
ModuleService moduleService,
Map<String, Object> argMap
) {
List<File> files = (List<File>)argMap.get("extension-file");
if(files == null) {
List<File> files = (List<File>) argMap.get("extension-file");
if (files == null) {
files = listFiles(
(String) argMap.get("extensions-dir"),
"properties"
);
}

List<String> loadedExtensions = new LinkedList<>();
for(File f : files) {
for (File f : files) {
log.debug("Loading extension file '{}'", f.getName());
try {
String name = extensionsManager.load(f);
Expand All @@ -231,7 +231,7 @@ private static void loadExtensions(
}
}

for(String extension : loadedExtensions) {
for (String extension : loadedExtensions) {
try {
extensionsManager.initialize(extension);
log.debug("Extension '{}' initialized", extension);
Expand All @@ -245,7 +245,7 @@ private static void loadExtensions(

private static Map<String, ModuleService> loadModules(Class cls) {
Map<String, ModuleService> modules = new HashMap<>();
if(cls != null) {
if (cls != null) {
ServiceLoader<ModuleService> loader = ServiceLoader.load(cls);
for (ModuleService module : loader) {
modules.put(module.getName(), module);
Expand All @@ -266,14 +266,14 @@ private static void setupLogger() {

private static void setupLogger(Map<String, Object> args) throws IOException {
Logger log = Logger.getLogger("");
String logfile = (String)args.get("log-file");
if(logfile != null) {
String logfile = (String) args.get("log-file");
if (logfile != null) {
FileHandler fh = new FileHandler(logfile, true);
fh.setFormatter(new SimpleFormatter());
log.addHandler(fh);
}

OVIRT_LOGGER.setLevel((Level)args.get("log-level"));
OVIRT_LOGGER.setLevel((Level) args.get("log-level"));
}

private static List<File> listFiles(String directory, String suffix) {
Expand All @@ -293,7 +293,7 @@ private static List<File> listFiles(String directory, String suffix) {

private static String getModules(Map<String, ModuleService> modules) {
StringBuilder sb = new StringBuilder();
for(Map.Entry<String, ModuleService> entry : new TreeMap<>(modules).entrySet()) {
for (Map.Entry<String, ModuleService> entry : new TreeMap<>(modules).entrySet()) {
sb.append(
String.format(" %-10s - %s%n", entry.getKey(), entry.getValue().getDescription())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public ExtMap getContext() {
@Override
public void parseArguments(List<String> args) throws Exception {
System.out.println("Available modules:");
for(Map.Entry<String, ModuleService> entry : new TreeMap<>(getContext().<Map<String, ModuleService>>get(ContextKeys.MODULES)).entrySet()) {
for (Map.Entry<String, ModuleService> entry : new TreeMap<>(getContext().<Map<String, ModuleService>>get(ContextKeys.MODULES)).entrySet()) {
System.out.printf(
String.format(" %-10s - %s%n",
entry.getKey(),
Expand Down
Loading

0 comments on commit 632e59c

Please sign in to comment.