Skip to content

Commit

Permalink
Fixed backport issues
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <[email protected]>
  • Loading branch information
Coduz committed Feb 6, 2023
1 parent ec96c7b commit 1959c07
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions console/web/src/main/resources/locator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
<api>org.eclipse.kapua.service.authentication.registration.RegistrationService</api>
<api>org.eclipse.kapua.service.authentication.token.AccessTokenService</api>
<api>org.eclipse.kapua.service.authentication.token.AccessTokenFactory</api>
<api>org.eclipse.kapua.service.authentication.user.UserCredentialsService</api>
<api>org.eclipse.kapua.service.authentication.user.UserCredentialsFactory</api>

<api>org.eclipse.kapua.service.authorization.AuthorizationService</api>
<api>org.eclipse.kapua.service.authorization.permission.PermissionFactory</api>
Expand Down
2 changes: 2 additions & 0 deletions job-engine/app/web/src/main/resources/locator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<api>org.eclipse.kapua.service.authentication.credential.mfa.ScratchCodeService</api>
<api>org.eclipse.kapua.service.authentication.token.AccessTokenService</api>
<api>org.eclipse.kapua.service.authentication.token.AccessTokenFactory</api>
<api>org.eclipse.kapua.service.authentication.user.UserCredentialsService</api>
<api>org.eclipse.kapua.service.authentication.user.UserCredentialsFactory</api>

<api>org.eclipse.kapua.service.authorization.AuthorizationService</api>
<api>org.eclipse.kapua.service.authorization.permission.PermissionFactory</api>
Expand Down
2 changes: 2 additions & 0 deletions qa/integration/src/test/resources/locator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
<api>org.eclipse.kapua.service.authentication.credential.mfa.ScratchCodeService</api>
<api>org.eclipse.kapua.service.authentication.token.AccessTokenService</api>
<api>org.eclipse.kapua.service.authentication.token.AccessTokenFactory</api>
<api>org.eclipse.kapua.service.authentication.user.UserCredentialsService</api>
<api>org.eclipse.kapua.service.authentication.user.UserCredentialsFactory</api>

<api>org.eclipse.kapua.service.authorization.AuthorizationService</api>
<api>org.eclipse.kapua.service.authorization.permission.PermissionFactory</api>
Expand Down
2 changes: 2 additions & 0 deletions rest-api/web/src/main/resources/locator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<api>org.eclipse.kapua.service.authentication.credential.mfa.ScratchCodeService</api>
<api>org.eclipse.kapua.service.authentication.token.AccessTokenService</api>
<api>org.eclipse.kapua.service.authentication.token.AccessTokenFactory</api>
<api>org.eclipse.kapua.service.authentication.user.UserCredentialsService</api>
<api>org.eclipse.kapua.service.authentication.user.UserCredentialsFactory</api>

<api>org.eclipse.kapua.service.authorization.AuthorizationService</api>
<api>org.eclipse.kapua.service.authorization.permission.PermissionFactory</api>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
*******************************************************************************/
package org.eclipse.kapua.service.authentication.user.shiro;

import org.eclipse.kapua.locator.KapuaProvider;
import org.eclipse.kapua.service.authentication.user.PasswordChangeRequest;
import org.eclipse.kapua.service.authentication.user.UserCredentialsFactory;

import javax.inject.Singleton;

@Singleton
@KapuaProvider
public class UserCredentialsFactoryImpl implements UserCredentialsFactory {
@Override
public PasswordChangeRequest newPasswordChangeRequest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.kapua.commons.util.ArgumentValidator;
import org.eclipse.kapua.commons.util.CommonsValidationRegex;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.locator.KapuaProvider;
import org.eclipse.kapua.service.authentication.AuthenticationService;
import org.eclipse.kapua.service.authentication.CredentialsFactory;
import org.eclipse.kapua.service.authentication.UsernamePasswordCredentials;
Expand All @@ -35,16 +36,15 @@
import org.eclipse.kapua.service.user.User;
import org.eclipse.kapua.service.user.UserService;

import javax.inject.Singleton;

/**
* {@link UserCredentialsService} implementation.
*
* @since 2.0.0
*/
@Singleton
@KapuaProvider
public class UserCredentialsServiceImpl implements UserCredentialsService {
private static final int SYSTEM_MAXIMUM_PASSWORD_LENGTH = 255;

@Override
public Credential changePasswordRequest(PasswordChangeRequest passwordChangeRequest) throws KapuaException {
ArgumentValidator.notNull(passwordChangeRequest.getNewPassword(), "passwordChangeRequest.newPassword");
Expand All @@ -70,9 +70,9 @@ public Credential changePasswordRequest(PasswordChangeRequest passwordChangeRequ
CredentialService credentialService = locator.getService(CredentialService.class);
CredentialListResult credentials = credentialService.findByUserId(KapuaSecurityUtils.getSession().getScopeId(), KapuaSecurityUtils.getSession().getUserId());
Credential passwordCredential = credentials.getItems().stream()
.filter(credential -> credential.getCredentialType().equals(CredentialType.PASSWORD))
.findAny()
.orElseThrow(() -> new IllegalStateException("User does not have any credential of type password"));
.filter(credential -> credential.getCredentialType().equals(CredentialType.PASSWORD))
.findAny()
.orElseThrow(() -> new IllegalStateException("User does not have any credential of type password"));

// Validate Password length
int minPasswordLength = credentialService.getMinimumPasswordLength(passwordCredential.getScopeId());
Expand Down

0 comments on commit 1959c07

Please sign in to comment.