Skip to content

Commit

Permalink
Rename UserCredential to UserCredentials
Browse files Browse the repository at this point in the history
  • Loading branch information
MDeLuise authored and Coduz committed Feb 6, 2023
1 parent 64c226f commit ec96c7b
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.eclipse.kapua.service.KapuaService;
import org.eclipse.kapua.service.authentication.credential.Credential;
import org.eclipse.kapua.service.authentication.user.PasswordChangeRequest;
import org.eclipse.kapua.service.authentication.user.UserCredentialService;
import org.eclipse.kapua.service.authentication.user.UserCredentialsService;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
Expand All @@ -30,7 +30,7 @@
@Path("{scopeId}/user/credentials")
public class UserCredential {
private final KapuaLocator locator = KapuaLocator.getInstance();
private final UserCredentialService userCredentialService = locator.getService(UserCredentialService.class);
private final UserCredentialsService userCredentialsService = locator.getService(UserCredentialsService.class);


/**
Expand All @@ -46,6 +46,6 @@ public class UserCredential {
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Credential newPassword(@PathParam("scopeId") ScopeId scopeId, PasswordChangeRequest passwordChangeRequest) throws KapuaException {
return userCredentialService.changePasswordRequest(passwordChangeRequest);
return userCredentialsService.changePasswordRequest(passwordChangeRequest);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ paths:
tags:
- User Credentials
summary: Change the user password
operationId: provisionRequestExecutionCount
operationId: passwordChangeRequest
parameters:
- $ref: '../openapi.yaml#/components/parameters/scopeId'
requestBody:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
import org.eclipse.kapua.service.authentication.token.AccessToken;
import org.eclipse.kapua.service.authentication.token.LoginInfo;
import org.eclipse.kapua.service.authentication.user.PasswordChangeRequest;
import org.eclipse.kapua.service.authentication.user.UserCredentialXmlRegistry;
import org.eclipse.kapua.service.authentication.user.UserCredentialsXmlRegistry;
import org.eclipse.kapua.service.authorization.access.AccessInfo;
import org.eclipse.kapua.service.authorization.access.AccessInfoCreator;
import org.eclipse.kapua.service.authorization.access.AccessInfoListResult;
Expand Down Expand Up @@ -685,7 +685,7 @@ public JaxbContextResolver() {

// User Credentials
PasswordChangeRequest.class,
UserCredentialXmlRegistry.class,
UserCredentialsXmlRegistry.class,

// KapuaEvent
ServiceEvent.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(factoryClass = UserCredentialXmlRegistry.class, factoryMethod = "newPasswordChangeRequest")
@XmlType(factoryClass = UserCredentialsXmlRegistry.class, factoryMethod = "newPasswordChangeRequest")
public interface PasswordChangeRequest {
@XmlElement(name = "currentPassword")
String getCurrentPassword();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

import org.eclipse.kapua.model.KapuaObjectFactory;

public interface UserCredentialFactory extends KapuaObjectFactory {
public interface UserCredentialsFactory extends KapuaObjectFactory {
PasswordChangeRequest newPasswordChangeRequest();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @since 2.0.0
*/
public interface UserCredentialService extends KapuaService {
public interface UserCredentialsService extends KapuaService {

Credential changePasswordRequest(PasswordChangeRequest passwordChangeRequest) throws KapuaException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import javax.xml.bind.annotation.XmlRegistry;

@XmlRegistry
public class UserCredentialXmlRegistry {
public class UserCredentialsXmlRegistry {

private static final KapuaLocator LOCATOR = KapuaLocator.getInstance();
private static final UserCredentialFactory USER_CREDENTIAL_FACTORY = LOCATOR.getFactory(UserCredentialFactory.class);
private static final UserCredentialsFactory USER_CREDENTIAL_FACTORY = LOCATOR.getFactory(UserCredentialsFactory.class);


/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
package org.eclipse.kapua.service.authentication.user.shiro;

import org.eclipse.kapua.service.authentication.user.PasswordChangeRequest;
import org.eclipse.kapua.service.authentication.user.UserCredentialFactory;
import org.eclipse.kapua.service.authentication.user.UserCredentialsFactory;

import javax.inject.Singleton;

@Singleton
public class UserCredentialFactoryImpl implements UserCredentialFactory {
public class UserCredentialsFactoryImpl implements UserCredentialsFactory {
@Override
public PasswordChangeRequest newPasswordChangeRequest() {
return new PasswordChangeRequestImpl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@
import org.eclipse.kapua.service.authentication.shiro.utils.AuthenticationUtils;
import org.eclipse.kapua.service.authentication.shiro.utils.CryptAlgorithm;
import org.eclipse.kapua.service.authentication.user.PasswordChangeRequest;
import org.eclipse.kapua.service.authentication.user.UserCredentialService;
import org.eclipse.kapua.service.authentication.user.UserCredentialsService;
import org.eclipse.kapua.service.user.User;
import org.eclipse.kapua.service.user.UserService;

import javax.inject.Singleton;

/**
* {@link UserCredentialService} implementation.
* {@link UserCredentialsService} implementation.
*
* @since 2.0.0
*/
@Singleton
public class UserCredentialServiceImpl implements UserCredentialService {
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");
ArgumentValidator.notNull(passwordChangeRequest.getCurrentPassword(), "passwordChangeRequest.oldPassword");
ArgumentValidator.notNull(passwordChangeRequest.getCurrentPassword(), "passwordChangeRequest.currentPassword");

return KapuaSecurityUtils.doPrivileged(() -> {
KapuaLocator locator = KapuaLocator.getInstance();
Expand All @@ -64,7 +64,7 @@ public Credential changePasswordRequest(PasswordChangeRequest passwordChangeRequ
try {
authenticationService.verifyCredentials(usernamePasswordCredentials);
} catch (KapuaAuthenticationException e) {
throw new KapuaIllegalArgumentException("passwordChangeRequest.oldPassword", passwordChangeRequest.getCurrentPassword());
throw new KapuaIllegalArgumentException("passwordChangeRequest.currentPassword", passwordChangeRequest.getCurrentPassword());
}

CredentialService credentialService = locator.getService(CredentialService.class);
Expand Down

0 comments on commit ec96c7b

Please sign in to comment.