Skip to content

Commit

Permalink
Introduce proxy support for backend oauth security
Browse files Browse the repository at this point in the history
  • Loading branch information
rmsamitha committed Nov 5, 2024
1 parent fbb797a commit c6e4219
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class EndpointSecurity {

private int socketTimeoutDuration = -1;

private ProxyConfigs proxyConfigs;

public EndpointSecurity(EndpointSecurity endpointSecurity) {

this.uniqueIdentifier = endpointSecurity.uniqueIdentifier;
Expand All @@ -72,11 +74,19 @@ public EndpointSecurity(EndpointSecurity endpointSecurity) {
this.connectionTimeoutDuration = endpointSecurity.connectionTimeoutDuration;
this.connectionRequestTimeoutDuration = endpointSecurity.connectionRequestTimeoutDuration;
this.socketTimeoutDuration = endpointSecurity.socketTimeoutDuration;
this.proxyConfigs = endpointSecurity.proxyConfigs;
}

public EndpointSecurity() {

}
public ProxyConfigs getProxyConfigs() {
return proxyConfigs;
}

public void setProxyConfigs(ProxyConfigs proxyConfigs) {
this.proxyConfigs = proxyConfigs;
}

public String getUniqueIdentifier() {

Expand Down Expand Up @@ -241,6 +251,63 @@ public void setSocketTimeoutDuration(int socketTimeoutDuration) {
this.socketTimeoutDuration = socketTimeoutDuration;
}

public static class ProxyConfigs {
private boolean proxyEnabled;
private String proxyHost;
private String proxyPort;
private String proxyProtocol;
private String proxyUsername;
private String proxyPassword;

public boolean isProxyEnabled() {
return proxyEnabled;
}

public void setProxyEnabled(boolean proxyEnabled) {
this.proxyEnabled = proxyEnabled;
}

public String getProxyHost() {
return proxyHost;
}

public void setProxyHost(String proxyHost) {
this.proxyHost = proxyHost;
}

public String getProxyPort() {
return proxyPort;
}

public void setProxyPort(String proxyPort) {
this.proxyPort = proxyPort;
}

public String getProxyProtocol() {
return proxyProtocol;
}

public void setProxyProtocol(String proxyProtocol) {
this.proxyProtocol = proxyProtocol;
}

public String getProxyUsername() {
return proxyUsername;
}

public void setProxyUsername(String proxyUsername) {
this.proxyUsername = proxyUsername;
}

public String getProxyPassword() {
return proxyPassword;
}

public void setProxyPassword(String proxyPassword) {
this.proxyPassword = proxyPassword;
}
}

@Override
public String toString() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1257,10 +1257,12 @@ private void updateEndpointSecurity(API oldApi, API api) throws APIManagementExc
endpointSecurity.setClientId(oldEndpointSecurity.getClientId());
endpointSecurity.setClientSecret(oldEndpointSecurity.getClientSecret());
endpointSecurity.setCustomParameters(oldEndpointSecurity.getCustomParameters());
endpointSecurity.setProxyConfigs(oldEndpointSecurity.getProxyConfigs());
}
}
endpointSecurityJson.replace(APIConstants.ENDPOINT_SECURITY_PRODUCTION, new JSONParser()
.parse(new ObjectMapper().writeValueAsString(endpointSecurity)));
endpointSecurityJson.replace(APIConstants.ENDPOINT_SECURITY_PRODUCTION,
new JSONParser().parse(
new ObjectMapper().writeValueAsString(endpointSecurity)));
}
}
if (endpointSecurityJson.get(APIConstants.ENDPOINT_SECURITY_SANDBOX) != null) {
Expand Down Expand Up @@ -1303,6 +1305,7 @@ private void updateEndpointSecurity(API oldApi, API api) throws APIManagementExc
endpointSecurity.setClientId(oldEndpointSecurity.getClientId());
endpointSecurity.setClientSecret(oldEndpointSecurity.getClientSecret());
endpointSecurity.setCustomParameters(oldEndpointSecurity.getCustomParameters());
endpointSecurity.setProxyConfigs(oldEndpointSecurity.getProxyConfigs());
}
}
endpointSecurityJson.replace(APIConstants.ENDPOINT_SECURITY_SANDBOX,
Expand Down

0 comments on commit c6e4219

Please sign in to comment.