Skip to content

Commit

Permalink
Updated example to KC26.0.7 (#1046)
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuster <[email protected]>
  • Loading branch information
sschu authored Jan 2, 2025
1 parent c229f70 commit b079f6c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions custom-user-federation-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ plugins {
}

ext {
keycloakVersion = '25.0.3'
keycloakVersion = '26.0.7'
}

dependencies {
compileOnly "org.keycloak:keycloak-services:${keycloakVersion}"
compileOnly "org.keycloak:keycloak-model-legacy:${keycloakVersion}"
compileOnly "org.keycloak:keycloak-model-storage:${keycloakVersion}"
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.keycloak.models.KeycloakSession
import org.keycloak.protocol.oidc.representations.OIDCConfigurationRepresentation
import org.keycloak.util.JsonSerialization
import java.io.IOException
import java.io.InputStream

class CustomIdentityProviderFactory : AbstractIdentityProviderFactory<CustomIdentityProvider>() {
override fun getName(): String = "custom idp"
Expand All @@ -17,14 +16,14 @@ class CustomIdentityProviderFactory : AbstractIdentityProviderFactory<CustomIden
return CustomIdentityProvider(session, CustomIdentityProviderConfig(model))
}

override fun parseConfig(session: KeycloakSession, inputStream: InputStream): Map<String, String> {
return parseOIDCConfig(session, inputStream)
override fun parseConfig(session: KeycloakSession, rawConfig: String): Map<String, String> {
return parseOIDCConfig(session, rawConfig)
}

private fun parseOIDCConfig(session: KeycloakSession, inputStream: InputStream): Map<String, String> {
private fun parseOIDCConfig(session: KeycloakSession, rawConfig: String): Map<String, String> {
val rep: OIDCConfigurationRepresentation
try {
rep = JsonSerialization.readValue(inputStream, OIDCConfigurationRepresentation::class.java)
rep = JsonSerialization.readValue(rawConfig, OIDCConfigurationRepresentation::class.java)
} catch (e: IOException) {
throw RuntimeException("failed to load openid connect metadata", e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.keycloak.credential.CredentialInput
import org.keycloak.credential.CredentialInputUpdater
import org.keycloak.credential.CredentialInputValidator
import org.keycloak.models.credential.PasswordCredentialModel
import org.keycloak.credential.LegacyUserCredentialManager
import org.keycloak.credential.UserCredentialManager
import org.keycloak.models.*
import org.keycloak.models.credential.*
import org.keycloak.storage.ReadOnlyException
Expand Down Expand Up @@ -50,7 +50,7 @@ class CustomUserStorageProvider(private val session: KeycloakSession, private va
}

override fun credentialManager(): SubjectCredentialManager {
return LegacyUserCredentialManager(session, realm, this)
return UserCredentialManager(session, realm, this)
}
}

Expand Down

0 comments on commit b079f6c

Please sign in to comment.