Merge branch 'develop' into stable
This commit is contained in:
commit
aad2ed6406
22
.gitignore
vendored
22
.gitignore
vendored
@ -1,11 +1,11 @@
|
||||
# Maven
|
||||
target
|
||||
pom.xml.versionsBackup
|
||||
|
||||
# Eclipse
|
||||
.project
|
||||
.classpath
|
||||
.settings
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode
|
||||
# Maven
|
||||
target
|
||||
pom.xml.versionsBackup
|
||||
|
||||
# Eclipse
|
||||
.project
|
||||
.classpath
|
||||
.settings
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode
|
||||
|
22
pom.xml
22
pom.xml
@ -2,7 +2,7 @@
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.inteligr8</groupId>
|
||||
<groupId>com.inteligr8.alfresco</groupId>
|
||||
<artifactId>activiti-java-enterprise-api</artifactId>
|
||||
<version>1.0.0-v1</version>
|
||||
<name>Alfresco Process Services ReST API Client for Java</name>
|
||||
@ -19,6 +19,7 @@
|
||||
<spring.version>5.2.14.RELEASE</spring.version>
|
||||
<spring-boot.version>2.3.10.RELEASE</spring-boot.version>
|
||||
<jersey.version>2.34</jersey.version>
|
||||
<cxf.version>3.3.2</cxf.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -26,27 +27,34 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<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>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.inject</groupId>
|
||||
<artifactId>jersey-hk2</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-json-jackson</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.security</groupId>
|
||||
<artifactId>oauth2-client</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<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;
|
||||
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.core.Feature;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -29,10 +28,7 @@ public class ApsClient {
|
||||
javax.ws.rs.client.Client client = ClientBuilder
|
||||
.newClient();
|
||||
|
||||
Feature feature = this.config.getAuthorizationFeature();
|
||||
if (feature != null)
|
||||
client.register(feature);
|
||||
|
||||
this.config.authorize(client);
|
||||
return new EnterpriseAPI(this.config.getBaseUrl() + "/api", client);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
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.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -28,14 +26,12 @@ public class ApsClientConfiguration {
|
||||
return this.baseUrl;
|
||||
}
|
||||
|
||||
public Feature getAuthorizationFeature() {
|
||||
public void authorize(Client client) {
|
||||
if (this.basicAuthUsername != null) {
|
||||
return HttpAuthenticationFeature.basic(this.basicAuthUsername, this.basicAuthPassword);
|
||||
client.register(new BasicAuthRequestFilter(this.basicAuthUsername, this.basicAuthPassword));
|
||||
} 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);
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
process.service.baseUrl=http://localhost:8080/activiti-app
|
||||
process.service.security.basicAuth.username=admin@app.activiti.com
|
||||
process.service.security.basicAuth.password=admin
|
||||
process.service.baseUrl=http://localhost:8080/activiti-app
|
||||
process.service.security.basicAuth.username=admin@app.activiti.com
|
||||
process.service.security.basicAuth.password=admin
|
||||
|
Loading…
x
Reference in New Issue
Block a user