Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java Password Validator

Status
Not open for further replies.

Jdickens

Programmer
Jun 18, 2009
3
MX
Hi there,

For my monthly programming project, I have to develop a boolean method that validates any password on any Web server. The user introduces the account name and its password, and the method returns true if the password belongs to that account. For example, if my Hotmail account is javan00b@hotmail.com and my password is Savitch, the program will run the following method:

System.out.println("Enter your user account");
String account=stdIn.readLine();
System.out.println("Enter your password");
String pass=stdIn.readLine();
boolean valid=validatePassword(account,pass);
if(valid) {System.out.println("Your password is valid");} else {System.out.println("Incorrect password");}

Running the program:

Enter your user account
javan00b@hotmail.com
Enter your password
savitch
Incorrect password

Please refrain from making n00b or stupid posts; I'll just ignore them, so don't waste your time. Just write helpful stuff.
 
Well, I need to write the method in order that I can login an actual server from a Java app. that invokes that method. I've already built the appropiate HTTP request that simulates the form submission, but I'm having some troubles when parsing it to Java.
 
Formulate a specific question regarding the specific difficulty you are having with your solution. Post the relevant bits of your code to support your question.

I will warn you now, this site does not help people with coursework. However, I think that if you can demonstrate that you at least have 'had a good go' at solving this yourself, then we here will try to help you as best we can.

We don't provide a coding service.


Tim
 
I've tried a solution using the Mail class, using Yahoo! POP3 server:

Code:
public class mailClient
{

	String eMail, passWord;
	public mailClient(String eMail, String passWord)
	{
		this.eMail=eMail;
		this.passWord=passWord;
	}
	
	public PasswordAuthentication getPasswordAuthentication()
	{
	        return new PasswordAuthentication(eMail,passWord);
	}
	
	public void checkMail() throws Exception
	{
	
	    Properties props = new Properties();
	
	    String host = "[URL unfurl="true"]http://mail.yahoo.com";[/URL]
	    String provider = "[URL unfurl="true"]http://pop.mail.yahoo.com";[/URL]
	
	    Session session = Session.getDefaultInstance(props, new MailAuthenticator());
	    Store store = session.getStore(provider);
	    store.connect(host, eMail, passWord);
	
	    if(store.isConnected()==true)
	    {
		    System.out.println("Success");
	    }
	    else
	    {
		    System.out.println("Fail");
	    }
	}
}

Note: I'm using the MailAuthenticator class, obtained from
But I have several inquiries about it:
1. According to the Java documentation, the provider is supposed to be the POP3 server. But, when running the method, it throws the javax.mail.NoSuchProviderException. Any idea?
2. The Mail class works only for POP3/SMTP mail servers. What about an HTTP based Hotmail server such as Hotmail? In that case, I've built the appropiate HTTP that simulates the form submission, but parsing it to Java is driving me bonkers. I think the same procedure would apply to validate any other server that requires an account and password, such as any blog or Facebook.
 
Maybe you should stary with a tutorial.

After understanding what yuo're doing, perhaps you will be able to do something that make sense

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top