> Which version of James are you using? I would guess it's 1.2.1. Can
> you try to use the latest 2.0a2?
it was the latest version .. but I shall confess .. this was my fault since
I
deleted the james.sar file just after deployement. I thought that all filles
were deployed under the james directory but this was not the case.
In any case, the latest version seems quite unstable, and disapear/crashes
from time to time. I have to restart the server quite often : 2 or 3 times a
day .. is it a known issue ?
> We are also preparing to make an
> alpha3 release shortly.
great
is there some planning for :
- a final release
- IMAP provider
- remote admin
BTW I developed a very simple java wrapper of telnet admin commands ...
if anybody interested, I post it hereafter ...
this is crude, simple ... and not so clean .. because it rely on text
input/ouput that may change in future version
but it works ...
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.Socket;
/**
* wrap telnet admin.
* @author <a href=mailto:[EMAIL PROTECTED]>Daniel Herlemont</a>
*/
public class JamesTelnetAdmin {
public void setServer(String server) {
this.server = server;
}
public String getServer() {
return server;
}
public void setPort(int port) {
this.port = port;
}
public int getPort() {
return port;
}
public void setRootUsername(String rootUsername) {
this.rootUsername = rootUsername;
}
public String getRootUsername() {
return rootUsername;
}
public void setRootPassword(String rootPassword) {
this.rootPassword = rootPassword;
}
public String getRootPassword() {
return rootPassword;
}
public void open() {
try {
socket = new Socket(server,port);
in = new BufferedReader(new InputStreamReader(
socket.getInputStream() ));
out = new PrintWriter( socket.getOutputStream(), true);
} catch (Exception e) { throw new RuntimeException(e);}
String line=null;
try {
line=in.readLine();
} catch (Exception e) { throw new RuntimeException(e);}
if (!line.startsWith("JAMES"))
throw new RuntimeException("james:JAMES exepected, was:"+line);
try {
line=in.readLine();
} catch (Exception e) { throw new RuntimeException(e);}
if (!line.startsWith("Please"))
throw new RuntimeException("james:Please exepected, was:"+line);
try {
line=in.readLine();
} catch (Exception e) { throw new RuntimeException(e);}
if (!line.startsWith("Login"))
throw new RuntimeException("james:Login exepected, was:"+line);
out.println(rootUsername);
try {
line=in.readLine();
} catch (Exception e) { throw new RuntimeException(e);}
if (!line.startsWith("Password"))
throw new RuntimeException("james:Password exepected, was:"+line);
out.println(rootPassword);
try {
line=in.readLine();
} catch (Exception e) { throw new RuntimeException(e);}
if (!line.startsWith("Welcome"))
throw new RuntimeException("james:Welcome exepected, was:"+line);
}
public void close() {
try {
socket.close();
} catch (Exception e) {}
}
public String sendCommand(String command) {
try {
out.println(command);
return in.readLine();
} catch (Exception e) { throw new RuntimeException(e);}
}
public boolean adduser(String username, String password) {
String ret=sendCommand("adduser "+username+" "+password);
return ret.startsWith("User "+username+" added");
}
public String[] listusers() {
String ret=sendCommand("listusers");
if (!ret.startsWith("Existing accounts"))
throw new RuntimeException("james:Existing accounts exepected,
was:"+ret);
int count=Integer.parseInt(ret.substring(ret.lastIndexOf(' ')+1));
String[] users=new String[count];
for (int i=0;i<users.length;i++) {
try {
String s=in.readLine();
users[i]=s.substring(s.indexOf(' ')+1).trim();
} catch (Exception e) { throw new RuntimeException(e);}
}
return users;
}
public boolean verify(String username) {
String ret=sendCommand("verify "+username);
return ret.startsWith("User "+username+" exist");
}
public boolean deluser(String username) {
String ret=sendCommand("deluser "+username);
return ret.startsWith("User "+username+" deleted");
}
public boolean setpassword(String username, String password) {
String ret=sendCommand("setpassword "+username+" "+password);
return ret.startsWith("Password for "+username+" reset");
}
public boolean setforwarding(String username, String forward) {
String ret=sendCommand("setforwarding "+username+" "+forward);
return ret.startsWith("Forwarding destination for "+username+" set
to:"+forward);
}
public BufferedReader getBufferedReader() { return in;}
public PrintWriter getPrintWriter() { return out;}
private String server;
private int port=4555;
private String rootUsername="root";
private String rootPassword;
private BufferedReader in;
private PrintWriter out;
private Socket socket;
//--------------------------------------------------------------------------
----
// command or agent exec.
//--------------------------------------------------------------------------
----
public void exec(String args[]) {
try {
// commands ...
boolean listusers=false;
boolean verify=false;
boolean deluser=false;
boolean adduser=false;
boolean setpassword=false;
boolean setforwarding=false;
String userUsername=null;
String userPassword=null;
String forward=null;
for (int argn = 0; argn < args.length; argn++) {
if (args[argn].equals("-help")) {
usage(System.out);
}
else if (args[argn].equals("-server") && argn < args.length - 1) {
server= args[++argn];
}
else if (args[argn].equals("-port") && argn < args.length - 1) {
port= Integer.parseInt(args[++argn]);
}
else if (args[argn].equals("-rooUsername") && argn < args.length -
1) {
rootUsername= args[++argn];
}
else if (args[argn].equals("-rootPassword") && argn < args.length -
1) {
rootPassword= args[++argn];
}
else if (args[argn].equals("-listusers")) {
listusers=true;
} else if (args[argn].equals("-adduser") && argn < args.length - 2)
{
userUsername= args[++argn];
userPassword= args[++argn];
adduser=true;
} else if (args[argn].equals("-verify") && argn < args.length - 1) {
userUsername= args[++argn];
verify=true;
} else if (args[argn].equals("-deluser") && argn < args.length - 1)
{
userUsername= args[++argn];
deluser=true;
} else if (args[argn].equals("-setpassword") && argn < args.length -
2) {
userUsername= args[++argn];
userPassword= args[++argn];
setpassword=true;
} else if (args[argn].equals("-setforwarding") && argn <
args.length - 2) {
userUsername= args[++argn];
forward= args[++argn];
setforwarding=true;
}
else {
System.err.println("unrecognized option : " + args[argn]);
usage(System.err);
}
}
open();
if (listusers) {
String[] users=listusers();
for (int i=0;i<users.length;i++) {
System.out.println(users[i]);
}
}
if (verify) System.out.println("verify :"+userUsername+" :
"+verify(userUsername));
if (deluser) System.out.println("deluser :"+userUsername+" :
"+deluser(userUsername));
if (adduser) {
System.out.println("adduser :"+userUsername+" "+userPassword+" : "
+adduser(userUsername,userPassword));
}
if (setpassword) {
System.out.println("setpassword :"+userUsername+" "+userPassword+" :
"
+setpassword(userUsername,userPassword));
}
if (setforwarding) {
System.out.println("setforwarding :"+userUsername+" "+forward+" : "
+setforwarding(userUsername,forward));
}
} catch (Exception e) { throw new RuntimeException(e);
} finally {
close();
}
}
public void usage(PrintStream ps) {
ps.println("Usage: java "+getClass().getName()+" see telnet commands");
ps.println();
ps.println("-help print this");
}
public static void main(String[] args) {
JamesTelnetAdmin inst = new JamesTelnetAdmin();
inst.exec(args);
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>