java - Store user/pass from user created account? -



java - Store user/pass from user created account? -

i'm working on blank programme allow user create business relationship can store balance , withdraw/deposit. 1 time user enters username , password, how can store info user can log in , see balance? i"m not trying create extremely secure, want able store business relationship info , able access later.

this class create business relationship (still work in progress):

import java.awt.flowlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.joptionpane; import javax.swing.jpasswordfield; import javax.swing.jtextfield; public class createaccount extends jframe implements actionlistener { jlabel username = new jlabel("enter username"); jtextfield enterusername = new jtextfield(null, 15); jlabel password = new jlabel("enter password"); jpasswordfield enterpassword = new jpasswordfield(null, 15); jlabel passwordconfirm = new jlabel("confirm password."); jpasswordfield enterconfirmpassword = new jpasswordfield(null, 15); jbutton okbutton = new jbutton("ok"); public createaccount() { add(username); add(enterusername); add(password); add(enterpassword); add(passwordconfirm); add(enterconfirmpassword); add(okbutton); okbutton.addactionlistener(this); settitle("new bank business relationship creation"); setvisible(true); setsize(270, 300); setdefaultcloseoperation(exit_on_close); setlayout(new flowlayout()); } @override public void actionperformed(actionevent e) { char[] pass = enterpassword.getpassword(); string passstring = new string(pass); char[] passconfirm = enterconfirmpassword.getpassword(); string passstringconfirm = new string(passconfirm); string username = enterusername.gettext(); if (e.getsource() == okbutton) { if (!passstring.equals(passstringconfirm) || username.equals(null) || passstring.equals(null) || passstringconfirm.equals(null)) { joptionpane.showmessagedialog(null, "entered invalid username or password!"); enterusername.settext(""); enterpassword.settext(""); enterconfirmpassword.settext(""); } } } }

here business relationship class these accounts stored as:

import javax.swing.joptionpane; public class business relationship { private string name; private double balance; public account(string name, double balance) { getname(); getbalance(); this.name = name; this.balance = balance; } string getname() { homecoming name = joptionpane.showinputdialog("what name?"); } double getbalance() { string userbalance = joptionpane.showinputdialog("how much money deposit?"); homecoming balance = double.parsedouble(userbalance); } public void setname() { this.name = name; } public void setbalance() { this.balance = balance; } }

imho, should utilize database. simple application, can utilize embedded databases such hsql, h2 or derby. migrate mysql, mariadb, or postgresql same api if needs grew later.

jdbc not nice api, extremely portable, considere looking @ jpa has implementation such hibernate, eclipselink or openjpa if want store more utilize information.

and forget, practices recommend store hash of password, never plain text version ...

java persistence

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -