You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "PakhomovAlexander (via GitHub)" <gi...@apache.org> on 2023/04/06 15:31:09 UTC

[GitHub] [ignite-3] PakhomovAlexander commented on a diff in pull request #1888: IGNITE-19075 CLI should ask for SSL settings

PakhomovAlexander commented on code in PR #1888:
URL: https://github.com/apache/ignite-3/pull/1888#discussion_r1159958620


##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/call/connect/ConnectSslConfigCall.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.call.connect;
+
+import jakarta.inject.Inject;
+import jakarta.inject.Singleton;
+import org.apache.ignite.internal.cli.config.CliConfigKeys;
+import org.apache.ignite.internal.cli.config.ConfigManager;
+import org.apache.ignite.internal.cli.config.ConfigManagerProvider;
+import org.apache.ignite.internal.cli.core.call.Call;
+import org.apache.ignite.internal.cli.core.call.CallOutput;
+import org.apache.ignite.internal.cli.core.call.DefaultCallOutput;
+import org.apache.ignite.internal.cli.core.call.UrlCallInput;
+import org.apache.ignite.internal.cli.core.exception.IgniteCliApiException;
+import org.apache.ignite.internal.cli.core.rest.ApiClientFactory;
+import org.apache.ignite.internal.cli.core.rest.ApiClientSettings;
+import org.apache.ignite.internal.util.StringUtils;
+import org.apache.ignite.rest.client.api.NodeConfigurationApi;
+import org.apache.ignite.rest.client.invoker.ApiClient;
+import org.apache.ignite.rest.client.invoker.ApiException;
+
+/**
+ * Call which connects to the Ignite 3 node with provided SSL configuration and saves the configuration to the config.
+ */
+@Singleton
+public class ConnectSslConfigCall implements Call<ConnectSslConfigCallInput, String> {
+    @Inject
+    private ConnectCall connectCall;
+
+    @Inject
+    private ConfigManagerProvider configManagerProvider;
+
+    @Override
+    public CallOutput<String> execute(ConnectSslConfigCallInput input) {
+        try {
+            SslConfig config = input.getConfig();
+            ApiClientSettings settings = ApiClientSettings.builder()
+                    .basePath(input.getUrl())
+                    .keyStorePath(config.keyStorePath())
+                    .keyStorePassword(config.keyStorePassword())
+                    .trustStorePath(config.trustStorePath())
+                    .trustStorePassword(config.trustStorePassword())
+                    .build();
+            ApiClient client = ApiClientFactory.buildClient(settings);
+            new NodeConfigurationApi(client).getNodeConfiguration();

Review Comment:
   Could you move this API call to the meaningful method named `checkConnection`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org