use of io.clownfish.clownfish.dbentities.CfUser in project Clownfish by rawdog71.
the class CfUserDAOImpl method findById.
@Override
public CfUser findById(Long id) {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery query = (TypedQuery) session.getNamedQuery("CfUser.findById");
query.setParameter("id", id);
CfUser cfuser = (CfUser) query.getSingleResult();
return cfuser;
}
use of io.clownfish.clownfish.dbentities.CfUser in project Clownfish by rawdog71.
the class CfUserDAOImpl method findAll.
@Override
public List<CfUser> findAll() {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery query = (TypedQuery) session.getNamedQuery("CfUser.findAll");
List<CfUser> cfuserlist = query.getResultList();
return cfuserlist;
}
use of io.clownfish.clownfish.dbentities.CfUser in project Clownfish by rawdog71.
the class BackendLoginServlet method processRequest.
protected void processRequest(HttpServletRequest request, HttpServletResponse response) {
Map<String, String[]> parameters = request.getParameterMap();
parameters.keySet().stream().filter((paramname) -> (paramname.compareToIgnoreCase("email") == 0)).map((paramname) -> parameters.get(paramname)).forEach((values) -> {
email = values[0];
});
String inst_email = email;
parameters.keySet().stream().filter((paramname) -> (paramname.compareToIgnoreCase("password") == 0)).map((paramname) -> parameters.get(paramname)).forEach((values) -> {
password = values[0];
});
String inst_password = password;
AuthToken at = null;
if ((null != inst_email) && (null != inst_password)) {
try {
CfUser cfuser = cfuserService.findByEmail(inst_email);
String salt = cfuser.getSalt();
String secure = PasswordUtil.generateSecurePassword(inst_password, salt);
if (secure.compareTo(cfuser.getPasswort()) == 0) {
String token = AuthToken.generateToken(inst_password, salt);
// Tokens valid for 60 minutes
at = new AuthToken(token, new DateTime().plusMinutes(60), cfuser);
authtokenlist.getAuthtokens().put(token, at);
} else {
// Invalid token
at = new AuthToken("", new DateTime(), null);
}
} catch (Exception ex) {
// Invalid token
at = new AuthToken("", new DateTime(), null);
}
}
Gson gson = new Gson();
String json = gson.toJson(at);
response.setContentType("application/json;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
out.print(json);
} catch (IOException ex) {
LOGGER.error(ex.getMessage());
}
}
use of io.clownfish.clownfish.dbentities.CfUser in project Clownfish by rawdog71.
the class UserList method onCreateUser.
public void onCreateUser(ActionEvent actionEvent) {
try {
CfUser newuser = new CfUser();
newuser.setEmail(email);
newuser.setVorname(vorname);
newuser.setNachname(nachname);
newuser.setAssetref(avatar);
newuser.setPasswort(passwort);
String salt = PasswordUtil.getSalt(30);
String secure = PasswordUtil.generateSecurePassword(passwort, salt);
newuser.setSalt(salt);
newuser.setPasswort(secure);
cfuserService.create(newuser);
userlist = cfuserService.findAll();
} catch (ConstraintViolationException ex) {
LOGGER.error(ex.getMessage());
}
}
use of io.clownfish.clownfish.dbentities.CfUser in project Clownfish by rawdog71.
the class CfUserDAOImpl method findByEmail.
@Override
public CfUser findByEmail(String email) {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery query = (TypedQuery) session.getNamedQuery("CfUser.findByEmail");
query.setParameter("email", email);
CfUser cfuser = (CfUser) query.getSingleResult();
return cfuser;
}
Aggregations