Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Commit

Permalink
Fixed issue with AuthRefreshTask not taking into account custom http …
Browse files Browse the repository at this point in the history
…clients for key and pods. This included adding get/set for SymAuth session/key http clients.
  • Loading branch information
ftbb committed Jul 9, 2018
1 parent 2c32705 commit 8b59ce7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,16 @@ public SymAuth runTask() {

AuthenticationClient authClient;


//Init the Symphony authorization client, which requires both the key and session URL's. In most cases,
//the same fqdn but different URLs.
if (symClient.getSymAuth() != null && symClient.getSymAuth().getHttpClient() != null) {
//the same fqdn but different URLs. Also take into account if there are different HTTP clients being used between POD and key manager.
if (symClient.getSymAuth() != null && symClient.getSymAuth().getHttpClientForKeyToken() != null && symClient.getSymAuth().getHttpClientForSessionToken() != null) {

//Take the stored http client configuration with the pre-loaded keystores.
authClient = new AuthenticationClient(symClient.getSymAuth().getSessionUrl(), symClient.getSymAuth().getKeyUrl(), symClient.getSymAuth().getHttpClientForSessionToken(), symClient.getSymAuth().getHttpClientForKeyToken());


} else if (symClient.getSymAuth() != null && symClient.getSymAuth().getHttpClient() != null) {

//Take the stored http client configuration with the pre-loaded keystores.
authClient = new AuthenticationClient(symClient.getSymAuth().getSessionUrl(), symClient.getSymAuth().getKeyUrl(), symClient.getSymAuth().getHttpClient());
Expand All @@ -92,7 +99,7 @@ public SymAuth runTask() {


//Create a SymAuth which holds both key and session tokens. This will call the external service.
symAuth = authClient.authenticate();
symAuth = authClient.authenticate();

symClient.getSymAuth().setKeyToken(symAuth.getKeyToken());
symClient.getSymAuth().setSessionToken(symAuth.getSessionToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.symphonyoss.symphony.clients.jmx.ClientCheck;
import org.symphonyoss.symphony.clients.model.ApiVersion;
import org.symphonyoss.symphony.clients.model.SymUser;
import org.symphonyoss.symphony.pod.invoker.JSON;


import javax.management.*;
import javax.ws.rs.client.Client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class SymAuth {
private String serverTruststorePassword;
private String clientKeystorePassword;
private Client httpClient;
private Client httpClientForSessionToken;
private Client httpClientForKeyToken;


public String getServerTruststore() {
Expand Down Expand Up @@ -130,6 +132,22 @@ public void setKeyUrl(String keyUrl) {
this.keyUrl = keyUrl;
}

public Client getHttpClientForSessionToken() {
return httpClientForSessionToken;
}

public void setHttpClientForSessionToken(Client httpClientForSessionToken) {
this.httpClientForSessionToken = httpClientForSessionToken;
}

public Client getHttpClientForKeyToken() {
return httpClientForKeyToken;
}

public void setHttpClientForKeyToken(Client httpClientForKeyToken) {
this.httpClientForKeyToken = httpClientForKeyToken;
}

public static SymAuth fromOboAuth(OboAuthResponse oboAuthResponse) {

if(oboAuthResponse==null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public SymAuth authenticate() throws AuthenticationException {

if (httpClientForSessionToken != null) {
Configuration.getDefaultApiClient().setHttpClient(httpClientForSessionToken);
symAuth.setHttpClientForSessionToken(httpClientForSessionToken);
}

symAuth.setSessionToken(authenticationApi.v1AuthenticatePost());
Expand All @@ -160,6 +161,7 @@ public SymAuth authenticate() throws AuthenticationException {

if (httpClientForKeyToken != null) {
Configuration.getDefaultApiClient().setHttpClient(httpClientForKeyToken);
symAuth.setHttpClientForKeyToken(httpClientForKeyToken);
}

symAuth.setKeyToken(authenticationApi.v1AuthenticatePost());
Expand Down

0 comments on commit 8b59ce7

Please sign in to comment.