Class UserService
java.lang.Object
es.kukenan.smartfi.microservice.clients.service.UserService
User management service.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AmqpControllerAMQP Controller (for event publishing).private AuditServiceBackoffice endpoints implementation.private intDefault page size in paginated request where page size is not specified.private final org.springframework.data.domain.ExampleMatcherExample matcher configuration.private es.kukenan.smartfi.common.service.jwt.JwtServiceJWT services.private KafkaControllerKafka Controller.private PasswordFormatValidatorPassword format validator.private intPassword length.private StringKey used for generate RSA cipher.private StringKey used for generate RSA cipher.private es.kukenan.smartfi.common.context.RequestContextManagerRequest/execution context manager.private StringKey used for generate hashing for Core cipher.private StringThis micro-service name.private static final StringError message for ian invalid sorting criteria specification.private UserBackofficeRepositoryUserBackofficeRepository repository.private UserCreatedEventMapperUser to UserCreatedEvent mapper.private UserDeviceRepositoryUsers device repository.private UserDocumentRepositoryUser Document repository.private UserEntityMapperUser entity mapper.private UserLanguageEntityMapperUserLanguageEntityMapper mapper.private UserLanguageRepositoryUserLanguageRepository repository.private UserPasswordChangeEventMapperUser to UserPasswordChangeEvent mapper.private UserPasswordResetEventMapperUser to UserPasswordResetEvent mapper.private UserRepositoryUsers repository.private UsersApiClientUsersApiClient usersApiClient.private UserUpdatedEventMapperUser to UserUpdatedEvent mapper. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckUserField(String field, String fieldName) private booleancheckUserLocked(int statusId, int typeId) private es.kukenan.smartfi.common.service.jwt.JwtBearerTokencreateImpersonationToken(es.kukenan.smartfi.common.service.jwt.JwtBearerToken currentToken, String userId) createUser(User user, UserManagementOperationContext context) Create the given user, that must previously exist.Set filter surname to null to avoid errors in case of null values in BBDD for these fields.Find a user by its user identifier.es.kukenan.smartfi.common.api.dtos.ResultsPageDto<es.kukenan.smartfi.microservice.clients.dto.UserDto>findUsers(UsersSearchFilter filter) Search for existing users with the given filtering criteria.es.kukenan.smartfi.microservice.clients.dto.language.UserLanguageResponseDtoGet user languages.es.kukenan.smartfi.microservice.clients.dto.SsoLoginDtogetLoginSsoForUser(String userId, Boolean securityLevel, String userIp, String userAgent) getting sso login access.es.kukenan.smartfi.microservice.clients.dto.UrlBolsaKukenanDtogetUrlBolsaKukenan(String userId, Boolean securityLevel, String userIp, String userAgent) getting url bolsa kukenbank with session.es.kukenan.smartfi.microservice.clients.dto.UserDtogetting personal data for userId.es.kukenan.smartfi.microservice.clients.dto.LoginResponseDtoimpersonateUser(es.kukenan.smartfi.microservice.clients.dto.ImpersonateRequestDto userIdDto, es.kukenan.smartfi.common.service.jwt.WalletAuthenticationJwtImpl authentication) Impersonate the user with a given identifier.private org.springframework.data.domain.PageRequestCreate aPageableinstance from the given paging specification.voidpasswordChange(String userId, es.kukenan.smartfi.microservice.clients.dto.PasswordChangeDto passwordChangeDto, es.kukenan.smartfi.common.service.jwt.WalletAuthenticationJwtImpl authentication, String userIp, String userAgent) Change user password.voidUpdate the persisted data of the given user.es.kukenan.smartfi.microservice.clients.dto.UserDtopatchUserLanguage(String userId, int language) Change user language.private voidpublishPasswordChange(User user) Publish a password change event for the specified user.voidpublishPasswordReset(User user, String password, String userIp, String userAgent) Publish a password reset event for the specified user.voidresetAndSendUserPassword(String userId, boolean audit, String userIp, String userAgent, String channel) Reset user password.private org.springframework.data.domain.SortCreate aSortinstance from the given sorting specification.private es.kukenan.smartfi.common.service.exceptions.UnexpectedExceptionunexpectedException(String msg, Throwable cause) Create (and log) anUnexpectedException.voidUnlock user.voiduserDeviceScaUpdated(String userId, String deviceId) Update user device SCA access date.voiduserForgotPassword(es.kukenan.smartfi.microservice.clients.dto.ForgotPasswordDto forgotPasswordDto, String userIp, String userAgent, String channel) Search user and forgot password if user exist.voiduserUpdateData(String userId, es.kukenan.smartfi.microservice.clients.dto.UserUpdatedDto userUpdateDto, es.kukenan.smartfi.common.service.jwt.WalletAuthenticationJwtImpl authentication) Change user locked flag.
-
Field Details
-
passwordLength
@Value("${client.password.length}") private int passwordLengthPassword length. -
SORT_ERROR
Error message for ian invalid sorting criteria specification.- See Also:
-
exampleMatcher
private final org.springframework.data.domain.ExampleMatcher exampleMatcherExample matcher configuration. -
serviceName
This micro-service name. -
defaultPageSize
@Value("${query.pagination.pageSize.default}") private int defaultPageSizeDefault page size in paginated request where page size is not specified. -
publicKey
Key used for generate RSA cipher. -
privateKey
Key used for generate RSA cipher. -
saltCore
Key used for generate hashing for Core cipher. -
userRepository
Users repository. -
userDeviceRepository
Users device repository. -
userEntityMapper
User entity mapper. -
jwtService
@Autowired private es.kukenan.smartfi.common.service.jwt.JwtService jwtServiceJWT services. -
amqpController
AMQP Controller (for event publishing). -
kafkaController
Kafka Controller. -
requestContextManager
@Autowired private es.kukenan.smartfi.common.context.RequestContextManager requestContextManagerRequest/execution context manager. -
passwordFormatValidator
Password format validator. -
userCreatedEventMapper
User to UserCreatedEvent mapper. -
userUpdatedEventMapper
User to UserUpdatedEvent mapper. -
userPasswordChangeEventMapper
User to UserPasswordChangeEvent mapper. -
userPasswordResetEventMapper
User to UserPasswordResetEvent mapper. -
usersApiClient
UsersApiClient usersApiClient. -
userBackofficeRepository
UserBackofficeRepository repository. -
userLanguageRepository
UserLanguageRepository repository. -
userLanguageEntityMapper
UserLanguageEntityMapper mapper. -
userDocumentRepository
User Document repository. -
auditService
Backoffice endpoints implementation.
-
-
Constructor Details
-
UserService
public UserService()
-
-
Method Details
-
findUser
Find a user by its user identifier.- Parameters:
userId- user identifier.companyId- user company identifier.- Returns:
- the user with the given identifier. If the user does not exist an
nullis returned.
-
createUser
Create the given user, that must previously exist.- Parameters:
user- the new user to create.context- the context of this operation, maybe an onboarding process for example.- Returns:
- the inserted instance data.
-
patchUser
Update the persisted data of the given user.- Parameters:
newUserData- an object that contains the information to update the existing user.oldUserData- previous user information.onboardingUpdate- update is coming from onboarding.
-
findUsers
public es.kukenan.smartfi.common.api.dtos.ResultsPageDto<es.kukenan.smartfi.microservice.clients.dto.UserDto> findUsers(UsersSearchFilter filter) Search for existing users with the given filtering criteria.- Parameters:
filter- the filter criteria.- Returns:
- the users matching the given filtering criteria.
-
impersonateUser
public es.kukenan.smartfi.microservice.clients.dto.LoginResponseDto impersonateUser(es.kukenan.smartfi.microservice.clients.dto.ImpersonateRequestDto userIdDto, es.kukenan.smartfi.common.service.jwt.WalletAuthenticationJwtImpl authentication) Impersonate the user with a given identifier.- Parameters:
userIdDto- the user identifier.authentication- presented credentials. Only JWT authentication is currently supported.- Returns:
- new credentials if the impersonation was successful.
-
passwordChange
public void passwordChange(String userId, es.kukenan.smartfi.microservice.clients.dto.PasswordChangeDto passwordChangeDto, es.kukenan.smartfi.common.service.jwt.WalletAuthenticationJwtImpl authentication, String userIp, String userAgent) Change user password.- Parameters:
userId- User identifierpasswordChangeDto- New password dataauthentication- presented credentials. Only JWT authentication is currently supported.userIp- user real ipuserAgent- user-agent header
-
userDeviceScaUpdated
Update user device SCA access date.- Parameters:
userId- user identifier.deviceId- device identifier.
-
publishPasswordChange
Publish a password change event for the specified user.- Parameters:
user- the user with the changed password.
-
sortedBy
Create aSortinstance from the given sorting specification.- Parameters:
sortedByClause- the sorting specification.- Returns:
- the
Sortinstance from the given sorting specification.
-
page
private org.springframework.data.domain.PageRequest page(Integer pageNumber, Integer pageSize, org.springframework.data.domain.Sort sort) Create aPageableinstance from the given paging specification.- Parameters:
pageNumber- page number, optional default 0.pageSize- page size, optional defaultdefaultPageSize.sort- sorting, optional.- Returns:
- the page request for the given paging specification.
-
createImpersonationToken
private es.kukenan.smartfi.common.service.jwt.JwtBearerToken createImpersonationToken(es.kukenan.smartfi.common.service.jwt.JwtBearerToken currentToken, String userId) -
unexpectedException
private es.kukenan.smartfi.common.service.exceptions.UnexpectedException unexpectedException(String msg, Throwable cause) Create (and log) anUnexpectedException.- Parameters:
msg- the exception message.cause- the exception cause, if any.- Returns:
UnexpectedException.
-
userUpdateData
public void userUpdateData(String userId, es.kukenan.smartfi.microservice.clients.dto.UserUpdatedDto userUpdateDto, es.kukenan.smartfi.common.service.jwt.WalletAuthenticationJwtImpl authentication) Change user locked flag.- Parameters:
userId- User identifier.userUpdateDto- Locked flag data.authentication- presented credentials. Only JWT authentication is currently supported.
-
getUser
getting personal data for userId.- Parameters:
userId- User identifier.- Returns:
- user dto.
-
getLoginSsoForUser
public es.kukenan.smartfi.microservice.clients.dto.SsoLoginDto getLoginSsoForUser(String userId, Boolean securityLevel, String userIp, String userAgent) getting sso login access.- Parameters:
userId- user identifiersecurityLevel- security LeveluserIp- user IpuserAgent- user Agent- Returns:
- ssoLogin dto.
-
getUrlBolsaKukenan
public es.kukenan.smartfi.microservice.clients.dto.UrlBolsaKukenanDto getUrlBolsaKukenan(String userId, Boolean securityLevel, String userIp, String userAgent) getting url bolsa kukenbank with session.- Parameters:
userId- user identifiersecurityLevel- security LeveluserIp- user IpuserAgent- user Agent- Returns:
- urlBolsaKukenbank dto.
-
unlock
Unlock user.- Parameters:
userId- User identifier
-
checkUserLocked
private boolean checkUserLocked(int statusId, int typeId) -
checkUserField
-
getLanguages
public es.kukenan.smartfi.microservice.clients.dto.language.UserLanguageResponseDto getLanguages()Get user languages.- Returns:
- languages.
-
patchUserLanguage
public es.kukenan.smartfi.microservice.clients.dto.UserDto patchUserLanguage(String userId, int language) Change user language.- Parameters:
userId- User identifierlanguage- user language- Returns:
- user changed
-
publishPasswordReset
Publish a password reset event for the specified user.- Parameters:
user- the user with the provisional password.password- Provisional password.userIp- user real ipuserAgent- user-agent header
-
resetAndSendUserPassword
public void resetAndSendUserPassword(String userId, boolean audit, String userIp, String userAgent, String channel) Reset user password.- Parameters:
userId- User identifieraudit- flag for audit processuserIp- user real ipuserAgent- user-agent headerchannel- user channel
-
filterSurnameForNullValues
Set filter surname to null to avoid errors in case of null values in BBDD for these fields.- Parameters:
filter- UserSearchFilter.- Returns:
- modified UserSearchFilter.
-
userForgotPassword
public void userForgotPassword(es.kukenan.smartfi.microservice.clients.dto.ForgotPasswordDto forgotPasswordDto, String userIp, String userAgent, String channel) Search user and forgot password if user exist.- Parameters:
forgotPasswordDto- Request object which contains username of user.userIp- user real ipuserAgent- user-agent headerchannel- user channel
-