From 1959c074cacd23e54678f8753dbe2e56b4ea675a Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Mon, 6 Feb 2023 12:52:56 +0100 Subject: [PATCH] Fixed backport issues Signed-off-by: Alberto Codutti --- console/web/src/main/resources/locator.xml | 2 ++ job-engine/app/web/src/main/resources/locator.xml | 2 ++ qa/integration/src/test/resources/locator.xml | 2 ++ rest-api/web/src/main/resources/locator.xml | 2 ++ .../user/shiro/UserCredentialsFactoryImpl.java | 5 ++--- .../user/shiro/UserCredentialsServiceImpl.java | 12 ++++++------ 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/console/web/src/main/resources/locator.xml b/console/web/src/main/resources/locator.xml index 33234f86d2e..c126bbbf6c9 100644 --- a/console/web/src/main/resources/locator.xml +++ b/console/web/src/main/resources/locator.xml @@ -29,6 +29,8 @@ org.eclipse.kapua.service.authentication.registration.RegistrationService org.eclipse.kapua.service.authentication.token.AccessTokenService org.eclipse.kapua.service.authentication.token.AccessTokenFactory + org.eclipse.kapua.service.authentication.user.UserCredentialsService + org.eclipse.kapua.service.authentication.user.UserCredentialsFactory org.eclipse.kapua.service.authorization.AuthorizationService org.eclipse.kapua.service.authorization.permission.PermissionFactory diff --git a/job-engine/app/web/src/main/resources/locator.xml b/job-engine/app/web/src/main/resources/locator.xml index 1445bde183e..84594276f7a 100644 --- a/job-engine/app/web/src/main/resources/locator.xml +++ b/job-engine/app/web/src/main/resources/locator.xml @@ -27,6 +27,8 @@ org.eclipse.kapua.service.authentication.credential.mfa.ScratchCodeService org.eclipse.kapua.service.authentication.token.AccessTokenService org.eclipse.kapua.service.authentication.token.AccessTokenFactory + org.eclipse.kapua.service.authentication.user.UserCredentialsService + org.eclipse.kapua.service.authentication.user.UserCredentialsFactory org.eclipse.kapua.service.authorization.AuthorizationService org.eclipse.kapua.service.authorization.permission.PermissionFactory diff --git a/qa/integration/src/test/resources/locator.xml b/qa/integration/src/test/resources/locator.xml index 9a01739fe71..607b1c97a2a 100644 --- a/qa/integration/src/test/resources/locator.xml +++ b/qa/integration/src/test/resources/locator.xml @@ -31,6 +31,8 @@ org.eclipse.kapua.service.authentication.credential.mfa.ScratchCodeService org.eclipse.kapua.service.authentication.token.AccessTokenService org.eclipse.kapua.service.authentication.token.AccessTokenFactory + org.eclipse.kapua.service.authentication.user.UserCredentialsService + org.eclipse.kapua.service.authentication.user.UserCredentialsFactory org.eclipse.kapua.service.authorization.AuthorizationService org.eclipse.kapua.service.authorization.permission.PermissionFactory diff --git a/rest-api/web/src/main/resources/locator.xml b/rest-api/web/src/main/resources/locator.xml index 45dab61ce0a..94f2980544f 100644 --- a/rest-api/web/src/main/resources/locator.xml +++ b/rest-api/web/src/main/resources/locator.xml @@ -27,6 +27,8 @@ org.eclipse.kapua.service.authentication.credential.mfa.ScratchCodeService org.eclipse.kapua.service.authentication.token.AccessTokenService org.eclipse.kapua.service.authentication.token.AccessTokenFactory + org.eclipse.kapua.service.authentication.user.UserCredentialsService + org.eclipse.kapua.service.authentication.user.UserCredentialsFactory org.eclipse.kapua.service.authorization.AuthorizationService org.eclipse.kapua.service.authorization.permission.PermissionFactory diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/user/shiro/UserCredentialsFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/user/shiro/UserCredentialsFactoryImpl.java index f0c4eeb4634..582f10439a9 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/user/shiro/UserCredentialsFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/user/shiro/UserCredentialsFactoryImpl.java @@ -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() { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/user/shiro/UserCredentialsServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/user/shiro/UserCredentialsServiceImpl.java index 7c807bc0a9b..1013240eb6e 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/user/shiro/UserCredentialsServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/user/shiro/UserCredentialsServiceImpl.java @@ -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; @@ -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"); @@ -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());