public class PasswordUtil extends Object
AdminImpl
SecuritySystem
,
AdminImpl
Modifier and Type | Class and Description |
---|---|
static class |
PasswordUtil.METHOD |
Modifier and Type | Field and Description |
---|---|
static 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,
Charset encoding) |
PasswordUtil(SqlAction sql,
Charset encoding) |
PasswordUtil(SqlAction sql,
Roles roles,
boolean passwordRequired) |
PasswordUtil(SqlAction sql,
Roles roles,
boolean passwordRequired,
Charset encoding) |
Modifier and Type | Method and Description |
---|---|
void |
changeUserPasswordById(Long id,
String password)
Calls
changeUserPasswordById(Long, String, METHOD) with
"false" as the value of the salt argument in order to provide backwards
compatibility. |
void |
changeUserPasswordById(Long id,
String password,
PasswordUtil.METHOD meth)
Calls either
preparePassword(String) or
prepareSaltedPassword(Long, String) and passes the resulting
value to SqlAction.setUserPassword(Long, String) . |
String |
generateRandomPasswd() |
boolean |
getDnById(Long id) |
String |
getUserPasswordHash(Long id) |
boolean |
isPasswordRequired(Long id)
Returns a boolean based on the supplied user ID and system property
setting.
|
static void |
main(String[] args)
Main method which takes exactly one argument, passes it to
preparePassword(String) and prints the results on
System.out . |
protected String |
passwordDigest(Long userId,
String clearText,
boolean salt) |
String |
passwordDigest(String clearText)
Creates an MD5 hash of the given clear text and base64 encodes it.
|
protected String |
preparePassword(Long userId,
String newPassword,
boolean salt) |
String |
preparePassword(String newPassword) |
String |
prepareSaltedPassword(Long userId,
String newPassword) |
String |
saltedPasswordDigest(Long userId,
String clearText)
Creates an MD5 hash of the given clear text and base64 encodes it.
|
List<String> |
userGroups(String name) |
Long |
userId(String name)
Get the user's ID
|
String |
userName(long id)
Get the user's name
|
public static final String DEFAULT_ENCODING
public PasswordUtil(SqlAction sql)
public PasswordUtil(SqlAction sql, boolean passwordRequired)
public static void main(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 String generateRandomPasswd()
public boolean getDnById(Long id)
public void changeUserPasswordById(Long id, 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(Long id, 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 Long userId(String name)
name
- the user's namenull
if they cannot be foundpublic String userName(long id)
id
- the user's IDnull
if they cannot be foundpublic String passwordDigest(String clearText)
clearText
- the cleartext of the passwordpublic String saltedPasswordDigest(Long userId, String clearText)
userId
- the user's ID, may be null
clearText
- the cleartext of the passwordpublic boolean isPasswordRequired(Long id)
false
. In all other cases
this returns true
.id
- The user ID.true
or false
Version: 5.3.5-ice35-b73
Copyright © 2017 The University of Dundee & Open Microscopy Environment. All Rights Reserved.