-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
39 additions
and
3 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
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/com/github/vacxe/googleplaycli/environments/SystemProxy.kt
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,32 @@ | ||
package com.github.vacxe.googleplaycli.environments | ||
|
||
import java.net.Authenticator | ||
import java.net.PasswordAuthentication | ||
|
||
object SystemProxy { | ||
private val host = Env.Proxy.host | ||
private val port = Env.Proxy.port | ||
private val username = Env.Proxy.username | ||
private val password = Env.Proxy.password | ||
|
||
fun apply() { | ||
if(host != null && port != null) { | ||
System.setProperty("proxyEnabled", "true") | ||
System.setProperty("proxyHost", host) | ||
System.setProperty("proxyPort", port) | ||
|
||
if(username != null && password != null) { | ||
Authenticator.setDefault( | ||
object : Authenticator() { | ||
override fun getPasswordAuthentication(): PasswordAuthentication = | ||
PasswordAuthentication(username, password.toCharArray()) | ||
} | ||
) | ||
|
||
System.setProperty("proxyUser", username) | ||
System.setProperty("proxyPassword", password) | ||
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "") | ||
} | ||
} | ||
} | ||
} |