Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit 1e81a65

Browse files
committed
Merge branch 'main' of github.com:corbado/corbado-java
2 parents b271a5a + 9156299 commit 1e81a65

5 files changed

Lines changed: 43 additions & 16 deletions

File tree

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ You can find the latest SDK version at [central repository](https://repo1.maven.
2727
Add this dependency to your project's build file:
2828

2929
```groovy
30-
implementation "com.corbado:corbado-java:1.0.5"
30+
implementation "com.corbado:corbado-java:1.0.6"
3131
```
3232

3333
#### Maven users
@@ -38,7 +38,7 @@ Add this dependency to your project's POM:
3838
<dependency>
3939
<groupId>com.corbado</groupId>
4040
<artifactId>corbado-java</artifactId>
41-
<version>1.0.5</version>
41+
<version>1.0.6</version>
4242
</dependency>
4343
```
4444

@@ -47,8 +47,18 @@ Add this dependency to your project's POM:
4747
To create a Corbado Java SDK instance you need to provide your `Project ID` and `API secret` which can be found at the [Developer Panel](https://app.corbado.com).
4848

4949
```Java
50-
final Config config = new Config(projectId, apiSecret);
51-
CorbadoSdk sdk = new CorbadoSDK(config);
50+
//Example initialization of Config class with builder (preferred).
51+
Config config = null;
52+
if (StringUtils.isEmpty(backendApi)) {
53+
config = Config.builder().apiSecret(apiSecret).projectId(projectId).build();
54+
} else {
55+
config =
56+
Config.builder().apiSecret(apiSecret).projectId(projectId).backendApi(backendApi).build();
57+
}
58+
//Alternative initialization with 'new'.
59+
final Config config = new Config(projectId, apiSecret);
60+
61+
CorbadoSdk sdk = new CorbadoSDK(config);
5262
```
5363

5464
### Examples

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.5
1+
1.0.6

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<groupId>com.corbado</groupId>
44
<artifactId>corbado-java</artifactId>
55
<packaging>jar</packaging>
6-
<version>1.0.5</version>
6+
<version>1.0.6</version>
77
<name>Corbado Java</name>
88
<description>Corbado Java SDK</description>
99
<url>https://github.com/corbado/corbado-java</url>

src/main/java/com/corbado/sdk/Config.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import java.net.MalformedURLException;
44
import java.net.URL;
5-
import org.apache.commons.lang3.StringUtils;
65
import lombok.Builder;
76
import lombok.Getter;
87
import lombok.NonNull;
98
import lombok.Setter;
109
import lombok.extern.slf4j.Slf4j;
10+
import org.apache.commons.lang3.StringUtils;
1111

1212
/**
1313
* Configuration class for setting up project parameters.
@@ -24,7 +24,6 @@ public class Config {
2424
private static final String HTTPS = "https://";
2525

2626
// Fields
27-
2827
/** The Constant API_VERSION. */
2928
private static final String API_VERSION = "2";
3029

@@ -34,17 +33,27 @@ public class Config {
3433
/** Project Id must begin with this prefix. */
3534
private static final String PROJECT_ID_PREFIX = "pro-";
3635

36+
/** Default backend API URL. */
37+
private static final String DEFAULT_BACKEND_API = "https://backendapi.cloud.corbado.io/v2";
38+
39+
/** Default short session cookie name. */
40+
private static final String DEFAULT_SHORT_SESSION_COOKIE_NAME = "cbo_short_session";
41+
42+
/** Default short session length in days. */
43+
private static final Integer DEFAULT_SHORT_SESSION_LENGTH = 300;
44+
3745
/** The project id with custom setter. Must be provided. */
3846
@NonNull @Getter private String projectId;
3947

4048
/** The api secret with custom setter. Must be provided. */
4149
@NonNull @Getter private String apiSecret;
4250

4351
/** The backend api with custom setter. Default value: "https://backendapi.cloud.corbado.io/v2" */
44-
@Getter @Builder.Default private String backendApi = "https://backendapi.cloud.corbado.io/v2";
52+
@Getter @Builder.Default private String backendApi = DEFAULT_BACKEND_API;
4553

4654
/** The short session cookie name. Default value: "cbo_short_session" */
47-
@Getter @Setter @Builder.Default private String shortSessionCookieName = "cbo_short_session";
55+
@Getter @Setter @Builder.Default
56+
private String shortSessionCookieName = DEFAULT_SHORT_SESSION_COOKIE_NAME;
4857

4958
/** The issuer. Used for session verification. */
5059
@Getter @Setter private String issuer;
@@ -53,7 +62,8 @@ public class Config {
5362
@Getter private String frontendApi;
5463

5564
/** The short session length for session service. Default = 300. */
56-
@Getter @Setter @Builder.Default private Integer shortSessionLength = 300;
65+
@Getter @Setter @Builder.Default
66+
private Integer shortSessionLength = DEFAULT_SHORT_SESSION_LENGTH;
5767

5868
/** Flag to cache keys in session service. Default = true. */
5969
@Getter @Setter @Builder.Default private boolean cacheKeys = true;
@@ -69,13 +79,16 @@ public class Config {
6979
* @param apiSecret the api secret
7080
*/
7181
public Config(@NonNull final String projectId, @NonNull final String apiSecret) {
72-
7382
setProjectId(projectId); // set and validate
7483
setApiSecret(apiSecret);
7584

7685
// default values
7786
setFrontendApi(projectId);
7887
setIssuer(this.frontendApi);
88+
this.backendApi = DEFAULT_BACKEND_API;
89+
this.shortSessionCookieName = DEFAULT_SHORT_SESSION_COOKIE_NAME;
90+
this.shortSessionLength = DEFAULT_SHORT_SESSION_LENGTH;
91+
this.cacheKeys = true;
7992
}
8093

8194
/**
@@ -163,7 +176,7 @@ public void setProjectId(@NonNull String projectId) {
163176
}
164177

165178
/**
166-
* Instantiates a new config.
179+
* Instantiates a new config. Full constructor used by Lomboc Builder.
167180
*
168181
* @param projectId the project id
169182
* @param apiSecret the api secret
@@ -189,13 +202,17 @@ public Config(
189202
setProjectId(projectId);
190203
setApiSecret(apiSecret);
191204
setBackendApi(backendApi);
192-
setShortSessionCookieName(shortSessionCookieName);
205+
setShortSessionCookieName(
206+
shortSessionCookieName != null
207+
? shortSessionCookieName
208+
: DEFAULT_SHORT_SESSION_COOKIE_NAME);
193209
if (StringUtils.isEmpty(frontendApi)) {
194210
setFrontendApi(projectId);
195211
} else {
196212
setFrontendApi(frontendApi);
197213
}
198-
setShortSessionLength(shortSessionLength);
214+
setShortSessionLength(
215+
shortSessionLength != null ? shortSessionLength : DEFAULT_SHORT_SESSION_LENGTH);
199216
setCacheKeys(cacheKeys);
200217
setCname(cname);
201218

src/main/java/com/corbado/sdk/CorbadoSdk.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ private static String getLanguageVersion() {
102102
* @return the version
103103
*/
104104
public String getVersion() {
105-
return "1.0.5";
105+
return "1.0.6";
106106
}
107107
}

0 commit comments

Comments
 (0)