package org.ldn.authority;
import lotus.domino.NotesException;
import lotus.domino.NotesFactory;
import lotus.domino.Session;
/**
* @author mike
*
*/
public class IIOPSession {
private lotus.domino.Session ldnSession = null;
private Account acc = null;
private AccountDialog dlg = null;
/**
*
*/
String host = null, user = "", pwd = "";
public IIOPSession(String argv[]) {
// TODO Автоматически созданная заглушка конструктора
if (argv.length < 1) {
acc = new Account();
dlg = new AccountDialog(new javax.swing.JFrame(), acc, true);
dlg.setVisible(true);
host = acc.getServer();
if (host.length() != 0) {
user = acc.getName();
pwd = acc.getPassword();
} else {
//throw new Error("account hasn't been initialized");
}
} else {
host = argv[0];
if (argv.length >= 2) {
user = argv[1];
}
if (argv.length >= 3) {
pwd = argv[2];
}
}
}
/**
* @param argv
*/
public static void main(String[] argv) {
// TODO Автоматически созданная заглушка метода
IIOPSession t;
t = new IIOPSession(argv);//new String [] {"rhel-ws"});
t.run();
// Thread nt = new Thread((Runnable) t);
// nt.start();
System.exit(0);
}
public Session createSession() {
String args[] = new String[1];
args[0] = "-ORBEnableSSLSecurity";
Session result = null;
try {
Class o = Class.forName("TrustedCerts");
try {
ldnSession = NotesFactory.createSession(host, args, user, pwd);
result = ldnSession;
} catch (NotesException ex) {
ex.printStackTrace();
} catch (NoClassDefFoundError ex) {
System.out.println("Create Session Error");
ex.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
return result;
}
public void run() {
// TODO Автоматически созданная заглушка метода
Session s = createSession();
if (s != null) {
try {
System.out.println("Platform = " + ldnSession.getPlatform());
System.out.println("User = " + ldnSession.getCommonUserName());
} catch (NotesException ex) {
ex.printStackTrace();
}
}
//System.exit(0);
}
}