Skip to content

Commit 589e149

Browse files
Merge pull request #84 from OneBusAway/release-please--branches--main--changes--next
release: 0.1.0-alpha.28
2 parents 7f835a5 + 00b00cd commit 589e149

File tree

66 files changed

+726
-358
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+726
-358
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.1.0-alpha.27"
2+
".": "0.1.0-alpha.28"
33
}

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
## 0.1.0-alpha.28 (2025-07-19)
4+
5+
Full Changelog: [v0.1.0-alpha.27...v0.1.0-alpha.28](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.27...v0.1.0-alpha.28)
6+
7+
### Features
8+
9+
* **client:** add https config options ([33a2005](https://github.com/OneBusAway/java-sdk/commit/33a20057b47858e95ed95e55929f53de8d1ea730))
10+
11+
12+
### Bug Fixes
13+
14+
* **client:** ensure error handling always occurs ([2673594](https://github.com/OneBusAway/java-sdk/commit/2673594be236598da80ba68129dbf43f6c6c9c63))
15+
16+
17+
### Chores
18+
19+
* **internal:** refactor delegating from client to options ([4fcb8ab](https://github.com/OneBusAway/java-sdk/commit/4fcb8abd83fe8b32a232364375a8f5e0051f8416))
20+
321
## 0.1.0-alpha.27 (2025-07-17)
422

523
Full Changelog: [v0.1.0-alpha.26...v0.1.0-alpha.27](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.26...v0.1.0-alpha.27)

README.md

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

33
<!-- x-release-please-start-version -->
44

5-
[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-java)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.27)
6-
[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.27/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.27)
5+
[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-java)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.28)
6+
[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.28/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.28)
77

88
<!-- x-release-please-end -->
99

@@ -15,7 +15,7 @@ It is generated with [Stainless](https://www.stainless.com/).
1515

1616
<!-- x-release-please-start-version -->
1717

18-
The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). Javadocs are available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.27).
18+
The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). Javadocs are available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.28).
1919

2020
<!-- x-release-please-end -->
2121

@@ -26,7 +26,7 @@ The REST API documentation can be found on [developer.onebusaway.org](https://de
2626
### Gradle
2727

2828
```kotlin
29-
implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.27")
29+
implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.28")
3030
```
3131

3232
### Maven
@@ -35,7 +35,7 @@ implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.27")
3535
<dependency>
3636
<groupId>org.onebusaway</groupId>
3737
<artifactId>onebusaway-sdk-java</artifactId>
38-
<version>0.1.0-alpha.27</version>
38+
<version>0.1.0-alpha.28</version>
3939
</dependency>
4040
```
4141

@@ -318,6 +318,27 @@ OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder()
318318
.build();
319319
```
320320

321+
### HTTPS
322+
323+
> [!NOTE]
324+
> Most applications should not call these methods, and instead use the system defaults. The defaults include
325+
> special optimizations that can be lost if the implementations are modified.
326+
327+
To configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:
328+
329+
```java
330+
import org.onebusaway.client.OnebusawaySdkClient;
331+
import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient;
332+
333+
OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder()
334+
.fromEnv()
335+
// If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.
336+
.sslSocketFactory(yourSSLSocketFactory)
337+
.trustManager(yourTrustManager)
338+
.hostnameVerifier(yourHostnameVerifier)
339+
.build();
340+
```
341+
321342
### Custom HTTP client
322343

323344
The SDK consists of three artifacts:

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repositories {
88

99
allprojects {
1010
group = "org.onebusaway"
11-
version = "0.1.0-alpha.27" // x-release-please-version
11+
version = "0.1.0-alpha.28" // x-release-please-version
1212
}
1313

1414
subprojects {

onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import java.io.InputStream
55
import java.net.Proxy
66
import java.time.Duration
77
import java.util.concurrent.CompletableFuture
8+
import javax.net.ssl.HostnameVerifier
9+
import javax.net.ssl.SSLSocketFactory
10+
import javax.net.ssl.X509TrustManager
811
import okhttp3.Call
912
import okhttp3.Callback
1013
import okhttp3.HttpUrl.Companion.toHttpUrl
@@ -191,13 +194,28 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC
191194

192195
private var timeout: Timeout = Timeout.default()
193196
private var proxy: Proxy? = null
197+
private var sslSocketFactory: SSLSocketFactory? = null
198+
private var trustManager: X509TrustManager? = null
199+
private var hostnameVerifier: HostnameVerifier? = null
194200

195201
fun timeout(timeout: Timeout) = apply { this.timeout = timeout }
196202

197203
fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build())
198204

199205
fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }
200206

207+
fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply {
208+
this.sslSocketFactory = sslSocketFactory
209+
}
210+
211+
fun trustManager(trustManager: X509TrustManager?) = apply {
212+
this.trustManager = trustManager
213+
}
214+
215+
fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply {
216+
this.hostnameVerifier = hostnameVerifier
217+
}
218+
201219
fun build(): OkHttpClient =
202220
OkHttpClient(
203221
okhttp3.OkHttpClient.Builder()
@@ -206,6 +224,19 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC
206224
.writeTimeout(timeout.write())
207225
.callTimeout(timeout.request())
208226
.proxy(proxy)
227+
.apply {
228+
val sslSocketFactory = sslSocketFactory
229+
val trustManager = trustManager
230+
if (sslSocketFactory != null && trustManager != null) {
231+
sslSocketFactory(sslSocketFactory, trustManager)
232+
} else {
233+
check((sslSocketFactory != null) == (trustManager != null)) {
234+
"Both or none of `sslSocketFactory` and `trustManager` must be set, but only one was set"
235+
}
236+
}
237+
238+
hostnameVerifier?.let(::hostnameVerifier)
239+
}
209240
.build()
210241
.apply {
211242
// We usually make all our requests to the same host so it makes sense to

onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt

Lines changed: 94 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ import com.fasterxml.jackson.databind.json.JsonMapper
66
import java.net.Proxy
77
import java.time.Clock
88
import java.time.Duration
9+
import java.util.Optional
10+
import javax.net.ssl.HostnameVerifier
11+
import javax.net.ssl.SSLSocketFactory
12+
import javax.net.ssl.X509TrustManager
13+
import kotlin.jvm.optionals.getOrNull
914
import org.onebusaway.client.OnebusawaySdkClient
1015
import org.onebusaway.client.OnebusawaySdkClientImpl
1116
import org.onebusaway.core.ClientOptions
1217
import org.onebusaway.core.Timeout
1318
import org.onebusaway.core.http.Headers
1419
import org.onebusaway.core.http.QueryParams
20+
import org.onebusaway.core.jsonMapper
1521

1622
class OnebusawaySdkOkHttpClient private constructor() {
1723

@@ -29,10 +35,63 @@ class OnebusawaySdkOkHttpClient private constructor() {
2935
class Builder internal constructor() {
3036

3137
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
32-
private var timeout: Timeout = Timeout.default()
3338
private var proxy: Proxy? = null
39+
private var sslSocketFactory: SSLSocketFactory? = null
40+
private var trustManager: X509TrustManager? = null
41+
private var hostnameVerifier: HostnameVerifier? = null
3442

35-
fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) }
43+
fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }
44+
45+
/** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
46+
fun proxy(proxy: Optional<Proxy>) = proxy(proxy.getOrNull())
47+
48+
/**
49+
* The socket factory used to secure HTTPS connections.
50+
*
51+
* If this is set, then [trustManager] must also be set.
52+
*
53+
* If unset, then the system default is used. Most applications should not call this method,
54+
* and instead use the system default. The default include special optimizations that can be
55+
* lost if the implementation is modified.
56+
*/
57+
fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply {
58+
this.sslSocketFactory = sslSocketFactory
59+
}
60+
61+
/** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */
62+
fun sslSocketFactory(sslSocketFactory: Optional<SSLSocketFactory>) =
63+
sslSocketFactory(sslSocketFactory.getOrNull())
64+
65+
/**
66+
* The trust manager used to secure HTTPS connections.
67+
*
68+
* If this is set, then [sslSocketFactory] must also be set.
69+
*
70+
* If unset, then the system default is used. Most applications should not call this method,
71+
* and instead use the system default. The default include special optimizations that can be
72+
* lost if the implementation is modified.
73+
*/
74+
fun trustManager(trustManager: X509TrustManager?) = apply {
75+
this.trustManager = trustManager
76+
}
77+
78+
/** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */
79+
fun trustManager(trustManager: Optional<X509TrustManager>) =
80+
trustManager(trustManager.getOrNull())
81+
82+
/**
83+
* The verifier used to confirm that response certificates apply to requested hostnames for
84+
* HTTPS connections.
85+
*
86+
* If unset, then a default hostname verifier is used.
87+
*/
88+
fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply {
89+
this.hostnameVerifier = hostnameVerifier
90+
}
91+
92+
/** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */
93+
fun hostnameVerifier(hostnameVerifier: Optional<HostnameVerifier>) =
94+
hostnameVerifier(hostnameVerifier.getOrNull())
3695

3796
/**
3897
* Whether to throw an exception if any of the Jackson versions detected at runtime are
@@ -49,6 +108,30 @@ class OnebusawaySdkOkHttpClient private constructor() {
49108

50109
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
51110

111+
fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) }
112+
113+
/** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */
114+
fun baseUrl(baseUrl: Optional<String>) = baseUrl(baseUrl.getOrNull())
115+
116+
fun responseValidation(responseValidation: Boolean) = apply {
117+
clientOptions.responseValidation(responseValidation)
118+
}
119+
120+
fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) }
121+
122+
/**
123+
* Sets the maximum time allowed for a complete HTTP call, not including retries.
124+
*
125+
* See [Timeout.request] for more details.
126+
*
127+
* For fine-grained control, pass a [Timeout] object.
128+
*/
129+
fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) }
130+
131+
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }
132+
133+
fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
134+
52135
fun headers(headers: Headers) = apply { clientOptions.headers(headers) }
53136

54137
fun headers(headers: Map<String, Iterable<String>>) = apply {
@@ -129,30 +212,6 @@ class OnebusawaySdkOkHttpClient private constructor() {
129212
clientOptions.removeAllQueryParams(keys)
130213
}
131214

132-
fun timeout(timeout: Timeout) = apply {
133-
clientOptions.timeout(timeout)
134-
this.timeout = timeout
135-
}
136-
137-
/**
138-
* Sets the maximum time allowed for a complete HTTP call, not including retries.
139-
*
140-
* See [Timeout.request] for more details.
141-
*
142-
* For fine-grained control, pass a [Timeout] object.
143-
*/
144-
fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build())
145-
146-
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }
147-
148-
fun proxy(proxy: Proxy) = apply { this.proxy = proxy }
149-
150-
fun responseValidation(responseValidation: Boolean) = apply {
151-
clientOptions.responseValidation(responseValidation)
152-
}
153-
154-
fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
155-
156215
fun fromEnv() = apply { clientOptions.fromEnv() }
157216

158217
/**
@@ -163,7 +222,15 @@ class OnebusawaySdkOkHttpClient private constructor() {
163222
fun build(): OnebusawaySdkClient =
164223
OnebusawaySdkClientImpl(
165224
clientOptions
166-
.httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build())
225+
.httpClient(
226+
OkHttpClient.builder()
227+
.timeout(clientOptions.timeout())
228+
.proxy(proxy)
229+
.sslSocketFactory(sslSocketFactory)
230+
.trustManager(trustManager)
231+
.hostnameVerifier(hostnameVerifier)
232+
.build()
233+
)
167234
.build()
168235
)
169236
}

0 commit comments

Comments
 (0)