com.apamax.authentication
Event CachedAuthentication


An authentication database storing hashed and salted passwords in a MemoryStore database either in memory or on disk. Includes a session cache for authenticating with a session token instead.
See Also:
com.apamax.authentication.CachedAuthentication#createFromStore() - CachedAuthentication objects must be created using one of the static create actions.
com.apamax.authentication.CachedAuthentication#createFromPath() - CachedAuthentication objects must be created using one of the static create actions.
com.apamax.authentication.CachedAuthentication#createInMemory() - CachedAuthentication objects must be created using one of the static create actions.
com.apamax.authentication.CachedAuthentication#initialize() - CachedAuthentication objects must be initialized after creation using the initialize action.

Action summary
 voidaddUser(string username, string password, sequence<string> groups)

Add a user to the authentication database. Replaces an existing user's password. The password is stored salted and hashed using MD5 crypt() password hashing.
 com.apamax.authentication.AuthResultcheckHeader(string authHeader)

Check an HTTP Authorization header. Will validate either an HTTP Basic auth header or a CacheToken session cache token.
 com.apamax.authentication.AuthResultcheckRequest(com.softwareag.connectivity.httpclient.Request req)

Check the HTTP Authorization header in a Request. Will validate either an HTTP Basic auth header or a CacheToken session cache token.
 booleancheckUser(string username, string password)

Check a users password.
 com.apamax.authentication.CachedAuthenticationstatic createFromPath(string path, integer timeoutSecs, integer maxSessionLengthSecs)

Create an CachedAuthentication database in the given path on disk.
 com.apamax.authentication.CachedAuthenticationstatic createFromStore(com.apama.memorystore.Store s, integer timeoutSecs, integer maxSessionLengthSecs)

Create a CachedAuthentication database within an already created and prepared store in the application.
 com.apamax.authentication.CachedAuthenticationstatic createInMemory(integer timeoutSecs, integer maxSessionLengthSecs)

Create an CachedAuthentication database purely in memory. The contents will not persist between runs of the correlator.
 sequence<string>getGroups(string username)

Return the groups for a given user.
 booleanhasGroup(string username, string #group)

Checks if a user is a member of a given group.
 booleanhasUser(string username)

Returns true if the database has a user of a given name.
 integerinitialize()

Initialize the CachedAuthentication database. The database cannot be used until this has completed and routed an AuthenticationInitialized event. It should be called like:
 on AuthenticationInitialized(auth.initialize()) { // you can use auth here } 
 voidremoveUser(string username)

Remove a user from the authentication database. Does nothing silently if the user does not exist.
 voidsetGroups(string username, sequence<string> groups)

Set the groups of a user.
 voidsetPassword(string username, string password)

Set the password of a user.
 
Action detail

addUser

void addUser(string username, string password, sequence<string> groups)
Add a user to the authentication database. Replaces an existing user's password. The password is stored salted and hashed using MD5 crypt() password hashing.
Parameters:
username - The username of the new user.
password - The password of the new user.
groups

checkHeader

com.apamax.authentication.AuthResult checkHeader(string authHeader)
Check an HTTP Authorization header. Will validate either an HTTP Basic auth header or a CacheToken session cache token.
Parameters:
authHeader - Either an HTTP Basic auth header or a CacheToken session cache token.
Returns:
An AuthResult describing whether the header was validated, the user it corresponds to and a new authentication token to use
Throws:
IllegalArgumentException If the header is not a properly formed HTTP basic header.

checkRequest

com.apamax.authentication.AuthResult checkRequest(com.softwareag.connectivity.httpclient.Request req)
Check the HTTP Authorization header in a Request. Will validate either an HTTP Basic auth header or a CacheToken session cache token.
Parameters:
req - The request object to check.
Returns:
An AuthResult describing whether the header was validated, the user it corresponds to and a new authentication token to use
Throws:
IllegalArgumentException If the header is not a properly formed HTTP basic header.

checkUser

boolean checkUser(string username, string password)
Check a users password.
Parameters:
username - The username to check.
password - The password to check.
Returns:
True if the user is in the database and the password matches, false otherwise.

createFromPath

com.apamax.authentication.CachedAuthentication static createFromPath(string path, integer timeoutSecs, integer maxSessionLengthSecs)
Create an CachedAuthentication database in the given path on disk.
Parameters:
path
timeoutSecs
maxSessionLengthSecs
Returns:
A new CachedAuthentication object.
See Also:
com.apamax.authentication.CachedAuthentication#initialize() - The CachedAuthentication object must be initialized after creation.

createFromStore

com.apamax.authentication.CachedAuthentication static createFromStore(com.apama.memorystore.Store s, integer timeoutSecs, integer maxSessionLengthSecs)
Create a CachedAuthentication database within an already created and prepared store in the application.
Parameters:
s - A prepared and open Store object.
timeoutSecs
maxSessionLengthSecs
Returns:
A new CachedAuthentication object.
See Also:
com.apamax.authentication.CachedAuthentication#initialize() - The CachedAuthentication object must be initialized after creation.

createInMemory

com.apamax.authentication.CachedAuthentication static createInMemory(integer timeoutSecs, integer maxSessionLengthSecs)
Create an CachedAuthentication database purely in memory. The contents will not persist between runs of the correlator.
Parameters:
timeoutSecs
maxSessionLengthSecs
Returns:
A new CachedAuthentication object.
See Also:
com.apamax.authentication.CachedAuthentication#initialize() - The CachedAuthentication object must be initialized after creation.

getGroups

sequence<string> getGroups(string username)
Return the groups for a given user.
Parameters:
username - The username to check.
Returns:
The groups the user is a member of.
Throws:
IllegalArgumentException If the username is not found.

hasGroup

boolean hasGroup(string username, string #group)
Checks if a user is a member of a given group.
Parameters:
username - The username to check.
#group - The group to check.
Returns:
True if the username exists and is in the group, false otherwise.

hasUser

boolean hasUser(string username)
Returns true if the database has a user of a given name.
Parameters:
username - The name of the user to check.
Returns:
True if the database has the user, false if not.

initialize

integer initialize()
Initialize the CachedAuthentication database. The database cannot be used until this has completed and routed an AuthenticationInitialized event. It should be called like:
 on AuthenticationInitialized(auth.initialize()) { // you can use auth here } 
Returns:
An ID for the associated AuthenticationInitialized completion event.

removeUser

void removeUser(string username)
Remove a user from the authentication database. Does nothing silently if the user does not exist.
Parameters:
username - The username of the user to remove.

setGroups

void setGroups(string username, sequence<string> groups)
Set the groups of a user.
Parameters:
username
groups - The replacement groups.
Throws:
IllegalArgumentException if the username is not found.

setPassword

void setPassword(string username, string password)
Set the password of a user.
Parameters:
username
password - The new password.
Throws:
IllegalArgumentException if the username is not found.