1 package com.srv4pos.server.api.user;
2
3 import com.srv4pos.server.api.auth.UserRole;
4 import com.srv4pos.server.api.infrastructure.Constraints;
5 import com.srv4pos.server.api.infrastructure.Info;
6 import org.springframework.roo.addon.javabean.RooJavaBean;
7 import org.springframework.roo.addon.json.RooJson;
8 import org.springframework.roo.addon.tostring.RooToString;
9
10 import javax.validation.constraints.NotNull;
11 import javax.validation.constraints.Pattern;
12 import javax.validation.constraints.Size;
13
14
15
16
17
18 @RooJavaBean
19 @RooToString
20 @RooJson(deepSerialize = true)
21 public class UserRegistrationInfo implements Info {
22
23
24
25
26 @NotNull
27 private boolean deleted = Boolean.FALSE;
28
29 @NotNull
30 @Size(max = 50, min = 1)
31 private String username;
32
33 @NotNull
34 @Size(max = 50, min = 6)
35 @Pattern(regexp = Constraints.EMAIL_REGEX)
36 private String email;
37
38 @NotNull
39 private UserRole role;
40
41
42
43
44
45 private Long softwareVendor;
46
47
48 @NotNull
49 @Size(min = 6, max = 64)
50 @Pattern.List({
51 @Pattern(regexp = Constraints.PASSWORD_REGEX_CONTAIN_DIGIT, message = "Password must contain at least one digit."),
52 @Pattern(regexp = Constraints.PASSWORD_REGEX_CONTAIN_LOWERCASE_LETTER, message = "Password must contain at least one lowercase letter."),
53 @Pattern(regexp = Constraints.PASSWORD_REGEX_CONTAIN_UPPERCASE_LETTER, message = "Password must contain at least one upper letter."),
54 @Pattern(regexp = Constraints.PASSWORD_REGEX_CONTAIN_SPECIAL_CHARACTER, message ="Password must contain at least one special character."),
55 @Pattern(regexp = Constraints.PASSWORD_REGEX_NO_CONTAIN_SPACE, message = "Password must contain no whitespace.")
56 })
57 private String password;
58
59
60
61
62
63
64 public UserInfo toUserInfo() {
65 final UserInfo userInfo = new UserInfo();
66 userInfo.setDeleted(isDeleted());
67 userInfo.setEmail(getEmail());
68 userInfo.setRole(getRole());
69 userInfo.setSoftwareVendor(getSoftwareVendor());
70 userInfo.setUsername(getUsername());
71 return userInfo;
72 }
73 }