Class Credentials
java.lang.Object
com.norconex.commons.lang.security.Credentials
- All Implemented Interfaces:
Serializable
User credentials with an optionally encrypted password. To be encrypted, there needs to be an encryption key. Without one, the password is assumed not to be encrypted.
Password encryption:
Passwords can be encrypted using EncryptionUtil (or
command-line "encrypt.bat" or "encrypt.sh" if those are available to you).
In order for the password to be decrypted properly, you need
to specify the encryption key used to encrypt it. The key can obtained
from a few supported locations. The combination of the password key
"value" and "source" is used to properly locate the key.
The supported sources are:
key |
The actual encryption key. |
file |
Path to a file containing the encryption key. |
environment |
Name of an environment variable containing the key. |
property |
Name of a JVM system property containing the key. |
- Since:
- 2.0.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCredentials(Credentials copy) Credentials(String username, String password) Creates a new Credentials instance with the supplied username and password.Credentials(String username, String password, EncryptionKey passwordKey) Creates a new Credentials instance with the supplied username, password and password key. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanvoidcopyFrom(Credentials creds) voidcopyTo(Credentials creds) booleanCredential password.Credential password encryption key pointer (provided the password is encrypted).Credential user name.inthashCode()booleanisEmpty()booleanisSet()Whether this credentials instance is set.setPassword(String password) Credential password.setPasswordKey(EncryptionKey passwordKey) Credential password encryption key pointer (provided the password is encrypted).setUsername(String username) Credential user name.toString()
-
Constructor Details
-
Credentials
public Credentials() -
Credentials
Creates a new Credentials instance with the supplied username and password.- Parameters:
username- the usernamepassword- the password- Since:
- 3.0.0
-
Credentials
Creates a new Credentials instance with the supplied username, password and password key.- Parameters:
username- the usernamepassword- the passwordpasswordKey- the password encryption key- Since:
- 3.0.0
-
Credentials
-
-
Method Details
-
isSet
public boolean isSet()Whether this credentials instance is set. That is, if any of user name and password is not blank.- Returns:
trueif set
-
isEmpty
public boolean isEmpty() -
copyTo
-
copyFrom
-
toString
-
getUsername
Credential user name. -
getPassword
Credential password. -
getPasswordKey
Credential password encryption key pointer (provided the password is encrypted). -
setUsername
Credential user name.- Returns:
this.
-
setPassword
Credential password.- Returns:
this.
-
setPasswordKey
Credential password encryption key pointer (provided the password is encrypted).- Returns:
this.
-
equals
-
canEqual
-
hashCode
public int hashCode()
-