1 package authentication
;
5 /** This is an abstract class with the generic code for the session
6 * authentication web service. To integrate authentication for a user
7 * account system, this class should be inherited. The abstract methods
8 * should be implemented with the business logic applicable to the user
11 * @author Esben Zeuthen
13 public abstract class AbstractAuthenticator
{
15 /** This function should be implemented to return an array of
16 * empty credential fields applicable for the user account
19 * @return Array of credential objects defining the credentials
20 * needed for authentication.
22 abstract public Credential
[] getEmptyCredentials() throws Exception
;
24 public boolean authenticate(String session_id
, Credential
[] credentials
) throws Exception
26 if (!checkCredentials(session_id
, credentials
))
32 String auth
= "update session set auth=1 where id=" + session_id
;
34 sql
= new SQLHelper();
36 return sql
.update(auth
) == 1;
43 /** This method should be implemented to check the credentials
44 * used for client authentication.
46 * This is the integration point for custom user account
47 * systems. It is also one of the places to perform integration
48 * between the user account system and the mote reservation
51 * @param session_id ID of the session object; for use with
52 * custom session attributes
53 * @param credentials The credentials supplied by the client
55 * @return authentication success or failure.
57 abstract protected boolean checkCredentials(String session_id
, Credential
[] credentials
) throws Exception
;