<p>This PR implements a number of refactorings and a couple minor substantive changes that I've been meaning to get to since <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/chimp1984/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/chimp1984">@chimp1984</a>'s original PoC in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="548269504" data-permission-text="Title is private" data-url="https://github.com/bisq-network/bisq/issues/3888" data-hovercard-type="pull_request" data-hovercard-url="/bisq-network/bisq/pull/3888/hovercard" href="https://github.com/bisq-network/bisq/pull/3888">#3888</a>.</p>
<p>The substantive changes include:</p>
<ul>
<li>Removing the <code>stopServer</code> method (until a clear use case for it emerges)</li>
<li>Adding an <code>--apiPort</code> configuration option to avoid hardcoding the 9998 port</li>
</ul>
<p>Otherwise these are pure refactorings that make the implementation of GrpcServer more idiomatic and hopefully easier to contribute to going forward, e.g. in the PR that will come together to <span class="issue-keyword tooltipped tooltipped-se" aria-label="This pull request closes issue #4198.">resolve</span> <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="607711954" data-permission-text="Title is private" data-url="https://github.com/bisq-network/bisq/issues/4198" data-hovercard-type="issue" data-hovercard-url="/bisq-network/bisq/issues/4198/hovercard" href="https://github.com/bisq-network/bisq/issues/4198">#4198</a>.</p>
<p>Note that this PR builds atop the commits in the as-yet unmerged PR <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="605087512" data-permission-text="Title is private" data-url="https://github.com/bisq-network/bisq/issues/4189" data-hovercard-type="pull_request" data-hovercard-url="/bisq-network/bisq/pull/4189/hovercard" href="https://github.com/bisq-network/bisq/pull/4189">#4189</a>. The commits specific to this PR begin with <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/bisq-network/bisq/commit/01580ae36ab8a0f67bd24178035a94bdb014b43a/hovercard" href="https://github.com/bisq-network/bisq/commit/01580ae36ab8a0f67bd24178035a94bdb014b43a"><tt>01580ae</tt></a> ("Remove StopServer rpc method"). In any case, <strong>PR <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="605087512" data-permission-text="Title is private" data-url="https://github.com/bisq-network/bisq/issues/4189" data-hovercard-type="pull_request" data-hovercard-url="/bisq-network/bisq/pull/4189/hovercard" href="https://github.com/bisq-network/bisq/pull/4189">#4189</a> should be merged before this one.</strong></p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/bisq-network/bisq/pull/4199'>https://github.com/bisq-network/bisq/pull/4199</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Implement simple cleartext gRPC authentication</li>
  <li>Inject Config directly into BisqGrpcServer</li>
  <li>Favor final fields declared one per line</li>
  <li>Do not declare local variables as final</li>
  <li>Wrap method parameters according to convention</li>
  <li>Simplify implementation of authenticate method</li>
  <li>Polish BisqCallCredentials style</li>
  <li>Rename AuthenticationInterceptor => TokenAuthInterceptor</li>
  <li>Use a single auth token vs username:password</li>
  <li>Simplify implementation to a single main class</li>
  <li>Update comments and console output</li>
  <li>Use var declarations where appropriate</li>
  <li>Refactor auth infrastructure naming</li>
  <li>Reduce AuthHeaderCallCredentials visibility to package-private</li>
  <li>Rename/repackage bisq.cli.{app.Bisq=>CliMain}</li>
  <li>Handle OptionException gracefully</li>
  <li>Print help text when no command is specified</li>
  <li>Print nested exception error message on connect failure</li>
  <li>Improve error handling</li>
  <li>Use 'method' vs 'command' naming</li>
  <li>Refine help output</li>
  <li>Refactor 'auth*' naming to 'password'</li>
  <li>Reduce PasswordAuthInterceptor visibility to package-private</li>
  <li>Fix typo in help output</li>
  <li>Allow double-quoted multiword apiPassword</li>
  <li>Remove redundant text from console err msg</li>
  <li>Revert 16c2efc</li>
  <li>Handle OptionException immediately</li>
  <li>Shutdown channel using a JVM shutdown hook</li>
  <li>Declare channel outside try/catch</li>
  <li>Add expect-based cli test suite</li>
  <li>Clean up whitespace in cli-test.sh</li>
  <li>Move cli-test.sh => cli/test.sh</li>
  <li>Touch up test descriptions and parameter naming</li>
  <li>Set --password as a required option in JOpt parser</li>
  <li>Update cli/test.sh instructions</li>
  <li>Add comment explaining exception message mangling</li>
  <li>Touch up help output</li>
  <li>Revert marking password as required in JOpt parser</li>
  <li>Remove note to self</li>
  <li>Remove StopServer rpc method</li>
  <li>Remove section comments from BisqGrpcServer</li>
  <li>Eliminate static fields in BisqGrpcServer</li>
  <li>Sort static inner classes at bottom</li>
  <li>Rename gRPC service classes from *{Impl=>Service}</li>
  <li>Make gRPC service classes non-static</li>
  <li>Use var declarations where appropriate</li>
  <li>Rename BisqGrpcServer => GrpcServer</li>
  <li>Refine GrpcServer log output</li>
  <li>Add 'apiPort' configuration option</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-c197962302397baf3a4cc36463dce5ea">build.gradle</a>
    (2)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-c373779aeb2c0f02199d152b537b0fd1">cli/src/main/java/bisq/cli/CliMain.java</a>
    (189)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-166cef371032bb05222c55363b3a1aba">cli/src/main/java/bisq/cli/PasswordCallCredentials.java</a>
    (45)
  </li>
  <li>
    <strong>D</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-a8578edbbfb64f313f4df527913010c8">cli/src/main/java/bisq/cli/app/BisqCliMain.java</a>
    (116)
  </li>
  <li>
    <strong>D</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-d9177b9a1771e1dea288527a141be530">cli/src/main/java/bisq/cli/app/CliCommand.java</a>
    (66)
  </li>
  <li>
    <strong>D</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-146c13fe7dbf75f37148656f62dcde51">cli/src/main/java/bisq/cli/app/CommandParser.java</a>
    (27)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-9368479f5696839c056de9f5b7d62e7b">cli/test.sh</a>
    (156)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-9528e70f6dabc9e219b668e538aef00c">common/src/main/java/bisq/common/config/Config.java</a>
    (21)
  </li>
  <li>
    <strong>R</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-64eb5835ca37d8f1ab4af8939934a860">core/src/main/java/bisq/core/grpc/GrpcServer.java</a>
    (144)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-c493ce020267a0600bbbb421fc95722e">core/src/main/java/bisq/core/grpc/PasswordAuthInterceptor.java</a>
    (45)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-01a7cf00fcce84b3e03a47b3b1c81bbd">daemon/src/main/java/bisq/daemon/app/BisqDaemonMain.java</a>
    (4)
  </li>
  <li>
    <strong>R</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-02df959c4a3b8bca0e324fc4430dfb94">daemon/src/main/resources/logback.xml</a>
    (0)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4199/files#diff-328b3309bc03d9ffb3ffb9e780dc7e91">proto/src/main/proto/grpc.proto</a>
    (15)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/bisq-network/bisq/pull/4199.patch'>https://github.com/bisq-network/bisq/pull/4199.patch</a></li>
  <li><a href='https://github.com/bisq-network/bisq/pull/4199.diff'>https://github.com/bisq-network/bisq/pull/4199.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/bisq/pull/4199">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJFFTNTTNO2XLGY7T2T2MVLROXCVNANCNFSM4MSERRZA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AJFFTNQN3PJNXTVQPMUOJH3ROXCVNA5CNFSM4MSERRZKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4JBZOQQA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bisq/pull/4199",
"url": "https://github.com/bisq-network/bisq/pull/4199",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>