private AuthenticationCommandResponse getAuthenticationCommandResponse()

in service/src/main/java/org/apache/fineract/cn/identity/rest/AuthorizationRestController.java [154:195]


  private AuthenticationCommandResponse getAuthenticationCommandResponse(
      final Object authenticationCommand) throws AmitAuthenticationException, InterruptedException {
    try
    {
      final CommandCallback<AuthenticationCommandResponse> ret =
          commandGateway.process(authenticationCommand,
                  AuthenticationCommandResponse.class);

      return ret.get();
    }
    catch (final ExecutionException e)
    {
      if (AmitAuthenticationException.class.isAssignableFrom(e.getCause().getClass()))
      {
        logger.debug("Authentication failed.", e);
        throw AmitAuthenticationException.class.cast(e.getCause());
      }
      else if (CommandProcessingException.class.isAssignableFrom(e.getCause().getClass()))
      {
        final CommandProcessingException commandProcessingException = (CommandProcessingException) e.getCause();
        if (ServiceException.class.isAssignableFrom(commandProcessingException.getCause().getClass()))
          throw (ServiceException)commandProcessingException.getCause();
        else {
          logger.error("Authentication failed with an unexpected error.", e);
          throw ServiceException.internalError("An error occurred while attempting to authenticate a user.");
        }
      }
      else if (ServiceException.class.isAssignableFrom(e.getCause().getClass()))
      {
        throw (ServiceException)e.getCause();
      }
      else {
        logger.error("Authentication failed with an unexpected error.", e);
        throw ServiceException.internalError("An error occurred while attempting to authenticate a user.");
      }
    }
    catch (final CommandProcessingException e)
    {
      logger.error("Authentication failed with an unexpected error.", e);
      throw ServiceException.internalError("An error occurred while attempting to authenticate a user.");
    }
  }