Authenticator

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top