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(ome.util.SqlAction sql) |
PasswordUtil(ome.util.SqlAction sql,
boolean passwordRequired) |
PasswordUtil(ome.util.SqlAction sql,
boolean passwordRequired,
java.nio.charset.Charset encoding) |
PasswordUtil(ome.util.SqlAction sql,
java.nio.charset.Charset encoding) |
PasswordUtil(ome.util.SqlAction sql,
ome.system.Roles roles,
boolean passwordRequired) |
PasswordUtil(ome.util.SqlAction sql,
ome.system.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.
|
void |
setQueryService(ome.api.IQuery iQuery) |
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(ome.util.SqlAction sql)
public PasswordUtil(ome.util.SqlAction sql, boolean passwordRequired)
public PasswordUtil(ome.util.SqlAction sql, java.nio.charset.Charset encoding)
public PasswordUtil(ome.util.SqlAction sql, boolean passwordRequired, java.nio.charset.Charset encoding)
public PasswordUtil(ome.util.SqlAction sql, ome.system.Roles roles, boolean passwordRequired)
public PasswordUtil(ome.util.SqlAction sql, ome.system.Roles roles, boolean passwordRequired, java.nio.charset.Charset encoding)
public void setQueryService(ome.api.IQuery iQuery)
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
for the guest user, true
for administrators,
otherwise matches the setting of omero.security.password_required
.id
- The user ID.true
or false