Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.stytch.java.b2b.api.ssooidc
// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!
import com.squareup.moshi.Moshi
import com.stytch.java.b2b.models.ssooidc.CreateConnectionRequest
import com.stytch.java.b2b.models.ssooidc.CreateConnectionRequestOptions
import com.stytch.java.b2b.models.ssooidc.CreateConnectionResponse
import com.stytch.java.b2b.models.ssooidc.UpdateConnectionRequest
import com.stytch.java.b2b.models.ssooidc.UpdateConnectionRequestOptions
import com.stytch.java.b2b.models.ssooidc.UpdateConnectionResponse
import com.stytch.java.common.InstantAdapter
import com.stytch.java.common.StytchResult
import com.stytch.java.http.HttpClient
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.future.asCompletableFuture
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.concurrent.CompletableFuture
public interface OIDC {
/**
* Create a new OIDC Connection. /%}
*/
public suspend fun createConnection(
data: CreateConnectionRequest,
methodOptions: CreateConnectionRequestOptions? = null,
): StytchResult
/**
* Create a new OIDC Connection. /%}
*/
public fun createConnection(
data: CreateConnectionRequest,
methodOptions: CreateConnectionRequestOptions? = null,
callback: (StytchResult) -> Unit,
)
/**
* Create a new OIDC Connection. /%}
*/
public fun createConnectionCompletable(
data: CreateConnectionRequest,
methodOptions: CreateConnectionRequestOptions? = null,
): CompletableFuture>
/**
* Updates an existing OIDC connection.
*
* When the value of `issuer` changes, Stytch will attempt to retrieve the
* [OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata) document found
* at `$/.well-known/openid-configuration`.
* If the metadata document can be retrieved successfully, Stytch will use it to infer the values of `authorization_url`,
* `token_url`, `jwks_url`, and `userinfo_url`.
* The `client_id` and `client_secret` values cannot be inferred from the metadata document, and *must* be passed in
* explicitly.
*
* If the metadata document cannot be retrieved, Stytch will still update the connection using values from the request
* body.
*
* If the metadata document can be retrieved, and values are passed in the request body, the explicit values passed in
* from the request body will take precedence over the values inferred from the metadata document.
*
* Note that a newly created connection will not become active until all of the following fields are provided:
* * `issuer`
* * `client_id`
* * `client_secret`
* * `authorization_url`
* * `token_url`
* * `userinfo_url`
* * `jwks_url`
* /%}
*/
public suspend fun updateConnection(
data: UpdateConnectionRequest,
methodOptions: UpdateConnectionRequestOptions? = null,
): StytchResult
/**
* Updates an existing OIDC connection.
*
* When the value of `issuer` changes, Stytch will attempt to retrieve the
* [OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata) document found
* at `$/.well-known/openid-configuration`.
* If the metadata document can be retrieved successfully, Stytch will use it to infer the values of `authorization_url`,
* `token_url`, `jwks_url`, and `userinfo_url`.
* The `client_id` and `client_secret` values cannot be inferred from the metadata document, and *must* be passed in
* explicitly.
*
* If the metadata document cannot be retrieved, Stytch will still update the connection using values from the request
* body.
*
* If the metadata document can be retrieved, and values are passed in the request body, the explicit values passed in
* from the request body will take precedence over the values inferred from the metadata document.
*
* Note that a newly created connection will not become active until all of the following fields are provided:
* * `issuer`
* * `client_id`
* * `client_secret`
* * `authorization_url`
* * `token_url`
* * `userinfo_url`
* * `jwks_url`
* /%}
*/
public fun updateConnection(
data: UpdateConnectionRequest,
methodOptions: UpdateConnectionRequestOptions? = null,
callback: (StytchResult) -> Unit,
)
/**
* Updates an existing OIDC connection.
*
* When the value of `issuer` changes, Stytch will attempt to retrieve the
* [OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata) document found
* at `$/.well-known/openid-configuration`.
* If the metadata document can be retrieved successfully, Stytch will use it to infer the values of `authorization_url`,
* `token_url`, `jwks_url`, and `userinfo_url`.
* The `client_id` and `client_secret` values cannot be inferred from the metadata document, and *must* be passed in
* explicitly.
*
* If the metadata document cannot be retrieved, Stytch will still update the connection using values from the request
* body.
*
* If the metadata document can be retrieved, and values are passed in the request body, the explicit values passed in
* from the request body will take precedence over the values inferred from the metadata document.
*
* Note that a newly created connection will not become active until all of the following fields are provided:
* * `issuer`
* * `client_id`
* * `client_secret`
* * `authorization_url`
* * `token_url`
* * `userinfo_url`
* * `jwks_url`
* /%}
*/
public fun updateConnectionCompletable(
data: UpdateConnectionRequest,
methodOptions: UpdateConnectionRequestOptions? = null,
): CompletableFuture>
}
internal class OIDCImpl(
private val httpClient: HttpClient,
private val coroutineScope: CoroutineScope,
) : OIDC {
private val moshi = Moshi.Builder().add(InstantAdapter()).build()
override suspend fun createConnection(
data: CreateConnectionRequest,
methodOptions: CreateConnectionRequestOptions?,
): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
methodOptions?.let {
headers = methodOptions.addHeaders(headers)
}
val asJson = moshi.adapter(CreateConnectionRequest::class.java).toJson(data)
httpClient.post("/v1/b2b/sso/oidc/${data.organizationId}", asJson, headers)
}
override fun createConnection(
data: CreateConnectionRequest,
methodOptions: CreateConnectionRequestOptions?,
callback: (StytchResult) -> Unit,
) {
coroutineScope.launch {
callback(createConnection(data, methodOptions))
}
}
override fun createConnectionCompletable(
data: CreateConnectionRequest,
methodOptions: CreateConnectionRequestOptions?,
): CompletableFuture> =
coroutineScope.async {
createConnection(data, methodOptions)
}.asCompletableFuture()
override suspend fun updateConnection(
data: UpdateConnectionRequest,
methodOptions: UpdateConnectionRequestOptions?,
): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
methodOptions?.let {
headers = methodOptions.addHeaders(headers)
}
val asJson = moshi.adapter(UpdateConnectionRequest::class.java).toJson(data)
httpClient.put("/v1/b2b/sso/oidc/${data.organizationId}/connections/${data.connectionId}", asJson, headers)
}
override fun updateConnection(
data: UpdateConnectionRequest,
methodOptions: UpdateConnectionRequestOptions?,
callback: (StytchResult) -> Unit,
) {
coroutineScope.launch {
callback(updateConnection(data, methodOptions))
}
}
override fun updateConnectionCompletable(
data: UpdateConnectionRequest,
methodOptions: UpdateConnectionRequestOptions?,
): CompletableFuture> =
coroutineScope.async {
updateConnection(data, methodOptions)
}.asCompletableFuture()
}