removed jersey dependency
This commit is contained in:
parent
3609199b4b
commit
2dc0024a1f
22
pom.xml
22
pom.xml
@ -2,7 +2,7 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.inteligr8</groupId>
|
<groupId>com.inteligr8.alfresco</groupId>
|
||||||
<artifactId>activiti-java-enterprise-api</artifactId>
|
<artifactId>activiti-java-enterprise-api</artifactId>
|
||||||
<version>1.0-v1-SNAPSHOT</version>
|
<version>1.0-v1-SNAPSHOT</version>
|
||||||
<name>Alfresco Process Services ReST API Client for Java</name>
|
<name>Alfresco Process Services ReST API Client for Java</name>
|
||||||
@ -19,6 +19,7 @@
|
|||||||
<spring.version>5.2.14.RELEASE</spring.version>
|
<spring.version>5.2.14.RELEASE</spring.version>
|
||||||
<spring-boot.version>2.3.10.RELEASE</spring-boot.version>
|
<spring-boot.version>2.3.10.RELEASE</spring-boot.version>
|
||||||
<jersey.version>2.34</jersey.version>
|
<jersey.version>2.34</jersey.version>
|
||||||
|
<cxf.version>3.3.2</cxf.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -26,27 +27,34 @@
|
|||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context</artifactId>
|
<artifactId>spring-context</artifactId>
|
||||||
<version>${spring.version}</version>
|
<version>${spring.version}</version>
|
||||||
<scope>provided</scope>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>2.12.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.ws.rs</groupId>
|
||||||
|
<artifactId>jakarta.ws.rs-api</artifactId>
|
||||||
|
<version>2.1.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.core</groupId>
|
<groupId>org.glassfish.jersey.core</groupId>
|
||||||
<artifactId>jersey-client</artifactId>
|
<artifactId>jersey-client</artifactId>
|
||||||
<version>${jersey.version}</version>
|
<version>${jersey.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.inject</groupId>
|
<groupId>org.glassfish.jersey.inject</groupId>
|
||||||
<artifactId>jersey-hk2</artifactId>
|
<artifactId>jersey-hk2</artifactId>
|
||||||
<version>${jersey.version}</version>
|
<version>${jersey.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.media</groupId>
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
<artifactId>jersey-media-json-jackson</artifactId>
|
<artifactId>jersey-media-json-jackson</artifactId>
|
||||||
<version>${jersey.version}</version>
|
<version>${jersey.version}</version>
|
||||||
</dependency>
|
<scope>test</scope>
|
||||||
<dependency>
|
|
||||||
<groupId>org.glassfish.jersey.security</groupId>
|
|
||||||
<artifactId>oauth2-client</artifactId>
|
|
||||||
<version>${jersey.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.ClientRequestContext;
|
||||||
|
import javax.ws.rs.client.ClientRequestFilter;
|
||||||
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
|
||||||
|
public class AccessTokenRequestFilter implements ClientRequestFilter {
|
||||||
|
|
||||||
|
private final String token;
|
||||||
|
|
||||||
|
public AccessTokenRequestFilter(String token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filter(ClientRequestContext requestContext) {
|
||||||
|
requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, "Bearer " + this.token);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package com.inteligr8.alfresco.activiti;
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
import javax.ws.rs.client.ClientBuilder;
|
||||||
import javax.ws.rs.core.Feature;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -29,10 +28,7 @@ public class ApsClient {
|
|||||||
javax.ws.rs.client.Client client = ClientBuilder
|
javax.ws.rs.client.Client client = ClientBuilder
|
||||||
.newClient();
|
.newClient();
|
||||||
|
|
||||||
Feature feature = this.config.getAuthorizationFeature();
|
this.config.authorize(client);
|
||||||
if (feature != null)
|
|
||||||
client.register(feature);
|
|
||||||
|
|
||||||
return new EnterpriseAPI(this.config.getBaseUrl() + "/api", client);
|
return new EnterpriseAPI(this.config.getBaseUrl() + "/api", client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package com.inteligr8.alfresco.activiti;
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
import javax.ws.rs.core.Feature;
|
import javax.ws.rs.client.Client;
|
||||||
|
|
||||||
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
|
|
||||||
import org.glassfish.jersey.client.oauth2.OAuth2ClientSupport;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@ -28,14 +26,12 @@ public class ApsClientConfiguration {
|
|||||||
return this.baseUrl;
|
return this.baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Feature getAuthorizationFeature() {
|
public void authorize(Client client) {
|
||||||
if (this.basicAuthUsername != null) {
|
if (this.basicAuthUsername != null) {
|
||||||
return HttpAuthenticationFeature.basic(this.basicAuthUsername, this.basicAuthPassword);
|
client.register(new BasicAuthRequestFilter(this.basicAuthUsername, this.basicAuthPassword));
|
||||||
} else if (this.accessToken != null) {
|
} else if (this.accessToken != null) {
|
||||||
return OAuth2ClientSupport.feature(this.accessToken);
|
client.register(new AccessTokenRequestFilter(this.accessToken));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.ClientRequestContext;
|
||||||
|
import javax.ws.rs.client.ClientRequestFilter;
|
||||||
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
|
||||||
|
public class BasicAuthRequestFilter implements ClientRequestFilter {
|
||||||
|
|
||||||
|
private final String username;
|
||||||
|
private final String password;
|
||||||
|
|
||||||
|
public BasicAuthRequestFilter(String username, String password) {
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filter(ClientRequestContext requestContext) throws UnsupportedEncodingException {
|
||||||
|
String userAndPass = this.username + ":" + this.password;
|
||||||
|
String userAndPassEncoded = Base64.getEncoder().encodeToString(userAndPass.getBytes("utf-8"));
|
||||||
|
|
||||||
|
requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, "Basic " + userAndPassEncoded);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user