Skip to content

Commit ca5edc6

Browse files
Merge pull request #46 from aquality-automation/revert-44-feature/project-id-as-part-of-api-url
Revert "Feature/project id as part of api url"
2 parents b0cebdf + f77bba1 commit ca5edc6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+379
-330
lines changed

src/main/java/main/controllers/Administration/AppSettingsController.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,46 +26,43 @@ public AppSettingsController(UserDto user) {
2626
}
2727

2828
public LdapDto getLdap() throws AqualityException {
29-
if (baseUser.isAdmin()) {
29+
if(baseUser.isAdmin()){
3030
return ldapDao.getAll().get(0);
31-
} else {
31+
}else{
3232
throw new AqualityPermissionsException("Account is not allowed to view LDAP Settings", baseUser);
3333
}
3434
}
35-
3635
public AppSettingsDto getApp() throws AqualityException {
3736
return appSettingsDao.getAll().get(0);
3837
}
3938

4039
public LdapDto create(LdapDto template) throws AqualityException {
41-
if (baseUser.isAdmin()) {
40+
if(baseUser.isAdmin()){
4241
template.setAdminSecret(template.getAdminSecret() == null || template.getAdminSecret().equals("")
4342
? ""
4443
: hideAdminSecret(template.getAdminSecret()));
4544
return ldapDao.create(template);
46-
} else {
45+
}else{
4746
throw new AqualityPermissionsException("Account is not allowed to update LDAP Settings", baseUser);
4847
}
4948
}
5049

5150

5251
@Override
5352
public AppSettingsDto create(AppSettingsDto template) throws AqualityException {
54-
if (baseUser.isAdmin()) {
53+
if(baseUser.isAdmin()){
5554
return appSettingsDao.create(template);
56-
} else {
55+
}else{
5756
throw new AqualityPermissionsException("Account is not allowed to update Application Settings", baseUser);
5857
}
5958
}
6059

61-
@Override
62-
@NotImplemented
60+
@Override @NotImplemented
6361
public List<AppSettingsDto> get(AppSettingsDto entity) throws AqualityException {
6462
throw new UnsupportedOperationException();
6563
}
6664

67-
@Override
68-
@NotImplemented
65+
@Override @NotImplemented
6966
public boolean delete(AppSettingsDto entity) throws AqualityException {
7067
throw new UnsupportedOperationException();
7168
}
@@ -82,11 +79,11 @@ public String getAdminSecret() throws AqualityException {
8279
}
8380

8481
private String hideAdminSecret(String secret) throws AqualityException {
85-
try {
82+
try{
8683
Base64 base64 = new Base64();
87-
secret = base64.encodeToString(("JmbGFzYmRmamtiYXNsZA" + secret + "qYXNkaGxma2poYXNka2xqZmJka2").getBytes("utf-8"));
88-
return base64.encodeToString(("YXNkamhmbGtqYXNkaGx" + secret + "a2poYXNka2xqZmJka2phc2JmbGFzYmRmamtiYXNsZA").getBytes("utf-8"));
89-
} catch (UnsupportedEncodingException e) {
84+
secret = base64.encodeToString(("JmbGFzYmRmamtiYXNsZA"+secret+"qYXNkaGxma2poYXNka2xqZmJka2").getBytes("utf-8"));
85+
return base64.encodeToString(("YXNkamhmbGtqYXNkaGx"+secret+"a2poYXNka2xqZmJka2phc2JmbGFzYmRmamtiYXNsZA").getBytes("utf-8"));
86+
}catch (UnsupportedEncodingException e){
9087
throw new AqualityException("Cannot hide Admin Secret.");
9188
}
9289
}

src/main/java/main/controllers/Administration/EmailSettingsController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ public EmailSettingsDto create(EmailSettingsDto template) throws AqualityExcepti
2929
return emailSettingsDao.create(template);
3030
}
3131

32-
@Override
33-
@NotImplemented
32+
@Override @NotImplemented
3433
public boolean delete(EmailSettingsDto entity) throws AqualityException {
3534
throw new UnsupportedOperationException();
3635
}

src/main/java/main/controllers/Administration/UserController.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public UserController(UserDto user) {
3838

3939
@Override
4040
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){
4343
template.setPassword(saltPassword(template, template.getPassword()));
4444
}
4545
return userDao.create(template);
46-
} else {
46+
}else{
4747
throw new AqualityPermissionsException("Account is not allowed to create User", baseUser);
4848
}
4949
}
@@ -55,9 +55,9 @@ public List<UserDto> get(UserDto template) throws AqualityException {
5555

5656
@Override
5757
public boolean delete(UserDto template) throws AqualityException {
58-
if (baseUser.isAdmin()) {
58+
if(baseUser.isAdmin()){
5959
return userDao.delete(template);
60-
} else {
60+
}else{
6161
throw new AqualityPermissionsException("Account is not allowed to delete User", baseUser);
6262
}
6363
}
@@ -77,7 +77,7 @@ public UserDto updatePassword(PasswordDto password) throws AqualityException {
7777
}
7878

7979
UserDto auth(String authString, boolean ldap) throws AqualityException {
80-
Base64 base64 = new Base64();
80+
Base64 base64= new Base64();
8181
String authStringDecoded = StringUtils.newStringUtf8(base64.decode(authString));
8282
String[] authStringSplit = authStringDecoded.split(":");
8383
ConnectionUrlParser.Pair<String, PrivateKey> privateKeyPair
@@ -94,7 +94,7 @@ UserDto auth(String authString, boolean ldap) throws AqualityException {
9494

9595
UserDto user = ldap ? handleLDAPAuthorization(authStringSplit[0], password) : checkUser(authStringSplit[0], password);
9696

97-
if (user != null) {
97+
if(user != null){
9898
user.setSession_code(generateSessionCode(user));
9999
updateSession(user);
100100
return user;
@@ -113,7 +113,7 @@ private List<UserDto> toPublicUsers(List<UserDto> users) {
113113
}
114114

115115
private String generateSessionCode(UserDto user) {
116-
Base64 base64 = new Base64();
116+
Base64 base64= new Base64();
117117
DateUtils dates = new DateUtils();
118118
String encode = null;
119119
try {
@@ -124,21 +124,21 @@ private String generateSessionCode(UserDto user) {
124124
return encode;
125125
}
126126

127-
private String saltPassword(UserDto user, String password) {
127+
private String saltPassword(UserDto user, String password){
128128
String passHash = DigestUtils.md5Hex(password);
129-
return DigestUtils.md5Hex(user.getEmail() + passHash + "kjr1fdd00das");
129+
return DigestUtils.md5Hex(user.getEmail()+passHash+"kjr1fdd00das");
130130
}
131131

132132
private UserDto checkUser(String user_name, String password) throws AqualityException {
133133
UserDto user = new UserDto();
134134
user.setUser_name(user_name);
135135
List<UserDto> users = userDao.searchAll(user);
136136

137-
if (users.size() > 0) {
137+
if(users.size() > 0){
138138
user = users.get(0);
139139
String correctHex = user.getPassword();
140140
String actualHex = saltPassword(user, password);
141-
if (correctHex.equals(actualHex)) {
141+
if(correctHex.equals(actualHex)){
142142
return user;
143143
}
144144
}
@@ -150,12 +150,12 @@ private UserDto handleLDAPAuthorization(String userName, String password) throws
150150
LDAPAuthenticator ldap = new LDAPAuthenticator();
151151
UserDto user;
152152
user = ldap.tryAuthWithLdap(userName, password);
153-
if (user != null) {
153+
if(user != null){
154154
UserDto templateUser = new UserDto();
155155
templateUser.setUser_name(user.getUser_name());
156156
List<UserDto> users = get(templateUser);
157157

158-
if (users.size() > 0) {
158+
if(users.size() > 0){
159159
user.setId(users.get(0).getId());
160160
}
161161

0 commit comments

Comments
 (0)