14 package cz.vutbr.fit.knot.annotations.web;
21 import java.io.Serializable;
22 import java.security.MessageDigest;
23 import java.security.NoSuchAlgorithmException;
24 import java.util.List;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
27 import javax.faces.bean.ManagedBean;
28 import javax.faces.bean.SessionScoped;
38 public class Login implements Serializable {
60 AppBean.getInstance();
61 PersistM persistMan = AppBean.getPersistenceManager();
68 if (
login.isEmpty() || password.isEmpty()) {
77 md5 = MessageDigest.getInstance(
"MD5");
78 md5.update(password.getBytes());
79 hash = MessageProcessor.getHexString(md5.digest());
80 }
catch (NoSuchAlgorithmException ex) {
83 String msg =
"NoSuchAlgorithmException for computing MD5.";
84 Logger.getLogger(SelectAT.class.getName()).log(Level.SEVERE, msg, ex);
90 Object[] params =
new Object[4];
93 params[2] =
"password";
95 List uList = persistMan.queryDB(
"User.findByCredentials", params);
96 if (uList != null && !uList.isEmpty()) {
97 user = (
User) uList.get(0);
103 uList = persistMan.queryDB(
"User.findByCredentials", params);
104 if (uList != null && !uList.isEmpty()) {
105 user = (
User) uList.get(0);
113 WebSession session = SessionManager.getSession();
114 session.setLoggedUser(user);
121 menuBean.setActualPage(
"index");
168 return MessageProvider.getMessage(
"badCredentials");
Persistence manager (database manipulator)
void setPassword(String password)
Class for manipulating with session.
Class for handling session variables in the web.
static Object getBeanByName(String name)
Singleton for storing global variables.
void setBadCredentials(boolean badCredentials)
void setLogin(String login)
Static class which parses and process XML with messages.
static final int LOG_LEVEL
String getCredentialsError()
static final int LOG_LEVEL_SERVER_ERRORS
boolean getBadCredentials()