package accounts;
import javax.ejb.*;
import java.rmi.*;
import javax.naming.*;
import java.util.Properties;
import java.util.Vector;
public class CreateNew {
private String username="";
private String password="";
private String stat_mess="";
private String ser_no="";
private int stat_int;
private String problems="";
//super class
public CreateNew(){
username=null;
password=null;
stat_mess=null;
ser_no=null; }
//standard set-get methods for a bean
public void setUser(String u) { username=u; this.username=username; }
public void setPass(String p) { password=p; this.password=password; }
public String getUser() { return username; }
public String getPass() { return password; }
public String getStatMess() { return stat_mess; }
public void setStatMess(String message) { stat_mess=message; this.stat_mess=stat_mess; }
public String getSerNo() { return ser_no; }
public void setSerNo(String sn) { ser_no=sn; this.ser_no=ser_no; }
public int getStatInt() { return stat_int; }
public void setStatInt(int si) { stat_int=si; this.stat_int=stat_int; }
public void SignUp(String us,String pa,String brow,String je,String pl) {
String browser=brow;
String java_en=je;
String plugins=pl;
setUser(us);
setPass(pa);
try{
Properties p=new Properties();
// put information about the vendor-specific EJB client context factory
p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
Context ctx = new InitialContext(p);
// get a reference to the home interface
cylikon.PreferencesEJB.CreateAccountHome home = (cylikon.PreferencesEJB.CreateAccountHome)
ctx.lookup("NewAccounts");
// run the ejbCreate method to get a reference to the remote interface and its methods...
cylikon.PreferencesEJB.CreateAccount new_acc = home.create();
// invoke the sign-up method (void) so we can get values from the other methods in
// the remote interface
Vector v = new_acc.DoSignup(getUser(),getPass(),browser,java_en,plugins);
if (v.size() ==3) {
setStatInt(Integer.valueOf(v.elementAt(0).toString().trim()).intValue());
setStatMess(v.elementAt(1).toString());
setSerNo(v.elementAt(2).toString().trim());
} else {
setStatInt(0);
setStatMess("System Error: Sign-up failed.");
}
} catch (Throwable t) { problems="ERROR creating new account.
There appears to be a problem with our site.
Please email the site owner with a copy of this message and alert them to the problem.
"+t+t.getMessage(); }
} //end getStat() method
public String ListProblems() { return problems; }
} //end of class