Skip to content

Commit 0f7a486

Browse files
Implemented Proxy support in Java SDK for Secret Server and Platform (#183)
* ci: update deploy.yml to publish on tag push instead of branch push * Implemented Proxy support in Java SDK for Secret Server and Platform * Removed RestTemplateConfig.java class and added proxy code in SecretServerFactoryBean.java * Changes in proxy code * changed proxy code
1 parent 6806e59 commit 0f7a486

17 files changed

Lines changed: 541 additions & 326 deletions

pom.xml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<groupId>com.delinea.secrets</groupId>
1616
<artifactId>tss-sdk-java</artifactId>
17-
<version>2.0</version>
17+
<version>2.1</version>
1818
<name>tss-sdk-java</name>
1919
<description>The Delinea Secret Server Java SDK</description>
2020

@@ -67,6 +67,19 @@
6767
<version>1.18.20</version>
6868
<scope>provided</scope>
6969
</dependency>
70+
71+
<dependency>
72+
<groupId>org.apache.httpcomponents.client5</groupId>
73+
<artifactId>httpclient5</artifactId>
74+
<version>5.5.1</version>
75+
</dependency>
76+
77+
<dependency>
78+
<groupId>org.apache.httpcomponents.core5</groupId>
79+
<artifactId>httpcore5</artifactId>
80+
<version>5.3.6</version>
81+
</dependency>
82+
7083
<dependency>
7184
<groupId>org.springframework.boot</groupId>
7285
<artifactId>spring-boot-starter</artifactId>

src/main/java/com/delinea/secrets/server/spring/AuthResult.java renamed to src/main/java/com/delinea/platform/model/AuthResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.delinea.secrets.server.spring;
1+
package com.delinea.platform.model;
22

33
/** Represents the result of an authentication attempt. */
44
public class AuthResult {

src/main/java/com/delinea/secrets/server/spring/OAuthTokens.java renamed to src/main/java/com/delinea/platform/model/OAuthTokens.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.delinea.secrets.server.spring;
1+
package com.delinea.platform.model;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
44

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.delinea.platform.model;
2+
3+
import lombok.Data;
4+
5+
/**
6+
* Represents the health and operational status of a Delinea platform server.
7+
* <p>
8+
* This model is typically used to communicate the results of a health check
9+
* or status endpoint, providing insights into the condition of key system components.
10+
* </p>
11+
* <p>Uses Lombok's {@link Data} annotation to automatically generate
12+
* getters, setters, {@code toString()}, {@code equals()}, and {@code hashCode()} methods.</p>
13+
*/
14+
@Data
15+
public class ServerResponseModel {
16+
private boolean healthy;
17+
private boolean databaseHealthy;
18+
private boolean serviceBusHealthy;
19+
private boolean storageAccountHealthy;
20+
private boolean scheduledForDeletion;
21+
}

src/main/java/com/delinea/secrets/server/spring/VaultsResponseModel.java renamed to src/main/java/com/delinea/platform/model/VaultsResponseModel.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.delinea.secrets.server.spring;
1+
package com.delinea.platform.model;
22

33
import java.util.ArrayList;
44
import java.util.List;
@@ -17,12 +17,20 @@ public class VaultsResponseModel {
1717
@JsonProperty("vaults")
1818
private List<Vault> vaults = new ArrayList<>();
1919

20-
/** Returns a copy of the vaults list */
20+
/**
21+
* Returns a copy of the vaults list.
22+
*
23+
* @return a list of {@link Vault} objects
24+
*/
2125
public List<Vault> getVaults() {
2226
return new ArrayList<>(vaults);
2327
}
2428

25-
/** Sets the vaults list */
29+
/**
30+
* Sets the vaults list.
31+
*
32+
* @param vaults the list of {@link Vault} objects to set
33+
*/
2634
public void setVaults(List<Vault> vaults) {
2735
this.vaults = (vaults == null) ? new ArrayList<>() : new ArrayList<>(vaults);
2836
}
@@ -49,12 +57,20 @@ public static class Vault {
4957
@JsonProperty("connection")
5058
private Connection connection;
5159

52-
/** Returns a copy of the connection */
60+
/**
61+
* Returns a copy of the connection object.
62+
*
63+
* @return a copy of the {@link Connection}, or {@code null} if not set
64+
*/
5365
public Connection getConnection() {
5466
return (connection == null) ? null : new Connection(connection);
5567
}
5668

57-
/** Sets the connection */
69+
/**
70+
* Sets the connection information for this Vault.
71+
*
72+
* @param connection the {@link Connection} object to set
73+
*/
5874
public void setConnection(Connection connection) {
5975
this.connection = (connection == null) ? null : new Connection(connection);
6076
}
@@ -73,7 +89,11 @@ public static class Connection {
7389
/** Constructor */
7490
public Connection() {}
7591

76-
/** Copy constructor */
92+
/**
93+
* Copy constructor that creates a new Connection from another instance.
94+
*
95+
* @param other the other {@link Connection} object to copy from
96+
*/
7797
public Connection(Connection other) {
7898
if (other != null) {
7999
this.url = other.url;

src/main/java/com/delinea/secrets/server/spring/AuthenticationService.java renamed to src/main/java/com/delinea/platform/service/AuthenticationService.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.delinea.secrets.server.spring;
1+
package com.delinea.platform.service;
22

33
import java.io.IOException;
44

@@ -7,6 +7,8 @@
77
import org.springframework.stereotype.Service;
88
import org.springframework.web.client.RestTemplate;
99

10+
import com.delinea.platform.model.ServerResponseModel;
11+
import com.delinea.server.spring.AuthenticationModel;
1012
import com.fasterxml.jackson.databind.ObjectMapper;
1113

1214
/**
@@ -16,8 +18,13 @@
1618
*/
1719
@Service
1820
public class AuthenticationService implements IAuthenticationService {
19-
private RestTemplate restTemplate = new RestTemplate();
21+
private RestTemplate restTemplate ;
2022
private PlatformLogin platformLogin = new PlatformLogin();
23+
24+
public void setRestTemplate(RestTemplate restTemplate) {
25+
this.restTemplate = restTemplate;
26+
this.platformLogin.setRestTemplate(restTemplate);
27+
}
2128

2229
/**
2330
* Determines whether to authenticate against Secret Server or Platform
@@ -40,9 +47,7 @@ public AuthenticationModel authenticateAsync(AuthenticationModel authModel) thro
4047
if (isPlatformHealthy) {
4148
authModel.setPlatformLogin(true);
4249
return platformLogin.platformAuthentication(authModel);
43-
} else {
44-
return null;
45-
}
50+
}
4651
}
4752
return authModel;
4853
} catch (IOException e) {
@@ -74,6 +79,4 @@ private boolean checkJsonResponseAsync(String url) throws IOException {
7479
throw new IOException(ex.getMessage(), ex);
7580
}
7681
}
77-
78-
7982
}

src/main/java/com/delinea/secrets/server/spring/IAuthenticationService.java renamed to src/main/java/com/delinea/platform/service/IAuthenticationService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
package com.delinea.secrets.server.spring;
1+
package com.delinea.platform.service;
2+
3+
import com.delinea.server.spring.AuthenticationModel;
24

35
/**
46
* Defines the contract for authentication services used by the SDK.

src/main/java/com/delinea/secrets/server/spring/PlatformLogin.java renamed to src/main/java/com/delinea/platform/service/PlatformLogin.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.delinea.secrets.server.spring;
1+
package com.delinea.platform.service;
22

33
import java.time.ZonedDateTime;
44
import java.util.Optional;
@@ -14,13 +14,19 @@
1414
import org.springframework.util.MultiValueMap;
1515
import org.springframework.web.client.RestTemplate;
1616

17-
import com.delinea.secrets.server.spring.VaultsResponseModel.Vault;
17+
import com.delinea.platform.model.OAuthTokens;
18+
import com.delinea.platform.model.VaultsResponseModel;
19+
import com.delinea.platform.model.VaultsResponseModel.Vault;
20+
import com.delinea.server.spring.AuthenticationModel;
1821
import com.fasterxml.jackson.databind.ObjectMapper;
1922

2023
/** Handles authentication against Delinea Platform and vault retrieval. */
2124
@Component
2225
public class PlatformLogin {
23-
private RestTemplate restTemplate = new RestTemplate();
26+
private RestTemplate restTemplate;
27+
public void setRestTemplate(RestTemplate restTemplate) {
28+
this.restTemplate = restTemplate;
29+
}
2430

2531
/**
2632
* Authenticates the user on the Delinea Platform and retrieves vault info.

0 commit comments

Comments
 (0)