-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add proxy settings for GCS repository (#2096)
Added proxy settings for GCS repository. Security settings: - gcs.client.*.proxy.username - Proxy user name - gcs.client.*.proxy.password - Proxy user password Common settings: - gcs.client.*.proxy.type - java Proxy.Type names: HTTP, SOCKS. default is DIRECT - gcs.client.*.proxy.host - Proxy host name - gcs.client.*.proxy.port - Proxy port Signed-off-by: Andrey Pleskach <[email protected]>
- Loading branch information
1 parent
9ea25c4
commit b9ff91d
Showing
7 changed files
with
340 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 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 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
80 changes: 80 additions & 0 deletions
80
plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/ProxySettings.java
This file contains 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,80 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.repositories.gcs; | ||
|
||
import org.opensearch.common.Strings; | ||
|
||
import java.net.InetAddress; | ||
import java.net.InetSocketAddress; | ||
import java.net.Proxy; | ||
import java.util.Objects; | ||
|
||
public class ProxySettings { | ||
|
||
public static final ProxySettings NO_PROXY_SETTINGS = new ProxySettings(Proxy.Type.DIRECT, null, -1, null, null); | ||
|
||
private final Proxy.Type type; | ||
|
||
private final InetAddress host; | ||
|
||
private final String username; | ||
|
||
private final String password; | ||
|
||
private final int port; | ||
|
||
public ProxySettings(final Proxy.Type type, final InetAddress host, final int port, final String username, final String password) { | ||
this.type = type; | ||
this.host = host; | ||
this.port = port; | ||
this.username = username; | ||
this.password = password; | ||
} | ||
|
||
public Proxy.Type getType() { | ||
return this.type; | ||
} | ||
|
||
public InetSocketAddress getAddress() { | ||
return new InetSocketAddress(host, port); | ||
} | ||
|
||
public String getUsername() { | ||
return this.username; | ||
} | ||
|
||
public String getPassword() { | ||
return this.password; | ||
} | ||
|
||
public boolean isAuthenticated() { | ||
return Strings.isNullOrEmpty(username) == false && Strings.isNullOrEmpty(password) == false; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
final ProxySettings that = (ProxySettings) o; | ||
return port == that.port | ||
&& type == that.type | ||
&& Objects.equals(host, that.host) | ||
&& Objects.equals(username, that.username) | ||
&& Objects.equals(password, that.password); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(type, host, username, password, port); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.