Cleanup exception handling
[remote/remote-ws.git] / src / authentication / Authenticator.java
blob371382326408b9bae395c916858433ef4b25019c
1 package authentication;
3 import java.sql.ResultSet;
4 import util.SQLHelper;
6 public class Authenticator extends AbstractAuthenticator {
8 public Credential[] getEmptyCredentials() throws Exception
10 Credential credentials[] = new Credential[3];
12 credentials[0] = new Credential("Project", false);
13 credentials[1] = new Credential("User", false);
14 credentials[2] = new Credential("Password", true);
16 return credentials;
19 protected boolean checkCredentials(String session_id, Credential[] credentials) throws Exception
21 SQLHelper sql = null;
22 String checkSQL = "select 1 from user u, project p, user_project up " +
23 "where u.login='" + credentials[1].getValue() + "' " +
24 "and u.password=md5('" + credentials[2].getValue() + "') " +
25 "and p.name='" + credentials[0].getValue() + "' " +
26 "and up.user_id=u.id " +
27 "and up.project_id=p.id";
29 try {
30 sql = new SQLHelper();
31 sql.openDB();
32 return sql.retrieve(checkSQL).next();
34 } finally {
35 sql.closeDB();