1 6 7 package com.quikj.application.web.talk.jspbeans; 8 9 import java.sql.*; 10 11 15 public class AceCustomerValidator implements ContactCenterAuthenticatorInterface 16 { 17 18 19 private String jdbcClass; 20 21 22 private String url; 23 24 25 private String user; 26 27 28 private String password; 29 30 31 public AceCustomerValidator() 32 { 33 } 34 35 public String init() 36 { 37 if ((jdbcClass == null) || (url == null)) 38 { 39 return "All required parameters have not been supplied"; 40 } 41 42 return null; 43 } 44 45 public void setParam(String name, String value) 46 { 47 if (name.equals("jdbc") == true) 48 { 49 jdbcClass = value; 50 } 51 else if (name.equals("url") == true) 52 { 53 url = value; 54 } 55 else if (name.equals("user") == true) 56 { 57 user = value; 58 } 59 else if (name.equals("password") == true) 60 { 61 password = value; 62 } 63 } 64 65 public CustomerInformationElement validate(String user, String password) 66 { 67 Connection c = null; 68 69 try 70 { 71 c = getConnection(); 72 if (c == null) 73 { 74 return null; 75 } 76 77 String sql = "select fullname,email,info from ace_restricted_access_user_tbl where user = ? and password = password(?)"; 78 PreparedStatement ps = c.prepareStatement(sql); 79 ps.setString(1, user); 80 ps.setString(2, password); 81 ResultSet rs = ps.executeQuery(); 82 83 if (rs.next() == false) 84 { 85 return null; 86 } 87 88 CustomerInformationElement element = new CustomerInformationElement(); 89 element.setFullName(rs.getString(1)); 90 element.setEmail(rs.getString(2)); 91 element.setInfo(rs.getString(3)); 92 93 c.close(); 94 return element; 95 } 96 catch (Exception ex) 97 { 98 if (c != null) 99 { 100 try 101 { 102 c.close(); 103 } 104 catch (SQLException ex1) 105 { 106 ; 107 } 108 } 109 } 110 111 return null; 112 } 113 114 118 public String getJdbcClass() 119 { 120 return this.jdbcClass; 121 } 122 123 127 public void setJdbcClass(String jdbcClass) 128 { 129 this.jdbcClass = jdbcClass; 130 } 131 132 136 public String getUrl() 137 { 138 return this.url; 139 } 140 141 145 public void setUrl(String url) 146 { 147 this.url = url; 148 } 149 150 154 public String getUser() 155 { 156 return this.user; 157 } 158 159 163 public void setUser(String user) 164 { 165 this.user = user; 166 } 167 168 172 public String getPassword() 173 { 174 return this.password; 175 } 176 177 181 public void setPassword(String password) 182 { 183 this.password = password; 184 } 185 186 private Connection getConnection() 187 throws ClassNotFoundException , InstantiationException , SQLException, IllegalAccessException 188 { 189 Class.forName(jdbcClass).newInstance(); 190 return DriverManager.getConnection(url, user, password); 191 } 192 193 } 194 | Popular Tags |