Skip to content

Commit

Permalink
Applied cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
salvatore-coppola committed Oct 30, 2023
1 parent 9c44038 commit 436145e
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2023 Eurotech and/or its affiliates and others
*
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* Eurotech
******************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public class IdentityService {

private static final String KURA_NEED_PASSWORD_CHANGE_PROPERTY = "kura.need.password.change";

private UserAdminHelper userAdminHelper;
private ConfigurationService configurationService;
private CryptoService cryptoService;
private final UserAdminHelper userAdminHelper;
private final ConfigurationService configurationService;
private final CryptoService cryptoService;

public IdentityService(CryptoService cryptoService, UserAdmin userAdmin,
ConfigurationService configurationService) {
Expand All @@ -65,11 +65,11 @@ public void createUser(UserDTO user) throws KuraException {

final String password = user.getPassword();
if (password != null) {
this.validateUserPassword(password);
validateUserPassword(password);
}

this.userAdminHelper.createUser(user.getUserName());
this.updateUser(user);
updateUser(user);
} else {
throw new KuraException(KuraErrorCode.BAD_REQUEST, "user " + user.getUserName() + " already exists");
}
Expand Down Expand Up @@ -198,7 +198,7 @@ private void updatePasswordOptions(UserDTO userDTO, final Dictionary<String, Obj
final String password = userDTO.getPassword();

if (password != null) {
this.validateUserPassword(password);
validateUserPassword(password);
try {
credentials.put(KURA_NEED_PASSWORD_CHANGE_PROPERTY, this.cryptoService.sha256Hash(password));
} catch (final Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public PermissionDTO(Set<String> permissions) {
}

public Set<String> getPermissions() {
return permissions;
return this.permissions;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class UserConfigDTO {
private Set<UserDTO> userConfig = new HashSet<>();

public Set<UserDTO> getUserConfig() {
return userConfig;
return this.userConfig;
}

public void setUserConfig(Set<UserDTO> userConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,39 @@ public UserDTO(final String userName, final Set<String> permissions, final boole
}

public String getUserName() {
return userName;
return this.userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public Optional<Boolean> isPasswordAuthEnabled() {
return Optional.ofNullable(passwordAuthEnabled);
return Optional.ofNullable(this.passwordAuthEnabled);
}

public void setPasswordAuthEnabled(boolean passwordAuthEnabled) {
this.passwordAuthEnabled = passwordAuthEnabled;
}

public Optional<Boolean> isPasswordChangeNeeded() {
return Optional.ofNullable(passwordChangeNeeded);
return Optional.ofNullable(this.passwordChangeNeeded);
}

public void setPasswordChangeNeeded(boolean passwordChangeNeeded) {
this.passwordChangeNeeded = passwordChangeNeeded;
}

public Set<String> getPermissions() {
return permissions;
return this.permissions;
}

public void setPermissions(Set<String> permissions) {
this.permissions = permissions;
}

public String getPassword() {
return password;
return this.password;
}

public void setPassword(String password) {
Expand All @@ -87,19 +87,19 @@ public void setPassword(String password) {

@Override
public int hashCode() {
return Objects.hash(userName);
return Objects.hash(this.userName);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
}
if ((obj == null) || (getClass() != obj.getClass())) {
return false;
}
UserDTO other = (UserDTO) obj;
return Objects.equals(userName, other.userName);
return Objects.equals(this.userName, other.userName);
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2023 Eurotech and/or its affiliates and others
*
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* Eurotech
*******************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2023 Eurotech and/or its affiliates and others
*
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* Eurotech
*******************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public ValidatorOptions(int passwordMinimumLength, boolean passwordRequireDigits

public ValidatorOptions(Map<String, Object> configurationProperties) {
if (configurationProperties != null) {
this.passwordMinimumLength = newPasswMinLenghthProperty.get(configurationProperties);
this.passwordRequireDigits = newPassRequireDigits.get(configurationProperties);
this.passwordRequireSpecialChars = newPassRequireSpecialChars.get(configurationProperties);
this.passwordRequireBothCases = newPassRequireBothCases.get(configurationProperties);
this.passwordMinimumLength = this.newPasswMinLenghthProperty.get(configurationProperties);
this.passwordRequireDigits = this.newPassRequireDigits.get(configurationProperties);
this.passwordRequireSpecialChars = this.newPassRequireSpecialChars.get(configurationProperties);
this.passwordRequireBothCases = this.newPassRequireBothCases.get(configurationProperties);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2023 Eurotech and/or its affiliates and others
*
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* Eurotech
*******************************************************************************/
Expand Down Expand Up @@ -41,7 +41,7 @@ public class IdentityRestServiceDependenciesTest {
private static final String REST_ROLE_NAME = "identity";
private static final String KURA_PERMISSION_REST_ROLE = "kura.permission.rest." + REST_ROLE_NAME;

private IdentityRestService service = new IdentityRestService();
private final IdentityRestService service = new IdentityRestService();
private UserAdmin userAdmin;
private CryptoService cryptoService;
private ConfigurationService configurationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public int getType() {

@Override
public Dictionary<String, Object> getProperties() {
Dictionary<String, Object> properties = new Hashtable<String, Object>();
Dictionary<String, Object> properties = new Hashtable<>();
properties.put("kura.need.password.change", this.needPasswordChange);
return properties;
}
Expand All @@ -425,15 +425,15 @@ public boolean hasCredential(String key, Object value) {

@Override
public Dictionary<String, Object> getCredentials() {
Dictionary<String, Object> credentials = new Hashtable<String, Object>();
Dictionary<String, Object> credentials = new Hashtable<>();
credentials.put("kura.password", this.password);

return credentials;
}
}

private static Map<String, Object> defaultValidatorProperties() {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();

properties.put("new.password.min.length", 8);
properties.put("new.password.require.digits", false);
Expand Down

0 comments on commit 436145e

Please sign in to comment.