Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

JPasswordField: getPassword return type

Thread view: 
obhiee@my-deja.com - 18 Jun 2006 15:31 GMT
Possibly OT, but I'm curious.
Why does getPassword return a char[] when getText returned a String?

It seems odd that the older method returned a String object while the
newer method returns a an array of char.

regards,
Abhishek.
ddimitrov - 18 Jun 2006 15:44 GMT
Check the javadoc:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JPasswordField.html#getPassword()

Since in Java the strings are immutable, there is a chance that the
password will stick in the heap for a long time. Thus, it's considered
safer to use the array representation of the password to calculate a
hash and then zero out the array's contents.

If you are not that concerned with security, you can keep using the
getText() or convert the pass to String and use it as plain text.

Dimitar


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.