I am using a JPasswordField
in my program. When I ask getPassword()
, I get a char[]
array. But when I add an ActionListener
to the JPasswordField
and ask getActionCommand()
, I get the password as a String
. Is this password save in the event object as String
? Isn't this a security issue?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
When you set no action command for a component, the text in it will be the action command. This is why you are getting the password.
Even for
JTextField
alsoThis is a security issue because you are getting password as String which is immutable rather than a
char[]
Whenever an explicit action command is not set, the text in the component will be sent to the
ActionEvent
constructor though you didn't specifically set it as action command. Thecommand
parameter can benull
though, but it is not recommended to benull
, therefore the text in the component is the action command by default. If there is no password in theJPasswordField
an empty string will be the action command.Don't try setting action command to
null
, if it isnull
, then the text in theJPasswordField
will be the action command. The problem comes again.So i would recommend you to set some action command for the
JPasswordField
without leaving it like that for now until this is rectified by Oracle.