Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy support with basic authentication has been added using system properties #314

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,8 @@ Basically, given the `documentation` as a model, we do this:

Dokka is built with Gradle. To build it, use `./gradlew build`.
Alternatively, open the project directory in IntelliJ IDEA and use the IDE to build and run Dokka.

## Using proxy with maven
```
mvn -Dhttp.proxyHost=host.domain.com -Dhttp.proxyPort=8080 -Dhttps.proxyHost=host.domain.com -Dhttps.proxyPort=8080 -DproxySet=true -DproxyUser=user -DproxyPassword=password dokka:dokka
```
10 changes: 10 additions & 0 deletions core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ class ExternalDocumentationLinkResolver @Inject constructor(
connection.connectTimeout = timeout
connection.readTimeout = timeout

// Add proxy basic authentication when proxyUser, proxyPassword is set and proxySet is true
val systemSettings = System.getProperties()
if (systemSettings.getValue("proxySet").toString() == "true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far, as I debugged, Gradle already support basic authentification, so no need for such code in Gradle runner plugin.
Isn't it better to use java.net.Authenticator? It looks like more straightforward approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why not to use http.proxyUser and so on?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you debug and verify also Maven + proxy + basic authentication ?

I will try also will try use "systemProp.jdk.http.auth.tunneling.disabledSchemes" too and let you know

we are no using Graddle at the moment so we need to fix Maven first

&& systemSettings.getValue("proxyUser").toString().isNotEmpty()
&& systemSettings.getValue("proxyPassword").toString().isNotEmpty()) {
val encoder = sun.misc.BASE64Encoder()
val encodedUserPwd = encoder.encode((systemSettings.getValue("proxyUser").toString() + ":" + systemSettings.getValue("proxyPassword").toString()).toByteArray())
connection.setRequestProperty("Proxy-Authorization","Basic $encodedUserPwd")
}

when (connection) {
is HttpURLConnection -> {
return when (connection.responseCode) {
Expand Down