I am trying to make a login check using vaadin sqlcontainer. I am getting stuck in trying to make it check the password string as an encrypted password to filter the result.
Anyone know the way to do it?
my code so far:
try {
JDBCConnectionPool connectionPool = new SimpleJDBCConnectionPool("com.mysql.jdbc.Driver", "jdbc:mysql://" + SharedData.ADDRESS + ":3306/" + SharedData.DATABASE + "?useUnicode=true&characterEncoding=UTF-8", "root", "pass");
TableQuery tq = new TableQuery("employees", connectionPool);
SQLContainer container = new SQLContainer(tq);
System.out.println(container.size());
container.addFilter(new Filter("username",ComparisonType.EQUALS, event.getLoginParameter("username")));
container.addFilter(new Filter("password",ComparisonType.EQUALS, event.getLoginParameter("password")));
System.out.println(container.size());
if (container.size() > 0) {
validlogin = true;
Item theitem = container.getItem(container.getIdByIndex(0));
((VaadinworkflowApplication) LoginPanel.this.getApplication()).getStoredUser().setUsername((String) theitem.getItemProperty("username").getValue());
((VaadinworkflowApplication) LoginPanel.this.getApplication()).getStoredUser().setEmailAddress((String) theitem.getItemProperty("email").getValue());
((VaadinworkflowApplication) LoginPanel.this.getApplication()).getStoredUser().setAccessLevel((Integer) theitem.getItemProperty("level").getValue());
((VaadinworkflowApplication) LoginPanel.this.getApplication()).getStoredUser().setFullName((String) theitem.getItemProperty("firstname").getValue() + " " + (String) theitem.getItemProperty("lastname").getValue());
}
connectionPool.destroy();
} catch (Exception e) {
e.printStackTrace();
}