@@ -38,12 +38,12 @@ public UserController(UserDto user) {
38
38
39
39
@ Override
40
40
public UserDto create (UserDto template ) throws AqualityException {
41
- if (baseUser .isAdmin () || baseUser .getId ().equals (template .getId ())) {
42
- if (template .getPassword () != null ) {
41
+ if (baseUser .isAdmin () || baseUser .getId ().equals (template .getId ())){
42
+ if (template .getPassword () != null ){
43
43
template .setPassword (saltPassword (template , template .getPassword ()));
44
44
}
45
45
return userDao .create (template );
46
- } else {
46
+ }else {
47
47
throw new AqualityPermissionsException ("Account is not allowed to create User" , baseUser );
48
48
}
49
49
}
@@ -55,9 +55,9 @@ public List<UserDto> get(UserDto template) throws AqualityException {
55
55
56
56
@ Override
57
57
public boolean delete (UserDto template ) throws AqualityException {
58
- if (baseUser .isAdmin ()) {
58
+ if (baseUser .isAdmin ()){
59
59
return userDao .delete (template );
60
- } else {
60
+ }else {
61
61
throw new AqualityPermissionsException ("Account is not allowed to delete User" , baseUser );
62
62
}
63
63
}
@@ -77,7 +77,7 @@ public UserDto updatePassword(PasswordDto password) throws AqualityException {
77
77
}
78
78
79
79
UserDto auth (String authString , boolean ldap ) throws AqualityException {
80
- Base64 base64 = new Base64 ();
80
+ Base64 base64 = new Base64 ();
81
81
String authStringDecoded = StringUtils .newStringUtf8 (base64 .decode (authString ));
82
82
String [] authStringSplit = authStringDecoded .split (":" );
83
83
ConnectionUrlParser .Pair <String , PrivateKey > privateKeyPair
@@ -94,7 +94,7 @@ UserDto auth(String authString, boolean ldap) throws AqualityException {
94
94
95
95
UserDto user = ldap ? handleLDAPAuthorization (authStringSplit [0 ], password ) : checkUser (authStringSplit [0 ], password );
96
96
97
- if (user != null ) {
97
+ if (user != null ){
98
98
user .setSession_code (generateSessionCode (user ));
99
99
updateSession (user );
100
100
return user ;
@@ -113,7 +113,7 @@ private List<UserDto> toPublicUsers(List<UserDto> users) {
113
113
}
114
114
115
115
private String generateSessionCode (UserDto user ) {
116
- Base64 base64 = new Base64 ();
116
+ Base64 base64 = new Base64 ();
117
117
DateUtils dates = new DateUtils ();
118
118
String encode = null ;
119
119
try {
@@ -124,21 +124,21 @@ private String generateSessionCode(UserDto user) {
124
124
return encode ;
125
125
}
126
126
127
- private String saltPassword (UserDto user , String password ) {
127
+ private String saltPassword (UserDto user , String password ){
128
128
String passHash = DigestUtils .md5Hex (password );
129
- return DigestUtils .md5Hex (user .getEmail () + passHash + "kjr1fdd00das" );
129
+ return DigestUtils .md5Hex (user .getEmail ()+ passHash + "kjr1fdd00das" );
130
130
}
131
131
132
132
private UserDto checkUser (String user_name , String password ) throws AqualityException {
133
133
UserDto user = new UserDto ();
134
134
user .setUser_name (user_name );
135
135
List <UserDto > users = userDao .searchAll (user );
136
136
137
- if (users .size () > 0 ) {
137
+ if (users .size () > 0 ){
138
138
user = users .get (0 );
139
139
String correctHex = user .getPassword ();
140
140
String actualHex = saltPassword (user , password );
141
- if (correctHex .equals (actualHex )) {
141
+ if (correctHex .equals (actualHex )){
142
142
return user ;
143
143
}
144
144
}
@@ -150,12 +150,12 @@ private UserDto handleLDAPAuthorization(String userName, String password) throws
150
150
LDAPAuthenticator ldap = new LDAPAuthenticator ();
151
151
UserDto user ;
152
152
user = ldap .tryAuthWithLdap (userName , password );
153
- if (user != null ) {
153
+ if (user != null ){
154
154
UserDto templateUser = new UserDto ();
155
155
templateUser .setUser_name (user .getUser_name ());
156
156
List <UserDto > users = get (templateUser );
157
157
158
- if (users .size () > 0 ) {
158
+ if (users .size () > 0 ){
159
159
user .setId (users .get (0 ).getId ());
160
160
}
161
161
0 commit comments