Skip to content

Commit

Permalink
Merge pull request #101 from whitesource/WEI-3783
Browse files Browse the repository at this point in the history
WEI-3783 add JWT access token API
  • Loading branch information
ChenLuigi authored May 20, 2024
2 parents 8b0b0d6 + 3ca6dad commit c1287a0
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>org.whitesource</groupId>
<artifactId>wss-agent-parent</artifactId>
<version>2.9.9.89-SNAPSHOT</version>
<version>2.9.9.90-SNAPSHOT</version>
<packaging>pom</packaging>

<name>White Source agent API</name>
Expand Down
2 changes: 1 addition & 1 deletion wss-agent-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.whitesource</groupId>
<artifactId>wss-agent-parent</artifactId>
<version>2.9.9.89-SNAPSHOT</version>
<version>2.9.9.90-SNAPSHOT</version>
</parent>
<artifactId>wss-agent-api</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.whitesource.agent.api.dispatch;

public class JwtAccessTokenRequest extends BaseRequest<JwtAccessTokenResult> {

private static final long serialVersionUID = -2280907846002128613L;

public JwtAccessTokenRequest() {
super(RequestType.JWT_ACCESS_TOKEN);
}

public JwtAccessTokenRequest(String orgToken) {
this();
this.orgToken = orgToken;
}

public JwtAccessTokenRequest(String orgToken, String userKey) {
this(orgToken);
this.userKey = userKey;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.whitesource.agent.api.dispatch;

public class JwtAccessTokenResult extends BaseResult {

private static final long serialVersionUID = 4617440013556093604L;

private String jwtAccessToken;

public JwtAccessTokenResult() {
super();
}

public JwtAccessTokenResult(String jwtAccessToken) {
super();
this.jwtAccessToken = jwtAccessToken;
}

public String getJwtAccessToken() {
return jwtAccessToken;
}

public void setJwtAccessToken(String jwtAccessToken) {
this.jwtAccessToken = jwtAccessToken;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public enum RequestType {
ASYNC_CHECK_POLICY_COMPLIANCE ("ASYNC_CHECK_POLICY_COMPLIANCE"),
ASYNC_CHECK_POLICY_COMPLIANCE_STATUS ("ASYNC_CHECK_POLICY_COMPLIANCE_STATUS"),
ASYNC_CHECK_POLICY_COMPLIANCE_RESPONSE ("ASYNC_CHECK_POLICY_COMPLIANCE_RESPONSE"),

UPLOAD_SCA_LOGS("UPLOAD_SCA_LOGS");
UPLOAD_SCA_LOGS("UPLOAD_SCA_LOGS"),
JWT_ACCESS_TOKEN("JWT_ACCESS_TOKEN");

private final String value;

Expand Down
2 changes: 1 addition & 1 deletion wss-agent-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>wss-agent-parent</artifactId>
<groupId>org.whitesource</groupId>
<version>2.9.9.89-SNAPSHOT</version>
<version>2.9.9.90-SNAPSHOT</version>
</parent>

<artifactId>wss-agent-api-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,6 @@ public interface WssServiceClient {
* @return the customer headers configured for this client
*/
Map<String, String> getHeaders();

JwtAccessTokenResult jwtAccessToken(JwtAccessTokenRequest request) throws WssServiceException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ public ConfigurationResult getConfiguration(ConfigurationRequest request) throws
return service(request);
}

@Override
public JwtAccessTokenResult jwtAccessToken(JwtAccessTokenRequest request) throws WssServiceException {
return service(request);
}

@Override
public void shutdown() {
httpClient.getConnectionManager().shutdown();
Expand Down Expand Up @@ -388,6 +393,9 @@ protected <R> R service(ServiceRequest<R> request) throws WssServiceException {
case GET_CONFIGURATION:
result = (R) gson.fromJson(data, ConfigurationResult.class);
break;
case JWT_ACCESS_TOKEN:
result = (R) gson.fromJson(data, JwtAccessTokenResult.class);
break;
default:
throw new IllegalStateException("Unsupported request type.");
}
Expand Down Expand Up @@ -480,6 +488,9 @@ protected <R> HttpRequestBase createHttpRequest(ServiceRequest<R> request) throw
case GET_CONFIGURATION:
jsonDiff = gson.toJson(((ConfigurationRequest) request).getProjects());
break;
case JWT_ACCESS_TOKEN:
jsonDiff = gson.toJson(((JwtAccessTokenRequest) request).getProjects());
break;
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions wss-agent-hash-calculator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<groupId>org.whitesource</groupId>
<artifactId>wss-agent-parent</artifactId>
<version>2.9.9.89-SNAPSHOT</version>
<version>2.9.9.90-SNAPSHOT</version>
</parent>

<groupId>org.whitesource</groupId>
<artifactId>wss-agent-hash-calculator</artifactId>
<version>2.9.9.89-SNAPSHOT</version>
<version>2.9.9.90-SNAPSHOT</version>

<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion wss-agent-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.whitesource</groupId>
<artifactId>wss-agent-parent</artifactId>
<version>2.9.9.89-SNAPSHOT</version>
<version>2.9.9.90-SNAPSHOT</version>
</parent>

<artifactId>wss-agent-report</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions wss-agent-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<groupId>org.whitesource</groupId>
<artifactId>wss-agent-parent</artifactId>
<version>2.9.9.89-SNAPSHOT</version>
<version>2.9.9.90-SNAPSHOT</version>
</parent>

<groupId>org.whitesource</groupId>
<artifactId>wss-agent-utils</artifactId>
<version>2.9.9.89-SNAPSHOT</version>
<version>2.9.9.90-SNAPSHOT</version>

<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion wss-agent-via-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>wss-agent-parent</artifactId>
<groupId>org.whitesource</groupId>
<version>2.9.9.89-SNAPSHOT</version>
<version>2.9.9.90-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down

0 comments on commit c1287a0

Please sign in to comment.