public class SimpleSecurityAuthority
Provides a basic security authority based on unique names. No passwords are used - a user is identified by a name which is guarded by a minimal protection scheme. This class is supplied as an example of implementing a security authority and not a robust implementation suitable for long term use.
Constructor and description |
---|
SimpleSecurityAuthority
() Creates a new simple authority. |
Type | Name and description |
---|---|
Challenge |
createChallenge() Creates a new challenge packet containing a timestamp and some random data. |
Response |
createResponse(Challenge c) Creates a response to the challenge based on the currently logged in user. |
UserID |
createUserID(String username) Creates and returns a user ID valid for this authority that represents the given user name. |
UserToken |
createUserToken(UserID user) Creates and returns an authentication token valid for this authority that represents the given user name. |
void |
denyUserAccess(UserID u) Removes a user from the set of permitted users. |
ServiceUserObject |
getUserObject() Returns the authority interface for this service. |
boolean |
init(ServiceSettings s) |
boolean |
isRunning() Returns true iff the service is running. |
void |
logoffUser() Clears the currently logged on user. |
void |
logonUser(UserToken u) Sets the currently logged on user. |
void |
permitUserAccess(UserID u) Adds a user to the set of permitted users. |
boolean |
start() Sets the service running. |
boolean |
stop() Stops the service. |
String |
toString() Returns a string description of this authority. |
boolean |
validateResponse(Challenge c, Response r) Checks if the generated response corresponds to one expected from a permitted user. |
Creates a new simple authority. The current username will be found from the preferences if available under the "user" variable. The system property "org.jcsp.net.security.user" will be checked first and take preference. If no user is found the name "default_user" is assumed.
Creates a new challenge packet containing a timestamp and some random data. The response must be returned within around 1 minute for the response to be considered valid so don't keep it too long.
Creates a response to the challenge based on the currently logged in user.
c
- the challenge to respond to.Creates and returns a user ID valid for this authority that represents the given user name.
username
- the unique user name.Creates and returns an authentication token valid for this authority that represents the given user name. Note that no additional credentials are supplied because this authority does not support passwords or anything more secure (hence the word 'Simple' in its name :).
user
- the user ID to authenticate.Removes a user from the set of permitted users.
u
- the user ID to remove.Returns the authority interface for this service. A seperate user object is returned to avoid giving away the service control interface also.
Initializes the service, setting a current user and the list of permitted users from the XML configuration file. For example:
<SERVICE ...> <SETTING name="logonUser" value="foo@bar.com"/> <SETTING name="permitUser0" value="a"/> <SETTING name="permitUser1" value="b"/> </SETTING>
This sets the current user to be "foo@bar.com" but will allow responses from users "a" and "b".
Returns true iff the service is running.
Clears the currently logged on user. After this call the createResponse
method will
fail until another user is logged in.
Sets the currently logged on user. If there is already a user logged in, they are logged off.
u
- the user's token.Adds a user to the set of permitted users.
u
- the user ID to add.Sets the service running.
Stops the service.
Returns a string description of this authority.
Checks if the generated response corresponds to one expected from a permitted user. The response must have come within a minute of the challenge being generated.
c
- the challenge returned by createChallenge
.r
- the response generated by the other authority.JCSP for Java 1.8 generated 14-10-2016 by Jon Kerridge, Edinburgh Napier University - j dot kerridge at napier dot ac dot uk