This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 63461b3bed Code clean-up. Formatting. No functional change.
63461b3bed is described below
commit 63461b3bed4d837d435afe4b72f05a370fd83f44
Author: Mark Thomas <[email protected]>
AuthorDate: Tue May 23 11:23:09 2023 +0100
Code clean-up. Formatting. No functional change.
---
.../catalina/authenticator/AuthenticatorBase.java | 12 +--
.../authenticator/DigestAuthenticator.java | 25 ++---
.../catalina/authenticator/SavedRequest.java | 2 +-
.../catalina/authenticator/SingleSignOn.java | 2 +-
.../catalina/authenticator/SingleSignOnEntry.java | 6 +-
.../jaspic/AuthConfigFactoryImpl.java | 107 +++++++++------------
.../authenticator/jaspic/CallbackHandlerImpl.java | 11 +--
.../authenticator/jaspic/MessageInfoImpl.java | 10 +-
.../jaspic/PersistentProviderRegistrations.java | 34 ++++---
.../jaspic/SimpleAuthConfigProvider.java | 18 ++--
.../jaspic/SimpleServerAuthConfig.java | 17 ++--
.../jaspic/SimpleServerAuthContext.java | 14 ++-
12 files changed, 118 insertions(+), 140 deletions(-)
diff --git a/java/org/apache/catalina/authenticator/AuthenticatorBase.java
b/java/org/apache/catalina/authenticator/AuthenticatorBase.java
index e53ffc7297..352f984c79 100644
--- a/java/org/apache/catalina/authenticator/AuthenticatorBase.java
+++ b/java/org/apache/catalina/authenticator/AuthenticatorBase.java
@@ -612,8 +612,8 @@ public abstract class AuthenticatorBase extends ValveBase
implements Authenticat
String originHeader =
request.getHeader(CorsFilter.REQUEST_HEADER_ORIGIN);
if (originHeader != null && !originHeader.isEmpty() &&
RequestUtil.isValidOrigin(originHeader) &&
!RequestUtil.isSameOrigin(request, originHeader)) {
- String accessControlRequestMethodHeader = request
-
.getHeader(CorsFilter.REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD);
+ String accessControlRequestMethodHeader =
+
request.getHeader(CorsFilter.REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD);
if (accessControlRequestMethodHeader != null &&
!accessControlRequestMethodHeader.isEmpty()) {
// This appears to be a CORS Preflight request
if (allowCorsPreflight == AllowCorsPreflight.ALWAYS) {
@@ -699,8 +699,8 @@ public abstract class AuthenticatorBase extends ValveBase
implements Authenticat
try {
CallbackHandler callbackHandler = getCallbackHandler();
- ServerAuthConfig serverAuthConfig =
jaspicProvider.getServerAuthConfig("HttpServlet", jaspicAppContextID,
- callbackHandler);
+ ServerAuthConfig serverAuthConfig =
+ jaspicProvider.getServerAuthConfig("HttpServlet",
jaspicAppContextID, callbackHandler);
String authContextID =
serverAuthConfig.getAuthContextID(jaspicState.messageInfo);
jaspicState.serverAuthContext =
serverAuthConfig.getAuthContext(authContextID, null, null);
} catch (AuthException e) {
@@ -1171,8 +1171,8 @@ public abstract class AuthenticatorBase extends ValveBase
implements Authenticat
if (client != null) {
ServerAuthContext serverAuthContext;
try {
- ServerAuthConfig serverAuthConfig =
provider.getServerAuthConfig("HttpServlet", jaspicAppContextID,
- getCallbackHandler());
+ ServerAuthConfig serverAuthConfig =
+ provider.getServerAuthConfig("HttpServlet",
jaspicAppContextID, getCallbackHandler());
String authContextID =
serverAuthConfig.getAuthContextID(messageInfo);
serverAuthContext =
serverAuthConfig.getAuthContext(authContextID, null, null);
serverAuthContext.cleanSubject(messageInfo, client);
diff --git a/java/org/apache/catalina/authenticator/DigestAuthenticator.java
b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
index 065efce308..399ffa8da4 100644
--- a/java/org/apache/catalina/authenticator/DigestAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
@@ -68,7 +68,7 @@ public class DigestAuthenticator extends AuthenticatorBase {
private static final String NONCE_DIGEST = "SHA-256";
// List permitted algorithms and maps them to Java standard names
- private static final Map<String, AuthDigest> PERMITTED_ALGORITHMS = new
HashMap<>();
+ private static final Map<String,AuthDigest> PERMITTED_ALGORITHMS = new
HashMap<>();
static {
// Allows the digester to be configured with either the Standard Java
name or the name used the RFC.
for (AuthDigest authDigest : AuthDigest.values()) {
@@ -91,7 +91,7 @@ public class DigestAuthenticator extends AuthenticatorBase {
/**
* List of server nonce values currently being tracked
*/
- protected Map<String, NonceInfo> nonces;
+ protected Map<String,NonceInfo> nonces;
/**
@@ -233,7 +233,7 @@ public class DigestAuthenticator extends AuthenticatorBase {
/*
- * Initialise algorithms, removing ones that the JRE does not support
+ * Initialise algorithms, removing ones that the JRE does not support
*/
private void initAlgorithms(List<AuthDigest> algorithms) {
Iterator<AuthDigest> algorithmIterator = algorithms.iterator();
@@ -243,7 +243,8 @@ public class DigestAuthenticator extends AuthenticatorBase {
ConcurrentMessageDigest.init(algorithm.getJavaName());
} catch (NoSuchAlgorithmException e) {
// In theory, a JRE can choose not to implement SHA-512/256
-
log.warn(sm.getString("digestAuthenticator.unsupportedAlgorithm", algorithms,
algorithm.getJavaName()), e);
+
log.warn(sm.getString("digestAuthenticator.unsupportedAlgorithm", algorithms,
algorithm.getJavaName()),
+ e);
algorithmIterator.remove();
}
}
@@ -461,7 +462,7 @@ public class DigestAuthenticator extends AuthenticatorBase {
private long lastLog = 0;
@Override
- protected boolean removeEldestEntry(Map.Entry<String, NonceInfo>
eldest) {
+ protected boolean removeEldestEntry(Map.Entry<String,NonceInfo>
eldest) {
// This is called from a sync so keep it simple
long currentTime = System.currentTimeMillis();
if (size() > getNonceCacheSize()) {
@@ -490,7 +491,7 @@ public class DigestAuthenticator extends AuthenticatorBase {
private final String opaque;
private final long nonceValidity;
private final String key;
- private final Map<String, NonceInfo> nonces;
+ private final Map<String,NonceInfo> nonces;
private boolean validateUri = true;
private String userName = null;
@@ -508,7 +509,7 @@ public class DigestAuthenticator extends AuthenticatorBase {
private AuthDigest algorithm = null;
- public DigestInfo(String opaque, long nonceValidity, String key,
Map<String, NonceInfo> nonces,
+ public DigestInfo(String opaque, long nonceValidity, String key,
Map<String,NonceInfo> nonces,
boolean validateUri) {
this.opaque = opaque;
this.nonceValidity = nonceValidity;
@@ -529,7 +530,7 @@ public class DigestAuthenticator extends AuthenticatorBase {
return false;
}
- Map<String, String> directives;
+ Map<String,String> directives;
try {
directives = Authorization.parseAuthorizationDigest(new
StringReader(authorization));
} catch (IOException e) {
@@ -625,8 +626,8 @@ public class DigestAuthenticator extends AuthenticatorBase {
}
String serverIpTimeKey = request.getRemoteAddr() + ":" + nonceTime
+ ":" + key;
// Note: The digest used to generate the nonce is independent of
the the digest used for authentication/
- byte[] buffer = ConcurrentMessageDigest.digest(NONCE_DIGEST,
- serverIpTimeKey.getBytes(StandardCharsets.ISO_8859_1));
+ byte[] buffer =
+ ConcurrentMessageDigest.digest(NONCE_DIGEST,
serverIpTimeKey.getBytes(StandardCharsets.ISO_8859_1));
String digestServerIpTimeKey = HexUtils.toHexString(buffer);
if (!digestServerIpTimeKey.equals(digestclientIpTimeKey)) {
return false;
@@ -692,8 +693,8 @@ public class DigestAuthenticator extends AuthenticatorBase {
ConcurrentMessageDigest.digest(algorithm.getJavaName(),
a2.getBytes(StandardCharsets.ISO_8859_1));
String digestA2 = HexUtils.toHexString(buffer);
- return realm.authenticate(
- userName, response, nonce, nc, cnonce, qop, realmName,
digestA2, algorithm.getJavaName());
+ return realm.authenticate(userName, response, nonce, nc, cnonce,
qop, realmName, digestA2,
+ algorithm.getJavaName());
}
}
diff --git a/java/org/apache/catalina/authenticator/SavedRequest.java
b/java/org/apache/catalina/authenticator/SavedRequest.java
index 8b9f08b618..a1ce589abe 100644
--- a/java/org/apache/catalina/authenticator/SavedRequest.java
+++ b/java/org/apache/catalina/authenticator/SavedRequest.java
@@ -60,7 +60,7 @@ public final class SavedRequest implements Serializable {
* The set of Headers associated with this Request. Each key is a header
name, while the value is a List containing
* one or more actual values for this header. The values are returned as
an Iterator when you ask for them.
*/
- private final Map<String, List<String>> headers = new HashMap<>();
+ private final Map<String,List<String>> headers = new HashMap<>();
public void addHeader(String name, String value) {
headers.computeIfAbsent(name, k -> new ArrayList<>()).add(value);
diff --git a/java/org/apache/catalina/authenticator/SingleSignOn.java
b/java/org/apache/catalina/authenticator/SingleSignOn.java
index 3d4767d8e3..4d302ab40b 100644
--- a/java/org/apache/catalina/authenticator/SingleSignOn.java
+++ b/java/org/apache/catalina/authenticator/SingleSignOn.java
@@ -76,7 +76,7 @@ public class SingleSignOn extends ValveBase {
* The cache of SingleSignOnEntry instances for authenticated Principals,
keyed by the cookie value that is used to
* select them.
*/
- protected Map<String, SingleSignOnEntry> cache = new ConcurrentHashMap<>();
+ protected Map<String,SingleSignOnEntry> cache = new ConcurrentHashMap<>();
/**
* Indicates whether this valve should require a downstream Authenticator
to reauthenticate each request, or if it
diff --git a/java/org/apache/catalina/authenticator/SingleSignOnEntry.java
b/java/org/apache/catalina/authenticator/SingleSignOnEntry.java
index 57e15931cf..1465bb7675 100644
--- a/java/org/apache/catalina/authenticator/SingleSignOnEntry.java
+++ b/java/org/apache/catalina/authenticator/SingleSignOnEntry.java
@@ -52,7 +52,7 @@ public class SingleSignOnEntry implements Serializable {
// Marked as transient so special handling can be applied to serialization
private transient Principal principal = null;
- private final Map<SingleSignOnSessionKey, SingleSignOnSessionKey>
sessionKeys = new ConcurrentHashMap<>();
+ private final Map<SingleSignOnSessionKey,SingleSignOnSessionKey>
sessionKeys = new ConcurrentHashMap<>();
private String username = null;
@@ -171,8 +171,8 @@ public class SingleSignOnEntry implements Serializable {
this.authType = authType;
this.username = username;
this.password = password;
- this.canReauthenticate =
(HttpServletRequest.BASIC_AUTH.equals(authType) ||
- HttpServletRequest.FORM_AUTH.equals(authType));
+ this.canReauthenticate =
+ (HttpServletRequest.BASIC_AUTH.equals(authType) ||
HttpServletRequest.FORM_AUTH.equals(authType));
}
diff --git
a/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
b/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
index 41c1de3973..9da0d05551 100644
--- a/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
+++ b/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
@@ -55,8 +55,7 @@ public class AuthConfigFactoryImpl extends AuthConfigFactory {
private static final StringManager sm =
StringManager.getManager(AuthConfigFactoryImpl.class);
private static final String CONFIG_PATH = "conf/jaspic-providers.xml";
- private static final File CONFIG_FILE =
- new File(System.getProperty(Globals.CATALINA_BASE_PROP),
CONFIG_PATH);
+ private static final File CONFIG_FILE = new
File(System.getProperty(Globals.CATALINA_BASE_PROP), CONFIG_PATH);
private static final Object CONFIG_FILE_LOCK = new Object();
private static final String[] EMPTY_STRING_ARRAY = new String[0];
@@ -65,16 +64,12 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
private static String DEFAULT_REGISTRATION_ID = getRegistrationID(null,
null);
- private final Map<String,RegistrationContextImpl>
layerAppContextRegistrations =
- new ConcurrentHashMap<>();
- private final Map<String,RegistrationContextImpl> appContextRegistrations =
- new ConcurrentHashMap<>();
- private final Map<String,RegistrationContextImpl> layerRegistrations =
- new ConcurrentHashMap<>();
+ private final Map<String,RegistrationContextImpl>
layerAppContextRegistrations = new ConcurrentHashMap<>();
+ private final Map<String,RegistrationContextImpl> appContextRegistrations
= new ConcurrentHashMap<>();
+ private final Map<String,RegistrationContextImpl> layerRegistrations = new
ConcurrentHashMap<>();
// Note: Although there will only ever be a maximum of one entry in this
- // Map, use a ConcurrentHashMap for consistency
- private final Map<String,RegistrationContextImpl> defaultRegistration =
- new ConcurrentHashMap<>(1);
+ // Map, use a ConcurrentHashMap for consistency
+ private final Map<String,RegistrationContextImpl> defaultRegistration =
new ConcurrentHashMap<>(1);
public AuthConfigFactoryImpl() {
@@ -83,14 +78,11 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
@Override
- public AuthConfigProvider getConfigProvider(String layer, String
appContext,
- RegistrationListener listener) {
- RegistrationContextImpl registrationContext =
- findRegistrationContextImpl(layer, appContext);
+ public AuthConfigProvider getConfigProvider(String layer, String
appContext, RegistrationListener listener) {
+ RegistrationContextImpl registrationContext =
findRegistrationContextImpl(layer, appContext);
if (registrationContext != null) {
if (listener != null) {
- RegistrationListenerWrapper wrapper = new
RegistrationListenerWrapper(
- layer, appContext, listener);
+ RegistrationListenerWrapper wrapper = new
RegistrationListenerWrapper(layer, appContext, listener);
registrationContext.addListener(wrapper);
}
return registrationContext.getProvider();
@@ -100,20 +92,18 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
@Override
- public String registerConfigProvider(String className, Map<String,String>
properties,
- String layer, String appContext, String description) {
- String registrationID =
- doRegisterConfigProvider(className, properties, layer,
appContext, description);
+ public String registerConfigProvider(String className, Map<String,String>
properties, String layer,
+ String appContext, String description) {
+ String registrationID = doRegisterConfigProvider(className,
properties, layer, appContext, description);
savePersistentRegistrations();
return registrationID;
}
- private String doRegisterConfigProvider(String className,
Map<String,String> properties,
- String layer, String appContext, String description) {
+ private String doRegisterConfigProvider(String className,
Map<String,String> properties, String layer,
+ String appContext, String description) {
if (log.isDebugEnabled()) {
- log.debug(sm.getString("authConfigFactoryImpl.registerClass",
- className, layer, appContext));
+ log.debug(sm.getString("authConfigFactoryImpl.registerClass",
className, layer, appContext));
}
AuthConfigProvider provider = null;
@@ -122,15 +112,15 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
}
String registrationID = getRegistrationID(layer, appContext);
- RegistrationContextImpl registrationContextImpl = new
RegistrationContextImpl(
- layer, appContext, description, true, provider, properties);
+ RegistrationContextImpl registrationContextImpl =
+ new RegistrationContextImpl(layer, appContext, description,
true, provider, properties);
addRegistrationContextImpl(layer, appContext, registrationID,
registrationContextImpl);
return registrationID;
}
- private AuthConfigProvider createAuthConfigProvider(String className,
- Map<String,String> properties) throws SecurityException {
+ private AuthConfigProvider createAuthConfigProvider(String className,
Map<String,String> properties)
+ throws SecurityException {
Class<?> clazz = null;
AuthConfigProvider provider = null;
try {
@@ -152,22 +142,22 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
@Override
- public String registerConfigProvider(AuthConfigProvider provider, String
layer,
- String appContext, String description) {
+ public String registerConfigProvider(AuthConfigProvider provider, String
layer, String appContext,
+ String description) {
if (log.isDebugEnabled()) {
- log.debug(sm.getString("authConfigFactoryImpl.registerInstance",
- provider.getClass().getName(), layer, appContext));
+ log.debug(sm.getString("authConfigFactoryImpl.registerInstance",
provider.getClass().getName(), layer,
+ appContext));
}
String registrationID = getRegistrationID(layer, appContext);
- RegistrationContextImpl registrationContextImpl = new
RegistrationContextImpl(
- layer, appContext, description, false, provider, null);
+ RegistrationContextImpl registrationContextImpl =
+ new RegistrationContextImpl(layer, appContext, description,
false, provider, null);
addRegistrationContextImpl(layer, appContext, registrationID,
registrationContextImpl);
return registrationID;
}
- private void addRegistrationContextImpl(String layer, String appContext,
- String registrationID, RegistrationContextImpl
registrationContextImpl) {
+ private void addRegistrationContextImpl(String layer, String appContext,
String registrationID,
+ RegistrationContextImpl registrationContextImpl) {
RegistrationContextImpl previous = null;
// Add the registration, noting any registration it replaces
@@ -190,12 +180,10 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
// Need to check existing appContext registrations
// (and layer and default)
// appContext must match
- RegistrationContextImpl registration =
- appContextRegistrations.get(getRegistrationID(null,
appContext));
+ RegistrationContextImpl registration =
appContextRegistrations.get(getRegistrationID(null, appContext));
if (registration != null) {
for (RegistrationListenerWrapper wrapper :
registration.listeners) {
- if (layer.equals(wrapper.getMessageLayer()) &&
- appContext.equals(wrapper.getAppContext())) {
+ if (layer.equals(wrapper.getMessageLayer()) &&
appContext.equals(wrapper.getAppContext())) {
registration.listeners.remove(wrapper);
wrapper.listener.notify(wrapper.messageLayer,
wrapper.appContext);
}
@@ -247,7 +235,7 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
registration = layerAppContextRegistrations.remove(registrationID);
}
if (registration == null) {
- registration = appContextRegistrations.remove(registrationID);
+ registration = appContextRegistrations.remove(registrationID);
}
if (registration == null) {
registration = layerRegistrations.remove(registrationID);
@@ -298,8 +286,8 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
}
- private void findProvider(AuthConfigProvider provider,
- Map<String,RegistrationContextImpl> registrations, List<String>
result) {
+ private void findProvider(AuthConfigProvider provider,
Map<String,RegistrationContextImpl> registrations,
+ List<String> result) {
for (Entry<String,RegistrationContextImpl> entry :
registrations.entrySet()) {
if (provider.equals(entry.getValue().getProvider())) {
result.add(entry.getKey());
@@ -375,12 +363,10 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
private static String getRegistrationID(String layer, String appContext) {
if (layer != null && layer.length() == 0) {
- throw new IllegalArgumentException(
-
sm.getString("authConfigFactoryImpl.zeroLengthMessageLayer"));
+ throw new
IllegalArgumentException(sm.getString("authConfigFactoryImpl.zeroLengthMessageLayer"));
}
if (appContext != null && appContext.length() == 0) {
- throw new IllegalArgumentException(
-
sm.getString("authConfigFactoryImpl.zeroLengthAppContext"));
+ throw new
IllegalArgumentException(sm.getString("authConfigFactoryImpl.zeroLengthAppContext"));
}
return (layer == null ? "" : layer) + ":" + (appContext == null ? "" :
appContext);
}
@@ -389,16 +375,15 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
private void loadPersistentRegistrations() {
synchronized (CONFIG_FILE_LOCK) {
if (log.isDebugEnabled()) {
- log.debug(sm.getString("authConfigFactoryImpl.load",
- CONFIG_FILE.getAbsolutePath()));
+ log.debug(sm.getString("authConfigFactoryImpl.load",
CONFIG_FILE.getAbsolutePath()));
}
if (!CONFIG_FILE.isFile()) {
return;
}
Providers providers =
PersistentProviderRegistrations.loadProviders(CONFIG_FILE);
for (Provider provider : providers.getProviders()) {
- doRegisterConfigProvider(provider.getClassName(),
provider.getProperties(),
- provider.getLayer(), provider.getAppContext(),
provider.getDescription());
+ doRegisterConfigProvider(provider.getClassName(),
provider.getProperties(), provider.getLayer(),
+ provider.getAppContext(), provider.getDescription());
}
}
}
@@ -416,16 +401,14 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
}
- private void savePersistentProviders(Providers providers,
- Map<String,RegistrationContextImpl> registrations) {
+ private void savePersistentProviders(Providers providers,
Map<String,RegistrationContextImpl> registrations) {
for (Entry<String,RegistrationContextImpl> entry :
registrations.entrySet()) {
savePersistentProvider(providers, entry.getValue());
}
}
- private void savePersistentProvider(Providers providers,
- RegistrationContextImpl registrationContextImpl) {
+ private void savePersistentProvider(Providers providers,
RegistrationContextImpl registrationContextImpl) {
if (registrationContextImpl != null &&
registrationContextImpl.isPersistent()) {
Provider provider = new Provider();
provider.setAppContext(registrationContextImpl.getAppContext());
@@ -460,8 +443,8 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
private static class RegistrationContextImpl implements
RegistrationContext {
- private RegistrationContextImpl(String messageLayer, String
appContext, String description,
- boolean persistent, AuthConfigProvider provider,
Map<String,String> properties) {
+ private RegistrationContextImpl(String messageLayer, String
appContext, String description, boolean persistent,
+ AuthConfigProvider provider, Map<String,String> properties) {
this.messageLayer = messageLayer;
this.appContext = appContext;
this.description = description;
@@ -542,8 +525,7 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
private final RegistrationListener listener;
- RegistrationListenerWrapper(String messageLayer, String appContext,
- RegistrationListener listener) {
+ RegistrationListenerWrapper(String messageLayer, String appContext,
RegistrationListener listener) {
this.messageLayer = messageLayer;
this.appContext = appContext;
this.listener = listener;
@@ -614,7 +596,8 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
@Override
public String getAuthContextID(MessageInfo messageInfo) {
- return messageInfo.toString(); }
+ return messageInfo.toString();
+ }
@Override
public void refresh() {
@@ -628,7 +611,7 @@ public class AuthConfigFactoryImpl extends
AuthConfigFactory {
@Override
public ServerAuthContext getAuthContext(String authContextID, Subject
serviceSubject,
- Map<String, Object> properties) throws AuthException {
+ Map<String,Object> properties) throws AuthException {
return context;
}
}
diff --git
a/java/org/apache/catalina/authenticator/jaspic/CallbackHandlerImpl.java
b/java/org/apache/catalina/authenticator/jaspic/CallbackHandlerImpl.java
index 75d230f617..17d97c683c 100644
--- a/java/org/apache/catalina/authenticator/jaspic/CallbackHandlerImpl.java
+++ b/java/org/apache/catalina/authenticator/jaspic/CallbackHandlerImpl.java
@@ -74,18 +74,17 @@ public class CallbackHandlerImpl implements
CallbackHandler, Contained {
if (container == null) {
log.warn(sm.getString("callbackHandlerImpl.containerMissing",
callback.getClass().getName()));
} else if (container.getRealm() == null) {
-
log.warn(sm.getString("callbackHandlerImpl.realmMissing",
- callback.getClass().getName(),
container.getName()));
+
log.warn(sm.getString("callbackHandlerImpl.realmMissing",
callback.getClass().getName(),
+ container.getName()));
} else {
PasswordValidationCallback pvc =
(PasswordValidationCallback) callback;
- principal =
container.getRealm().authenticate(pvc.getUsername(),
- String.valueOf(pvc.getPassword()));
+ principal =
+
container.getRealm().authenticate(pvc.getUsername(),
String.valueOf(pvc.getPassword()));
pvc.setResult(principal != null);
subject = pvc.getSubject();
}
} else {
-
log.error(sm.getString("callbackHandlerImpl.jaspicCallbackMissing",
- callback.getClass().getName()));
+
log.error(sm.getString("callbackHandlerImpl.jaspicCallbackMissing",
callback.getClass().getName()));
}
}
diff --git a/java/org/apache/catalina/authenticator/jaspic/MessageInfoImpl.java
b/java/org/apache/catalina/authenticator/jaspic/MessageInfoImpl.java
index cc7bf6eba4..6b1c8a436d 100644
--- a/java/org/apache/catalina/authenticator/jaspic/MessageInfoImpl.java
+++ b/java/org/apache/catalina/authenticator/jaspic/MessageInfoImpl.java
@@ -30,7 +30,7 @@ public class MessageInfoImpl implements MessageInfo {
public static final String IS_MANDATORY =
"jakarta.security.auth.message.MessagePolicy.isMandatory";
- private final Map<String, Object> map = new HashMap<>();
+ private final Map<String,Object> map = new HashMap<>();
private HttpServletRequest request;
private HttpServletResponse response;
@@ -61,8 +61,8 @@ public class MessageInfoImpl implements MessageInfo {
@Override
public void setRequestMessage(Object request) {
if (!(request instanceof HttpServletRequest)) {
- throw new
IllegalArgumentException(sm.getString("authenticator.jaspic.badRequestType",
- request.getClass().getName()));
+ throw new IllegalArgumentException(
+ sm.getString("authenticator.jaspic.badRequestType",
request.getClass().getName()));
}
this.request = (HttpServletRequest) request;
}
@@ -70,8 +70,8 @@ public class MessageInfoImpl implements MessageInfo {
@Override
public void setResponseMessage(Object response) {
if (!(response instanceof HttpServletResponse)) {
- throw new
IllegalArgumentException(sm.getString("authenticator.jaspic.badResponseType",
- response.getClass().getName()));
+ throw new IllegalArgumentException(
+ sm.getString("authenticator.jaspic.badResponseType",
response.getClass().getName()));
}
this.response = (HttpServletResponse) response;
}
diff --git
a/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java
b/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java
index b53310574e..40845783a0 100644
---
a/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java
+++
b/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java
@@ -40,14 +40,12 @@ import org.apache.tomcat.util.res.StringManager;
import org.xml.sax.SAXException;
/**
- * Utility class for the loading and saving of JASPIC persistent provider
- * registrations.
+ * Utility class for the loading and saving of JASPIC persistent provider
registrations.
*/
public final class PersistentProviderRegistrations {
private static final Log log =
LogFactory.getLog(PersistentProviderRegistrations.class);
- private static final StringManager sm =
- StringManager.getManager(PersistentProviderRegistrations.class);
+ private static final StringManager sm =
StringManager.getManager(PersistentProviderRegistrations.class);
private PersistentProviderRegistrations() {
@@ -100,15 +98,13 @@ public final class PersistentProviderRegistrations {
// Remove left over temporary files if present
if (configFileOld.exists()) {
if (configFileOld.delete()) {
- throw new SecurityException(sm.getString(
- "persistentProviderRegistrations.existsDeleteFail",
+ throw new
SecurityException(sm.getString("persistentProviderRegistrations.existsDeleteFail",
configFileOld.getAbsolutePath()));
}
}
if (configFileNew.exists()) {
if (configFileNew.delete()) {
- throw new SecurityException(sm.getString(
- "persistentProviderRegistrations.existsDeleteFail",
+ throw new
SecurityException(sm.getString("persistentProviderRegistrations.existsDeleteFail",
configFileNew.getAbsolutePath()));
}
}
@@ -116,9 +112,7 @@ public final class PersistentProviderRegistrations {
// Write out the providers to the temporary new file
try (OutputStream fos = new FileOutputStream(configFileNew);
Writer writer = new OutputStreamWriter(fos,
StandardCharsets.UTF_8)) {
- writer.write(
- "<?xml version='1.0' encoding='utf-8'?>\n" +
- "<jaspic-providers\n" +
+ writer.write("<?xml version='1.0' encoding='utf-8'?>\n" +
"<jaspic-providers\n" +
" xmlns=\"http://tomcat.apache.org/xml\"\n" +
"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
" xsi:schemaLocation=\"http://tomcat.apache.org/xml
jaspic-providers.xsd\"\n" +
@@ -143,8 +137,7 @@ public final class PersistentProviderRegistrations {
} catch (IOException e) {
if (!configFileNew.delete()) {
Log log =
LogFactory.getLog(PersistentProviderRegistrations.class);
-
log.warn(sm.getString("persistentProviderRegistrations.deleteFail",
- configFileNew.getAbsolutePath()));
+
log.warn(sm.getString("persistentProviderRegistrations.deleteFail",
configFileNew.getAbsolutePath()));
}
throw new SecurityException(e);
}
@@ -166,8 +159,7 @@ public final class PersistentProviderRegistrations {
// Remove the old file
if (configFileOld.exists() && !configFileOld.delete()) {
Log log = LogFactory.getLog(PersistentProviderRegistrations.class);
- log.warn(sm.getString("persistentProviderRegistrations.deleteFail",
- configFileOld.getAbsolutePath()));
+
log.warn(sm.getString("persistentProviderRegistrations.deleteFail",
configFileOld.getAbsolutePath()));
}
}
@@ -205,6 +197,7 @@ public final class PersistentProviderRegistrations {
public String getClassName() {
return className;
}
+
public void setClassName(String className) {
this.className = className;
}
@@ -213,6 +206,7 @@ public final class PersistentProviderRegistrations {
public String getLayer() {
return layer;
}
+
public void setLayer(String layer) {
this.layer = layer;
}
@@ -221,6 +215,7 @@ public final class PersistentProviderRegistrations {
public String getAppContext() {
return appContext;
}
+
public void setAppContext(String appContext) {
this.appContext = appContext;
}
@@ -229,6 +224,7 @@ public final class PersistentProviderRegistrations {
public String getDescription() {
return description;
}
+
public void setDescription(String description) {
this.description = description;
}
@@ -240,16 +236,20 @@ public final class PersistentProviderRegistrations {
/**
* Used by IntrospectionUtils via reflection.
- * @param name - the name of of the property to set on this object
+ *
+ * @param name - the name of of the property to set on this object
* @param value - the value to set
+ *
* @see #addProperty(String, String)
*/
public void setProperty(String name, String value) {
addProperty(name, value);
}
+
void addProperty(String name, String value) {
properties.put(name, value);
}
+
public Map<String,String> getProperties() {
return properties;
}
@@ -264,6 +264,7 @@ public final class PersistentProviderRegistrations {
public String getName() {
return name;
}
+
public void setName(String name) {
this.name = name;
}
@@ -272,6 +273,7 @@ public final class PersistentProviderRegistrations {
public String getValue() {
return value;
}
+
public void setValue(String value) {
this.value = value;
}
diff --git
a/java/org/apache/catalina/authenticator/jaspic/SimpleAuthConfigProvider.java
b/java/org/apache/catalina/authenticator/jaspic/SimpleAuthConfigProvider.java
index 9fe70b8d33..bbc64a330e 100644
---
a/java/org/apache/catalina/authenticator/jaspic/SimpleAuthConfigProvider.java
+++
b/java/org/apache/catalina/authenticator/jaspic/SimpleAuthConfigProvider.java
@@ -28,8 +28,7 @@ import jakarta.security.auth.message.config.ServerAuthConfig;
/**
* Basic implementation primarily intended for use when using third-party
- * {@link jakarta.security.auth.message.module.ServerAuthModule}
implementations
- * that only provide the module.
+ * {@link jakarta.security.auth.message.module.ServerAuthModule}
implementations that only provide the module.
*/
public class SimpleAuthConfigProvider implements AuthConfigProvider {
@@ -48,19 +47,18 @@ public class SimpleAuthConfigProvider implements
AuthConfigProvider {
/**
* {@inheritDoc}
* <p>
- * This implementation does not support client-side authentication and
- * therefore always returns {@code null}.
+ * This implementation does not support client-side authentication and
therefore always returns {@code null}.
*/
@Override
- public ClientAuthConfig getClientAuthConfig(String layer, String
appContext,
- CallbackHandler handler) throws AuthException {
+ public ClientAuthConfig getClientAuthConfig(String layer, String
appContext, CallbackHandler handler)
+ throws AuthException {
return null;
}
@Override
- public ServerAuthConfig getServerAuthConfig(String layer, String
appContext,
- CallbackHandler handler) throws AuthException {
+ public ServerAuthConfig getServerAuthConfig(String layer, String
appContext, CallbackHandler handler)
+ throws AuthException {
ServerAuthConfig serverAuthConfig = this.serverAuthConfig;
if (serverAuthConfig == null) {
synchronized (this) {
@@ -74,8 +72,8 @@ public class SimpleAuthConfigProvider implements
AuthConfigProvider {
}
- protected ServerAuthConfig createServerAuthConfig(String layer, String
appContext,
- CallbackHandler handler, Map<String,Object> properties) {
+ protected ServerAuthConfig createServerAuthConfig(String layer, String
appContext, CallbackHandler handler,
+ Map<String,Object> properties) {
return new SimpleServerAuthConfig(layer, appContext, handler,
properties);
}
diff --git
a/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthConfig.java
b/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthConfig.java
index 5ebc4b236f..2c6cd51748 100644
--- a/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthConfig.java
+++ b/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthConfig.java
@@ -33,10 +33,9 @@ import jakarta.security.auth.message.module.ServerAuthModule;
import org.apache.tomcat.util.res.StringManager;
/**
- * Basic implementation primarily intended for use when using third-party
- * {@link ServerAuthModule} implementations that only provide the module. This
- * implementation supports configuring the {@link ServerAuthContext} with
- * multiple modules.
+ * Basic implementation primarily intended for use when using third-party
{@link ServerAuthModule} implementations that
+ * only provide the module. This implementation supports configuring the
{@link ServerAuthContext} with multiple
+ * modules.
*/
public class SimpleServerAuthConfig implements ServerAuthConfig {
@@ -92,8 +91,8 @@ public class SimpleServerAuthConfig implements
ServerAuthConfig {
@Override
- public ServerAuthContext getAuthContext(String authContextID, Subject
serviceSubject,
- Map<String,Object> properties) throws AuthException {
+ public ServerAuthContext getAuthContext(String authContextID, Subject
serviceSubject, Map<String,Object> properties)
+ throws AuthException {
ServerAuthContext serverAuthContext = this.serverAuthContext;
if (serverAuthContext == null) {
synchronized (this) {
@@ -113,12 +112,10 @@ public class SimpleServerAuthConfig implements
ServerAuthConfig {
while (moduleClassName instanceof String) {
try {
Class<?> clazz = Class.forName((String)
moduleClassName);
- ServerAuthModule module =
- (ServerAuthModule)
clazz.getConstructor().newInstance();
+ ServerAuthModule module = (ServerAuthModule)
clazz.getConstructor().newInstance();
module.initialize(null, null, handler,
mergedProperties);
modules.add(module);
- } catch (ReflectiveOperationException |
IllegalArgumentException |
- SecurityException e) {
+ } catch (ReflectiveOperationException |
IllegalArgumentException | SecurityException e) {
AuthException ae = new AuthException();
ae.initCause(e);
throw ae;
diff --git
a/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthContext.java
b/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthContext.java
index d01dc267a0..dca6bd0450 100644
--- a/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthContext.java
+++ b/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthContext.java
@@ -27,10 +27,9 @@ import
jakarta.security.auth.message.config.ServerAuthContext;
import jakarta.security.auth.message.module.ServerAuthModule;
/**
- * Basic implementation primarily intended for use when using third-party
- * {@link ServerAuthModule} implementations that only provide the module. This
- * implementation supports multiple modules and will treat the user as
- * authenticated if any one module is able to authenticate the user.
+ * Basic implementation primarily intended for use when using third-party
{@link ServerAuthModule} implementations that
+ * only provide the module. This implementation supports multiple modules and
will treat the user as authenticated if
+ * any one module is able to authenticate the user.
*/
public class SimpleServerAuthContext implements ServerAuthContext {
@@ -43,8 +42,8 @@ public class SimpleServerAuthContext implements
ServerAuthContext {
@Override
- public AuthStatus validateRequest(MessageInfo messageInfo, Subject
clientSubject,
- Subject serviceSubject) throws AuthException {
+ public AuthStatus validateRequest(MessageInfo messageInfo, Subject
clientSubject, Subject serviceSubject)
+ throws AuthException {
for (int moduleIndex = 0; moduleIndex < modules.size(); moduleIndex++)
{
ServerAuthModule module = modules.get(moduleIndex);
AuthStatus result = module.validateRequest(messageInfo,
clientSubject, serviceSubject);
@@ -58,8 +57,7 @@ public class SimpleServerAuthContext implements
ServerAuthContext {
@Override
- public AuthStatus secureResponse(MessageInfo messageInfo, Subject
serviceSubject)
- throws AuthException {
+ public AuthStatus secureResponse(MessageInfo messageInfo, Subject
serviceSubject) throws AuthException {
ServerAuthModule module = modules.get(((Integer)
messageInfo.getMap().get("moduleIndex")).intValue());
return module.secureResponse(messageInfo, serviceSubject);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]