// in FirstApplet.class:
class FirstApplet extend Applet {
Applet otherApplet = null;
public void init() {
// do your authentification
}
public void start() {
if (authentified==true) {
otherApplet = new SecondApplet();
}
}
}
// in SecondApplet.class:
class SecondApplet extends Applet {
public void init() { ... }
public void start() { ... }
}
another way:
you can also use plain .htaccess / .htpasswd files and let the webserver do the authentification.
once the user is logged in, the user can access the applet.
public class FirstApplet extends Applet {
private boolean authentified = false;
private SecondApplet applet = null;
public void init() {
System.out.println("FirstApplet: init()");
authentified=authentificate();
}
public void start() {
System.out.println("FirstApplet: start() "+authentified);
if (authentified==true) {
applet=new SecondApplet();
applet.init();
applet.start();
}
}
public void stop() {
System.out.println("FirstApplet: stop()");
if (applet!=null) applet.stop();
}
public void destroy() {
System.out.println("FirstApplet: destroy()");
if (applet!=null) applet.destroy();
}
private boolean authentificate() {
System.out.println("FirstApplet: authentificate()");
// ask the user for username and password
// check the password, if it's ok, return true
// if it's not okay, return false
// how to do a login window, see
// http://www.codeguru.com/java/articles/510.shtml
return true;
}
}
public class SecondApplet extends Applet {
public void init() {
System.out.println("SecondApplet(): init()");
}
public void start() {
System.out.println("SecondApplet(): start()");
}
public void stop() {
System.out.println("SecondApplet(): stop()");
}
public void destroy() {
System.out.println("SecondApplet(): destroy()");
}
}