Ask for Username and Password while Opening an Applet

Can we code such a way that , While we open an Applet , It should ask for User and password and upon sucessful validation , the Main applet must be loaded !Any Suggestions Please !Thanks .....
[213 byte] By [IT_Skilla] at [2007-9-29 19:47:07]
# 1
create two applest, a loader applet with the authentification and then dynamically load the other applet.i do this with an Applet and a JApplet. my loader-Applet checks java version, and if everything is okay, it loads the JApplet applet.
hamstaa at 2007-7-15 21:31:44 > top of Java-index,Security,Signed Applets...
# 2
to be more specific can u pls give me a simple example?
IT_Skilla at 2007-7-15 21:31:44 > top of Java-index,Security,Signed Applets...
# 3

// 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.

hamstaa at 2007-7-15 21:31:44 > top of Java-index,Security,Signed Applets...
# 4

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;

}

}

hamstaa at 2007-7-15 21:31:44 > top of Java-index,Security,Signed Applets...
# 5

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()");

}

}

hamstaa at 2007-7-15 21:31:45 > top of Java-index,Security,Signed Applets...
# 6
Thanks for ur efforts ! Can u pls give me the steps for configuring tomcat - to accept htaccess and htpass..Thanks!!
IT_Skilla at 2007-7-15 21:31:45 > top of Java-index,Security,Signed Applets...
# 7
no, because that is not the right forum these issues.go and look for another forum, search google or buy a book.there is really enough information about that in the net
hamstaa at 2007-7-15 21:31:45 > top of Java-index,Security,Signed Applets...