11/*
2- * CursusDB
3- * Java Native Client Package
4- * ******************************************************************
5- * Copyright (C) 2023 CursusDB
6- *
7- * This program is free software: you can redistribute it and/or modify
8- * it under the terms of the GNU General Public License as published by
9- * the Free Software Foundation, either version 3 of the License, or
10- * (at your option) any later version.
11- *
12- * This program is distributed in the hope that it will be useful,
13- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- * GNU General Public License for more details.
16- *
17- * You should have received a copy of the GNU General Public License
18- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2+ * CursusDB
3+ * Java Native Client Package
4+ * ******************************************************************
5+ * Copyright (C) 2023 CursusDB
6+ *
7+ * This program is free software: you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation, either version 3 of the License, or
10+ * (at your option) any later version.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1919 */
2020
21- package cursusdbjava ;
21+ package com . cursusdb . java ;
2222
2323import javax .net .SocketFactory ;
2424import javax .net .ssl .SSLSocket ;
2525import javax .net .ssl .SSLSocketFactory ;
26- import java .io .*;
26+ import java .io .DataInputStream ;
27+ import java .io .DataOutputStream ;
28+ import java .io .IOException ;
2729import java .net .InetSocketAddress ;
2830import java .net .Socket ;
2931import java .util .Base64 ;
@@ -68,8 +70,6 @@ void Connect() throws IOException {
6870 secureSocket .setEnabledCipherSuites (new String [] { "TLS_AES_128_GCM_SHA256" });
6971 secureSocket .setEnabledProtocols (new String [] { "TLSv1.3" });
7072
71- // Connect to cluster
72- secureSocket .connect (new InetSocketAddress ("0.0.0.0" , port ), 1000 );
7373
7474 // Setup writer and reader
7575 reader = new DataInputStream (secureSocket .getInputStream ());
@@ -78,7 +78,6 @@ void Connect() throws IOException {
7878 // Create new socket
7979 socket = new Socket ();
8080
81-
8281 // Connect to cluster
8382 socket .connect (new InetSocketAddress ("0.0.0.0" , port ), 1000 );
8483
@@ -87,18 +86,18 @@ void Connect() throws IOException {
8786 writer = new DataOutputStream (socket .getOutputStream ());
8887 }
8988
90- Base64 .Encoder base64Encoder = Base64 .getEncoder ();
91- String userPassEncoded = base64Encoder .encodeToString ((username + "\\ 0" + password ).getBytes ());
89+ Base64 .Encoder base64Encoder = Base64 .getEncoder ();
90+ String userPassEncoded = base64Encoder .encodeToString ((username + "\\ 0" + password ).getBytes ());
9291
93- writer .writeBytes ("Authentication: " + userPassEncoded + "\r \n " );
92+ writer .writeBytes ("Authentication: " + userPassEncoded + "\r \n " );
9493
95- String clusterResponse = reader .readLine ();
94+ String clusterResponse = reader .readLine ();
9695
97- if (clusterResponse .startsWith ("0" )) {
98- System .out .println ("Connected to cluster." );
99- } else {
100- throw new InvalidAuthenticationException ("Could not authenticate to cluster" );
101- }
96+ if (clusterResponse .startsWith ("0" )) {
97+ System .out .println ("Connected to cluster." );
98+ } else {
99+ throw new InvalidAuthenticationException ("Could not authenticate to cluster" );
100+ }
102101
103102 }
104103
0 commit comments