Reputation: 899
I'm trying to migrate an example user federation provider to a new version of keycloak (https://github.com/Smartling/keycloak-user-migration-provider) but I'm not finding any obvious documentation around incompatible API changes (i.e. the UserFederationProvider
interface seems to have been replaced with several more specific interfaces, but there don't seem to be any examples of how to migrate between them).
I think I've gotten most of the changes by following the keycloak samples, but I'm confused where in the Smartling example RemoteUserFederationProvider
makes use of the UserModel
interface, which has an updateCredential
method that seems to have been removed in the latest version. How should this be implemented in more recent versions of Keycloak?
Upvotes: 1
Views: 646
Reputation: 121
I think the UserModel change happened somewhere between Keycloak 1.7 and 2.0.
This snippet is from our Keycloak 2.0 implementation.
package org.sample.keycloak.federation;
import org.keycloak.models.UserCredentialModel;
import org.keycloak.models.UserCredentialValueModel;
import org.keycloak.models.UserModel;
import org.keycloak.models.utils.UserModelDelegate;
/**
* Readonly proxy for a UserModel that prevents passwords from being updated.
*
* @author <a href="mailto:[email protected]">Bill Burke</a>
* @version $Revision: 1 $
*/
public class UserModelProxy extends UserModelDelegate {
public UserModelProxy(UserModel delegate) {
super(delegate);
}
@Override
public void setUsername(String username) {
throw new IllegalStateException("Username is readonly");
}
@Override
public void updateCredentialDirectly(UserCredentialValueModel cred) {
if (cred.getType().equals(UserCredentialModel.PASSWORD)) {
throw new IllegalStateException("Passwords are readonly");
}
super.updateCredentialDirectly(cred);
}
@Override
public void updateCredential(UserCredentialModel cred) {
if (cred.getType().equals(UserCredentialModel.PASSWORD)) {
throw new IllegalStateException("Passwords are readonly");
}
super.updateCredential(cred);
}
}
Hope this helps.
Upvotes: 1