Skip to content

Commit

Permalink
Make cert and key in MQTT5 pubsub sample optional (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfod authored Sep 9, 2024
1 parent 49a4889 commit 227c674
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,18 @@ private void parseCommonMQTTCommands(SampleCommandLineData returnData) {
returnData.input_ca = getCommandOrDefault(m_cmd_ca_file, "");
}

private void parseKeyAndCertCommands(SampleCommandLineData returnData)
private void parseKeyAndCertCommandsRequired(SampleCommandLineData returnData)
{
returnData.input_cert = getCommandRequired(m_cmd_cert_file);
returnData.input_key = getCommandRequired(m_cmd_key_file);
}

private void parseKeyAndCertCommandsOptional(SampleCommandLineData returnData)
{
returnData.input_cert = getCommandOrDefault(m_cmd_cert_file, "");
returnData.input_key = getCommandOrDefault(m_cmd_key_file, "");
}

private void parseClientIdAndPort(SampleCommandLineData returnData) {
returnData.input_clientId = getCommandOrDefault(m_cmd_client_id, "test-" + UUID.randomUUID().toString());
returnData.input_port = Integer.parseInt(getCommandOrDefault(m_cmd_port, "8883"));
Expand Down Expand Up @@ -385,7 +391,7 @@ public SampleCommandLineData parseSampleInputBasicConnect(String[] args)
parseCommonLoggingCommands(returnData);
parseCommonMQTTCommands(returnData);
parseCommonProxyCommands(returnData);
parseKeyAndCertCommands(returnData);
parseKeyAndCertCommandsRequired(returnData);
parseClientIdAndPort(returnData);
return returnData;
}
Expand All @@ -403,7 +409,7 @@ public SampleCommandLineData parseSampleInputPubSub(String [] args)
SampleCommandLineData returnData = new SampleCommandLineData();
parseCommonLoggingCommands(returnData);
parseCommonMQTTCommands(returnData);
parseKeyAndCertCommands(returnData);
parseKeyAndCertCommandsRequired(returnData);
parseCommonTopicMessageCommands(returnData);
parseCommonProxyCommands(returnData);
parseClientIdAndPort(returnData);
Expand Down Expand Up @@ -465,7 +471,7 @@ public SampleCommandLineData parseSampleInputCustomKeyOpsConnect(String [] args)
SampleCommandLineData returnData = new SampleCommandLineData();
parseCommonLoggingCommands(returnData);
parseCommonMQTTCommands(returnData);
parseKeyAndCertCommands(returnData);
parseKeyAndCertCommandsRequired(returnData);
parseClientIdAndPort(returnData);
return returnData;
}
Expand Down Expand Up @@ -499,7 +505,7 @@ public SampleCommandLineData parseSampleInputFleetProvisioning(String [] args)
parseMqttVersion(returnData);
parseCommonLoggingCommands(returnData);
parseCommonMQTTCommands(returnData);
parseKeyAndCertCommands(returnData);
parseKeyAndCertCommandsRequired(returnData);
parseClientIdAndPort(returnData);
returnData.input_templateName = getCommandRequired(m_cmd_fleet_template_name);
returnData.input_templateParameters = getCommandRequired(m_cmd_fleet_template_parameters);
Expand All @@ -523,7 +529,7 @@ public SampleCommandLineData parseSampleInputGreengrassDiscovery(String [] args)

SampleCommandLineData returnData = new SampleCommandLineData();
parseCommonLoggingCommands(returnData);
parseKeyAndCertCommands(returnData);
parseKeyAndCertCommandsRequired(returnData);
returnData.input_ca = getCommandOrDefault(m_cmd_ca_file, null);
returnData.input_thingName = getCommandRequired(m_cmd_thing_name);
returnData.input_signingRegion = getCommandRequired(m_cmd_region, m_cmd_signing_region);
Expand Down Expand Up @@ -574,7 +580,7 @@ public SampleCommandLineData parseSampleInputJobs(String[] args)
parseMqttVersion(returnData);
parseCommonLoggingCommands(returnData);
parseCommonMQTTCommands(returnData);
parseKeyAndCertCommands(returnData);
parseKeyAndCertCommandsRequired(returnData);
parseClientIdAndPort(returnData);
returnData.input_thingName = getCommandRequired(m_cmd_thing_name);
return returnData;
Expand All @@ -595,7 +601,7 @@ public SampleCommandLineData parseSampleInputMqtt5PubSub(String [] args)
parseCommonLoggingCommands(returnData);
parseCommonMQTTCommands(returnData);
parseCommonTopicMessageCommands(returnData);
parseKeyAndCertCommands(returnData);
parseKeyAndCertCommandsOptional(returnData);
parseCommonProxyCommands(returnData);
parseClientIdAndPort(returnData);
returnData.input_signingRegion = getCommandOrDefault(m_cmd_signing_region, null);
Expand All @@ -617,7 +623,7 @@ public SampleCommandLineData parseSampleInputMqtt5SharedSubscription(String [] a
parseCommonLoggingCommands(returnData);
parseCommonMQTTCommands(returnData);
parseCommonTopicMessageCommands(returnData);
parseKeyAndCertCommands(returnData);
parseKeyAndCertCommandsRequired(returnData);
parseCommonProxyCommands(returnData);
parseClientIdAndPort(returnData);
returnData.input_groupIdentifier = getCommandOrDefault(m_cmd_group_identifier, "java-sample");
Expand Down Expand Up @@ -669,7 +675,7 @@ public SampleCommandLineData parseSampleInputShadow(String [] args)
parseMqttVersion(returnData);
parseCommonLoggingCommands(returnData);
parseCommonMQTTCommands(returnData);
parseKeyAndCertCommands(returnData);
parseKeyAndCertCommandsRequired(returnData);
parseClientIdAndPort(returnData);
returnData.input_thingName = getCommandRequired(m_cmd_thing_name);
returnData.input_shadowProperty = getCommand(m_cmd_shadow_property);
Expand Down

0 comments on commit 227c674

Please sign in to comment.