svn commit: r1848251 - in /tomcat/trunk/java/org/apache/catalina/realm: JAASMemoryLoginModule.java JAASRealm.java LocalStrings.properties RealmBase.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1848251 - in /tomcat/trunk/java/org/apache/catalina/realm: JAASMemoryLoginModule.java JAASRealm.java LocalStrings.properties RealmBase.java

Rémy Maucherat
Author: remm
Date: Wed Dec  5 21:25:54 2018
New Revision: 1848251

URL: http://svn.apache.org/viewvc?rev=1848251&view=rev
Log:
Add i18n for the realm package.

Modified:
    tomcat/trunk/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
    tomcat/trunk/java/org/apache/catalina/realm/JAASRealm.java
    tomcat/trunk/java/org/apache/catalina/realm/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java

Modified: tomcat/trunk/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/JAASMemoryLoginModule.java?rev=1848251&r1=1848250&r2=1848251&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/JAASMemoryLoginModule.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/JAASMemoryLoginModule.java Wed Dec  5 21:25:54 2018
@@ -285,8 +285,9 @@ public class JAASMemoryLoginModule exten
     @Override
     public boolean login() throws LoginException {
         // Set up our CallbackHandler requests
-        if (callbackHandler == null)
-            throw new LoginException("No CallbackHandler specified");
+        if (callbackHandler == null) {
+            throw new LoginException(sm.getString("jaasMemoryLoginModule.noCallbackHandler"));
+        }
         Callback callbacks[] = new Callback[9];
         callbacks[0] = new NameCallback("Username: ");
         callbacks[1] = new PasswordCallback("Password: ", false);
@@ -322,7 +323,7 @@ public class JAASMemoryLoginModule exten
             md5a2 = ((TextInputCallback) callbacks[7]).getText();
             authMethod = ((TextInputCallback) callbacks[8]).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
@@ -335,7 +336,7 @@ public class JAASMemoryLoginModule exten
         } 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()) {
@@ -346,7 +347,7 @@ public class JAASMemoryLoginModule exten
         if (principal != null) {
             return true;
         } else {
-            throw new FailedLoginException("Username or password is incorrect");
+            throw new FailedLoginException(sm.getString("jaasMemoryLoginModule.invalidCredentials"));
         }
     }
 
@@ -380,14 +381,14 @@ public class JAASMemoryLoginModule exten
         if (!file.isAbsolute()) {
             String catalinaBase = getCatalinaBase();
             if (catalinaBase == null) {
-                log.warn("Unable to determine Catalina base to load file " + pathname);
+                log.warn(sm.getString("jaasMemoryLoginModule.noCatalinaBase", pathname));
                 return;
             } else {
                 file = new File(catalinaBase, pathname);
             }
         }
         if (!file.canRead()) {
-            log.warn("Cannot load configuration file " + file.getAbsolutePath());
+            log.warn(sm.getString("jaasMemoryLoginModule.noConfig", file.getAbsolutePath()));
             return;
         }
 
@@ -399,7 +400,7 @@ public class JAASMemoryLoginModule exten
             digester.push(this);
             digester.parse(file);
         } catch (Exception e) {
-            log.warn("Error processing configuration file " + file.getAbsolutePath(), e);
+            log.warn(sm.getString("jaasMemoryLoginModule.parseError", file.getAbsolutePath()), e);
         } finally {
             digester.reset();
         }

Modified: tomcat/trunk/java/org/apache/catalina/realm/JAASRealm.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/JAASRealm.java?rev=1848251&r1=1848250&r2=1848251&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/JAASRealm.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/JAASRealm.java Wed Dec  5 21:25:54 2018
@@ -208,8 +208,7 @@ public class JAASRealm extends RealmBase
      * @param useContext True means use context ClassLoader
      */
     public void setUseContextClassLoader(boolean useContext) {
-      useContextClassLoader = useContext;
-      log.info("Setting useContextClassLoader = " + useContext);
+        useContextClassLoader = useContext;
     }
 
     /**
@@ -228,8 +227,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));
         }
     }
 
@@ -280,11 +278,10 @@ public class JAASRealm extends RealmBase
                  if (Principal.class.isAssignableFrom(principalClass)) {
                      classNamesList.add(classNames[i]);
                  } else {
-                     log.error("Class "+classNames[i]+" is not implementing "+
-                               "java.security.Principal! Class not added.");
+                     log.error(sm.getString("jaasRealm.notPrincipal", classNames[i]));
                  }
              } catch (ClassNotFoundException e) {
-                 log.error("Class "+classNames[i]+" not found! Class not added.");
+                 log.error(sm.getString("jassRealm.classNotFound", classNames[i]));
              }
          }
      }

Modified: tomcat/trunk/java/org/apache/catalina/realm/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/LocalStrings.properties?rev=1848251&r1=1848250&r2=1848251&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/LocalStrings.properties [UTF-8] (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/LocalStrings.properties [UTF-8] Wed Dec  5 21:25:54 2018
@@ -34,15 +34,26 @@ dataSourceRealm.getRoles.exception=Excep
 
 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}]
+jassRealm.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
@@ -99,6 +110,8 @@ realmBase.gssContextNotEstablished=Authe
 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}]

Modified: tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java?rev=1848251&r1=1848250&r2=1848251&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java Wed Dec  5 21:25:54 2018
@@ -46,6 +46,7 @@ import org.apache.catalina.Service;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
+import org.apache.catalina.realm.RealmBase.AllRolesMode;
 import org.apache.catalina.util.LifecycleMBeanBase;
 import org.apache.catalina.util.SessionConfig;
 import org.apache.catalina.util.ToStringUtil;
@@ -409,8 +410,7 @@ public abstract class RealmBase extends
         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 = MD5Encoder.encode(ConcurrentMessageDigest.digestMD5(valueBytes));
@@ -1159,8 +1159,7 @@ public abstract class RealmBase extends
         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 MD5Encoder.encode(ConcurrentMessageDigest.digestMD5(valueBytes));
@@ -1458,44 +1457,42 @@ public abstract class RealmBase extends
          */
         public static final AllRolesMode STRICT_AUTH_ONLY_MODE = new AllRolesMode("strictAuthOnly");
 
-        static AllRolesMode toMode(String name)
-        {
+        static AllRolesMode toMode(String name) {
             AllRolesMode mode;
-            if( name.equalsIgnoreCase(STRICT_MODE.name) )
+            if (name.equalsIgnoreCase(STRICT_MODE.name)) {
                 mode = STRICT_MODE;
-            else if( name.equalsIgnoreCase(AUTH_ONLY_MODE.name) )
+            } else if (name.equalsIgnoreCase(AUTH_ONLY_MODE.name)) {
                 mode = AUTH_ONLY_MODE;
-            else if( name.equalsIgnoreCase(STRICT_AUTH_ONLY_MODE.name) )
+            } 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");
+            } else {
+                throw new IllegalStateException(
+                        sm.getString("realmBase.unknownAllRolesMode", name));
+            }
             return mode;
         }
 
-        private AllRolesMode(String name)
-        {
+        private AllRolesMode(String name) {
             this.name = name;
         }
 
         @Override
-        public boolean equals(Object o)
-        {
+        public boolean equals(Object o) {
             boolean equals = false;
-            if( o instanceof AllRolesMode )
-            {
+            if (o instanceof AllRolesMode) {
                 AllRolesMode mode = (AllRolesMode) o;
                 equals = name.equals(mode.name);
             }
             return equals;
         }
+
         @Override
-        public int hashCode()
-        {
+        public int hashCode() {
             return name.hashCode();
         }
+
         @Override
-        public String toString()
-        {
+        public String toString() {
             return name;
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]