1 package dinamica.security; 2 3 import java.sql.Connection ; 4 import java.util.HashMap ; 5 import javax.servlet.http.HttpServletRequest ; 6 import javax.sql.DataSource ; 7 8 import dinamica.*; 9 10 30 public class PasswordNotUsed extends AbstractValidator 31 { 32 33 36 public boolean isValid( 37 HttpServletRequest req, 38 Recordset inputParams, 39 HashMap attribs) 40 throws Throwable 41 { 42 43 boolean flag = true; 44 45 String jndiName = (String )getContext().getAttribute("dinamica.security.datasource"); 47 if (jndiName==null) 48 throw new Throwable ("Context attribute [dinamica.security.datasource] is null, check your security filter configuration."); 49 50 DataSource ds = Jndi.getDataSource(jndiName); 52 Connection conn = ds.getConnection(); 53 this.setConnection(conn); 54 55 try 56 { 57 Db db = getDb(); 59 60 boolean bSql = attribs.containsKey("sql"); 62 63 if (!bSql) 64 { 65 throw new Throwable ("[" + this.getClass().getName() + "] Missing attribute [sql] in validator.xml"); 66 } 67 else 68 { 69 70 String query = (String )attribs.get("sql"); 72 73 String sql = getResource(query); 75 sql = getSQL(sql, inputParams); 76 77 Recordset rs = db.get(sql); 79 if (rs.getRecordCount()>0) 80 flag = false; 81 82 } 83 } 84 catch (Throwable e) 85 { 86 throw e; 87 } 88 finally 89 { 90 if (conn!=null) 91 conn.close(); 92 } 93 94 return flag; 95 96 } 97 98 } 99 | Popular Tags |