F
freesoft_2000
Hi everyone,
I really need some advice and guidance on the
following code
import javax.swing.*;
import java.util.*;
public class PopupAuthenticator
extends Authenticator {
public PasswordAuthentication
getPasswordAuthentication() {
String username, password;
String result = JOptionPane.showInputDialog(
"Enter 'username,password'");
StringTokenizer st =
new StringTokenizer(result, ",");
username = st.nextToken();
password = st.nextToken();
return new PasswordAuthentication(
username, password);
}
}
As you guys see above there is JOptionPane that requests
both the username and password to access a http website, but i have a
dilemma about someting about the method getPasswordAuthentication() that
i am supposed to overide.
The thing is i am afraid the getPasswordAuthentication() method
may actually return the value of the of both the username and password
before the user has even had the chance to type in the correct
username and password.
As you guys can see that the gui that i set gets the value of
the input optionpane and i was hoping that that the function returns after
the user had pressed "OK" but the thing is i suspect that the function may
be returning as soon as the option pane is shown thus causing both the
values of the username and password to be null.
Am i using the Authenticator class with gui the correct way or
am i missing something??
I really hope someone can explain to me in detail on how this
Authenticator class works and maybe help suggest a possible solution that
can help me out of my dillema.
Any help is greatly appreciated
Thank You
Yours Sincerely
Richard West
I really need some advice and guidance on the
following code
import javax.swing.*;
import java.util.*;
public class PopupAuthenticator
extends Authenticator {
public PasswordAuthentication
getPasswordAuthentication() {
String username, password;
String result = JOptionPane.showInputDialog(
"Enter 'username,password'");
StringTokenizer st =
new StringTokenizer(result, ",");
username = st.nextToken();
password = st.nextToken();
return new PasswordAuthentication(
username, password);
}
}
As you guys see above there is JOptionPane that requests
both the username and password to access a http website, but i have a
dilemma about someting about the method getPasswordAuthentication() that
i am supposed to overide.
The thing is i am afraid the getPasswordAuthentication() method
may actually return the value of the of both the username and password
before the user has even had the chance to type in the correct
username and password.
As you guys can see that the gui that i set gets the value of
the input optionpane and i was hoping that that the function returns after
the user had pressed "OK" but the thing is i suspect that the function may
be returning as soon as the option pane is shown thus causing both the
values of the username and password to be null.
Am i using the Authenticator class with gui the correct way or
am i missing something??
I really hope someone can explain to me in detail on how this
Authenticator class works and maybe help suggest a possible solution that
can help me out of my dillema.
Any help is greatly appreciated
Thank You
Yours Sincerely
Richard West