org.hackystat.telemetry.service.server
Class Authenticator
java.lang.Object
org.restlet.Uniform
org.restlet.Restlet
org.restlet.Filter
org.restlet.Guard
org.hackystat.telemetry.service.server.Authenticator
public class Authenticator
- extends org.restlet.Guard
Performs authentication of each HTTP request using HTTP Basic authentication. Checks
user/password credentials by pinging SensorBase, then caching authentic user/password
combinations. If a cached user/password combo does not match the current user/password combo,
then the SensorBase is pinged again (because maybe the user has changed their password recently).
Because this resource will always want to communicate with the underlying DailyProjectData
service, this Authenticator also creates a map of user-to-DailyProjectDataClient instances which
can be retrieved from the server context. This keeps the user password info in this class, while
making the DailyProjectDataClient instance available to the service.
- Author:
- Philip Johnson
Fields inherited from class org.restlet.Guard |
AUTHENTICATION_INVALID, AUTHENTICATION_MISSING, AUTHENTICATION_STALE, AUTHENTICATION_VALID, DEFAULT_NONCE_LIFESPAN_MILLIS |
Fields inherited from class org.restlet.Filter |
CONTINUE, SKIP, STOP |
Constructor Summary |
Authenticator(org.restlet.Context context,
java.lang.String sensorBaseHost,
java.lang.String dpdHost)
Initializes this Guard to do HTTP Basic authentication. |
Method Summary |
boolean |
checkSecret(org.restlet.data.Request request,
java.lang.String identifier,
char[] secretCharArray)
Returns true if the passed credentials are OK. |
Methods inherited from class org.restlet.Guard |
accept, authenticate, authorize, challenge, challenge, checkSecret, doHandle, findSecret, forbid, getDomainUris, getNonceLifespan, getRealm, getScheme, getSecretResolver, getSecrets, getServerKey, isRechallengeEnabled, setDomainUris, setNonceLifespan, setRealm, setRechallengeEnabled, setScheme, setSecretResolver, setServerKey |
Methods inherited from class org.restlet.Filter |
afterHandle, beforeHandle, getNext, handle, hasNext, setNext, setNext |
Methods inherited from class org.restlet.Restlet |
getApplication, getContext, getLogger, init, isStarted, isStopped, setContext, start, stop |
Methods inherited from class org.restlet.Uniform |
delete, delete, get, get, handle, head, head, options, options, post, post, put, put |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AUTHENTICATOR_DPD_CLIENTS_KEY
public static final java.lang.String AUTHENTICATOR_DPD_CLIENTS_KEY
- The key to be used to retrieve the DailyProjectDataClient map from the server context.
- See Also:
- Constant Field Values
AUTHENTICATOR_SENSORBASE_CLIENTS_KEY
public static final java.lang.String AUTHENTICATOR_SENSORBASE_CLIENTS_KEY
- The key to be used to retrieve the SensorbaseClient map from the server context.
- See Also:
- Constant Field Values
Authenticator
public Authenticator(org.restlet.Context context,
java.lang.String sensorBaseHost,
java.lang.String dpdHost)
- Initializes this Guard to do HTTP Basic authentication. Puts the credentials map in the server
context so that Resources can get the password associated with the uriUser for their own
invocations to the SensorBase.
- Parameters:
context
- The server context.sensorBaseHost
- The sensorbase service, such as 'http://localhost:9876/sensorbase/'.dpdHost
- The DPD service, such as 'http://localhost:9877/dailyprojectdata/'.
checkSecret
public boolean checkSecret(org.restlet.data.Request request,
java.lang.String identifier,
char[] secretCharArray)
- Returns true if the passed credentials are OK.
- Overrides:
checkSecret
in class org.restlet.Guard
- Parameters:
request
- Ignored.identifier
- The account name.secretCharArray
- The password.
- Returns:
- If the credentials are valid.