Skip to content

Commit

Permalink
#280 fixed indent
Browse files Browse the repository at this point in the history
  • Loading branch information
DirkMahler committed Dec 6, 2022
1 parent f87a944 commit 6bdcdcb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/bsc/confluence/ConfluenceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ class Credentials {

public final String username;
public final String password;
public final Map<String, String> httpHeaders;
public final Map<String, String> httpHeaders;

public Credentials(String username, String password, Map<String, String> httpHeaders) {
this.username = username;
this.password = password;
this.httpHeaders = httpHeaders;
this.httpHeaders = httpHeaders;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public abstract class AbstractBaseConfluenceMojo extends AbstractMojo implements
* Additional HTTP headers for Confluence.
*/
@Parameter(property = "confluence.httpHeaders", required = false)
private Map<String, String> httpHeaders = new HashMap<>();
private Map<String, String> httpHeaders = new HashMap<>();

/**
* @parameter expression="${settings}"
Expand Down Expand Up @@ -319,17 +319,17 @@ private void loadUserInfoFromSettings() throws MojoExecutionException {
}
}

if (getHttpHeaders().isEmpty() && server.getConfiguration() != null) {
httpHeaders = stream(((Xpp3Dom) server.getConfiguration()).getChild("httpHeaders").getChildren())
.filter(child ->
child.getName().equals("property")
&& child.getChild("name") != null
&& child.getChild("value") != null
)
.collect(toMap(
property -> property.getChild("name").getValue(),
property -> property.getChild("value").getValue()));
}
if (getHttpHeaders().isEmpty() && server.getConfiguration() != null) {
httpHeaders = stream(((Xpp3Dom) server.getConfiguration()).getChild("httpHeaders").getChildren())
.filter(child ->
child.getName().equals("property")
&& child.getChild("name") != null
&& child.getChild("value") != null
)
.collect(toMap(
property -> property.getChild("name").getValue(),
property -> property.getChild("value").getValue()));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,20 @@ public RESTConfluenceService(String url, Credentials credentials, SSLCertificate
;
}

client.addInterceptor(chain -> {
Request.Builder requestBuilder = chain.request().newBuilder();
if (credentials.username != null) {
final String credential =
okhttp3.Credentials.basic(credentials.username, credentials.password);
requestBuilder.header("Authorization", credential);
}
if (!credentials.httpHeaders.isEmpty()) {
credentials.httpHeaders.entrySet().forEach(entry ->
requestBuilder.header(entry.getKey(), entry.getValue()));
}
return chain.proceed(requestBuilder.build());
});
// Use interceptor which transparently adds credentials and HTTP headers for each request
client.addInterceptor(chain -> {
Request.Builder requestBuilder = chain.request().newBuilder();
if (credentials.username != null) {
final String credential =
okhttp3.Credentials.basic(credentials.username, credentials.password);
requestBuilder.header("Authorization", credential);
}
if (!credentials.httpHeaders.isEmpty()) {
credentials.httpHeaders.entrySet().forEach(entry ->
requestBuilder.header(entry.getKey(), entry.getValue()));
}
return chain.proceed(requestBuilder.build());
});

}

Expand Down

0 comments on commit 6bdcdcb

Please sign in to comment.