public class SecurityContext
extends java.lang.Object
Constructor and Description |
---|
SecurityContext() |
Modifier and Type | Method and Description |
---|---|
static void |
auth(java.lang.String id)
Authenticates the specified user.
|
static void |
authClear()
Removes any previous authentication.
|
static void |
authHash(java.lang.String id,
java.lang.String suffix,
java.lang.String hash)
Authenticates the specified user with an MD5 two-step hash.
|
static void |
authToken(java.lang.String token)
Authenticates with a user authentication token.
|
static User |
currentUser()
Returns the currently authenticated user for this thread.
|
static boolean |
hasAccess(java.lang.String path,
java.lang.String permission)
Checks if the currently authenticated user has has access
permission for a storage path.
|
static boolean |
hasAccess(User user,
java.lang.String path,
java.lang.String permission)
Checks if the specified user has has access permission for a
storage path.
|
static boolean |
hasInternalAccess(java.lang.String path)
Checks if the currently authenticated user has internal access
to a storage path.
|
static boolean |
hasReadAccess(java.lang.String path)
Checks if the currently authenticated user has read access to
a storage path.
|
static boolean |
hasSearchAccess(java.lang.String path)
Checks if the currently authenticated user has search access to
a storage path.
|
static boolean |
hasWriteAccess(java.lang.String path)
Checks if the currently authenticated user has write access to
a storage path.
|
static void |
init(Storage storage)
Initializes the security context.
|
static java.lang.String |
nonce()
Creates a unique number to be used once for hashing.
|
static void |
verifyNonce(java.lang.String nonce)
Verifies that the specified nonce is sufficiently recently
generated to be acceptable.
|
public static void init(Storage storage) throws StorageException
storage
- the data storage to useStorageException
- if the storage couldn't be read or
writtenpublic static User currentUser()
public static boolean hasInternalAccess(java.lang.String path)
path
- the object storage pathpublic static boolean hasReadAccess(java.lang.String path)
path
- the object storage pathpublic static boolean hasSearchAccess(java.lang.String path)
path
- the object storage pathpublic static boolean hasWriteAccess(java.lang.String path)
path
- the object storage pathpublic static boolean hasAccess(java.lang.String path, java.lang.String permission)
path
- the object storage pathpermission
- the requested permissionRole.hasAccess(String, String)
public static boolean hasAccess(User user, java.lang.String path, java.lang.String permission)
user
- the user to check, or null or anonymouspath
- the object storage pathpermission
- the requested permissionRole.hasAccess(String, String)
public static java.lang.String nonce()
public static void verifyNonce(java.lang.String nonce) throws java.lang.SecurityException
nonce
- the nonce to checkjava.lang.SecurityException
- if the nonce was invalidpublic static void auth(java.lang.String id) throws java.lang.SecurityException
id
- the unique user idjava.lang.SecurityException
- if the user failed authenticationpublic static void authHash(java.lang.String id, java.lang.String suffix, java.lang.String hash) throws java.lang.Exception
id
- the unique user idsuffix
- the user password hash suffix to appendhash
- the expected hashed resultjava.lang.Exception
- if the authentication failedpublic static void authToken(java.lang.String token) throws java.lang.Exception
token
- the authentication tokenjava.lang.Exception
- if the authentication failedpublic static void authClear()