This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 4c52586cf4 Code clean-up - formatting. No functional change 4c52586cf4 is described below commit 4c52586cf4ad4347fa35a668bad8c04a921e0408 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue May 14 11:02:12 2024 +0100 Code clean-up - formatting. No functional change --- java/org/apache/catalina/users/AbstractGroup.java | 5 +- java/org/apache/catalina/users/AbstractRole.java | 5 +- java/org/apache/catalina/users/AbstractUser.java | 5 +- java/org/apache/catalina/users/Constants.java | 2 +- .../catalina/users/DataSourceUserDatabase.java | 49 +++++----- .../users/DataSourceUserDatabaseFactory.java | 48 +++++----- java/org/apache/catalina/users/GenericGroup.java | 17 ++-- java/org/apache/catalina/users/GenericRole.java | 15 ++- java/org/apache/catalina/users/GenericUser.java | 16 ++-- java/org/apache/catalina/users/MemoryGroup.java | 22 +++-- java/org/apache/catalina/users/MemoryRole.java | 22 +++-- java/org/apache/catalina/users/MemoryUser.java | 30 +++--- .../apache/catalina/users/MemoryUserDatabase.java | 102 +++++++++------------ .../catalina/users/MemoryUserDatabaseFactory.java | 52 +++++------ 14 files changed, 195 insertions(+), 195 deletions(-) diff --git a/java/org/apache/catalina/users/AbstractGroup.java b/java/org/apache/catalina/users/AbstractGroup.java index 0430b65f33..8d4e4f74cd 100644 --- a/java/org/apache/catalina/users/AbstractGroup.java +++ b/java/org/apache/catalina/users/AbstractGroup.java @@ -21,9 +21,12 @@ import org.apache.catalina.Group; /** - * <p>Convenience base class for {@link Group} implementations.</p> + * <p> + * Convenience base class for {@link Group} implementations. + * </p> * * @author Craig R. McClanahan + * * @since 4.1 */ public abstract class AbstractGroup implements Group { diff --git a/java/org/apache/catalina/users/AbstractRole.java b/java/org/apache/catalina/users/AbstractRole.java index 7de9d545aa..610aedde73 100644 --- a/java/org/apache/catalina/users/AbstractRole.java +++ b/java/org/apache/catalina/users/AbstractRole.java @@ -21,9 +21,12 @@ import org.apache.catalina.Role; /** - * <p>Convenience base class for {@link Role} implementations.</p> + * <p> + * Convenience base class for {@link Role} implementations. + * </p> * * @author Craig R. McClanahan + * * @since 4.1 */ public abstract class AbstractRole implements Role { diff --git a/java/org/apache/catalina/users/AbstractUser.java b/java/org/apache/catalina/users/AbstractUser.java index 7ff6752f62..a00ead6c80 100644 --- a/java/org/apache/catalina/users/AbstractUser.java +++ b/java/org/apache/catalina/users/AbstractUser.java @@ -21,9 +21,12 @@ import org.apache.catalina.User; /** - * <p>Convenience base class for {@link User} implementations.</p> + * <p> + * Convenience base class for {@link User} implementations. + * </p> * * @author Craig R. McClanahan + * * @since 4.1 */ public abstract class AbstractUser implements User { diff --git a/java/org/apache/catalina/users/Constants.java b/java/org/apache/catalina/users/Constants.java index c79f517a7b..df7e150ca8 100644 --- a/java/org/apache/catalina/users/Constants.java +++ b/java/org/apache/catalina/users/Constants.java @@ -20,8 +20,8 @@ package org.apache.catalina.users; /** * Manifest constants for this Java package. * - * * @author Craig R. McClanahan + * * @since 4.1 */ public final class Constants { diff --git a/java/org/apache/catalina/users/DataSourceUserDatabase.java b/java/org/apache/catalina/users/DataSourceUserDatabase.java index 8ad9aa7a7f..99b4c2fe59 100644 --- a/java/org/apache/catalina/users/DataSourceUserDatabase.java +++ b/java/org/apache/catalina/users/DataSourceUserDatabase.java @@ -61,17 +61,17 @@ public class DataSourceUserDatabase extends SparseUserDatabase { */ protected final String id; - protected final ConcurrentHashMap<String, User> createdUsers = new ConcurrentHashMap<>(); - protected final ConcurrentHashMap<String, User> modifiedUsers = new ConcurrentHashMap<>(); - protected final ConcurrentHashMap<String, User> removedUsers = new ConcurrentHashMap<>(); + protected final ConcurrentHashMap<String,User> createdUsers = new ConcurrentHashMap<>(); + protected final ConcurrentHashMap<String,User> modifiedUsers = new ConcurrentHashMap<>(); + protected final ConcurrentHashMap<String,User> removedUsers = new ConcurrentHashMap<>(); - protected final ConcurrentHashMap<String, Group> createdGroups = new ConcurrentHashMap<>(); - protected final ConcurrentHashMap<String, Group> modifiedGroups = new ConcurrentHashMap<>(); - protected final ConcurrentHashMap<String, Group> removedGroups = new ConcurrentHashMap<>(); + protected final ConcurrentHashMap<String,Group> createdGroups = new ConcurrentHashMap<>(); + protected final ConcurrentHashMap<String,Group> modifiedGroups = new ConcurrentHashMap<>(); + protected final ConcurrentHashMap<String,Group> removedGroups = new ConcurrentHashMap<>(); - protected final ConcurrentHashMap<String, Role> createdRoles = new ConcurrentHashMap<>(); - protected final ConcurrentHashMap<String, Role> modifiedRoles = new ConcurrentHashMap<>(); - protected final ConcurrentHashMap<String, Role> removedRoles = new ConcurrentHashMap<>(); + protected final ConcurrentHashMap<String,Role> createdRoles = new ConcurrentHashMap<>(); + protected final ConcurrentHashMap<String,Role> modifiedRoles = new ConcurrentHashMap<>(); + protected final ConcurrentHashMap<String,Role> removedRoles = new ConcurrentHashMap<>(); // ----------------------------------------------------- Instance Variables @@ -269,7 +269,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase { * * @param roleNameCol The column name */ - public void setRoleNameCol( String roleNameCol ) { + public void setRoleNameCol(String roleNameCol) { this.roleNameCol = roleNameCol; } @@ -285,8 +285,8 @@ public class DataSourceUserDatabase extends SparseUserDatabase { * * @param userCredCol The column name */ - public void setUserCredCol( String userCredCol ) { - this.userCredCol = userCredCol; + public void setUserCredCol(String userCredCol) { + this.userCredCol = userCredCol; } /** @@ -301,8 +301,8 @@ public class DataSourceUserDatabase extends SparseUserDatabase { * * @param userNameCol The column name */ - public void setUserNameCol( String userNameCol ) { - this.userNameCol = userNameCol; + public void setUserNameCol(String userNameCol) { + this.userNameCol = userNameCol; } /** @@ -317,7 +317,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase { * * @param userRoleTable The table name */ - public void setUserRoleTable( String userRoleTable ) { + public void setUserRoleTable(String userRoleTable) { this.userRoleTable = userRoleTable; } @@ -333,8 +333,8 @@ public class DataSourceUserDatabase extends SparseUserDatabase { * * @param userTable The table name */ - public void setUserTable( String userTable ) { - this.userTable = userTable; + public void setUserTable(String userTable) { + this.userTable = userTable; } @@ -461,7 +461,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase { try { groupsReadLock.lock(); try { - HashMap<String, Group> groups = new HashMap<>(); + HashMap<String,Group> groups = new HashMap<>(); groups.putAll(createdGroups); groups.putAll(modifiedGroups); @@ -501,7 +501,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase { try { rolesReadLock.lock(); try { - HashMap<String, Role> roles = new HashMap<>(); + HashMap<String,Role> roles = new HashMap<>(); roles.putAll(createdRoles); roles.putAll(modifiedRoles); @@ -541,7 +541,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase { try { usersReadLock.lock(); try { - HashMap<String, User> users = new HashMap<>(); + HashMap<String,User> users = new HashMap<>(); users.putAll(createdUsers); users.putAll(modifiedUsers); @@ -934,7 +934,8 @@ public class DataSourceUserDatabase extends SparseUserDatabase { if (log.isDebugEnabled()) { // As there are lots of parameters to configure, log some debug to help out - log.debug(sm.getString("dataSourceUserDatabase.features", Boolean.toString(userRoleTable != null && roleNameCol != null), + log.debug(sm.getString("dataSourceUserDatabase.features", + Boolean.toString(userRoleTable != null && roleNameCol != null), Boolean.toString(isRoleStoreDefined()), Boolean.toString(isGroupStoreDefined()))); } @@ -1567,16 +1568,18 @@ public class DataSourceUserDatabase extends SparseUserDatabase { /** * Only use groups if the tables are fully defined. + * * @return true when groups are used */ protected boolean isGroupStoreDefined() { - return groupTable != null && userGroupTable != null && groupNameCol != null - && groupRoleTable != null && isRoleStoreDefined(); + return groupTable != null && userGroupTable != null && groupNameCol != null && groupRoleTable != null && + isRoleStoreDefined(); } /** * Only use roles if the tables are fully defined. + * * @return true when roles are used */ protected boolean isRoleStoreDefined() { diff --git a/java/org/apache/catalina/users/DataSourceUserDatabaseFactory.java b/java/org/apache/catalina/users/DataSourceUserDatabaseFactory.java index 1a69b7f546..bb0d4ceb6a 100644 --- a/java/org/apache/catalina/users/DataSourceUserDatabaseFactory.java +++ b/java/org/apache/catalina/users/DataSourceUserDatabaseFactory.java @@ -28,17 +28,17 @@ import javax.sql.DataSource; /** - * <p>JNDI object creation factory for <code>DataSourceUserDatabase</code> - * instances. This makes it convenient to configure a user database - * in the global JNDI resources associated with this Catalina instance, - * and then link to that resource for web applications that administer - * the contents of the user database.</p> - * - * <p>The <code>DataSourceUserDatabase</code> instance is configured based - * on the following parameter values:</p> + * <p> + * JNDI object creation factory for <code>DataSourceUserDatabase</code> instances. This makes it convenient to configure + * a user database in the global JNDI resources associated with this Catalina instance, and then link to that resource + * for web applications that administer the contents of the user database. + * </p> + * <p> + * The <code>DataSourceUserDatabase</code> instance is configured based on the following parameter values: + * </p> * <ul> - * <li><strong>dataSourceName</strong> - JNDI name of the DataSource, which - * must be located in the same Context environment as the UserDatabase</li> + * <li><strong>dataSourceName</strong> - JNDI name of the DataSource, which must be located in the same Context + * environment as the UserDatabase</li> * </ul> * * @author Craig R. McClanahan @@ -50,24 +50,22 @@ public class DataSourceUserDatabaseFactory implements ObjectFactory { /** - * <p>Create and return a new <code>DataSourceUserDatabase</code> instance - * that has been configured according to the properties of the - * specified <code>Reference</code>. If you instance can be created, - * return <code>null</code> instead.</p> + * <p> + * Create and return a new <code>DataSourceUserDatabase</code> instance that has been configured according to the + * properties of the specified <code>Reference</code>. If you instance can be created, return <code>null</code> + * instead. + * </p> * - * @param obj The possibly null object containing location or - * reference information that can be used in creating an object - * @param name The name of this object relative to <code>nameCtx</code> - * @param nameCtx The context relative to which the <code>name</code> - * parameter is specified, or <code>null</code> if <code>name</code> - * is relative to the default initial context - * @param environment The possibly null environment that is used in - * creating this object + * @param obj The possibly null object containing location or reference information that can be used in + * creating an object + * @param name The name of this object relative to <code>nameCtx</code> + * @param nameCtx The context relative to which the <code>name</code> parameter is specified, or + * <code>null</code> if <code>name</code> is relative to the default initial context + * @param environment The possibly null environment that is used in creating this object */ @Override - public Object getObjectInstance(Object obj, Name name, Context nameCtx, - Hashtable<?,?> environment) - throws Exception { + public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) + throws Exception { // We only know how to deal with <code>javax.naming.Reference</code>s // that specify a class name of "org.apache.catalina.UserDatabase" diff --git a/java/org/apache/catalina/users/GenericGroup.java b/java/org/apache/catalina/users/GenericGroup.java index 909cf9ef37..58e56e052f 100644 --- a/java/org/apache/catalina/users/GenericGroup.java +++ b/java/org/apache/catalina/users/GenericGroup.java @@ -28,8 +28,9 @@ import org.apache.catalina.UserDatabase; /** - * <p>Concrete implementation of {@link org.apache.catalina.Group} for a - * {@link UserDatabase}.</p> + * <p> + * Concrete implementation of {@link org.apache.catalina.Group} for a {@link UserDatabase}. + * </p> * * @param <UD> The specific type of UserDase with which this group is associated * @@ -42,16 +43,14 @@ public class GenericGroup<UD extends UserDatabase> extends AbstractGroup { /** - * Package-private constructor used by the factory method in - * {@link UserDatabase}. + * Package-private constructor used by the factory method in {@link UserDatabase}. * - * @param database The {@link UserDatabase} that owns this group - * @param groupname Group name of this group + * @param database The {@link UserDatabase} that owns this group + * @param groupname Group name of this group * @param description Description of this group - * @param roles The roles of this group + * @param roles The roles of this group */ - GenericGroup(UD database, - String groupname, String description, List<Role> roles) { + GenericGroup(UD database, String groupname, String description, List<Role> roles) { super(); this.database = database; diff --git a/java/org/apache/catalina/users/GenericRole.java b/java/org/apache/catalina/users/GenericRole.java index 31a6a4ce44..71ccb5e888 100644 --- a/java/org/apache/catalina/users/GenericRole.java +++ b/java/org/apache/catalina/users/GenericRole.java @@ -21,8 +21,9 @@ import org.apache.catalina.UserDatabase; /** - * <p>Concrete implementation of {@link org.apache.catalina.Role} for a - * {@link UserDatabase}.</p> + * <p> + * Concrete implementation of {@link org.apache.catalina.Role} for a {@link UserDatabase}. + * </p> * * @param <UD> The specific type of UserDase with which this role is associated * @@ -35,15 +36,13 @@ public class GenericRole<UD extends UserDatabase> extends AbstractRole { /** - * Package-private constructor used by the factory method in - * {@link UserDatabase}. + * Package-private constructor used by the factory method in {@link UserDatabase}. * - * @param database The {@link UserDatabase} that owns this role - * @param rolename Role name of this role + * @param database The {@link UserDatabase} that owns this role + * @param rolename Role name of this role * @param description Description of this role */ - GenericRole(UD database, - String rolename, String description) { + GenericRole(UD database, String rolename, String description) { super(); this.database = database; diff --git a/java/org/apache/catalina/users/GenericUser.java b/java/org/apache/catalina/users/GenericUser.java index 18aa8c13e3..f2c0ad892a 100644 --- a/java/org/apache/catalina/users/GenericUser.java +++ b/java/org/apache/catalina/users/GenericUser.java @@ -26,8 +26,9 @@ import org.apache.catalina.Role; import org.apache.catalina.UserDatabase; /** - * <p>Concrete implementation of {@link org.apache.catalina.User} for a - * {@link UserDatabase}.</p> + * <p> + * Concrete implementation of {@link org.apache.catalina.User} for a {@link UserDatabase}. + * </p> * * @param <UD> The specific type of UserDase with which this role is associated * @@ -40,19 +41,16 @@ public class GenericUser<UD extends UserDatabase> extends AbstractUser { /** - * Package-private constructor used by the factory method in - * {@link UserDatabase}. + * Package-private constructor used by the factory method in {@link UserDatabase}. * * @param database The {@link UserDatabase} that owns this user * @param username Logon username of the new user * @param password Logon password of the new user * @param fullName Full name of the new user - * @param groups The groups of this user - * @param roles The roles of this user + * @param groups The groups of this user + * @param roles The roles of this user */ - GenericUser(UD database, String username, - String password, String fullName, List<Group> groups, - List<Role> roles) { + GenericUser(UD database, String username, String password, String fullName, List<Group> groups, List<Role> roles) { super(); this.database = database; diff --git a/java/org/apache/catalina/users/MemoryGroup.java b/java/org/apache/catalina/users/MemoryGroup.java index 7f5d90eb2b..666cbef5a1 100644 --- a/java/org/apache/catalina/users/MemoryGroup.java +++ b/java/org/apache/catalina/users/MemoryGroup.java @@ -22,11 +22,15 @@ import org.apache.tomcat.util.buf.StringUtils; import org.apache.tomcat.util.security.Escape; /** - * <p>Concrete implementation of {@link org.apache.catalina.Group} for the - * {@link MemoryUserDatabase} implementation of {@link UserDatabase}.</p> + * <p> + * Concrete implementation of {@link org.apache.catalina.Group} for the {@link MemoryUserDatabase} implementation of + * {@link UserDatabase}. + * </p> * * @author Craig R. McClanahan + * * @since 4.1 + * * @deprecated Use {@link GenericGroup} instead. */ @Deprecated @@ -34,21 +38,21 @@ public class MemoryGroup extends GenericGroup<MemoryUserDatabase> { /** - * Package-private constructor used by the factory method in - * {@link MemoryUserDatabase}. + * Package-private constructor used by the factory method in {@link MemoryUserDatabase}. * - * @param database The {@link MemoryUserDatabase} that owns this group - * @param groupname Group name of this group + * @param database The {@link MemoryUserDatabase} that owns this group + * @param groupname Group name of this group * @param description Description of this group */ - MemoryGroup(MemoryUserDatabase database, - String groupname, String description) { + MemoryGroup(MemoryUserDatabase database, String groupname, String description) { super(database, groupname, description, null); } /** - * <p>Return a String representation of this group in XML format.</p> + * <p> + * Return a String representation of this group in XML format. + * </p> */ @Override public String toString() { diff --git a/java/org/apache/catalina/users/MemoryRole.java b/java/org/apache/catalina/users/MemoryRole.java index 08f6cec0bf..ca1c561824 100644 --- a/java/org/apache/catalina/users/MemoryRole.java +++ b/java/org/apache/catalina/users/MemoryRole.java @@ -21,11 +21,15 @@ import org.apache.catalina.UserDatabase; import org.apache.tomcat.util.security.Escape; /** - * <p>Concrete implementation of {@link org.apache.catalina.Role} for the - * {@link MemoryUserDatabase} implementation of {@link UserDatabase}.</p> + * <p> + * Concrete implementation of {@link org.apache.catalina.Role} for the {@link MemoryUserDatabase} implementation of + * {@link UserDatabase}. + * </p> * * @author Craig R. McClanahan + * * @since 4.1 + * * @deprecated Use {@link GenericRole} instead. */ @Deprecated @@ -33,21 +37,21 @@ public class MemoryRole extends GenericRole<MemoryUserDatabase> { /** - * Package-private constructor used by the factory method in - * {@link MemoryUserDatabase}. + * Package-private constructor used by the factory method in {@link MemoryUserDatabase}. * - * @param database The {@link MemoryUserDatabase} that owns this role - * @param rolename Role name of this role + * @param database The {@link MemoryUserDatabase} that owns this role + * @param rolename Role name of this role * @param description Description of this role */ - MemoryRole(MemoryUserDatabase database, - String rolename, String description) { + MemoryRole(MemoryUserDatabase database, String rolename, String description) { super(database, rolename, description); } /** - * <p>Return a String representation of this role in XML format.</p> + * <p> + * Return a String representation of this role in XML format. + * </p> */ @Override public String toString() { diff --git a/java/org/apache/catalina/users/MemoryUser.java b/java/org/apache/catalina/users/MemoryUser.java index 4d241fe6f5..7d68001089 100644 --- a/java/org/apache/catalina/users/MemoryUser.java +++ b/java/org/apache/catalina/users/MemoryUser.java @@ -22,11 +22,15 @@ import org.apache.tomcat.util.buf.StringUtils; import org.apache.tomcat.util.security.Escape; /** - * <p>Concrete implementation of {@link org.apache.catalina.User} for the - * {@link MemoryUserDatabase} implementation of {@link UserDatabase}.</p> + * <p> + * Concrete implementation of {@link org.apache.catalina.User} for the {@link MemoryUserDatabase} implementation of + * {@link UserDatabase}. + * </p> * * @author Craig R. McClanahan + * * @since 4.1 + * * @deprecated Use {@link GenericUser} instead. */ @Deprecated @@ -34,27 +38,27 @@ public class MemoryUser extends GenericUser<MemoryUserDatabase> { /** - * Package-private constructor used by the factory method in - * {@link MemoryUserDatabase}. + * Package-private constructor used by the factory method in {@link MemoryUserDatabase}. * * @param database The {@link MemoryUserDatabase} that owns this user * @param username Logon username of the new user * @param password Logon password of the new user * @param fullName Full name of the new user */ - MemoryUser(MemoryUserDatabase database, String username, - String password, String fullName) { + MemoryUser(MemoryUserDatabase database, String username, String password, String fullName) { super(database, username, password, fullName, null, null); } /** - * <p>Return a String representation of this user in XML format.</p> + * <p> + * Return a String representation of this user in XML format. + * </p> + * <p> + * <strong>IMPLEMENTATION NOTE</strong> - For backwards compatibility, the reader that processes this entry will + * accept either <code>username</code> or <code>name</code> for the username property. + * </p> * - * <p><strong>IMPLEMENTATION NOTE</strong> - For backwards compatibility, - * the reader that processes this entry will accept either - * <code>username</code> or <code>name</code> for the username - * property.</p> * @return the XML representation */ public String toXml() { @@ -81,7 +85,9 @@ public class MemoryUser extends GenericUser<MemoryUserDatabase> { /** - * <p>Return a String representation of this user.</p> + * <p> + * Return a String representation of this user. + * </p> */ @Override public String toString() { diff --git a/java/org/apache/catalina/users/MemoryUserDatabase.java b/java/org/apache/catalina/users/MemoryUserDatabase.java index e989fb961d..85c9114ebe 100644 --- a/java/org/apache/catalina/users/MemoryUserDatabase.java +++ b/java/org/apache/catalina/users/MemoryUserDatabase.java @@ -49,36 +49,30 @@ import org.apache.tomcat.util.security.Escape; import org.xml.sax.Attributes; /** - * Concrete implementation of {@link UserDatabase} that loads all defined users, - * groups, and roles into an in-memory data structure, and uses a specified XML - * file for its persistent storage. + * Concrete implementation of {@link UserDatabase} that loads all defined users, groups, and roles into an in-memory + * data structure, and uses a specified XML file for its persistent storage. * <p> * This class is thread-safe. * <p> - * This class does not enforce what, in an RDBMS, would be called referential - * integrity. Concurrent modifications may result in inconsistent data such as - * a User retaining a reference to a Role that has been removed from the - * database. + * This class does not enforce what, in an RDBMS, would be called referential integrity. Concurrent modifications may + * result in inconsistent data such as a User retaining a reference to a Role that has been removed from the database. * * @author Craig R. McClanahan + * * @since 4.1 */ /* * Implementation notes: * - * Any operation that acts on a single element of the database (e.g. operations - * that create, read, update or delete a user, role or group) must first obtain - * the read lock. Operations that return iterators for users, roles or groups + * Any operation that acts on a single element of the database (e.g. operations that create, read, update or delete a + * user, role or group) must first obtain the read lock. Operations that return iterators for users, roles or groups * also fall into this category. * - * Iterators must always be created from copies of the data to prevent possible - * corruption of the iterator due to the remove of all elements from the - * underlying Map that would occur during a subsequent re-loading of the - * database. + * Iterators must always be created from copies of the data to prevent possible corruption of the iterator due to the + * remove of all elements from the underlying Map that would occur during a subsequent re-loading of the database. * - * Any operation that acts on multiple elements and expects the database to - * remain consistent during the operation (e.g. saving or loading the database) - * must first obtain the write lock. + * Any operation that acts on multiple elements and expects the database to remain consistent during the operation (e.g. + * saving or loading the database) must first obtain the write lock. */ public class MemoryUserDatabase implements UserDatabase { @@ -110,7 +104,7 @@ public class MemoryUserDatabase implements UserDatabase { /** * The set of {@link Group}s defined in this database, keyed by group name. */ - protected final Map<String, Group> groups = new ConcurrentHashMap<>(); + protected final Map<String,Group> groups = new ConcurrentHashMap<>(); /** * The unique global identifier of this user database. @@ -118,20 +112,19 @@ public class MemoryUserDatabase implements UserDatabase { protected final String id; /** - * The relative (to <code>catalina.base</code>) or absolute pathname to the - * XML file in which we will save our persistent information. + * The relative (to <code>catalina.base</code>) or absolute pathname to the XML file in which we will save our + * persistent information. */ protected String pathname = "conf/tomcat-users.xml"; /** - * The relative or absolute pathname to the file in which our old - * information is stored while renaming is in progress. + * The relative or absolute pathname to the file in which our old information is stored while renaming is in + * progress. */ protected String pathnameOld = pathname + ".old"; /** - * The relative or absolute pathname of the file in which we write our new - * information prior to renaming. + * The relative or absolute pathname of the file in which we write our new information prior to renaming. */ protected String pathnameNew = pathname + ".new"; @@ -143,12 +136,12 @@ public class MemoryUserDatabase implements UserDatabase { /** * The set of {@link Role}s defined in this database, keyed by role name. */ - protected final Map<String, Role> roles = new ConcurrentHashMap<>(); + protected final Map<String,Role> roles = new ConcurrentHashMap<>(); /** * The set of {@link User}s defined in this database, keyed by user name. */ - protected final Map<String, User> users = new ConcurrentHashMap<>(); + protected final Map<String,User> users = new ConcurrentHashMap<>(); private final ReentrantReadWriteLock dbLock = new ReentrantReadWriteLock(); private final Lock readLock = dbLock.readLock(); @@ -220,7 +213,6 @@ public class MemoryUserDatabase implements UserDatabase { } - public void setWatchSource(boolean watchSource) { this.watchSource = watchSource; } @@ -372,17 +364,13 @@ public class MemoryUserDatabase implements UserDatabase { // Construct a digester to read the XML input file Digester digester = new Digester(); try { - digester.setFeature( - "http://apache.org/xml/features/allow-java-encodings", true); + digester.setFeature("http://apache.org/xml/features/allow-java-encodings", true); } catch (Exception e) { log.warn(sm.getString("memoryUserDatabase.xmlFeatureEncoding"), e); } - digester.addFactoryCreate("tomcat-users/group", - new MemoryGroupCreationFactory(this), true); - digester.addFactoryCreate("tomcat-users/role", - new MemoryRoleCreationFactory(this), true); - digester.addFactoryCreate("tomcat-users/user", - new MemoryUserCreationFactory(this), true); + digester.addFactoryCreate("tomcat-users/group", new MemoryGroupCreationFactory(this), true); + digester.addFactoryCreate("tomcat-users/role", new MemoryRoleCreationFactory(this), true); + digester.addFactoryCreate("tomcat-users/user", new MemoryUserCreationFactory(this), true); // Parse the XML input to load this database digester.parse(resource.getInputStream()); @@ -450,13 +438,11 @@ public class MemoryUserDatabase implements UserDatabase { /** - * Check for permissions to save this user database to persistent storage - * location. + * Check for permissions to save this user database to persistent storage location. * * @return <code>true</code> if the database is writable * - * @deprecated Use {@link #isWritable()}. This method will be removed in - * Tomcat 10.1.x onwards. + * @deprecated Use {@link #isWritable()}. This method will be removed in Tomcat 10.1.x onwards. */ @Deprecated public boolean isWriteable() { @@ -465,8 +451,7 @@ public class MemoryUserDatabase implements UserDatabase { /** - * Check for permissions to save this user database to persistent storage - * location. + * Check for permissions to save this user database to persistent storage location. * * @return <code>true</code> if the database is writable */ @@ -518,12 +503,12 @@ public class MemoryUserDatabase implements UserDatabase { // Print entries for each defined role, group, and user Iterator<?> values = null; values = getRoles(); - while(values.hasNext()) { - Role role = (Role)values.next(); + while (values.hasNext()) { + Role role = (Role) values.next(); writer.print(" <role rolename=\""); writer.print(Escape.xml(role.getRolename())); writer.print("\""); - if(null != role.getDescription()) { + if (null != role.getDescription()) { writer.print(" description=\""); writer.print(Escape.xml(role.getDescription())); writer.print("\""); @@ -532,20 +517,20 @@ public class MemoryUserDatabase implements UserDatabase { } values = getGroups(); while (values.hasNext()) { - Group group = (Group)values.next(); + Group group = (Group) values.next(); writer.print(" <group groupname=\""); writer.print(Escape.xml(group.getName())); writer.print("\""); - if(null != group.getDescription()) { + if (null != group.getDescription()) { writer.print(" description=\""); writer.print(Escape.xml(group.getDescription())); writer.print("\""); } writer.print(" roles=\""); - for (Iterator<Role> roles=group.getRoles(); roles.hasNext();) { + for (Iterator<Role> roles = group.getRoles(); roles.hasNext();) { Role role = roles.next(); writer.print(Escape.xml(role.getRolename())); - if(roles.hasNext()) { + if (roles.hasNext()) { writer.print(','); } } @@ -554,30 +539,30 @@ public class MemoryUserDatabase implements UserDatabase { values = getUsers(); while (values.hasNext()) { - User user = (User)values.next(); + User user = (User) values.next(); writer.print(" <user username=\""); writer.print(Escape.xml(user.getUsername())); writer.print("\" password=\""); writer.print(Escape.xml(user.getPassword())); writer.print("\""); - if(null != user.getFullName()) { + if (null != user.getFullName()) { writer.print(" fullName=\""); writer.print(Escape.xml(user.getFullName())); writer.print("\""); } writer.print(" groups=\""); - for (Iterator<Group> groups=user.getGroups(); groups.hasNext();) { + for (Iterator<Group> groups = user.getGroups(); groups.hasNext();) { Group group = groups.next(); writer.print(Escape.xml(group.getGroupname())); - if(groups.hasNext()) { + if (groups.hasNext()) { writer.print(','); } } writer.print("\" roles=\""); - for (Iterator<Role> roles=user.getRoles(); roles.hasNext();) { + for (Iterator<Role> roles = user.getRoles(); roles.hasNext();) { Role role = roles.next(); writer.print(Escape.xml(role.getRolename())); - if(roles.hasNext()) { + if (roles.hasNext()) { writer.print(','); } } @@ -589,8 +574,7 @@ public class MemoryUserDatabase implements UserDatabase { // Check for errors that occurred while printing if (writer.checkError()) { - throw new IOException(sm.getString("memoryUserDatabase.writeException", - fileNew.getAbsolutePath())); + throw new IOException(sm.getString("memoryUserDatabase.writeException", fileNew.getAbsolutePath())); } } catch (IOException e) { if (fileNew.exists() && !fileNew.delete()) { @@ -617,8 +601,7 @@ public class MemoryUserDatabase implements UserDatabase { } if (fileOrig.exists()) { if (!fileOrig.renameTo(fileOld)) { - throw new IOException(sm.getString("memoryUserDatabase.renameOld", - fileOld.getAbsolutePath())); + throw new IOException(sm.getString("memoryUserDatabase.renameOld", fileOld.getAbsolutePath())); } } if (!fileNew.renameTo(fileOrig)) { @@ -627,8 +610,7 @@ public class MemoryUserDatabase implements UserDatabase { log.warn(sm.getString("memoryUserDatabase.restoreOrig", fileOld)); } } - throw new IOException(sm.getString("memoryUserDatabase.renameNew", - fileOrig.getAbsolutePath())); + throw new IOException(sm.getString("memoryUserDatabase.renameNew", fileOrig.getAbsolutePath())); } if (fileOld.exists() && !fileOld.delete()) { throw new IOException(sm.getString("memoryUserDatabase.fileDelete", fileOld)); diff --git a/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java b/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java index 4e5bbee051..f953c50d2f 100644 --- a/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java +++ b/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java @@ -27,22 +27,22 @@ import javax.naming.spi.ObjectFactory; /** - * <p>JNDI object creation factory for <code>MemoryUserDatabase</code> - * instances. This makes it convenient to configure a user database - * in the global JNDI resources associated with this Catalina instance, - * and then link to that resource for web applications that administer - * the contents of the user database.</p> - * - * <p>The <code>MemoryUserDatabase</code> instance is configured based - * on the following parameter values:</p> + * <p> + * JNDI object creation factory for <code>MemoryUserDatabase</code> instances. This makes it convenient to configure a + * user database in the global JNDI resources associated with this Catalina instance, and then link to that resource for + * web applications that administer the contents of the user database. + * </p> + * <p> + * The <code>MemoryUserDatabase</code> instance is configured based on the following parameter values: + * </p> * <ul> - * <li><strong>pathname</strong> - Absolute or relative (to the directory - * path specified by the <code>catalina.base</code> system property) - * pathname to the XML file from which our user information is loaded, - * and to which it is stored. [conf/tomcat-users.xml]</li> + * <li><strong>pathname</strong> - Absolute or relative (to the directory path specified by the + * <code>catalina.base</code> system property) pathname to the XML file from which our user information is loaded, and + * to which it is stored. [conf/tomcat-users.xml]</li> * </ul> * * @author Craig R. McClanahan + * * @since 4.1 */ public class MemoryUserDatabaseFactory implements ObjectFactory { @@ -52,24 +52,22 @@ public class MemoryUserDatabaseFactory implements ObjectFactory { /** - * <p>Create and return a new <code>MemoryUserDatabase</code> instance - * that has been configured according to the properties of the - * specified <code>Reference</code>. If you instance can be created, - * return <code>null</code> instead.</p> + * <p> + * Create and return a new <code>MemoryUserDatabase</code> instance that has been configured according to the + * properties of the specified <code>Reference</code>. If you instance can be created, return <code>null</code> + * instead. + * </p> * - * @param obj The possibly null object containing location or - * reference information that can be used in creating an object - * @param name The name of this object relative to <code>nameCtx</code> - * @param nameCtx The context relative to which the <code>name</code> - * parameter is specified, or <code>null</code> if <code>name</code> - * is relative to the default initial context - * @param environment The possibly null environment that is used in - * creating this object + * @param obj The possibly null object containing location or reference information that can be used in + * creating an object + * @param name The name of this object relative to <code>nameCtx</code> + * @param nameCtx The context relative to which the <code>name</code> parameter is specified, or + * <code>null</code> if <code>name</code> is relative to the default initial context + * @param environment The possibly null environment that is used in creating this object */ @Override - public Object getObjectInstance(Object obj, Name name, Context nameCtx, - Hashtable<?,?> environment) - throws Exception { + public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) + throws Exception { // We only know how to deal with <code>javax.naming.Reference</code>s // that specify a class name of "org.apache.catalina.UserDatabase" --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org