public class PasswordUtil
extends java.lang.Object
AdminImpl
SecuritySystem
,
AdminImpl
Modifier and Type | Class and Description |
---|---|
static class |
PasswordUtil.METHOD |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_ENCODING
The default encoding for converting plain text passwords to byte arrays
(UTF-8)
|
Constructor and Description |
---|
PasswordUtil(SqlAction sql) |
PasswordUtil(SqlAction sql,
boolean passwordRequired) |
PasswordUtil(SqlAction sql,
boolean passwordRequired,
java.nio.charset.Charset encoding) |
PasswordUtil(SqlAction sql,
java.nio.charset.Charset encoding) |
PasswordUtil(SqlAction sql,
Roles roles,
boolean passwordRequired) |
PasswordUtil(SqlAction sql,
Roles roles,
boolean passwordRequired,
java.nio.charset.Charset encoding) |
Modifier and Type | Method and Description |
---|---|
void |
changeUserPasswordById(java.lang.Long id,
java.lang.String password)
Calls
changeUserPasswordById(Long, String, METHOD) with
"false" as the value of the salt argument in order to provide backwards
compatibility. |
void |
changeUserPasswordById(java.lang.Long id,
java.lang.String password,
PasswordUtil.METHOD meth)
Calls either
preparePassword(String) or
prepareSaltedPassword(Long, String) and passes the resulting
value to SqlAction.setUserPassword(Long, String) . |
java.lang.String |
generateRandomPasswd() |
boolean |
getDnById(java.lang.Long id) |
java.lang.String |
getUserPasswordHash(java.lang.Long id) |
boolean |
isPasswordRequired(java.lang.Long id)
Returns a boolean based on the supplied user ID and system property
setting.
|
static void |
main(java.lang.String[] args)
Main method which takes exactly one argument, passes it to
preparePassword(String) and prints the results on
System.out . |
protected java.lang.String |
passwordDigest(java.lang.Long userId,
java.lang.String clearText,
boolean salt) |
java.lang.String |
passwordDigest(java.lang.String clearText)
Creates an MD5 hash of the given clear text and base64 encodes it.
|
protected java.lang.String |
preparePassword(java.lang.Long userId,
java.lang.String newPassword,
boolean salt) |
java.lang.String |
preparePassword(java.lang.String newPassword) |
java.lang.String |
prepareSaltedPassword(java.lang.Long userId,
java.lang.String newPassword) |
java.lang.String |
saltedPasswordDigest(java.lang.Long userId,
java.lang.String clearText)
Creates an MD5 hash of the given clear text and base64 encodes it.
|
java.util.List<java.lang.String> |
userGroups(java.lang.String name) |
java.lang.Long |
userId(java.lang.String name)
Get the user's ID
|
java.lang.String |
userName(long id)
Get the user's name
|
public static final java.lang.String DEFAULT_ENCODING
public PasswordUtil(SqlAction sql)
public PasswordUtil(SqlAction sql, boolean passwordRequired)
public PasswordUtil(SqlAction sql, java.nio.charset.Charset encoding)
public PasswordUtil(SqlAction sql, boolean passwordRequired, java.nio.charset.Charset encoding)
public static void main(java.lang.String[] args)
preparePassword(String)
and prints the results on
System.out
. This is used by the build system to define the
"@ROOTPASS@" placeholder in data.sql.args
- the command-line argumentspublic java.lang.String generateRandomPasswd()
public boolean getDnById(java.lang.Long id)
public void changeUserPasswordById(java.lang.Long id, java.lang.String password)
changeUserPasswordById(Long, String, METHOD)
with
"false" as the value of the salt argument in order to provide backwards
compatibility.id
- the user IDpassword
- the passwordpublic void changeUserPasswordById(java.lang.Long id, java.lang.String password, PasswordUtil.METHOD meth)
preparePassword(String)
or
prepareSaltedPassword(Long, String)
and passes the resulting
value to SqlAction.setUserPassword(Long, String)
.
An InternalException
is thrown if the modification is not
successful, which should only occur if the user has been deleted.id
- the user IDpassword
- the passwordmeth
- how to encode the passwordpublic java.lang.String getUserPasswordHash(java.lang.Long id)
public java.lang.Long userId(java.lang.String name)
name
- the user's namenull
if they cannot be foundpublic java.lang.String userName(long id)
id
- the user's IDnull
if they cannot be foundpublic java.util.List<java.lang.String> userGroups(java.lang.String name)
public java.lang.String preparePassword(java.lang.String newPassword)
public java.lang.String prepareSaltedPassword(java.lang.Long userId, java.lang.String newPassword)
protected java.lang.String preparePassword(java.lang.Long userId, java.lang.String newPassword, boolean salt)
public java.lang.String passwordDigest(java.lang.String clearText)
clearText
- the cleartext of the passwordpublic java.lang.String saltedPasswordDigest(java.lang.Long userId, java.lang.String clearText)
userId
- the user's ID, may be null
clearText
- the cleartext of the passwordprotected java.lang.String passwordDigest(java.lang.Long userId, java.lang.String clearText, boolean salt)
public boolean isPasswordRequired(java.lang.Long id)
false
. In all other cases
this returns true
.id
- The user ID.true
or false
Version: 5.4.4-ice35-b82
Copyright © 2018 The University of Dundee & Open Microscopy Environment. All Rights Reserved.