-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserService.java
More file actions
46 lines (34 loc) · 1.12 KB
/
Copy pathUserService.java
File metadata and controls
46 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package services;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import org.mindrot.jbcrypt.BCrypt;
import pojos.User;
@ManagedBean(name="userService")
@RequestScoped
public class UserService {
private User user;
public UserService(){
this.user = new User();
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String printIT(){
System.out.println(user.getPassword());
System.out.println(user.getUsername());
String originalPassword = "password";
String generatedSecuredPasswordHash = BCrypt.hashpw(originalPassword, BCrypt.gensalt(12));
System.out.println(generatedSecuredPasswordHash);
boolean matched = BCrypt.checkpw(originalPassword, generatedSecuredPasswordHash);
System.out.println(matched);
// user.setUsername(null);
// user.setPassword(null);
UIViewRoot view = FacesContext.getCurrentInstance().getViewRoot();
return view.getViewId() + "?faces-redirect=true";
}
}