Remove empty lines
[remote/remote-ws.git] / src / authentication / Authenticator.java
blob9ed6768e00ac26a198278853a689386daae7e953
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];
11 credentials[0] = new Credential("Project",false);
12 credentials[1] = new Credential("User",false);
13 credentials[2] = new Credential("Password",true);
14 return credentials;
17 protected boolean checkCredentials(String session_id, Credential[] credentials) throws Exception {
18 String checkSQL = "select 1 from user u, project p, user_project up " +
19 "where u.login='"+credentials[1].getValue()+"' " +
20 "and u.password=md5('"+credentials[2].getValue()+"') " +
21 "and p.name='"+credentials[0].getValue()+"' " +
22 "and up.user_id=u.id " +
23 "and up.project_id=p.id";
25 SQLHelper sql = null;
26 ResultSet rs = null;
27 Exception ex=null;
28 boolean result = false;
30 try {
31 sql = new SQLHelper();
32 sql.openDB();
33 rs = sql.retrieve(checkSQL);
34 if (rs.next()) result = true;
35 } catch (Exception e) {
36 ex = e;
37 } finally {
38 sql.closeDB();
39 if (ex != null) throw ex;
41 return result;