NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

How to make "log in" to authenticate the users of my java application?

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
Beginner Girl



Joined: 03 Dec 2009
Posts: 1

PostPosted: Thu Dec 03, 2009 10:31 pm    Post subject: How to make "log in" to authenticate the users of my java application? Reply with quote

Greetings,

As it's clear from my username, I'm a beginner student in Java..

I've built a project using NetBeans. It's a java application containing JFrame forms. I have a main window which contains 2 buttons. When clicking any one, a specific part will be opened.

Now, I want to add "log in" functionality. I actually don't know whether this is possible or not!
What I want is that when a user clicks on either buttons, log in information are requested first (then checking them with the authorized users which are stored in an Oracle database .. I've already connected my NetBeans application to Oracle). After that, if the user is authorized with the correct username & password, the window will be opened.

Is that possible?
If not, any another idea of achieving the log in?

I really appreciate any help. Thanks in advance!
Back to top
Pat Farrell
Posted via mailing list.





PostPosted: Fri Dec 04, 2009 8:23 pm    Post subject: How to make "log in" to authenticate the users of my java application? Reply with quote

Beginner Girl wrote:
Quote:
Now, I want to add "log in" functionality. I actually don't know whether this is possible or not!
What I want is that when a user click on either buttons, a log in information is requested first (then checking it with the authorized users which are stored in an Oracle database .. I've already connected my NetBeans application to Oracle). After that, if the user is authorized with correct user & pass.. the window will be opened.

Is that possible?
If not, any another idea of achieving the log in?

Of course its possible, its all software.

Sounds like this is a executable program that a user just runs.

All you need to do is set a global variable, something like
boolean isLoggedIn = false;

and test it when the buttons are clicked, if its false, dispatch off to
a login form, and set the value to true when the user is logged in.



--
Pat Farrell
http://www.pfarrell.com/
Back to top
Bayless Kirtley
Posted via mailing list.





PostPosted: Sat Dec 05, 2009 5:44 am    Post subject: How to make "log in" to authenticate the users of my java application? Reply with quote

Hello Beginner Girl,

This is really a Java question rather than Netbeans. But, since you are
new, I'll help you out a bit. Here is a fairly simple although not very
elegant way using Java features. You can improve on the design of the
JOptionPane to make it look better. But, this will work. Note that we
use the JPassword field so the typed value is obscured. The user name
is visible since it uses a JTextField.

// set up dialog
String usrMsg = "Enter username";
JTextField usrFld = new JTextField();
String pwdMsg = "Enter password";
JPasswordField pwdFld = new JPasswordField();
Object[] obj = {usrMsg, usrFld, pwdMsg, pwdFld};
// now get username and password using JOptionPane
int ans = JOptionPane.showOptionDialog(this,
obj, "Enter Password", JOptionPane.OK_OPTION,
JOptionPane.QUESTION_MESSAGE, null, null, null);
// if user did not click OK button then quit
if (ans != JOptionPane.OK_OPTION)
dispose();
// get username and decode password from obscured field
String usr = usrFld.getText();
String pwd = new String(psdFld.getPassword());
// now you have the username and password to validate

Good luck and enjoy.
Bayless


----- Original Message -----
From: "Beginner Girl" <address-removed>
To: <address-removed>
Sent: Thursday, December 03, 2009 4:31 PM
Subject: [nbusers] How to make "log in" to authenticate the users of my java
application?


Quote:
Greetings,

As it's clear from my username, I'm a beginner student in Java..

I've built an application using NetBeans. It's a java project containing
JFrame forms. I have a main window which contains 2 buttons. When clicking
any one, a specific part will be opened.

Now, I want to add "log in" functionality. I actually don't know whether
this is possible or not!
What I want is that when a user click on either buttons, a log in
information is requested first (then checking it with the authorized users
which are stored in an Oracle database .. I've already connected my
NetBeans application to Oracle). After that, if the user is authorized
with correct user & pass.. the window will be opened.

Is that possible?
If not, any another idea of achieving the log in?

I really appreciate any help. Thanks in advance!



Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo