-
Notifications
You must be signed in to change notification settings - Fork 41
refactor client command line parsing and LoginStatus success check #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tonygermano
merged 2 commits into
OpenIntegrationEngine:main
from
tonygermano:maint/refactor-client-login
Nov 26, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
client/src/com/mirth/connect/client/ui/CommandLineOptions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
| // SPDX-FileCopyrightText: Mirth Corporation | ||
|
|
||
| package com.mirth.connect.client.ui; | ||
|
|
||
| import org.apache.commons.lang3.StringUtils; | ||
|
|
||
| /** | ||
| * Immutable holder for command line options used by the Mirth client. | ||
| */ | ||
| public class CommandLineOptions { | ||
| private final String server; | ||
| private final String version; | ||
| private final String username; | ||
| private final String password; | ||
| private final String protocols; | ||
| private final String cipherSuites; | ||
|
|
||
| /** | ||
| * Parse command line arguments for Mirth client. | ||
| */ | ||
| public CommandLineOptions(String[] args) { | ||
| String server = "https://localhost:8443"; | ||
| String version = ""; | ||
| String username = ""; | ||
| String password = ""; | ||
| String protocols = ""; | ||
| String cipherSuites = ""; | ||
|
|
||
| if (args == null) { | ||
| args = new String[0]; | ||
| } | ||
|
|
||
| if (args.length > 0) { | ||
| server = args[0]; | ||
| } | ||
| if (args.length > 1) { | ||
| version = args[1]; | ||
| } | ||
tonygermano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (args.length > 2) { | ||
| if (StringUtils.equalsIgnoreCase(args[2], "-ssl")) { | ||
| // <server> <version> -ssl [<protocols> [<ciphersuites> [<username> [<password>]]]] | ||
| if (args.length > 3) { | ||
| protocols = args[3]; | ||
| } | ||
| if (args.length > 4) { | ||
| cipherSuites = args[4]; | ||
| } | ||
| if (args.length > 5) { | ||
| username = args[5]; | ||
| } | ||
| if (args.length > 6) { | ||
| password = args[6]; | ||
| } | ||
| } else { | ||
| // <server> <version> <username> [<password> [-ssl [<protocols> [<ciphersuites>]]]] | ||
| username = args[2]; | ||
| if (args.length > 3) { | ||
| password = args[3]; | ||
| } | ||
tonygermano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (args.length > 4 && StringUtils.equalsIgnoreCase(args[4], "-ssl")) { | ||
| if (args.length > 5) { | ||
| protocols = args[5]; | ||
| } | ||
| if (args.length > 6) { | ||
| cipherSuites = args[6]; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| this.server = server; | ||
| this.version = version; | ||
| this.username = username; | ||
| this.password = password; | ||
| this.protocols = protocols; | ||
| this.cipherSuites = cipherSuites; | ||
| } | ||
|
|
||
| public String getServer() { | ||
| return server; | ||
| } | ||
|
|
||
| public String getVersion() { | ||
| return version; | ||
| } | ||
|
|
||
| public String getUsername() { | ||
| return username; | ||
| } | ||
|
|
||
| public String getPassword() { | ||
| return password; | ||
| } | ||
|
|
||
| public String getProtocols() { | ||
| return protocols; | ||
| } | ||
|
|
||
| public String getCipherSuites() { | ||
| return cipherSuites; | ||
| } | ||
kpalang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
client/test/com/mirth/connect/client/ui/CommandLineOptionsTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
| // SPDX-FileCopyrightText: 2025 Mitch Gaffigan | ||
|
|
||
| package com.mirth.connect.client.ui; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| public class CommandLineOptionsTest { | ||
|
|
||
| @Test | ||
| public void testParseSslForm() { | ||
| String[] args = new String[] { "https://example:8443", "1.0", "-ssl", "TLSv1.2,TLSv1.3", "TLS_RSA_WITH_AES_128_GCM_SHA256", "alice", "secret" }; | ||
| CommandLineOptions opts = new CommandLineOptions(args); | ||
|
|
||
| assertEquals("https://example:8443", opts.getServer()); | ||
| assertEquals("1.0", opts.getVersion()); | ||
| assertEquals("alice", opts.getUsername()); | ||
| assertEquals("secret", opts.getPassword()); | ||
| assertEquals("TLSv1.2,TLSv1.3", opts.getProtocols()); | ||
| assertEquals("TLS_RSA_WITH_AES_128_GCM_SHA256", opts.getCipherSuites()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testParseUsernameFormWithSsl() { | ||
| String[] args = new String[] { "https://example:8443", "1.0", "bob", "pw", "-ssl", "TLSv1.2", "CIPHER" }; | ||
| CommandLineOptions opts = new CommandLineOptions(args); | ||
|
|
||
| assertEquals("https://example:8443", opts.getServer()); | ||
| assertEquals("1.0", opts.getVersion()); | ||
| assertEquals("bob", opts.getUsername()); | ||
| assertEquals("pw", opts.getPassword()); | ||
| assertEquals("TLSv1.2", opts.getProtocols()); | ||
| assertEquals("CIPHER", opts.getCipherSuites()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testNullArgsUsesDefaults() { | ||
| CommandLineOptions opts = new CommandLineOptions((String[]) null); | ||
|
|
||
| assertEquals("https://localhost:8443", opts.getServer()); | ||
| assertEquals("", opts.getVersion()); | ||
| assertEquals("", opts.getUsername()); | ||
| assertEquals("", opts.getPassword()); | ||
| assertEquals("", opts.getProtocols()); | ||
| assertEquals("", opts.getCipherSuites()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testNormal() { | ||
| String[] args = new String[] { "https://example:8443", "1.0" }; | ||
| CommandLineOptions opts = new CommandLineOptions(args); | ||
|
|
||
| assertEquals("https://example:8443", opts.getServer()); | ||
| assertEquals("1.0", opts.getVersion()); | ||
| assertEquals("", opts.getUsername()); | ||
| assertEquals("", opts.getPassword()); | ||
| assertEquals("", opts.getProtocols()); | ||
| assertEquals("", opts.getCipherSuites()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.