You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/09/27 07:45:57 UTC

[tomcat] branch 8.5.x updated (00dca673b7 -> 05693857aa)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


    from 00dca673b7 Align with 9.0.x onwards
     new 9893123cc8 Code clean-up - no functional change
     new 05693857aa Align with 9.0.x onwards

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/catalina/realm/CombinedRealm.java  | 11 ++--
 .../org/apache/catalina/realm/DataSourceRealm.java |  6 +-
 .../realm/DigestCredentialHandlerBase.java         |  4 +-
 .../apache/catalina/realm/GenericPrincipal.java    | 10 +---
 .../catalina/realm/JAASMemoryLoginModule.java      | 25 ++++----
 java/org/apache/catalina/realm/JAASRealm.java      | 31 +++-------
 java/org/apache/catalina/realm/JNDIRealm.java      | 59 +++++++++----------
 .../apache/catalina/realm/LocalStrings.properties  | 13 +++++
 .../catalina/realm/LocalStrings_fr.properties      | 13 +++++
 .../catalina/realm/LocalStrings_ja.properties      | 13 +++++
 .../catalina/realm/LocalStrings_ko.properties      | 13 +++++
 .../catalina/realm/LocalStrings_zh_CN.properties   | 13 +++++
 java/org/apache/catalina/realm/LockOutRealm.java   | 10 ++--
 java/org/apache/catalina/realm/MemoryRealm.java    |  5 +-
 java/org/apache/catalina/realm/MemoryRuleSet.java  |  6 --
 java/org/apache/catalina/realm/RealmBase.java      | 68 ++++++++++------------
 .../apache/catalina/realm/UserDatabaseRealm.java   |  3 +-
 17 files changed, 166 insertions(+), 137 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 02/02: Align with 9.0.x onwards

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 05693857aa2c09bebede13661cd8a717ab483f3f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Sep 27 08:34:02 2023 +0100

    Align with 9.0.x onwards
---
 .../apache/catalina/realm/GenericPrincipal.java    | 10 +-------
 .../catalina/realm/JAASMemoryLoginModule.java      | 15 ++++++------
 java/org/apache/catalina/realm/JAASRealm.java      | 27 ++++++----------------
 java/org/apache/catalina/realm/JNDIRealm.java      | 10 ++++----
 .../apache/catalina/realm/LocalStrings.properties  | 13 +++++++++++
 .../catalina/realm/LocalStrings_fr.properties      | 13 +++++++++++
 .../catalina/realm/LocalStrings_ja.properties      | 13 +++++++++++
 .../catalina/realm/LocalStrings_ko.properties      | 13 +++++++++++
 .../catalina/realm/LocalStrings_zh_CN.properties   | 13 +++++++++++
 java/org/apache/catalina/realm/MemoryRealm.java    |  3 ++-
 java/org/apache/catalina/realm/MemoryRuleSet.java  |  6 -----
 java/org/apache/catalina/realm/RealmBase.java      | 18 +++++++--------
 12 files changed, 95 insertions(+), 59 deletions(-)

diff --git a/java/org/apache/catalina/realm/GenericPrincipal.java b/java/org/apache/catalina/realm/GenericPrincipal.java
index b731f846d5..e4c72f613c 100644
--- a/java/org/apache/catalina/realm/GenericPrincipal.java
+++ b/java/org/apache/catalina/realm/GenericPrincipal.java
@@ -138,7 +138,7 @@ public class GenericPrincipal implements TomcatPrincipal, Serializable {
     /**
      * The set of roles associated with this user.
      */
-    protected final String roles[];
+    protected final String[] roles;
 
     public String[] getRoles() {
         return this.roles;
@@ -217,14 +217,6 @@ public class GenericPrincipal implements TomcatPrincipal, Serializable {
     }
 
 
-    /**
-     * Calls logout, if necessary, on any associated JAASLoginContext. May in the future be extended to cover other
-     * logout requirements.
-     *
-     * @throws Exception If something goes wrong with the logout. Uses Exception to allow for future expansion of this
-     *                       method to cover other logout mechanisms that might throw a different exception to
-     *                       LoginContext
-     */
     @Override
     public void logout() throws Exception {
         if (loginContext != null) {
diff --git a/java/org/apache/catalina/realm/JAASMemoryLoginModule.java b/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
index 9e43d809c8..cff832dbd6 100644
--- a/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
+++ b/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
@@ -236,7 +236,7 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule {
     public boolean login() throws LoginException {
         // Set up our CallbackHandler requests
         if (callbackHandler == null) {
-            throw new LoginException("No CallbackHandler specified");
+            throw new LoginException(sm.getString("jaasMemoryLoginModule.noCallbackHandler"));
         }
         Callback callbacks[] = new Callback[10];
         callbacks[0] = new NameCallback("Username: ");
@@ -276,7 +276,7 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule {
             algorithm = ((TextInputCallback) callbacks[8]).getText();
             authMethod = ((TextInputCallback) callbacks[9]).getText();
         } catch (IOException | UnsupportedCallbackException e) {
-            throw new LoginException(e.toString());
+            throw new LoginException(sm.getString("jaasMemoryLoginModule.callbackHandlerError", e.toString()));
         }
 
         // Validate the username and password we have received
@@ -288,7 +288,7 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule {
         } else if (authMethod.equals(HttpServletRequest.CLIENT_CERT_AUTH)) {
             principal = super.getPrincipal(username);
         } else {
-            throw new LoginException("Unknown authentication method");
+            throw new LoginException(sm.getString("jaasMemoryLoginModule.unknownAuthenticationMethod"));
         }
 
         if (log.isDebugEnabled()) {
@@ -299,7 +299,7 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule {
         if (principal != null) {
             return true;
         } else {
-            throw new FailedLoginException("Username or password is incorrect");
+            throw new FailedLoginException(sm.getString("jaasMemoryLoginModule.invalidCredentials"));
         }
     }
 
@@ -325,14 +325,14 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule {
         if (!file.isAbsolute()) {
             String catalinaBase = getCatalinaBase();
             if (catalinaBase == null) {
-                log.warn("Unable to determine Catalina base to load file " + pathname);
+                log.error(sm.getString("jaasMemoryLoginModule.noCatalinaBase", pathname));
                 return;
             } else {
                 file = new File(catalinaBase, pathname);
             }
         }
         if (!file.canRead()) {
-            log.warn("Cannot load configuration file " + file.getAbsolutePath());
+            log.error(sm.getString("jaasMemoryLoginModule.noConfig", file.getAbsolutePath()));
             return;
         }
 
@@ -344,8 +344,7 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule {
             digester.push(this);
             digester.parse(file);
         } catch (Exception e) {
-            log.warn("Error processing configuration file " + file.getAbsolutePath(), e);
-            return;
+            log.error(sm.getString("jaasMemoryLoginModule.parseError", file.getAbsolutePath()), e);
         } finally {
             digester.reset();
         }
diff --git a/java/org/apache/catalina/realm/JAASRealm.java b/java/org/apache/catalina/realm/JAASRealm.java
index 5b491f5419..71bd35ba21 100644
--- a/java/org/apache/catalina/realm/JAASRealm.java
+++ b/java/org/apache/catalina/realm/JAASRealm.java
@@ -232,8 +232,7 @@ public class JAASRealm extends RealmBase {
 
         if (appName == null) {
             appName = makeLegalForJAAS(container.getName());
-
-            log.info("Set JAAS app name " + appName);
+            log.info(sm.getString("jaasRealm.appName", appName));
         }
     }
 
@@ -286,11 +285,10 @@ public class JAASRealm extends RealmBase {
                 if (Principal.class.isAssignableFrom(principalClass)) {
                     classNamesList.add(className);
                 } else {
-                    log.error("Class " + className + " is not implementing " +
-                            "java.security.Principal! Class not added.");
+                    log.error(sm.getString("jaasRealm.notPrincipal", className));
                 }
             } catch (ClassNotFoundException e) {
-                log.error("Class " + className + " not found! Class not added.");
+                log.error(sm.getString("jaasRealm.classNotFound", className));
             }
         }
     }
@@ -399,7 +397,7 @@ public class JAASRealm extends RealmBase {
                     if (log.isDebugEnabled()) {
                         log.debug(sm.getString("jaasRealm.failedLogin", username));
                     }
-                    return (null);
+                    return null;
                 }
             } catch (AccountExpiredException e) {
                 if (log.isDebugEnabled()) {
@@ -451,7 +449,7 @@ public class JAASRealm extends RealmBase {
                 return null;
             }
             if (log.isDebugEnabled()) {
-                log.debug(sm.getString("jaasRealm.authenticateSuccess", username));
+                log.debug(sm.getString("jaasRealm.authenticateSuccess", username, principal));
             }
 
             return principal;
@@ -623,21 +621,10 @@ public class JAASRealm extends RealmBase {
                 this.jaasConfigurationLoaded = true;
                 return this.jaasConfiguration;
             }
-        } catch (URISyntaxException ex) {
-            throw new RuntimeException(ex);
-        } catch (NoSuchMethodException ex) {
-            throw new RuntimeException(ex);
-        } catch (SecurityException ex) {
-            throw new RuntimeException(ex);
-        } catch (InstantiationException ex) {
-            throw new RuntimeException(ex);
-        } catch (IllegalAccessException ex) {
-            throw new RuntimeException(ex);
-        } catch (IllegalArgumentException ex) {
-            throw new RuntimeException(ex);
         } catch (InvocationTargetException ex) {
             throw new RuntimeException(ex.getCause());
-        } catch (ClassNotFoundException ex) {
+        } catch (SecurityException | URISyntaxException | ClassNotFoundException | IllegalAccessException |
+                InstantiationException | NoSuchMethodException | IllegalArgumentException ex) {
             throw new RuntimeException(ex);
         }
     }
diff --git a/java/org/apache/catalina/realm/JNDIRealm.java b/java/org/apache/catalina/realm/JNDIRealm.java
index 192c415b9e..52cb739c8b 100644
--- a/java/org/apache/catalina/realm/JNDIRealm.java
+++ b/java/org/apache/catalina/realm/JNDIRealm.java
@@ -3166,26 +3166,26 @@ public class JNDIRealm extends RealmBase {
         /**
          * The MessageFormat object associated with the current <code>userSearch</code>.
          */
-        protected MessageFormat userSearchFormat = null;
+        public MessageFormat userSearchFormat = null;
 
         /**
          * An array of MessageFormat objects associated with the current <code>userPatternArray</code>.
          */
-        protected MessageFormat[] userPatternFormatArray = null;
+        public MessageFormat[] userPatternFormatArray = null;
 
         /**
          * The MessageFormat object associated with the current <code>roleBase</code>.
          */
-        protected MessageFormat roleBaseFormat = null;
+        public MessageFormat roleBaseFormat = null;
 
         /**
          * The MessageFormat object associated with the current <code>roleSearch</code>.
          */
-        protected MessageFormat roleFormat = null;
+        public MessageFormat roleFormat = null;
 
         /**
          * The directory context linking us to our directory server.
          */
-        protected DirContext context = null;
+        public DirContext context = null;
     }
 }
diff --git a/java/org/apache/catalina/realm/LocalStrings.properties b/java/org/apache/catalina/realm/LocalStrings.properties
index eda93dd8cf..7ac439ff9d 100644
--- a/java/org/apache/catalina/realm/LocalStrings.properties
+++ b/java/org/apache/catalina/realm/LocalStrings.properties
@@ -36,15 +36,26 @@ dataSourceRealm.noNamingContext=Cannot access the server to retrieve the naming
 
 jaasCallback.username=Returned username [{0}]
 
+jaasMemoryLoginModule.callbackHandlerError=Error invoking callback handler: [{0}]
+jaasMemoryLoginModule.invalidCredentials=User name or password is incorrect
+jaasMemoryLoginModule.noCallbackHandler=No CallbackHandler specified
+jaasMemoryLoginModule.noCatalinaBase=Unable to determine Catalina base to load file [{0}]
+jaasMemoryLoginModule.noConfig=Cannot load configuration file [{0}]
+jaasMemoryLoginModule.parseError=Error processing configuration file [{0}]
+jaasMemoryLoginModule.unknownAuthenticationMethod=Unknown authentication method
+
 jaasRealm.accountExpired=Username [{0}] NOT authenticated due to expired account
+jaasRealm.appName=Set JAAS app name [{0}]
 jaasRealm.authenticateFailure=Username [{0}] NOT successfully authenticated
 jaasRealm.authenticateSuccess=Username [{0}] successfully authenticated as Principal [{1}] -- Subject was created too
 jaasRealm.beginLogin=JAASRealm login requested for username [{0}] using LoginContext for application [{1}]
 jaasRealm.checkPrincipal=Checking Principal [{0}] [{1}]
+jaasRealm.classNotFound=Class [{0}] was not found
 jaasRealm.credentialExpired=Username [{0}] NOT authenticated due to expired credential
 jaasRealm.failedLogin=Username [{0}] NOT authenticated due to failed login
 jaasRealm.loginContextCreated=JAAS LoginContext created for username [{0}]
 jaasRealm.loginException=Login exception authenticating username [{0}]
+jaasRealm.notPrincipal=Class [{0}] not added as it does not implement java.security.Principal
 jaasRealm.rolePrincipalAdd=Adding role Principal [{0}] to this user Principal''s roles
 jaasRealm.rolePrincipalFailure=No valid role Principals found.
 jaasRealm.unexpectedError=Unexpected error
@@ -103,6 +114,8 @@ realmBase.gssContextNotEstablished=Authenticator implementation error: the passe
 realmBase.gssNameFail=Failed to extract name from established GSSContext
 realmBase.hasRoleFailure=Username [{0}] does NOT have role [{1}]
 realmBase.hasRoleSuccess=Username [{0}] has role [{1}]
+realmBase.invalidDigestEncoding=Invalid digest encoding [{0}]
+realmBase.unknownAllRolesMode=Unknown mode [{0}], must be one of: strict, authOnly, strictAuthOnly
 
 userDatabaseRealm.lookup=Exception looking up UserDatabase under key [{0}]
 userDatabaseRealm.noDatabase=No UserDatabase component found under key [{0}]
diff --git a/java/org/apache/catalina/realm/LocalStrings_fr.properties b/java/org/apache/catalina/realm/LocalStrings_fr.properties
index 0da62b067b..75679b9016 100644
--- a/java/org/apache/catalina/realm/LocalStrings_fr.properties
+++ b/java/org/apache/catalina/realm/LocalStrings_fr.properties
@@ -35,15 +35,26 @@ dataSourceRealm.getRoles.exception=Exception lors de la récupération des rôle
 
 jaasCallback.username=Nom d''utilisateur renvoyé [{0}]
 
+jaasMemoryLoginModule.callbackHandlerError=Erreur lors de l''invocation du CallbackHandler : [{0}]
+jaasMemoryLoginModule.invalidCredentials=Le nom d'utilisateur ou le mot de passe est incorrect
+jaasMemoryLoginModule.noCallbackHandler=Aucun CallbackHandler n'a été spécifié
+jaasMemoryLoginModule.noCatalinaBase=Impossible de déterminer le répertoire de base de Catalina pour pouvoir charger le fichier [{0}]
+jaasMemoryLoginModule.noConfig=Impossible de charger le fichier de configuration [{0}]
+jaasMemoryLoginModule.parseError=Erreur de traitement du fichier de configuration [{0}]
+jaasMemoryLoginModule.unknownAuthenticationMethod=Méthode d'authentification inconnue
+
 jaasRealm.accountExpired=le nom d''utilisateur [{0}] N''A PAS été authentifié car le compte a expiré
+jaasRealm.appName=Définition du nom d''application JAAS comme [{0}]
 jaasRealm.authenticateFailure=Le nom d''utilisateur [{0}] n''a pas été authentifié avec succès
 jaasRealm.authenticateSuccess=le nom d''utilisateur [{0}] a été authentifié avec succès
 jaasRealm.beginLogin=La connection avec le JAASRealm a demandé le nom d''utilisateur [{0}] en utilisant le LoginContext de l''application [{1}]
 jaasRealm.checkPrincipal=Vérification du principal [{0}] [{1}]
+jaasRealm.classNotFound=La classe [{0}] n''a pas été trouvée
 jaasRealm.credentialExpired=le nom d''utilisateur [{0}] N''A PAS été authentifié car son crédit a expiré (expired credential)
 jaasRealm.failedLogin=le nom d''utilisateur [{0}] N''A PAS été authentifié car son contrôle d''accès (login) a échoué
 jaasRealm.loginContextCreated=Le LoginContext JAAS a été crée pour le nom d''utilisateur [{0}]
 jaasRealm.loginException=Exception lors de l''authentification par login du nom d''utilisateur [{0}]
+jaasRealm.notPrincipal=La classe [{0}] n''a pas été ajoutée car elle n''implémente pas java.security.Principal
 jaasRealm.rolePrincipalAdd=Ajout du rôle Pincipal [{0}] aux rôles du principal de l''utilisateur
 jaasRealm.rolePrincipalFailure=Aucun principal avec un rôle valide trouvé
 jaasRealm.unexpectedError=Erreur inattendue
@@ -102,6 +113,8 @@ realmBase.gssContextNotEstablished=Erreur d'implémentation de l'authenticateur
 realmBase.gssNameFail=Impossible d'extraire le nom du GSSContext qui a été établi
 realmBase.hasRoleFailure=Le nom d''utilisateur [{0}] N''A PAS de rôle [{1}]
 realmBase.hasRoleSuccess=Le nom d''utilisateur [{0}] a pour rôle [{1}]
+realmBase.invalidDigestEncoding=L''encodage de digest spécifié [{0}] est invalide
+realmBase.unknownAllRolesMode=Le mode [{0}] est inconnu, il doit être : strict, authOnly ou strictAuthOnly
 
 userDatabaseRealm.lookup=Exception lors de la recherche dans la base de données utilisateurs avec la clé [{0}]
 userDatabaseRealm.noDatabase=Aucun composant base de données utilisateurs trouvé pour la clé [{0}]
diff --git a/java/org/apache/catalina/realm/LocalStrings_ja.properties b/java/org/apache/catalina/realm/LocalStrings_ja.properties
index 81a0749465..e572a0f274 100644
--- a/java/org/apache/catalina/realm/LocalStrings_ja.properties
+++ b/java/org/apache/catalina/realm/LocalStrings_ja.properties
@@ -35,15 +35,26 @@ dataSourceRealm.getRoles.exception=[{0}] のロールを取得中に例外が発
 
 jaasCallback.username=返されたユーザー名[{0}]
 
+jaasMemoryLoginModule.callbackHandlerError=コールバックハンドラーの呼び出し中のエラー: [{0}]
+jaasMemoryLoginModule.invalidCredentials=ユーザー名、または、パスワードが間違っています。
+jaasMemoryLoginModule.noCallbackHandler=CallbackHandler が未指定です。
+jaasMemoryLoginModule.noCatalinaBase=ファイル[{0}]をロードするCatalina baseを特定できません
+jaasMemoryLoginModule.noConfig=設定ファイルを読み込めませんでした。 [{0}]
+jaasMemoryLoginModule.parseError=設定ファイル [{0}] 処理中のエラー
+jaasMemoryLoginModule.unknownAuthenticationMethod=未知の認証方法です
+
 jaasRealm.accountExpired=ユーザ名 [{0}] はアカウントの期限が切れているために認証されません
+jaasRealm.appName=JAASアプリケーション名[{0}]を設定します。
 jaasRealm.authenticateFailure=ユーザー名[{0}]は正常に認証されませんでした
 jaasRealm.authenticateSuccess=ユーザ名 [{0}] は認証に成功しました
 jaasRealm.beginLogin=アプリケーション[{1}]のLoginContextを使用して、ユーザー名[{0}]に対するJAASRealmログインが要求されました。
 jaasRealm.checkPrincipal=プリンシパル [{0}] [{1}] をチェックします
+jaasRealm.classNotFound=クラス [{0}] が見つかりませんでした
 jaasRealm.credentialExpired=ユーザ名 [{0}] は証明書の期限が切れたために認証されません
 jaasRealm.failedLogin=ユーザ名 [{0}] はログインに失敗したために認証されませんでした
 jaasRealm.loginContextCreated=ユーザー名[{0}]用に作成されたJAAS LoginContext
 jaasRealm.loginException=ユーザ名 [{0}] の認証中にログイン例外が発生しました
+jaasRealm.notPrincipal=クラス [{0}] はjava.security.Principalを実装していないため追加されません
 jaasRealm.rolePrincipalAdd=このユーザープリンシパルロールにロールプリンシパル [{0}] を追加
 jaasRealm.rolePrincipalFailure=有効な役割はありません。
 jaasRealm.unexpectedError=予期せぬエラー
@@ -102,6 +113,8 @@ realmBase.gssContextNotEstablished=Authenticator 実装エラー:渡された
 realmBase.gssNameFail=確立されたGSSContextから名前を抽出できませんでした。
 realmBase.hasRoleFailure=ユーザ名 [{0}] はロール [{1}] を持っていません
 realmBase.hasRoleSuccess=ユーザ名 [{0}] はロール [{1}] を持っています
+realmBase.invalidDigestEncoding=無効なダイジェストエンコーディング [{0}]
+realmBase.unknownAllRolesMode=未知のモード [{0}]。strict、authOnly、strictAuthOnly のどれか1つでなければなりません。
 
 userDatabaseRealm.lookup=キー [{0}] でユーザデータベースを検索中の例外です
 userDatabaseRealm.noDatabase=キー [{0}] でユーザデータベースコンポーネントが見つかりません
diff --git a/java/org/apache/catalina/realm/LocalStrings_ko.properties b/java/org/apache/catalina/realm/LocalStrings_ko.properties
index 89c8f9aa2f..43a1f697fe 100644
--- a/java/org/apache/catalina/realm/LocalStrings_ko.properties
+++ b/java/org/apache/catalina/realm/LocalStrings_ko.properties
@@ -35,15 +35,26 @@ dataSourceRealm.getRoles.exception=사용자 [{0}]을(를) 위한 역할들을 
 
 jaasCallback.username=반환된 사용자명 [{0}]
 
+jaasMemoryLoginModule.callbackHandlerError=콜백 핸들러 호출 중 오류 발생: [{0}]
+jaasMemoryLoginModule.invalidCredentials=사용자 이름 또는 비밀번호가 올바르지 않습니다.
+jaasMemoryLoginModule.noCallbackHandler=CallbackHandler가 지정되지 않았습니다.
+jaasMemoryLoginModule.noCatalinaBase=파일 [{0}]을(를) 로드하기 위한 Catalina base를 결정할 수 없습니다.
+jaasMemoryLoginModule.noConfig=설정 파일 [{0}]을(를) 로드할 수 없습니다.
+jaasMemoryLoginModule.parseError=설정 파일 [{0}]을(를) 처리하는 중 오류 발생
+jaasMemoryLoginModule.unknownAuthenticationMethod=알 수 없는 인증 메소드
+
 jaasRealm.accountExpired=사용자명 [{0}]은(는) 만료된 계정이라서 인증되지 않았습니다.
+jaasRealm.appName=JAAS 앱 이름 [{0}]을(를) 설정합니다.
 jaasRealm.authenticateFailure=사용자명 [{0}]은(는) 성공적으로 인증되지 못했습니다.
 jaasRealm.authenticateSuccess=사용자명 [{0}]이(가) 성공적으로 Principal [{1}](으)로서 인증되었습니다 -- Subject 또한 생성되었습니다.
 jaasRealm.beginLogin=애플리케이션 [{1}]을(를) 위한 LoginContext를 사용하여, 사용자명 [{0}]을(를) 위한 JAASRealm 로그인이 요청되었습니다.
 jaasRealm.checkPrincipal=Principal [{0}] [{1}]을(를) 점검합니다.
+jaasRealm.classNotFound=클래스 [{0}]을(를) 찾을 수 없었습니다.
 jaasRealm.credentialExpired=만료된 credentials로 인하여, 사용자명 [{0}]이(가) 인증되지 않았습니다.
 jaasRealm.failedLogin=사용자명 [{0}]은(는) 로그인 실패로 인하여 인증되지 않았습니다.
 jaasRealm.loginContextCreated=사용자명 [{0}]을(를) 위해 생성된 JAAS LoginContext
 jaasRealm.loginException=사용자 이름 [{0}]을(를) 인증하는 중 로그인 예외 발생
+jaasRealm.notPrincipal=java.security.Principal을 구현하고 있지 않아, 클래스 [{0}]이(가) 추가되지 않았습니다.
 jaasRealm.rolePrincipalAdd=이 사용자 Principal의 역할들에, 역할 Principal [{0}]을(를) 추가합니다.
 jaasRealm.rolePrincipalFailure=유효한 역할 Principal들을 찾을 수 없습니다.
 jaasRealm.unexpectedError=예기치 않은 오류
@@ -101,6 +112,8 @@ realmBase.gssContextNotEstablished=Authenticator 구현 오류: 전달된 보안
 realmBase.gssNameFail=확립된 GSSContext로부터, 이름을 추출하지 못했습니다.
 realmBase.hasRoleFailure=사용자명 [{0}]은(는) 역할 [{1}]을(를) 가지고 있지 않습니다.
 realmBase.hasRoleSuccess=사용자명 [{0}]이(가) 역할 [{1}]을(를) 가지고 있습니다.
+realmBase.invalidDigestEncoding=유효하지 않은 digest 인코딩: [{0}]
+realmBase.unknownAllRolesMode=알 수 없는 모드 [{0}]. 모드는 반드시 다음 중 하나여야만 합니다: strict, authOnly, strictAuthOnly
 
 userDatabaseRealm.lookup=키 [{0}]을(를) 사용하여 사용자 데이터베이스를 찾는 중 예외 발생
 userDatabaseRealm.noDatabase=키 [{0}]을(를) 사용하여 UserDatabase 구성요소를 찾을 수 없습니다.
diff --git a/java/org/apache/catalina/realm/LocalStrings_zh_CN.properties b/java/org/apache/catalina/realm/LocalStrings_zh_CN.properties
index d5343454a3..d526197b11 100644
--- a/java/org/apache/catalina/realm/LocalStrings_zh_CN.properties
+++ b/java/org/apache/catalina/realm/LocalStrings_zh_CN.properties
@@ -35,15 +35,26 @@ dataSourceRealm.getRoles.exception=检索角色[{0}]异常
 
 jaasCallback.username=返回用户名 [{0}]
 
+jaasMemoryLoginModule.callbackHandlerError=调用回调处理程序时出错:[{0}]
+jaasMemoryLoginModule.invalidCredentials=用户名或密码不正确
+jaasMemoryLoginModule.noCallbackHandler=未指定回调处理程序
+jaasMemoryLoginModule.noCatalinaBase=无法确定要加载文件的Catalina基[{0}]
+jaasMemoryLoginModule.noConfig=无法加载配置文件 [{0}]
+jaasMemoryLoginModule.parseError=处理配置文件[{0}]时出错
+jaasMemoryLoginModule.unknownAuthenticationMethod=未知的身份验证方法
+
 jaasRealm.accountExpired=由于帐户过期,用户名[{0}]未通过身份验证
+jaasRealm.appName=设置JAAS应用程序名称[{0}]
 jaasRealm.authenticateFailure=用户 [{0}] 认证失败
 jaasRealm.authenticateSuccess=用户名 [{0}] 已被成功认证为身份 [{1}] -- 主体也已创建
 jaasRealm.beginLogin=使用应用程序[{1}]的LoginContext为用户名[{0}]请求JAASRealm登录
 jaasRealm.checkPrincipal=正在检查主体[{0}][{1}]
+jaasRealm.classNotFound=找不到类 [{0}]
 jaasRealm.credentialExpired=由于凭据过期,用户名[{0}]未通过身份验证
 jaasRealm.failedLogin=由于登录失败,用户名 [{0}] 无法授权
 jaasRealm.loginContextCreated=为用户名创建的JAAS 登陆上下文[{0}]
 jaasRealm.loginException=登录异常,认证用户名  [{0}]
+jaasRealm.notPrincipal=类[{0}]未添加,因为它未实现java.security.Principal
 jaasRealm.rolePrincipalAdd=已经将角色主体[{0}]添加到此用户主体的角色
 jaasRealm.rolePrincipalFailure=找不到有效的角色主体。
 jaasRealm.unexpectedError=意外错误
@@ -101,6 +112,8 @@ realmBase.gssContextNotEstablished=身份验证器实现错误:传递的安全
 realmBase.gssNameFail=无法从已建立的GSSContext中提取名称
 realmBase.hasRoleFailure=用户[{0}]没有角色[{1}]
 realmBase.hasRoleSuccess=用户名[{0}] 有角色[{1}]
+realmBase.invalidDigestEncoding=无效的摘要编码[{0}]
+realmBase.unknownAllRolesMode=未知模式[{0}],必须是以下之一:strict、authOnly、strictAuthOnly
 
 userDatabaseRealm.lookup=在键[{0}]下查找用户数据库时发生异常
 userDatabaseRealm.noDatabase=未找到key[{0}]对应的UserDatabase组件。
diff --git a/java/org/apache/catalina/realm/MemoryRealm.java b/java/org/apache/catalina/realm/MemoryRealm.java
index 41ae5a0a97..0414ece4f1 100644
--- a/java/org/apache/catalina/realm/MemoryRealm.java
+++ b/java/org/apache/catalina/realm/MemoryRealm.java
@@ -21,6 +21,7 @@ import java.io.InputStream;
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.catalina.LifecycleException;
@@ -157,7 +158,7 @@ public class MemoryRealm extends RealmBase {
     void addUser(String username, String password, String roles) {
 
         // Accumulate the list of roles for this user
-        ArrayList<String> list = new ArrayList<>();
+        List<String> list = new ArrayList<>();
         roles += ",";
         while (true) {
             int comma = roles.indexOf(',');
diff --git a/java/org/apache/catalina/realm/MemoryRuleSet.java b/java/org/apache/catalina/realm/MemoryRuleSet.java
index a88c13aedb..5846f815ce 100644
--- a/java/org/apache/catalina/realm/MemoryRuleSet.java
+++ b/java/org/apache/catalina/realm/MemoryRuleSet.java
@@ -16,13 +16,11 @@
  */
 package org.apache.catalina.realm;
 
-
 import org.apache.tomcat.util.digester.Digester;
 import org.apache.tomcat.util.digester.Rule;
 import org.apache.tomcat.util.digester.RuleSetBase;
 import org.xml.sax.Attributes;
 
-
 /**
  * <p>
  * <strong>RuleSet</strong> for recognizing the users defined in the XML file processed by <code>MemoryRealm</code>.
@@ -36,7 +34,6 @@ public class MemoryRuleSet extends RuleSetBase {
 
     // ----------------------------------------------------- Instance Variables
 
-
     /**
      * The matching pattern prefix to use for recognizing our elements.
      */
@@ -45,14 +42,11 @@ public class MemoryRuleSet extends RuleSetBase {
 
     // ------------------------------------------------------------ Constructor
 
-
     /**
      * Construct an instance of this <code>RuleSet</code> with the default matching pattern prefix.
      */
     public MemoryRuleSet() {
-
         this("tomcat-users/");
-
     }
 
 
diff --git a/java/org/apache/catalina/realm/RealmBase.java b/java/org/apache/catalina/realm/RealmBase.java
index ce16edcf28..9eb3057f11 100644
--- a/java/org/apache/catalina/realm/RealmBase.java
+++ b/java/org/apache/catalina/realm/RealmBase.java
@@ -48,6 +48,7 @@ import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.util.LifecycleMBeanBase;
 import org.apache.catalina.util.SessionConfig;
+import org.apache.catalina.util.ToStringUtil;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.IntrospectionUtils;
@@ -411,8 +412,8 @@ public abstract class RealmBase extends LifecycleMBeanBase implements org.apache
         try {
             valueBytes = serverDigestValue.getBytes(getDigestCharset());
         } catch (UnsupportedEncodingException uee) {
-            log.error("Illegal digestEncoding: " + getDigestEncoding(), uee);
-            throw new IllegalArgumentException(uee.getMessage());
+            throw new IllegalArgumentException(sm.getString("realmBase.invalidDigestEncoding", getDigestEncoding()),
+                    uee);
         }
 
         String serverDigest = HexUtils.toHexString(ConcurrentMessageDigest.digest(algorithm, valueBytes));
@@ -1103,10 +1104,7 @@ public abstract class RealmBase extends LifecycleMBeanBase implements org.apache
 
     @Override
     public String toString() {
-        StringBuilder sb = new StringBuilder("Realm[");
-        sb.append(getName());
-        sb.append(']');
-        return sb.toString();
+        return ToStringUtil.toString(this);
     }
 
 
@@ -1165,8 +1163,8 @@ public abstract class RealmBase extends LifecycleMBeanBase implements org.apache
         try {
             valueBytes = digestValue.getBytes(getDigestCharset());
         } catch (UnsupportedEncodingException uee) {
-            log.error("Illegal digestEncoding: " + getDigestEncoding(), uee);
-            throw new IllegalArgumentException(uee.getMessage());
+            throw new IllegalArgumentException(sm.getString("realmBase.invalidDigestEncoding", getDigestEncoding()),
+                    uee);
         }
 
         return HexUtils.toHexString(ConcurrentMessageDigest.digest(algorithm, valueBytes));
@@ -1225,7 +1223,7 @@ public abstract class RealmBase extends LifecycleMBeanBase implements org.apache
             log.debug(sm.getString("realmBase.gotX509Username", username));
         }
 
-        return (getPrincipal(username));
+        return getPrincipal(username);
     }
 
 
@@ -1558,7 +1556,7 @@ public abstract class RealmBase extends LifecycleMBeanBase implements org.apache
             } else if (name.equalsIgnoreCase(STRICT_AUTH_ONLY_MODE.name)) {
                 mode = STRICT_AUTH_ONLY_MODE;
             } else {
-                throw new IllegalStateException("Unknown mode, must be one of: strict, authOnly, strictAuthOnly");
+                throw new IllegalStateException(sm.getString("realmBase.unknownAllRolesMode", name));
             }
             return mode;
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 01/02: Code clean-up - no functional change

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 9893123cc841de69139ced881aee5fb005aaf9af
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Sep 26 19:04:39 2023 +0100

    Code clean-up - no functional change
---
 java/org/apache/catalina/realm/CombinedRealm.java  | 11 ++---
 .../org/apache/catalina/realm/DataSourceRealm.java |  6 +--
 .../realm/DigestCredentialHandlerBase.java         |  4 +-
 .../catalina/realm/JAASMemoryLoginModule.java      | 10 ++---
 java/org/apache/catalina/realm/JAASRealm.java      |  4 +-
 java/org/apache/catalina/realm/JNDIRealm.java      | 49 +++++++++++----------
 java/org/apache/catalina/realm/LockOutRealm.java   | 10 ++---
 java/org/apache/catalina/realm/MemoryRealm.java    |  2 +-
 java/org/apache/catalina/realm/RealmBase.java      | 50 ++++++++++------------
 .../apache/catalina/realm/UserDatabaseRealm.java   |  3 +-
 10 files changed, 71 insertions(+), 78 deletions(-)

diff --git a/java/org/apache/catalina/realm/CombinedRealm.java b/java/org/apache/catalina/realm/CombinedRealm.java
index d5bdcca187..f850f4ca2d 100644
--- a/java/org/apache/catalina/realm/CombinedRealm.java
+++ b/java/org/apache/catalina/realm/CombinedRealm.java
@@ -105,7 +105,8 @@ public class CombinedRealm extends RealmBase {
                 log.debug(sm.getString("combinedRealm.authStart", username, realm.getClass().getName()));
             }
 
-            authenticatedUser = realm.authenticate(username, clientDigest, nonce, nc, cnonce, qop, realmName, digestA2, algorithm);
+            authenticatedUser =
+                    realm.authenticate(username, clientDigest, nonce, nc, cnonce, qop, realmName, digestA2, algorithm);
 
             if (authenticatedUser == null) {
                 if (log.isDebugEnabled()) {
@@ -377,8 +378,8 @@ public class CombinedRealm extends RealmBase {
     protected String getPassword(String username) {
         // This method should never be called
         // Stack trace will show where this was called from
-        UnsupportedOperationException uoe = new UnsupportedOperationException(
-                sm.getString("combinedRealm.getPassword"));
+        UnsupportedOperationException uoe =
+                new UnsupportedOperationException(sm.getString("combinedRealm.getPassword"));
         log.error(sm.getString("combinedRealm.unexpectedMethod"), uoe);
         throw uoe;
     }
@@ -387,8 +388,8 @@ public class CombinedRealm extends RealmBase {
     protected Principal getPrincipal(String username) {
         // This method should never be called
         // Stack trace will show where this was called from
-        UnsupportedOperationException uoe = new UnsupportedOperationException(
-                sm.getString("combinedRealm.getPrincipal"));
+        UnsupportedOperationException uoe =
+                new UnsupportedOperationException(sm.getString("combinedRealm.getPrincipal"));
         log.error(sm.getString("combinedRealm.unexpectedMethod"), uoe);
         throw uoe;
     }
diff --git a/java/org/apache/catalina/realm/DataSourceRealm.java b/java/org/apache/catalina/realm/DataSourceRealm.java
index a27129a5da..31943685aa 100644
--- a/java/org/apache/catalina/realm/DataSourceRealm.java
+++ b/java/org/apache/catalina/realm/DataSourceRealm.java
@@ -236,9 +236,9 @@ public class DataSourceRealm extends RealmBase {
     /**
      * {@inheritDoc}
      * <p>
-     * If there are any errors with the JDBC connection, executing the query or anything this method returns
-     * null (doesn't authenticate). This event is also logged, and the connection will be closed so that a subsequent
-     * request will automatically re-open it.
+     * If there are any errors with the JDBC connection, executing the query or anything this method returns null
+     * (doesn't authenticate). This event is also logged, and the connection will be closed so that a subsequent request
+     * will automatically re-open it.
      */
     @Override
     public Principal authenticate(String username, String credentials) {
diff --git a/java/org/apache/catalina/realm/DigestCredentialHandlerBase.java b/java/org/apache/catalina/realm/DigestCredentialHandlerBase.java
index 2743184df0..03db3b5bb2 100644
--- a/java/org/apache/catalina/realm/DigestCredentialHandlerBase.java
+++ b/java/org/apache/catalina/realm/DigestCredentialHandlerBase.java
@@ -190,8 +190,8 @@ public abstract class DigestCredentialHandlerBase implements CredentialHandler {
             return false;
         }
 
-        String inputHexEncoded = mutate(inputCredentials, salt, iterations,
-                HexUtils.fromHexString(storedHexEncoded).length * Byte.SIZE);
+        String inputHexEncoded =
+                mutate(inputCredentials, salt, iterations, HexUtils.fromHexString(storedHexEncoded).length * Byte.SIZE);
         if (inputHexEncoded == null) {
             // Failed to mutate user credentials. Automatic fail.
             // Root cause should be logged by mutate()
diff --git a/java/org/apache/catalina/realm/JAASMemoryLoginModule.java b/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
index 1fd058b439..9e43d809c8 100644
--- a/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
+++ b/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
@@ -91,7 +91,7 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule {
     /**
      * The configuration information for this <code>LoginModule</code>.
      */
-    protected Map<String, ?> options = null;
+    protected Map<String,?> options = null;
 
 
     /**
@@ -109,7 +109,7 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule {
     /**
      * The state information that is shared with other configured <code>LoginModule</code> instances.
      */
-    protected Map<String, ?> sharedState = null;
+    protected Map<String,?> sharedState = null;
 
 
     /**
@@ -180,8 +180,8 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule {
 
 
     @Override
-    public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState,
-            Map<String, ?> options) {
+    public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String,?> sharedState,
+            Map<String,?> options) {
         if (log.isDebugEnabled()) {
             log.debug("Init");
         }
@@ -212,7 +212,7 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule {
             credentialHandler = new MessageDigestCredentialHandler();
         }
 
-        for (Entry<String, ?> entry : options.entrySet()) {
+        for (Entry<String,?> entry : options.entrySet()) {
             if ("pathname".equals(entry.getKey())) {
                 continue;
             }
diff --git a/java/org/apache/catalina/realm/JAASRealm.java b/java/org/apache/catalina/realm/JAASRealm.java
index 63aea5a289..5b491f5419 100644
--- a/java/org/apache/catalina/realm/JAASRealm.java
+++ b/java/org/apache/catalina/realm/JAASRealm.java
@@ -615,8 +615,8 @@ public class JAASRealm extends RealmBase {
                 URL resource = Thread.currentThread().getContextClassLoader().getResource(configFile);
                 URI uri = resource.toURI();
                 @SuppressWarnings("unchecked")
-                Class<Configuration> sunConfigFile = (Class<Configuration>) Class
-                        .forName("com.sun.security.auth.login.ConfigFile");
+                Class<Configuration> sunConfigFile =
+                        (Class<Configuration>) Class.forName("com.sun.security.auth.login.ConfigFile");
                 Constructor<Configuration> constructor = sunConfigFile.getConstructor(URI.class);
                 Configuration config = constructor.newInstance(uri);
                 this.jaasConfiguration = config;
diff --git a/java/org/apache/catalina/realm/JNDIRealm.java b/java/org/apache/catalina/realm/JNDIRealm.java
index 725229f882..192c415b9e 100644
--- a/java/org/apache/catalina/realm/JNDIRealm.java
+++ b/java/org/apache/catalina/realm/JNDIRealm.java
@@ -1129,9 +1129,9 @@ public class JNDIRealm extends RealmBase {
     /**
      * {@inheritDoc}
      * <p>
-     * If there are any errors with the JNDI connection, executing the query or anything we return
-     * null (don't authenticate). This event is also logged, and the connection will be closed so that a subsequent
-     * request will automatically re-open it.
+     * If there are any errors with the JNDI connection, executing the query or anything we return null (don't
+     * authenticate). This event is also logged, and the connection will be closed so that a subsequent request will
+     * automatically re-open it.
      */
     @Override
     public Principal authenticate(String username, String credentials) {
@@ -1241,7 +1241,7 @@ public class JNDIRealm extends RealmBase {
         }
 
         ClassLoader ocl = null;
-        Thread currentThread= null;
+        Thread currentThread = null;
         try {
             // https://bz.apache.org/bugzilla/show_bug.cgi?id=65553
             // This can move back to open() once it is known that Tomcat must be
@@ -1986,14 +1986,14 @@ public class JNDIRealm extends RealmBase {
         }
 
         // Perform the configured search and process the results
-        NamingEnumeration<SearchResult> results = searchAsUser(connection.context, user, base, filter, controls,
-                isRoleSearchAsUser());
+        NamingEnumeration<SearchResult> results =
+                searchAsUser(connection.context, user, base, filter, controls, isRoleSearchAsUser());
 
         if (results == null) {
             return list; // Should never happen, but just in case ...
         }
 
-        Map<String, String> groupMap = new HashMap<>();
+        Map<String,String> groupMap = new HashMap<>();
         try {
             while (results.hasMore()) {
                 SearchResult result = results.next();
@@ -2016,9 +2016,9 @@ public class JNDIRealm extends RealmBase {
         }
 
         if (containerLog.isTraceEnabled()) {
-            Set<Entry<String, String>> entries = groupMap.entrySet();
+            Set<Entry<String,String>> entries = groupMap.entrySet();
             containerLog.trace("  Found " + entries.size() + " direct roles");
-            for (Entry<String, String> entry : entries) {
+            for (Entry<String,String> entry : entries) {
                 containerLog.trace("  Found direct role " + entry.getKey() + " -> " + entry.getValue());
             }
         }
@@ -2030,11 +2030,11 @@ public class JNDIRealm extends RealmBase {
             // Directory Groups". It avoids group slurping and handles cyclic group memberships as well.
             // See http://middleware.internet2.edu/dir/ for details
 
-            Map<String, String> newGroups = new HashMap<>(groupMap);
+            Map<String,String> newGroups = new HashMap<>(groupMap);
             while (!newGroups.isEmpty()) {
-                Map<String, String> newThisRound = new HashMap<>(); // Stores the groups we find in this iteration
+                Map<String,String> newThisRound = new HashMap<>(); // Stores the groups we find in this iteration
 
-                for (Entry<String, String> group : newGroups.entrySet()) {
+                for (Entry<String,String> group : newGroups.entrySet()) {
                     // Group key is already value escaped if required
                     // Group value is not value escaped
                     // Everything needs to be filter escaped
@@ -2371,11 +2371,10 @@ public class JNDIRealm extends RealmBase {
                 principal = getPrincipal(connection, username, gssCredential);
 
             } catch (NamingException e) {
-                /* While we would like to catch specialized exceptions like
-                 * CommunicationException and ServiceUnavailableException,
-                 * some network communication problems are reported as
-                 * this general exception. This is fixed in Java 18 by
-                 * https://bugs.openjdk.org/browse/JDK-8273402
+                /*
+                 * While we would like to catch specialized exceptions like CommunicationException and
+                 * ServiceUnavailableException, some network communication problems are reported as this general
+                 * exception. This is fixed in Java 18 by https://bugs.openjdk.org/browse/JDK-8273402
                  */
                 // log the exception so we know it's there.
                 containerLog.info(sm.getString("jndiRealm.exception.retry"), e);
@@ -2427,7 +2426,7 @@ public class JNDIRealm extends RealmBase {
 
         User user = null;
         List<String> roles = null;
-        Hashtable<?, ?> preservedEnvironment = null;
+        Hashtable<?,?> preservedEnvironment = null;
         DirContext context = connection.context;
 
         try {
@@ -2462,7 +2461,7 @@ public class JNDIRealm extends RealmBase {
 
 
     private void restoreEnvironmentParameter(DirContext context, String parameterName,
-            Hashtable<?, ?> preservedEnvironment) {
+            Hashtable<?,?> preservedEnvironment) {
         try {
             context.removeFromEnvironment(parameterName);
             if (preservedEnvironment != null && preservedEnvironment.containsKey(parameterName)) {
@@ -2582,7 +2581,7 @@ public class JNDIRealm extends RealmBase {
     }
 
 
-    private DirContext createDirContext(Hashtable<String, String> env) throws NamingException {
+    private DirContext createDirContext(Hashtable<String,String> env) throws NamingException {
         if (useStartTls) {
             return createTlsDirContext(env);
         } else {
@@ -2647,8 +2646,8 @@ public class JNDIRealm extends RealmBase {
      *
      * @throws NamingException when something goes wrong while negotiating the connection
      */
-    private DirContext createTlsDirContext(Hashtable<String, String> env) throws NamingException {
-        Map<String, Object> savedEnv = new HashMap<>();
+    private DirContext createTlsDirContext(Hashtable<String,String> env) throws NamingException {
+        Map<String,Object> savedEnv = new HashMap<>();
         for (String key : Arrays.asList(Context.SECURITY_AUTHENTICATION, Context.SECURITY_CREDENTIALS,
                 Context.SECURITY_PRINCIPAL, Context.SECURITY_PROTOCOL)) {
             Object entry = env.remove(key);
@@ -2674,7 +2673,7 @@ public class JNDIRealm extends RealmBase {
             }
         } finally {
             if (result != null) {
-                for (Map.Entry<String, Object> savedEntry : savedEnv.entrySet()) {
+                for (Map.Entry<String,Object> savedEntry : savedEnv.entrySet()) {
                     result.addToEnvironment(savedEntry.getKey(), savedEntry.getValue());
                 }
             }
@@ -2688,9 +2687,9 @@ public class JNDIRealm extends RealmBase {
      *
      * @return java.util.Hashtable the configuration for the directory context.
      */
-    protected Hashtable<String, String> getDirectoryContextEnvironment() {
+    protected Hashtable<String,String> getDirectoryContextEnvironment() {
 
-        Hashtable<String, String> env = new Hashtable<>();
+        Hashtable<String,String> env = new Hashtable<>();
 
         // Configure our directory context environment.
         if (containerLog.isDebugEnabled() && connectionAttempt == 0) {
diff --git a/java/org/apache/catalina/realm/LockOutRealm.java b/java/org/apache/catalina/realm/LockOutRealm.java
index ea26e00be5..82238e1421 100644
--- a/java/org/apache/catalina/realm/LockOutRealm.java
+++ b/java/org/apache/catalina/realm/LockOutRealm.java
@@ -74,7 +74,7 @@ public class LockOutRealm extends CombinedRealm {
      * Users whose last authentication attempt failed. Entries will be ordered in access order from least recent to most
      * recent.
      */
-    protected Map<String, LockRecord> failedUsers = null;
+    protected Map<String,LockRecord> failedUsers = null;
 
 
     @Override
@@ -84,11 +84,11 @@ public class LockOutRealm extends CombinedRealm {
          * LRU cache so if the cache size is exceeded the users who most recently failed authentication will be
          * retained.
          */
-        failedUsers = new LinkedHashMap<String, LockRecord>(cacheSize, 0.75f, true) {
+        failedUsers = new LinkedHashMap<String,LockRecord>(cacheSize, 0.75f, true) {
             private static final long serialVersionUID = 1L;
 
             @Override
-            protected boolean removeEldestEntry(Map.Entry<String, LockRecord> eldest) {
+            protected boolean removeEldestEntry(Map.Entry<String,LockRecord> eldest) {
                 if (size() > cacheSize) {
                     // Check to see if this element has been removed too quickly
                     long timeInCache = (System.currentTimeMillis() - eldest.getValue().getLastFailureTime()) / 1000;
@@ -111,8 +111,8 @@ public class LockOutRealm extends CombinedRealm {
     public Principal authenticate(String username, String clientDigest, String nonce, String nc, String cnonce,
             String qop, String realmName, String digestA2, String algorithm) {
 
-        Principal authenticatedUser = super.authenticate(username, clientDigest, nonce, nc, cnonce, qop, realmName,
-                digestA2, algorithm);
+        Principal authenticatedUser =
+                super.authenticate(username, clientDigest, nonce, nc, cnonce, qop, realmName, digestA2, algorithm);
         return filterLockedAccounts(username, authenticatedUser);
     }
 
diff --git a/java/org/apache/catalina/realm/MemoryRealm.java b/java/org/apache/catalina/realm/MemoryRealm.java
index 59d1a60893..41ae5a0a97 100644
--- a/java/org/apache/catalina/realm/MemoryRealm.java
+++ b/java/org/apache/catalina/realm/MemoryRealm.java
@@ -73,7 +73,7 @@ public class MemoryRealm extends RealmBase {
     /**
      * The set of valid Principals for this Realm, keyed by user name.
      */
-    private final Map<String, GenericPrincipal> principals = new HashMap<>();
+    private final Map<String,GenericPrincipal> principals = new HashMap<>();
 
 
     // ------------------------------------------------------------- Properties
diff --git a/java/org/apache/catalina/realm/RealmBase.java b/java/org/apache/catalina/realm/RealmBase.java
index 9fccf63ed4..ce16edcf28 100644
--- a/java/org/apache/catalina/realm/RealmBase.java
+++ b/java/org/apache/catalina/realm/RealmBase.java
@@ -81,14 +81,15 @@ public abstract class RealmBase extends LifecycleMBeanBase implements org.apache
     protected static final String USER_ATTRIBUTES_DELIMITER = ",";
 
     /**
-     * The character used as wildcard in user attribute lists. Using it means
-     * <i>query all available user attributes</i>.
+     * The character used as wildcard in user attribute lists. Using it means <i>query all available user
+     * attributes</i>.
      * <p>
      * Applies to some of the Realm implementations only.
      */
     protected static final String USER_ATTRIBUTES_WILDCARD = "*";
 
-    private static final List<Class<? extends DigestCredentialHandlerBase>> credentialHandlerClasses = new ArrayList<>();
+    private static final List<Class<? extends DigestCredentialHandlerBase>> credentialHandlerClasses =
+            new ArrayList<>();
 
     static {
         // Order is important since it determines the search order for a
@@ -160,17 +161,15 @@ public abstract class RealmBase extends LifecycleMBeanBase implements org.apache
 
 
     /**
-     * The comma separated names of user attributes to additionally query from the
-     * realm. These will be provided to the user through the created
-     * Principal's <i>attributes</i> map. Support for this feature is optional.
+     * The comma separated names of user attributes to additionally query from the realm. These will be provided to the
+     * user through the created Principal's <i>attributes</i> map. Support for this feature is optional.
      */
     protected String userAttributes = null;
 
 
     /**
-     * The list of user attributes to additionally query from the
-     * realm. These will be provided to the user through the created
-     * Principal's <i>attributes</i> map. Support for this feature is optional.
+     * The list of user attributes to additionally query from the realm. These will be provided to the user through the
+     * created Principal's <i>attributes</i> map. Support for this feature is optional.
      */
     protected List<String> userAttributesList = null;
 
@@ -304,18 +303,14 @@ public abstract class RealmBase extends LifecycleMBeanBase implements org.apache
     }
 
     /**
-     * Set the comma separated names of user attributes to additionally query from
-     * the realm. These will be provided to the user through the created
-     * Principal's <i>attributes</i> map. In this map, each field value is bound to
-     * the field's name, that is, the name of the field serves as the key of the
-     * mapping.
+     * Set the comma separated names of user attributes to additionally query from the realm. These will be provided to
+     * the user through the created Principal's <i>attributes</i> map. In this map, each field value is bound to the
+     * field's name, that is, the name of the field serves as the key of the mapping.
      * <p>
-     * If set to the wildcard character, or, if the wildcard character is part of
-     * the comma separated list, all available attributes - except the
-     * <i>password</i> attribute (as specified by <code>userCredCol</code>) - are
-     * queried. The wildcard character is defined by constant
-     * {@link RealmBase#USER_ATTRIBUTES_WILDCARD}. It defaults to the asterisk (*)
-     * character.
+     * If set to the wildcard character, or, if the wildcard character is part of the comma separated list, all
+     * available attributes - except the <i>password</i> attribute (as specified by <code>userCredCol</code>) - are
+     * queried. The wildcard character is defined by constant {@link RealmBase#USER_ATTRIBUTES_WILDCARD}. It defaults to
+     * the asterisk (*) character.
      *
      * @param userAttributes the comma separated names of user attributes
      */
@@ -916,15 +911,14 @@ public abstract class RealmBase extends LifecycleMBeanBase implements org.apache
 
 
     /**
-     * Parse the specified delimiter separated attribute names and return a list of
-     * that names or <code>null</code>, if no attributes have been specified.
+     * Parse the specified delimiter separated attribute names and return a list of that names or <code>null</code>, if
+     * no attributes have been specified.
      * <p>
-     * If a wildcard character is found, return a list consisting of a single
-     * wildcard character only.
+     * If a wildcard character is found, return a list consisting of a single wildcard character only.
      *
      * @param userAttributes comma separated names of attributes to parse
-     * @return a list containing the parsed attribute names or <code>null</code>, if
-     *         no attributes have been specified
+     *
+     * @return a list containing the parsed attribute names or <code>null</code>, if no attributes have been specified
      */
     protected List<String> parseUserAttributes(String userAttributes) {
         if (userAttributes == null) {
@@ -1601,8 +1595,8 @@ public abstract class RealmBase extends LifecycleMBeanBase implements org.apache
 
         try {
             @SuppressWarnings("unchecked")
-            Class<? extends X509UsernameRetriever> clazz = (Class<? extends X509UsernameRetriever>) Class
-                    .forName(className);
+            Class<? extends X509UsernameRetriever> clazz =
+                    (Class<? extends X509UsernameRetriever>) Class.forName(className);
             return clazz.getConstructor().newInstance();
         } catch (ReflectiveOperationException e) {
             throw new LifecycleException(sm.getString("realmBase.createUsernameRetriever.newInstance", className), e);
diff --git a/java/org/apache/catalina/realm/UserDatabaseRealm.java b/java/org/apache/catalina/realm/UserDatabaseRealm.java
index 5ff8847bef..a5979159c0 100644
--- a/java/org/apache/catalina/realm/UserDatabaseRealm.java
+++ b/java/org/apache/catalina/realm/UserDatabaseRealm.java
@@ -127,8 +127,7 @@ public class UserDatabaseRealm extends RealmBase {
 
 
     /**
-     * Calls {@link MemoryUserDatabase#backgroundProcess()} if the Realm is
-     * configured with a MemoryUserDatabase.
+     * Calls {@link MemoryUserDatabase#backgroundProcess()} if the Realm is configured with a MemoryUserDatabase.
      */
     @Override
     public void backgroundProcess() {


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org