Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkstyle upgrade #989

Merged
merged 2 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,93 +37,87 @@ private interface Logic {
}

private enum Action {
CONFIGURATION(
module -> {
ExtensionProxy extension = module.getExtensionsManager().getExtensionByName((String) module.argMap.get("extension-name"));
Collection<?> sensitive = extension.getContext().get(Base.ContextKeys.CONFIGURATION_SENSITIVE_KEYS);
CONFIGURATION(module -> {
ExtensionProxy extension = module.getExtensionsManager().getExtensionByName((String) module.argMap.get("extension-name"));
Collection<?> sensitive = extension.getContext().get(Base.ContextKeys.CONFIGURATION_SENSITIVE_KEYS);


Map<Object, Object> config = extension.getContext().<Properties>get(Base.ContextKeys.CONFIGURATION);
Collection<Object> keys = new HashSet<>(config.keySet());
if (module.argMap.get("key") != null) {
keys.retainAll((List<String>) module.argMap.get("key"));
}
Map<Object, Object> config = extension.getContext().<Properties>get(Base.ContextKeys.CONFIGURATION);
Collection<Object> keys = new HashSet<>(config.keySet());
if (module.argMap.get("key") != null) {
keys.retainAll((List<String>) module.argMap.get("key"));
}

for (Object key : keys) {
module.output(
((String) module.argMap.get("format")).replace(
"{key}",
String.format("%s", key)
).replace(
"{value}",
sensitive.contains(key) ? "***" : String.format("%s", config.get(key))
),
" "
);
for (Object key : keys) {
module.output(
((String) module.argMap.get("format")).replace(
"{key}",
String.format("%s", key)
).replace(
"{value}",
sensitive.contains(key) ? "***" : String.format("%s", config.get(key))
),
" "
);
}
}),
CONTEXT(module -> {
ExtensionProxy extension = module.getExtensionsManager().getExtensionByName((String) module.argMap.get("extension-name"));
Collection<ExtKey> keys = new HashSet<>(extension.getContext().keySet());
if (module.argMap.get("key") != null) {
Collection<ExtKey> k = new HashSet<>();
for (String uuid : (List<String>) module.argMap.get("key")) {
k.add(new ExtKey("Unknown", Object.class, uuid));
}
keys.retainAll(k);
}
),
CONTEXT(
module -> {
ExtensionProxy extension = module.getExtensionsManager().getExtensionByName((String) module.argMap.get("extension-name"));
Collection<ExtKey> keys = new HashSet<>(extension.getContext().keySet());
if (module.argMap.get("key") != null) {
Collection<ExtKey> k = new HashSet<>();
for (String uuid : (List<String>) module.argMap.get("key")) {
k.add(new ExtKey("Unknown", Object.class, uuid));
}
keys.retainAll(k);
for (ExtKey key : keys) {
if (CONTEXT_IGNORE_KEYS.contains(key)) {
continue;
}
for (ExtKey key : keys) {
if (CONTEXT_IGNORE_KEYS.contains(key)) {
continue;
}
if ((key.getFlags() & ExtKey.Flags.SKIP_DUMP) != 0) {
continue;
}

module.output(
((String) module.argMap.get("format")).replace(
"{key}",
key.getUuid().getUuid().toString()
).replace(
"{name}",
key.getUuid().getName()
).replace(
"{value}",
(key.getFlags() & ExtKey.Flags.SENSITIVE) != 0 ? "***" : extension.getContext().get(key).toString()
),
" "
);
if ((key.getFlags() & ExtKey.Flags.SKIP_DUMP) != 0) {
continue;
}

module.output(
((String) module.argMap.get("format")).replace(
"{key}",
key.getUuid().getUuid().toString()
).replace(
"{name}",
key.getUuid().getName()
).replace(
"{value}",
(key.getFlags() & ExtKey.Flags.SENSITIVE) != 0 ? "***" : extension.getContext().get(key).toString()
),
" "
);
}
),
LIST_EXTENSIONS(
module -> {
for (ExtensionProxy extension : module.getExtensionsManager().getExtensions()) {
ExtMap extContext = extension.getContext();
module.output(
((String) module.argMap.get("format")).replace(
"{instance}",
extContext.<String>get(Base.ContextKeys.INSTANCE_NAME, "")
).replace(
"{name}",
extContext.<String>get(Base.ContextKeys.EXTENSION_NAME, "")
).replace(
"{version}",
extContext.<String>get(Base.ContextKeys.VERSION, "")
).replace(
"{license}",
extContext.<String>get(Base.ContextKeys.LICENSE, "")
).replace(
"{notes}",
extContext.<String>get(Base.ContextKeys.EXTENSION_NOTES, "")
),
""
);
}
}),
LIST_EXTENSIONS(module -> {
for (ExtensionProxy extension : module.getExtensionsManager().getExtensions()) {
ExtMap extContext = extension.getContext();
module.output(
((String) module.argMap.get("format")).replace(
"{instance}",
extContext.<String>get(Base.ContextKeys.INSTANCE_NAME, "")
).replace(
"{name}",
extContext.<String>get(Base.ContextKeys.EXTENSION_NAME, "")
).replace(
"{version}",
extContext.<String>get(Base.ContextKeys.VERSION, "")
).replace(
"{license}",
extContext.<String>get(Base.ContextKeys.LICENSE, "")
).replace(
"{notes}",
extContext.<String>get(Base.ContextKeys.EXTENSION_NOTES, "")
),
""
);
}
);
});

private Logic logic;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,47 +30,44 @@ private interface Logic {
}

private enum Action {
LOG_RECORD(
module -> {
ExtensionProxy proxy = module.getExtensionsManager().getExtensionByName((String) module.argMap.get("extension-name"));

LogRecord logRecord = new LogRecord(
(Level) module.argMap.get("level"),
(String) module.argMap.get("message")
);
logRecord.setLoggerName((String) module.argMap.get("logger-name"));

log.info("API: -->Logger.InvokeCommands.PUBLISH level={}, name={}", logRecord.getLevel(), logRecord.getLoggerName());
proxy.invoke(
new ExtMap().mput(
Base.InvokeKeys.COMMAND,
Logger.InvokeCommands.PUBLISH
).mput(
Logger.InvokeKeys.LOG_RECORD,
logRecord
)
);
log.info("API: <--Logger.InvokeCommands.PUBLISH");

log.info("API: -->Logger.InvokeCommands.FLUSH");
proxy.invoke(
new ExtMap().mput(
Base.InvokeKeys.COMMAND,
Logger.InvokeCommands.FLUSH
)
);
log.info("API: <--Logger.InvokeCommands.FLUSH");

log.info("API: -->Logger.InvokeCommands.CLOSE");
proxy.invoke(
new ExtMap().mput(
Base.InvokeKeys.COMMAND,
Logger.InvokeCommands.CLOSE
)
);
log.info("API: <--Logger.InvokeCommands.CLOSE");
}
);
LOG_RECORD(module -> {
ExtensionProxy proxy = module.getExtensionsManager().getExtensionByName((String) module.argMap.get("extension-name"));

LogRecord logRecord = new LogRecord(
(Level) module.argMap.get("level"),
(String) module.argMap.get("message")
);
logRecord.setLoggerName((String) module.argMap.get("logger-name"));

log.info("API: -->Logger.InvokeCommands.PUBLISH level={}, name={}", logRecord.getLevel(), logRecord.getLoggerName());
proxy.invoke(
new ExtMap().mput(
Base.InvokeKeys.COMMAND,
Logger.InvokeCommands.PUBLISH
).mput(
Logger.InvokeKeys.LOG_RECORD,
logRecord
)
);
log.info("API: <--Logger.InvokeCommands.PUBLISH");

log.info("API: -->Logger.InvokeCommands.FLUSH");
proxy.invoke(
new ExtMap().mput(
Base.InvokeKeys.COMMAND,
Logger.InvokeCommands.FLUSH
)
);
log.info("API: <--Logger.InvokeCommands.FLUSH");

log.info("API: -->Logger.InvokeCommands.CLOSE");
proxy.invoke(
new ExtMap().mput(
Base.InvokeKeys.COMMAND,
Logger.InvokeCommands.CLOSE
));
log.info("API: <--Logger.InvokeCommands.CLOSE");
});

private Logic logic;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public static void reportRecords(
String authzName,
String user,
String message,
Object... msgArgs
) {
Object... msgArgs) {
ExtMap input = new ExtMap();
input.put(Acct.InvokeKeys.REASON, reportReason);
input.put(Acct.InvokeKeys.PRINCIPAL_RECORD,
Expand All @@ -52,7 +51,7 @@ public static void reportRecords(
Acct.InvokeKeys.MESSAGE,
String.format(message, msgArgs)
)
);
);
report(input);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,28 +138,28 @@ private void doAuth(HttpServletRequest req, HttpServletResponse rsp, Deque<Authe
);

switch (output.<Integer> get(Authn.InvokeKeys.RESULT)) {
case Authn.AuthResult.SUCCESS:
req.setAttribute(FiltersHelper.Constants.REQUEST_AUTH_RECORD_KEY,
output.<ExtMap> get(Authn.InvokeKeys.AUTH_RECORD));
req.setAttribute(FiltersHelper.Constants.REQUEST_AUTH_TYPE_KEY,
AuthType.NEGOTIATION);
req.setAttribute(FiltersHelper.Constants.REQUEST_PROFILE_KEY, profile.getName());
stack.clear();
break;

case Authn.AuthResult.NEGOTIATION_UNAUTHORIZED:
stack.pop();
break;

case Authn.AuthResult.NEGOTIATION_INCOMPLETE:
stop = true;
break;

default:
log.error("Unexpected authentication result. AuthResult code is {}",
output.<Integer> get(Authn.InvokeKeys.RESULT));
stack.pop();
break;
case Authn.AuthResult.SUCCESS:
req.setAttribute(FiltersHelper.Constants.REQUEST_AUTH_RECORD_KEY,
output.<ExtMap> get(Authn.InvokeKeys.AUTH_RECORD));
req.setAttribute(FiltersHelper.Constants.REQUEST_AUTH_TYPE_KEY,
AuthType.NEGOTIATION);
req.setAttribute(FiltersHelper.Constants.REQUEST_PROFILE_KEY, profile.getName());
stack.clear();
break;

case Authn.AuthResult.NEGOTIATION_UNAUTHORIZED:
stack.pop();
break;

case Authn.AuthResult.NEGOTIATION_INCOMPLETE:
stop = true;
break;

default:
log.error("Unexpected authentication result. AuthResult code is {}",
output.<Integer> get(Authn.InvokeKeys.RESULT));
stack.pop();
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
FiltersHelper.getBackend(ctx).runAction(
ActionType.LogoutSession,
new ActionParametersBase(engineSessionId)
);
);
HttpSession session = req.getSession(false);
if (session != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
request.getRemoteAddr(),
(Collection<ExtMap>) payload.get("group_ids"),
loginAsAdmin));
if (!queryRetVal.getSucceeded() ) {
if (!queryRetVal.getSucceeded()) {
if (queryRetVal.getActionReturnValue() == CreateUserSessionsError.NUM_OF_SESSIONS_EXCEEDED) {
throw new RuntimeException(String.format(
"Unable to login user %s@%s with profile [%s]" +
Expand Down
Loading
Loading