private <A extends AbstractAuthenticationAction<R>, R extends AbstractAuthenticationResult>
      void constructAndSendResponse(
          UserId userId,
          String clearTextPassword,
          ChapSession chapSession,
          AuthenticationActionFactory<A, R> actionFactory,
          final DispatchServiceCallback<AuthenticationResponse> callback) {
    SaltedPasswordDigest saltedPasswordDigest =
        passwordDigestAlgorithm.getDigestOfSaltedPassword(clearTextPassword, chapSession.getSalt());

    ChapResponse response =
        responseDigestAlgorithm.getChapResponseDigest(
            chapSession.getChallengeMessage(), saltedPasswordDigest);

    sendResponse(userId, chapSession, response, actionFactory, callback);
  }
 private <A extends AbstractAuthenticationAction<R>, R extends AbstractAuthenticationResult>
     void sendResponse(
         UserId userId,
         ChapSession chapSession,
         ChapResponse chapResponse,
         AuthenticationActionFactory<A, R> actionFactory,
         final DispatchServiceCallback<AuthenticationResponse> callback) {
   ChapSessionId chapSessionId = chapSession.getId();
   A action = actionFactory.createAction(chapSessionId, userId, chapResponse);
   dispatchServiceManager.execute(
       action,
       new DispatchServiceCallback<R>() {
         @Override
         public void handleSuccess(R loginResult) {
           callback.onSuccess(loginResult.getResponse());
         }
       });
 }