You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by he...@apache.org on 2003/04/10 18:41:38 UTC
cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/services/security/torque RolePeerManager.java TorqueSecurityService.java TorqueUser.java UserPeerManager.java
henning 2003/04/10 09:41:38
Modified: src/java/org/apache/turbine/om/security TurbineUser.java
src/java/org/apache/turbine/services/security/db
DBSecurityService.java DBUserManager.java
src/java/org/apache/turbine/services/security/ldap
LDAPSecurityConstants.java LDAPSecurityService.java
LDAPUser.java LDAPUserManager.java
src/java/org/apache/turbine/services/security/torque
RolePeerManager.java TorqueSecurityService.java
TorqueUser.java UserPeerManager.java
Log:
use getName() everywhere, make sure that the removal of
user.getUserName() will actually work.
Revision Changes Path
1.10 +2 -14 jakarta-turbine-2/src/java/org/apache/turbine/om/security/TurbineUser.java
Index: TurbineUser.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/om/security/TurbineUser.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TurbineUser.java 8 Apr 2003 13:15:31 -0000 1.9
+++ TurbineUser.java 10 Apr 2003 16:41:35 -0000 1.10
@@ -286,19 +286,7 @@
*/
public String getUserName()
{
- String tmp = null;
- try
- {
- tmp = (String) getPerm(User.USERNAME);
- if(tmp.length() == 0)
- {
- tmp = null;
- }
- }
- catch(Exception e)
- {
- }
- return tmp;
+ return getName();
}
/**
1.19 +6 -6 jakarta-turbine-2/src/java/org/apache/turbine/services/security/db/DBSecurityService.java
Index: DBSecurityService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/db/DBSecurityService.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- DBSecurityService.java 9 Mar 2003 03:06:31 -0000 1.18
+++ DBSecurityService.java 10 Apr 2003 16:41:36 -0000 1.19
@@ -135,7 +135,7 @@
if (!TurbineSecurity.accountExists(user))
{
throw new UnknownEntityException("The account '"
- + user.getUserName() + "' does not exist");
+ + user.getName() + "' does not exist");
}
try
{
@@ -176,7 +176,7 @@
catch (Exception e)
{
throw new DataBackendException("Failed to build ACL for user '"
- + user.getUserName() + "'", e);
+ + user.getName() + "'", e);
}
finally
{
@@ -236,7 +236,7 @@
if (!userExists)
{
throw new UnknownEntityException("Unknown user '"
- + user.getUserName() + "'");
+ + user.getName() + "'");
}
if (!groupExists)
{
@@ -297,7 +297,7 @@
if (!userExists)
{
throw new UnknownEntityException("Unknown user '"
- + user.getUserName() + "'");
+ + user.getName() + "'");
}
if (!groupExists)
{
@@ -347,7 +347,7 @@
unlockExclusive();
}
throw new UnknownEntityException("Unknown user '"
- + user.getUserName() + "'");
+ + user.getName() + "'");
}
/**
1.15 +14 -14 jakarta-turbine-2/src/java/org/apache/turbine/services/security/db/DBUserManager.java
Index: DBUserManager.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/db/DBUserManager.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DBUserManager.java 8 Apr 2003 12:11:16 -0000 1.14
+++ DBUserManager.java 10 Apr 2003 16:41:36 -0000 1.15
@@ -128,7 +128,7 @@
public boolean accountExists(User user)
throws DataBackendException
{
- return accountExists(user.getUserName());
+ return accountExists(user.getName());
}
/**
@@ -310,7 +310,7 @@
if (!accountExists(user))
{
throw new UnknownEntityException("The account '" +
- user.getUserName() + "' does not exist");
+ user.getName() + "' does not exist");
}
Criteria criteria = TurbineUserPeer.buildCriteria(user);
@@ -347,7 +347,7 @@
if (!accountExists(user))
{
throw new UnknownEntityException("The account '" +
- user.getUserName() + "' does not exist");
+ user.getName() + "' does not exist");
}
Criteria crit = new Criteria();
if (!((Persistent) user).isNew())
@@ -402,7 +402,7 @@
if (!accountExists(user))
{
throw new UnknownEntityException("The account '" +
- user.getUserName() + "' does not exist");
+ user.getName() + "' does not exist");
}
// log.debug("Supplied Pass: " + password);
@@ -442,13 +442,13 @@
if (!accountExists(user))
{
throw new UnknownEntityException("The account '" +
- user.getUserName() + "' does not exist");
+ user.getName() + "' does not exist");
}
if (!TurbineSecurity.checkPassword(oldPassword, user.getPassword()))
{
throw new PasswordMismatchException(
- "The supplied old password for '" + user.getUserName() +
+ "The supplied old password for '" + user.getName() +
"' was incorrect");
}
user.setPassword(TurbineSecurity.encryptPassword(newPassword));
@@ -479,7 +479,7 @@
if (!accountExists(user))
{
throw new UnknownEntityException("The account '" +
- user.getUserName() + "' does not exist");
+ user.getName() + "' does not exist");
}
user.setPassword(TurbineSecurity.encryptPassword(password));
// save the changes in the database immediately, to prevent the
@@ -500,7 +500,7 @@
public void createAccount(User user, String initialPassword)
throws EntityExistsException, DataBackendException
{
- if (StringUtils.isEmpty(user.getUserName()))
+ if (StringUtils.isEmpty(user.getName()))
{
throw new DataBackendException("Could not create "
+ "an user with empty name!");
@@ -509,7 +509,7 @@
if (accountExists(user))
{
throw new EntityExistsException("The account '" +
- user.getUserName() + "' already exists");
+ user.getName() + "' already exists");
}
user.setPassword(TurbineSecurity.encryptPassword(initialPassword));
@@ -528,7 +528,7 @@
catch (Exception e)
{
throw new DataBackendException("Failed to create account '" +
- user.getUserName() + "'", e);
+ user.getName() + "'", e);
}
}
@@ -546,10 +546,10 @@
if (!accountExists(user))
{
throw new UnknownEntityException("The account '" +
- user.getUserName() + "' does not exist");
+ user.getName() + "' does not exist");
}
Criteria criteria = new Criteria();
- criteria.add(TurbineUserPeer.USERNAME, user.getUserName());
+ criteria.add(TurbineUserPeer.USERNAME, user.getName());
try
{
TurbineUserPeer.doDelete(criteria);
@@ -557,7 +557,7 @@
catch (Exception e)
{
throw new DataBackendException("Failed to remove account '" +
- user.getUserName() + "'", e);
+ user.getName() + "'", e);
}
}
}
1.7 +11 -1 jakarta-turbine-2/src/java/org/apache/turbine/services/security/ldap/LDAPSecurityConstants.java
Index: LDAPSecurityConstants.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/ldap/LDAPSecurityConstants.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- LDAPSecurityConstants.java 9 Mar 2003 03:06:31 -0000 1.6
+++ LDAPSecurityConstants.java 10 Apr 2003 16:41:36 -0000 1.7
@@ -259,9 +259,19 @@
* Get the value of the Username Attribute.
* @return the value of the property.
*/
- public static String getUserNameAttribute()
+ public static String getNameAttribute()
{
return getProperty(LDAP_USER_USERNAME_KEY, LDAP_USER_USERNAME_DEFAULT);
+ }
+
+ /**
+ * Get the value of the Username Attribute.
+ * @return the value of the property.
+ * @deprecated Use getNameAttribute()
+ */
+ public static String getUserNameAttribute()
+ {
+ return getNameAttribute();
}
/**
1.14 +8 -8 jakarta-turbine-2/src/java/org/apache/turbine/services/security/ldap/LDAPSecurityService.java
Index: LDAPSecurityService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/ldap/LDAPSecurityService.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- LDAPSecurityService.java 9 Mar 2003 03:06:31 -0000 1.13
+++ LDAPSecurityService.java 10 Apr 2003 16:41:36 -0000 1.14
@@ -129,7 +129,7 @@
if (!TurbineSecurity.accountExists(user))
{
throw new UnknownEntityException("The account '"
- + user.getUserName() + "' does not exist");
+ + user.getName() + "' does not exist");
}
try
{
@@ -174,7 +174,7 @@
catch (Exception e)
{
throw new DataBackendException("Failed to build ACL for user '"
- + user.getUserName() + "'", e);
+ + user.getName() + "'", e);
}
finally
{
@@ -207,7 +207,7 @@
{
lockExclusive();
- String userName = user.getUserName();
+ String userName = user.getName();
String roleName = role.getName();
String groupName = group.getName();
@@ -231,7 +231,7 @@
// Make the distinguished name.
String dn = "turbineGroupName=" + groupName + ","
- + LDAPSecurityConstants.getUserNameAttribute()
+ + LDAPSecurityConstants.getNameAttribute()
+ "=" + userName + ","
+ LDAPSecurityConstants.getBaseSearch();
@@ -287,7 +287,7 @@
{
lockExclusive();
- String userName = user.getUserName();
+ String userName = user.getName();
String roleName = role.getName();
String groupName = group.getName();
@@ -311,7 +311,7 @@
// Make the distinguished name.
String dn = "turbineGroupName=" + groupName + ","
- + LDAPSecurityConstants.getUserNameAttribute()
+ + LDAPSecurityConstants.getNameAttribute()
+ "=" + userName + ","
+ LDAPSecurityConstants.getBaseSearch();
@@ -565,7 +565,7 @@
String filter = "(& ";
filter += "(objectclass=turbineUserGroup)";
- filter += "(turbineUserUniqueId=" + user.getUserName() + ")";
+ filter += "(turbineUserUniqueId=" + user.getName() + ")";
filter += "(turbineGroupName=" + group.getName() + ")";
filter += ")";
1.12 +19 -16 jakarta-turbine-2/src/java/org/apache/turbine/services/security/ldap/LDAPUser.java
Index: LDAPUser.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/ldap/LDAPUser.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- LDAPUser.java 8 Apr 2003 13:32:16 -0000 1.11
+++ LDAPUser.java 10 Apr 2003 16:41:37 -0000 1.12
@@ -149,7 +149,7 @@
}
// Set the Username.
- attrName = LDAPSecurityConstants.getUserNameAttribute();
+ attrName = LDAPSecurityConstants.getNameAttribute();
if (attrName != null)
{
attr = attribs.get(attrName);
@@ -239,10 +239,10 @@
}
// Set the Username.
- attrName = LDAPSecurityConstants.getUserNameAttribute();
+ attrName = LDAPSecurityConstants.getNameAttribute();
if (attrName != null)
{
- Object value = getUserName();
+ Object value = getName();
if (value != null)
{
@@ -318,9 +318,9 @@
*/
public String getDN()
{
- String filterAttribute = LDAPSecurityConstants.getUserNameAttribute();
+ String filterAttribute = LDAPSecurityConstants.getNameAttribute();
String userBaseSearch = LDAPSecurityConstants.getBaseSearch();
- String userName = getUserName();
+ String userName = getName();
String dn = filterAttribute + "=" + userName + "," + userBaseSearch;
@@ -547,17 +547,11 @@
* the user is considered logged in.
*
* @return A String with the username.
+ * @deprecated Use getName() instead
*/
public String getUserName()
{
- String tmp = null;
-
- tmp = (String) getPerm(User.USERNAME);
- if (tmp != null && tmp.length() == 0)
- {
- tmp = null;
- }
- return tmp;
+ return getName();
}
/**
@@ -915,12 +909,21 @@
}
/**
- * Not implemented.
- * @return Empty String
+ * Returns the username for this user. If this is defined, then
+ * the user is considered logged in.
+ *
+ * @return A String with the username.
*/
public String getName()
{
- return "";
+ String tmp = null;
+
+ tmp = (String) getPerm(User.USERNAME);
+ if (tmp != null && tmp.length() == 0)
+ {
+ tmp = null;
+ }
+ return tmp;
}
/**
1.13 +8 -8 jakarta-turbine-2/src/java/org/apache/turbine/services/security/ldap/LDAPUserManager.java
Index: LDAPUserManager.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/ldap/LDAPUserManager.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- LDAPUserManager.java 8 Apr 2003 12:11:16 -0000 1.12
+++ LDAPUserManager.java 10 Apr 2003 16:41:37 -0000 1.13
@@ -123,7 +123,7 @@
*/
public boolean accountExists(User user) throws DataBackendException
{
- return accountExists(user.getUserName());
+ return accountExists(user.getName());
}
/**
@@ -171,7 +171,7 @@
* Define the search.
*/
String userBaseSearch = LDAPSecurityConstants.getBaseSearch();
- String filter = LDAPSecurityConstants.getUserNameAttribute();
+ String filter = LDAPSecurityConstants.getNameAttribute();
filter = "(" + filter + "=" + username + ")";
@@ -253,7 +253,7 @@
DirContext ctx = bindAsAdmin();
String userBaseSearch = LDAPSecurityConstants.getBaseSearch();
- String filter = LDAPSecurityConstants.getUserNameAttribute();
+ String filter = LDAPSecurityConstants.getNameAttribute();
filter = "(" + filter + "=*)";
@@ -325,7 +325,7 @@
if (!accountExists(user))
{
throw new UnknownEntityException("The account '"
- + user.getUserName() + "' does not exist");
+ + user.getName() + "' does not exist");
}
try
@@ -363,7 +363,7 @@
if (!accountExists(user))
{
throw new UnknownEntityException("The account '" +
- user.getUserName() + "' does not exist");
+ user.getName() + "' does not exist");
}
}
@@ -461,7 +461,7 @@
if (accountExists(user))
{
throw new EntityExistsException("The account '"
- + user.getUserName() + "' already exist");
+ + user.getName() + "' already exist");
}
try
@@ -493,7 +493,7 @@
if (!accountExists(user))
{
throw new UnknownEntityException("The account '"
- + user.getUserName() + "' does not exist");
+ + user.getName() + "' does not exist");
}
try
1.4 +2 -2 jakarta-turbine-2/src/java/org/apache/turbine/services/security/torque/RolePeerManager.java
Index: RolePeerManager.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/torque/RolePeerManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RolePeerManager.java 8 Apr 2003 09:50:35 -0000 1.3
+++ RolePeerManager.java 10 Apr 2003 16:41:38 -0000 1.4
@@ -347,7 +347,7 @@
Criteria criteria = new Criteria();
criteria.add(UserPeerManager.getNameColumn(),
- user.getUserName());
+ user.getName());
criteria.add(TurbineUserGroupRolePeer.GROUP_ID,
((Persistent) group).getPrimaryKey());
1.4 +6 -6 jakarta-turbine-2/src/java/org/apache/turbine/services/security/torque/TorqueSecurityService.java
Index: TorqueSecurityService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/torque/TorqueSecurityService.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TorqueSecurityService.java 8 Apr 2003 09:50:35 -0000 1.3
+++ TorqueSecurityService.java 10 Apr 2003 16:41:38 -0000 1.4
@@ -145,7 +145,7 @@
if (!TurbineSecurity.accountExists(user))
{
throw new UnknownEntityException("The account '"
- + user.getUserName() + "' does not exist");
+ + user.getName() + "' does not exist");
}
try
{
@@ -186,7 +186,7 @@
catch (Exception e)
{
throw new DataBackendException("Failed to build ACL for user '" +
- user.getUserName() + "'" , e);
+ user.getName() + "'" , e);
}
finally
{
@@ -246,7 +246,7 @@
if (!userExists)
{
throw new UnknownEntityException("Unknown user '"
- + user.getUserName() + "'");
+ + user.getName() + "'");
}
if (!groupExists)
{
@@ -307,7 +307,7 @@
if (!userExists)
{
throw new UnknownEntityException("Unknown user '"
- + user.getUserName() + "'");
+ + user.getName() + "'");
}
if (!groupExists)
{
@@ -367,7 +367,7 @@
unlockExclusive();
}
throw new UnknownEntityException("Unknown user '"
- + user.getUserName() + "'");
+ + user.getName() + "'");
}
/**
1.4 +4 -3 jakarta-turbine-2/src/java/org/apache/turbine/services/security/torque/TorqueUser.java
Index: TorqueUser.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/torque/TorqueUser.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TorqueUser.java 8 Apr 2003 09:50:35 -0000 1.3
+++ TorqueUser.java 10 Apr 2003 16:41:38 -0000 1.4
@@ -217,7 +217,7 @@
*/
public String getName()
{
- return getUserName();
+ return UserPeerManager.getName(getPersistentObj());
}
/**
@@ -264,10 +264,11 @@
* Returns the name of this user.
*
* @return The name of the user.
+ * @deprecated Use getName() instead.
*/
public String getUserName()
{
- return UserPeerManager.getUserName(getPersistentObj());
+ return getName();
}
/**
1.4 +17 -3 jakarta-turbine-2/src/java/org/apache/turbine/services/security/torque/UserPeerManager.java
Index: UserPeerManager.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/torque/UserPeerManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- UserPeerManager.java 8 Apr 2003 09:50:35 -0000 1.3
+++ UserPeerManager.java 10 Apr 2003 16:41:38 -0000 1.4
@@ -601,14 +601,14 @@
criteria.addSelectColumn(getIdColumn());
- criteria.add(getNameColumn(), user.getUserName());
+ criteria.add(getNameColumn(), user.getName());
List results = BasePeer.doSelect(criteria);
if (results.size() > 1)
{
throw new DataBackendException("Multiple users named '" +
- user.getUserName() + "' exist!");
+ user.getName() + "' exist!");
}
return (results.size() == 1);
}
@@ -846,8 +846,22 @@
* @param obj The object to use for getting the name
*
* @return A string containing the name
+ *
+ * @deprecated use getName(obj)
*/
public static String getUserName(Persistent obj)
+ {
+ return getName(obj);
+ }
+
+ /**
+ * Invokes getName() on the supplied base object
+ *
+ * @param obj The object to use for getting the name
+ *
+ * @return A string containing the name
+ */
+ public static String getName(Persistent obj)
{
String name = null;
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org