java.lang.Object
es.kukenan.smartfi.microservice.clients.service.UserService

@Service public class UserService extends Object
User management service.
  • Field Details

    • passwordLength

      @Value("${client.password.length}") private int passwordLength
      Password length.
    • SORT_ERROR

      private static final String SORT_ERROR
      Error message for ian invalid sorting criteria specification.
      See Also:
    • exampleMatcher

      private final org.springframework.data.domain.ExampleMatcher exampleMatcher
      Example matcher configuration.
    • serviceName

      @Value("${spring.application.name}") private String serviceName
      This micro-service name.
    • defaultPageSize

      @Value("${query.pagination.pageSize.default}") private int defaultPageSize
      Default page size in paginated request where page size is not specified.
    • publicKey

      @Value("${kuken.publicKey}") private String publicKey
      Key used for generate RSA cipher.
    • privateKey

      @Value("${kuken.privateKey}") private String privateKey
      Key used for generate RSA cipher.
    • saltCore

      @Value("${salt.core}") private String saltCore
      Key used for generate hashing for Core cipher.
    • userRepository

      @Autowired private UserRepository userRepository
      Users repository.
    • userDeviceRepository

      @Autowired private UserDeviceRepository userDeviceRepository
      Users device repository.
    • userEntityMapper

      @Autowired private UserEntityMapper userEntityMapper
      User entity mapper.
    • jwtService

      @Autowired private es.kukenan.smartfi.common.service.jwt.JwtService jwtService
      JWT services.
    • amqpController

      @Autowired private AmqpController amqpController
      AMQP Controller (for event publishing).
    • kafkaController

      @Autowired private KafkaController kafkaController
      Kafka Controller.
    • requestContextManager

      @Autowired private es.kukenan.smartfi.common.context.RequestContextManager requestContextManager
      Request/execution context manager.
    • passwordFormatValidator

      @Autowired private PasswordFormatValidator passwordFormatValidator
      Password format validator.
    • userCreatedEventMapper

      @Autowired private UserCreatedEventMapper userCreatedEventMapper
      User to UserCreatedEvent mapper.
    • userUpdatedEventMapper

      @Autowired private UserUpdatedEventMapper userUpdatedEventMapper
      User to UserUpdatedEvent mapper.
    • userPasswordChangeEventMapper

      @Autowired private UserPasswordChangeEventMapper userPasswordChangeEventMapper
      User to UserPasswordChangeEvent mapper.
    • userPasswordResetEventMapper

      @Autowired private UserPasswordResetEventMapper userPasswordResetEventMapper
      User to UserPasswordResetEvent mapper.
    • usersApiClient

      @Autowired private UsersApiClient usersApiClient
      UsersApiClient usersApiClient.
    • userBackofficeRepository

      @Autowired private UserBackofficeRepository userBackofficeRepository
      UserBackofficeRepository repository.
    • userLanguageRepository

      @Autowired private UserLanguageRepository userLanguageRepository
      UserLanguageRepository repository.
    • userLanguageEntityMapper

      @Autowired private UserLanguageEntityMapper userLanguageEntityMapper
      UserLanguageEntityMapper mapper.
    • userDocumentRepository

      @Autowired private UserDocumentRepository userDocumentRepository
      User Document repository.
    • auditService

      @Autowired private AuditService auditService
      Backoffice endpoints implementation.
  • Constructor Details

    • UserService

      public UserService()
  • Method Details

    • findUser

      public User findUser(String userId, String companyId)
      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 null is returned.
    • createUser

      public User createUser(User user, UserManagementOperationContext context)
      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

      public void patchUser(User newUserData, User oldUserData, Boolean onboardingUpdate)
      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 identifier
      passwordChangeDto - New password data
      authentication - presented credentials. Only JWT authentication is currently supported.
      userIp - user real ip
      userAgent - user-agent header
    • userDeviceScaUpdated

      public void userDeviceScaUpdated(String userId, String deviceId)
      Update user device SCA access date.
      Parameters:
      userId - user identifier.
      deviceId - device identifier.
    • publishPasswordChange

      private void publishPasswordChange(User user)
      Publish a password change event for the specified user.
      Parameters:
      user - the user with the changed password.
    • sortedBy

      private org.springframework.data.domain.Sort sortedBy(String sortedByClause)
      Create a Sort instance from the given sorting specification.
      Parameters:
      sortedByClause - the sorting specification.
      Returns:
      the Sort instance from the given sorting specification.
    • page

      private org.springframework.data.domain.PageRequest page(Integer pageNumber, Integer pageSize, org.springframework.data.domain.Sort sort)
      Create a Pageable instance from the given paging specification.
      Parameters:
      pageNumber - page number, optional default 0.
      pageSize - page size, optional default defaultPageSize.
      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) an UnexpectedException.
      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

      public es.kukenan.smartfi.microservice.clients.dto.UserDto getUser(String userId)
      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 identifier
      securityLevel - security Level
      userIp - user Ip
      userAgent - 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 identifier
      securityLevel - security Level
      userIp - user Ip
      userAgent - user Agent
      Returns:
      urlBolsaKukenbank dto.
    • unlock

      public void unlock(String userId)
      Unlock user.
      Parameters:
      userId - User identifier
    • checkUserLocked

      private boolean checkUserLocked(int statusId, int typeId)
    • checkUserField

      private void checkUserField(String field, String fieldName)
    • 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 identifier
      language - user language
      Returns:
      user changed
    • publishPasswordReset

      public void publishPasswordReset(User user, String password, String userIp, String userAgent)
      Publish a password reset event for the specified user.
      Parameters:
      user - the user with the provisional password.
      password - Provisional password.
      userIp - user real ip
      userAgent - user-agent header
    • resetAndSendUserPassword

      public void resetAndSendUserPassword(String userId, boolean audit, String userIp, String userAgent, String channel)
      Reset user password.
      Parameters:
      userId - User identifier
      audit - flag for audit process
      userIp - user real ip
      userAgent - user-agent header
      channel - user channel
    • filterSurnameForNullValues

      public UsersSearchFilter filterSurnameForNullValues(UsersSearchFilter filter)
      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 ip
      userAgent - user-agent header
      channel - user channel