-
-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve HTTP Proxy parameters from the external configuration. (#1035)
- Loading branch information
1 parent
bcbd5c5
commit 94691a2
Showing
10 changed files
with
317 additions
and
7 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
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
19 changes: 19 additions & 0 deletions
19
sentry/src/main/java/io/sentry/transport/AuthenticatorWrapper.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,19 @@ | ||
package io.sentry.transport; | ||
|
||
import java.net.Authenticator; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** Wraps {@link Authenticator} in order to make classes that use it testable. */ | ||
final class AuthenticatorWrapper { | ||
private static final AuthenticatorWrapper instance = new AuthenticatorWrapper(); | ||
|
||
public static AuthenticatorWrapper getInstance() { | ||
return instance; | ||
} | ||
|
||
private AuthenticatorWrapper() {} | ||
|
||
public void setDefault(final @NotNull Authenticator authenticator) { | ||
Authenticator.setDefault(authenticator); | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
sentry/src/main/java/io/sentry/transport/ProxyAuthenticator.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,38 @@ | ||
package io.sentry.transport; | ||
|
||
import io.sentry.util.Objects; | ||
import java.net.Authenticator; | ||
import java.net.PasswordAuthentication; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
final class ProxyAuthenticator extends Authenticator { | ||
private final @NotNull String user; | ||
private final @NotNull String password; | ||
|
||
/** | ||
* Proxy authenticator. | ||
* | ||
* @param user proxy username | ||
* @param password proxy password | ||
*/ | ||
ProxyAuthenticator(final @NotNull String user, final @NotNull String password) { | ||
this.user = Objects.requireNonNull(user, "user is required"); | ||
this.password = Objects.requireNonNull(password, "password is required"); | ||
} | ||
|
||
@Override | ||
protected PasswordAuthentication getPasswordAuthentication() { | ||
if (getRequestorType() == RequestorType.PROXY) { | ||
return new PasswordAuthentication(user, password.toCharArray()); | ||
} | ||
return null; | ||
} | ||
|
||
String getUser() { | ||
return user; | ||
} | ||
|
||
String getPassword() { | ||
return password; | ||
} | ||
} |
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.