public String process()

in service/src/main/java/org/apache/fineract/cn/teller/service/internal/command/handler/TellerAggregate.java [231:262]


  public String process(final DrawerUnlockCommand drawerUnlockCommand) {
    final String tellerCode = drawerUnlockCommand.tellerCode();
    final UnlockDrawerCommand unlockDrawerCommand = drawerUnlockCommand.tellerAuthentication();

    final Optional<TellerEntity> optionalTeller = this.tellerRepository.findByIdentifier(tellerCode);
    if (optionalTeller.isPresent()) {
      final TellerEntity tellerEntity = optionalTeller.get();
      if (tellerEntity.getState().equals(Teller.State.CLOSED.name())) {
        throw ServiceException.notFound("Teller {0} not found.", tellerCode);
      }

      if (!UserContextHolder.checkedGetUser().equals(tellerEntity.getAssignedEmployeeIdentifier())) {
        throw ServiceException.notFound("Teller {0} not found.", tellerCode);
      }

      final byte[] givenPassword = this.hashGenerator.hash(unlockDrawerCommand.getPassword(),
          Base64Utils.decodeFromString(tellerEntity.getSalt()), ServiceConstants.ITERATION_COUNT, ServiceConstants.LENGTH);

      if (!tellerEntity.getPassword().equals(Base64Utils.encodeToString(givenPassword))) {
        throw ServiceException.notFound("Teller {0} not found.", tellerCode);
      }

      tellerEntity.setState(Teller.State.ACTIVE.name());
      tellerEntity.setLastModifiedBy(UserContextHolder.checkedGetUser());
      tellerEntity.setLastModifiedOn(LocalDateTime.now(Clock.systemUTC()));
      this.tellerRepository.save(tellerEntity);

      return tellerCode;
    } else {
      throw ServiceException.notFound("Teller {0} not found.", tellerCode);
    }
  }