You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Gautam Mani <g_...@vsnl.com> on 2001/05/01 20:51:34 UTC

Change User Password Feature?

Hi,
I have been hanging around this place for sometime now - recently there
seem a large number of users who want to have this feature. I do not
have a full understanding of James, but I could give it a shot.

Here is what I understand of it: We need to have a method 

       void updateUser(String name, Objects attributes) 
    
in the UsersRepository interface. This would change the implementations
of UsersRepository (File, Town and LDAP). I can do File, attempt Town,
but am not sure about LDAP; someone else  would have to do it.

If this is the right way to go about it, let me know and I'll post the
changes to FileRepository and RemoteManager.

Cheers,
Gautam


-- 
uptime: 12:10am up 57 min, 3 users, load average: 0.12, 0.33, 0.53
PGP Key: 0x7586EF34

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


Re: Change User Password Feature?

Posted by Gautam Mani <g_...@vsnl.com>.
On Wed, May 02, 2001 at 12:21:34AM +0530, Gautam Mani wrote:
> Date: Wed, 2 May 2001 00:21:34 +0530
> From: Gautam Mani <g_...@vsnl.com>
> To: Java Apache Mail Server <ja...@jakarta.apache.org>
> Subject: Change User Password Feature?
> User-Agent: Mutt/1.3.13i
> 
> Hi,
> I have been hanging around this place for sometime now - recently there
> seem a large number of users who want to have this feature. I do not
> have a full understanding of James, but I could give it a shot.
> 
> Here is what I understand of it: We need to have a method 
> 
>        void updateUser(String name, Objects attributes) 
>     
> in the UsersRepository interface. This would change the implementations
> of UsersRepository (File, Town and LDAP). I can do File, attempt Town,
> but am not sure about LDAP; someone else  would have to do it.
 
Hi,
Here are the diffs. I have done the FileRepository, taken a shot at
TownRepository (should work ok), but haven't figured out the
LDAPRepository. So, could someone update that and commit the changes?
All that needs to be done is update the password in the  repository with the 
new one.

Index: services/UsersRepository.java
===================================================================
RCS file: /home/cvspublic/jakarta-james/src/org/apache/james/services/UsersRepository.java,v
retrieving revision 1.4
diff -u -r1.4 UsersRepository.java
--- services/UsersRepository.java       2001/03/13 06:00:38     1.4
+++ services/UsersRepository.java       2001/05/02 17:08:48
@@ -28,6 +28,12 @@
     void addUser(String name, Object attributes);
 
     /**
+     * Update a user in the repository with the specified attributes.  In current
+     * implementations, the Object attributes is a String password.
+     */
+    void updateUser(String name, Object attributes);
+
+    /**
      * Gets the attribute for a user.  Not clear on behavior.
      */
     Object getAttributes(String name);

Index: userrepository/UsersFileRepository.java
===================================================================
RCS file: /home/cvspublic/jakarta-james/src/org/apache/james/userrepository/UsersFileRepository.java,v
retrieving revision 1.13
diff -u -r1.13 UsersFileRepository.java
--- userrepository/UsersFileRepository.java     2001/04/28 15:14:39     1.13
+++ userrepository/UsersFileRepository.java     2001/05/02 17:09:04
@@ -98,6 +98,15 @@
         }
     }
 
+    public synchronized void updateUser(String name, Object attributes) {
+        try {
+            or.remove(name);
+            or.put(name, attributes);
+        } catch (Exception e) {
+            throw new RuntimeException("Exception caught while storing user: " + e );
+        }
+    }
+
     public synchronized Object getAttributes(String name) {
         try {
             return or.get(name);

Index: userrepository/UsersTownRepository.java
===================================================================
RCS file: /home/cvspublic/jakarta-james/src/org/apache/james/userrepository/UsersTownRepository.java,v
retrieving revision 1.10
diff -u -r1.10 UsersTownRepository.java
--- userrepository/UsersTownRepository.java     2001/04/28 12:43:19     1.10
+++ userrepository/UsersTownRepository.java     2001/05/02 17:09:04
@@ -75,6 +75,26 @@
         }
     }
 
+    public synchronized void updateUser(String strUserName, Object attributes) {
+        try {
+            TableDataSet MRUser = new TableDataSet(ConnDefinition.getInstance(conndefinition), tableName);
+            MRUser.setWhere("username = '" + strUserName+"'");
+            Record user = null;
+            if (MRUser.size() == 0) {
+                // file://User does not  exists: ignore
+                logger.warn("User "+strUserName+" does not exist.");
+            } else {
+                // file://update user attributes
+                user = MRUser.getRecord(0);
+                user.setValue("password", attributes.toString());
+                user.save();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("Exception caught while storing user: " + e);
+        }
+    }
+
     public synchronized Object getAttributes(String strUserName) {
         try {
             TableDataSet MRUser = new TableDataSet(ConnDefinition.getInstance(conndefinition), tableName);

Cheers,
Gautam

-- 
uptime: 10:32pm up 1:54, 3 users, load average: 1.19, 1.17, 1.08
PGP Key: 0x7586EF34

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