Defoncesko
Defoncesko

Reputation: 687

Keycloak Example - The method getValue() is undefined for the type UserCredentialModel

I am trying to handle keycloak's Custom User Storage SPI with the example provided. https://github.com/keycloak/keycloak-quickstarts/tree/latest/user-storage-simple

When launching mvn clean install wildfly:deploy while Keycloak is launched, I get 3 errors from this file PropertyFileUserStorageProvider.java:

variable cred of type org.keycloak.models.UserCredentialModel cannot find symbol (method getValue())

I don't get why I am facing those errors. They also use this getValue method in the documentation. https://www.keycloak.org/docs/latest/server_development/index.html#_user-storage-spi

Java & Maven versions

Thanks for your help

Upvotes: 1

Views: 1057

Answers (1)

Fabrice G.
Fabrice G.

Reputation: 150

UserCredentialModel class has changed a lot in the latest Keycloak release 8.0.0

It looks like the "quick start examples" need some fixes to work with this release

Something like :

    @Override
    public boolean isValid(RealmModel realm, UserModel user, CredentialInput input) {
        // No need to check input is of type UserCredentialModel since there no need to cast it anymore
        if (!supportsCredentialType(input.getType())) return false;

        String password = properties.getProperty(user.getUsername());
        if (password == null) return false;
        // Input Password can now be obtained using the getChallengeResponse() method of the CredentialInput  type
        return password.equals(input.getChallengeResponse());
    }

Hope this will help.

Regards,

Upvotes: 2

Related Questions