Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Squidex/sdk-java into simplify-build
Browse files Browse the repository at this point in the history
# Conflicts:
#	.openapi-generator-ignore
#	.openapi-generator/FILES
#	build.gradle
#	src/main/java/com/squidex/api/AuthInterceptor.java
#	src/main/java/com/squidex/api/SquidexClient.java
#	src/main/java/com/squidex/api/SquidexClientBuilder.java
#	src/test/java/com/squidex/api/TestSetup.java
  • Loading branch information
SebastianStehle committed Sep 1, 2024
2 parents 4a3962f + 820fa20 commit 0333680
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.7
with:
token: ${{ secrets.WORKFLOW_SECRET }}

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4.1.7

- name: Set up Java
id: setup-jre
uses: actions/setup-java@v1
uses: actions/setup-java@v4.2.2
with:
java-version: "11"
architecture: x64
distribution: microsoft

- name: Compile
run: ./gradlew compileJava
Expand Down Expand Up @@ -50,4 +51,4 @@ jobs:
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_PUBLISH_REGISTRY_URL: "https://s01.oss.sonatype.org/content/repositories/releases/"
MAVEN_PUBLISH_REGISTRY_URL: "https://s01.oss.sonatype.org/content/repositories/releases/"
9 changes: 4 additions & 5 deletions src/main/java/com/squidex/api/AuthInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.time.Instant;
import java.util.Objects;

import okhttp3.FormBody;
Expand All @@ -18,15 +17,15 @@

public final class AuthInterceptor implements Interceptor {
private final Gson gson = new Gson();
private final String baseUrl;
private final String url;
private final String clientId;
private final String clientSecret;
private final TokenStore tokenStore;
private final OkHttpClient httpClient;

public AuthInterceptor(OkHttpClient httpClient, String baseUrl, String clientId, String clientSecret, TokenStore tokenStore) {
public AuthInterceptor(OkHttpClient httpClient, String url, String clientId, String clientSecret, TokenStore tokenStore) {
this.httpClient = httpClient;
this.baseUrl = baseUrl;
this.url = url;
this.clientId = clientId;
this.clientSecret = clientSecret;
this.tokenStore = tokenStore;
Expand Down Expand Up @@ -72,7 +71,7 @@ private AccessToken acquireToken() throws IOException {
.add("scope", "squidex-api")
.build();

HttpUrl tokenUrl = Objects.requireNonNull(HttpUrl.parse(baseUrl))
HttpUrl tokenUrl = Objects.requireNonNull(HttpUrl.parse(url))
.newBuilder()
.addPathSegments("identity-server/connect/token")
.build();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/squidex/api/SquidexClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public class SquidexClient {
private final String appName;
private final String clientId;
private final String clientSecret;
private final String baseUrl;
private final String url;

public SquidexClient(ApiClient apiClient, String appName, String clientId, String clientSecret, String baseUrl) {
this.appName = appName;
this.clientId = clientId;
this.clientSecret = clientSecret;
this.baseUrl = baseUrl;
this.url = baseUrl;
this.appsApi = memoize(() -> new AppsApi(apiClient));
this.assetsApi = memoize(() -> new AssetsApi(apiClient));
this.backupsApi = memoize(() -> new BackupsApi(apiClient));
Expand Down Expand Up @@ -106,8 +106,8 @@ public String getClientSecret() {
return clientSecret;
}

public String getBaseUrl() {
return baseUrl;
public String getUrl() {
return url;
}

public UserManagementApi userManagement() {
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/com/squidex/api/SquidexClientBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@
import okhttp3.Response;

public final class SquidexClientBuilder {
private String baseUrl = "https://cloud.squidex.io";
private String url = "https://cloud.squidex.io";
private String clientId;
private String clientSecret;
private String appName;
private TokenStore tokenStore;
private OkHttpClient httpClient;
private boolean trustAllCerts;

public SquidexClientBuilder baseUrl(String baseUrl) {
this.baseUrl = baseUrl;
public SquidexClientBuilder url(String url) {
this.url = url;
return this;
}

public String url() {
return this.url;
}

public SquidexClientBuilder clientId(String clientId) {
this.clientId = clientId;
return this;
Expand Down Expand Up @@ -124,7 +128,7 @@ public java.security.cert.X509Certificate[] getAcceptedIssuers() {

AuthInterceptor interceptor = new AuthInterceptor(
this.httpClient,
this.baseUrl,
this.url,
this.clientId,
this.clientSecret,
this.tokenStore);
Expand All @@ -148,9 +152,9 @@ public Response intercept(@NotNull Chain chain) throws IOException {
.build();

ApiClient apiClient = new ApiClient(this.httpClient);
apiClient.setBasePath(this.baseUrl);
apiClient.setBasePath(this.url);
apiClient.setVerifyingSsl(!this.trustAllCerts);

return new SquidexClient(apiClient, this.appName, this.clientId, this.clientSecret, this.baseUrl);
return new SquidexClient(apiClient, this.appName, this.clientId, this.clientSecret, this.url);
}
}
2 changes: 1 addition & 1 deletion src/test/java/com/squidex/api/TestSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void beforeAll(ExtensionContext context) throws Exception {
System.out.printf("Using <appName>=<%s>%n", client.getAppName());
System.out.printf("Using <clientId>=<%s>%n", client.getClientId());
System.out.printf("Using <clientSecret>=<%s>%n", client.getClientSecret());
System.out.printf("Using <baseUrl>=<%s>%n", client.getBaseUrl());
System.out.printf("Using <baseUrl>=<%s>%n", client.getUrl());

this.waitForServer();

Expand Down

0 comments on commit 0333680

Please sign in to comment.