james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Danielsson" <atada...@hotmail.com>
Subject RemoteManager modifications that I find usefull.
Date Fri, 16 Nov 2001 14:32:01 GMT
Hello,
I have made some modifications on the RemoteManager.
The RemoteManager was a bit short of basic administration commands.

I added:
-listrepo, lists the repositories that exists.
-checkuser, checks status of alias and forwarding.
-unsetforwarding

Furthermore I added a "command prompt" containing the current-repository 
like
this: "jakarta-james::list-james>".
The modified files are:

jakarta-james/kava/org/apache/james/

core/AvalonUsersStore.java     (to get the repository names)
services/UsersStore.java       (to get the repository names)
remotemanager/RemoteHandlerManager.java (new commands)

These small modifications truly made the runtime administration
a bit less painfull.

//Regards
Erik Danielsson

The patches:

---- Begin AvalonUsersStore_patch
Index: jakarta-james/src/java/org/apache/james/core/AvalonUsersStore.java
diff -c
jakarta-james/src/java/org/apache/james/core/AvalonUsersStore.java:1.3
jakarta-james/src/java/org/apache/james/core/AvalonUsersStore.java:1.4
***
jakarta-james/src/java/org/apache/james/core/AvalonUsersStore.java:1.3	Thu
Sep 27 23:12:17 2001
--- jakarta-james/src/java/org/apache/james/core/AvalonUsersStore.java	Fri
Nov 16 13:35:05 2001
***************
*** 100,103 ****
--- 100,107 ----
          }
          return response;
      }
+
+     public Iterator getRepositoryNames() {
+         return this.repositories.keySet().iterator();
+     }
  }
---- End AvalonUsersStore_patch




---- Begin  UsersStore_patch
Index: jakarta-james/src/java/org/apache/james/services/UsersStore.java
diff -c jakarta-james/src/java/org/apache/james/services/UsersStore.java:1.2
jakarta-james/src/java/org/apache/james/services/UsersStore.java:1.3
*** jakarta-james/src/java/org/apache/james/services/UsersStore.java:1.2	Thu
Sep  6 15:19:32 2001
--- jakarta-james/src/java/org/apache/james/services/UsersStore.java	Fri Nov
16 13:35:46 2001
***************
*** 8,14 ****
  package org.apache.james.services;

  import org.apache.avalon.phoenix.Service;
!
  /**
   * Interface for Phoenix blocks to access a store of Users. A UserStore
   * contains one or more UserRepositories. Multiple UserRepositories may or
may
--- 8,14 ----
  package org.apache.james.services;

  import org.apache.avalon.phoenix.Service;
! import java.util.Iterator;
  /**
   * Interface for Phoenix blocks to access a store of Users. A UserStore
   * contains one or more UserRepositories. Multiple UserRepositories may or
may
***************
*** 24,27 ****
--- 24,29 ----
      String ROLE = "org.apache.james.services.UsersStore";

      UsersRepository getRepository( String name );
+
+     Iterator getRepositoryNames();
  }
---- End UsersStore_patch



--- Begin RemoteManagerHandler_patch
Index:
jakarta-james/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
diff -c
jakarta-james/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java:1.2
jakarta-james/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java:1.3
***
jakarta-james/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java:1.2
Mon
Jun 11 11:29:27 2001
---
jakarta-james/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
Tue Sep 11 06:33:21 2001
***************
*** 31,36 ****
--- 31,37 ----
  import org.apache.james.services.UsersRepository;
  import org.apache.james.services.UsersStore;
  import org.apache.mailet.MailAddress;
+ import org.apache.james.userrepository.DefaultUser;

  /**
   * Provides a really rude network interface to administer James.
***************
*** 43,50 ****
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   * @author <a href="mailto:charles@benett1.demon.co.uk">Charles Benett</a>
   *
!  * Last changed by: $Author: charlesb $ on $Date: 2001/06/11 09:29:27 $
!  * $Revision: 1.2 $
   *
   */
  public class RemoteManagerHandler
--- 44,51 ----
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   * @author <a href="mailto:charles@benett1.demon.co.uk">Charles Benett</a>
   *
!  * Last changed by: $Author: serge $ on $Date: 2001/09/11 04:33:21 $
!  * $Revision: 1.3 $
   *
   */
  public class RemoteManagerHandler
***************
*** 53,58 ****
--- 54,60 ----

      private UsersStore usersStore;
      private UsersRepository users;
+     private boolean inLocalUsers = true;
      private TimeScheduler scheduler;
      private MailServer mailServer;

***************
*** 137,144 ****
              out.println( "Welcome " + login + ". HELP for a list of
commands" );
              getLogger().info("Login for " + login + " succesful");

!             while (parseCommand(in.readLine())) {
!                 scheduler.resetTrigger(this.toString());
              }
              getLogger().info("Logout for " + login + ".");
              socket.close();
--- 139,152 ----
              out.println( "Welcome " + login + ". HELP for a list of
commands" );
              getLogger().info("Login for " + login + " succesful");

!             try {
!                 while (parseCommand(in.readLine())) {
!                     scheduler.resetTrigger(this.toString());
!                 }
!             }
!             catch (Throwable thr) {
!                 System.out.println("Exception: " + thr.getMessage());
!                 thr.printStackTrace();
              }
              getLogger().info("Logout for " + login + ".");
              socket.close();
***************
*** 191,206 ****
                  out.println("usage: adduser [username] [password]");
                  return true;
              }
              if (users.contains(username)) {
                  out.println("user " + username + " already exist");
!             } else {
!                 if(mailServer.addUser(username, passwd)) {
!                     out.println("User " + username + " added");
!                     getLogger().info("User " + username + " added");
!                 } else {
!                     out.println("Error adding user " + username);
!                     getLogger().info("Error adding user " + username);
!                 }
              }
              out.flush();
          } else if (command.equalsIgnoreCase("SETPASSWORD")) {
--- 199,224 ----
                  out.println("usage: adduser [username] [password]");
                  return true;
              }
+
+             boolean success = false;
              if (users.contains(username)) {
                  out.println("user " + username + " already exist");
!             }
!             else if ( inLocalUsers ) {
!                 success = mailServer.addUser(username, passwd);
!             }
!             else {
!                 DefaultUser user = new DefaultUser(username, "SHA");
!                 user.setPassword(passwd);
!                 success = users.addUser(user);
!             }
!             if ( success ) {
!                 out.println("User " + username + " added");
!                 getLogger().info("User " + username + " added");
!             }
!             else {
!                 out.println("Error adding user " + username);
!                 getLogger().info("Error adding user " + username);
              }
              out.flush();
          } else if (command.equalsIgnoreCase("SETPASSWORD")) {
***************
*** 214,220 ****
                  out.println("usage: adduser [username] [password]");
                  return true;
  	    }
! 	    JamesUser user = (JamesUser) users.getUserByName(username);
  	    if (user == null) {
  		out.println("No such user");
  		return true;
--- 232,238 ----
                  out.println("usage: adduser [username] [password]");
                  return true;
  	    }
! 	    User user = users.getUserByName(username);
  	    if (user == null) {
  		out.println("No such user");
  		return true;
***************
*** 321,331 ****
                  return true;
  	    }
  	    // Verify user exists
! 	    JamesUser user = (JamesUser) users.getUserByName(username);
! 	    if (user == null) {
  		out.println("No such user");
  		return true;
  	    }
  	    // Veriy acceptable email address
  	    MailAddress forwardAddr;
              try {
--- 339,354 ----
                  return true;
  	    }
  	    // Verify user exists
! 	    User baseuser = users.getUserByName(username);
! 	    if (baseuser == null) {
  		out.println("No such user");
  		return true;
  	    }
+             else if (! (baseuser instanceof JamesUser ) ) {
+                 out.println("Can't set forwarding for this user type.");
+                 return true;
+             }
+             JamesUser user = (JamesUser)baseuser;
  	    // Veriy acceptable email address
  	    MailAddress forwardAddr;
              try {
***************
*** 379,384 ****
--- 402,430 ----
  	    }
              out.flush();
  	    return true;
+         } else if (command.equalsIgnoreCase("USE")) {
+ 	    if (argument == null || argument.equals("")) {
+                 out.println("usage: use [repositoryName]");
+                 return true;
+ 	    }
+             String repositoryName = argument;
+             UsersRepository repos =
usersStore.getRepository(repositoryName);
+             if ( repos == null ) {
+                 out.println("no such repository");
+                 return true;
+             }
+             else {
+                 users = repos;
+                 out.println("Changed to repository '" + repositoryName +
"'.");
+                 if ( repositoryName.equalsIgnoreCase("localusers") ) {
+                     inLocalUsers = true;
+                 }
+                 else {
+                     inLocalUsers = false;
+                 }
+                 return true;
+             }
+
          } else if (command.equalsIgnoreCase("QUIT")) {
              out.println("bye");
              return false;
---- End RemoteManagerHandler_patch



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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


Mime
View raw message