JSON migration
This commit is contained in:
parent
91283878ac
commit
7badd3d5e5
2 changed files with 26 additions and 11 deletions
|
@ -266,6 +266,10 @@ public class RealmRepresentation {
|
|||
this.codeSecret = codeSecret;
|
||||
}
|
||||
|
||||
public Boolean isPasswordCredentialGrantAllowed() {
|
||||
return passwordCredentialGrantAllowed;
|
||||
}
|
||||
|
||||
public Boolean isRegistrationAllowed() {
|
||||
return registrationAllowed;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.keycloak.models.KeycloakSession;
|
|||
import org.keycloak.models.LDAPConstants;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.UserFederationEventAwareProviderFactory;
|
||||
import org.keycloak.models.UserFederationMapperModel;
|
||||
import org.keycloak.models.UserFederationProvider;
|
||||
import org.keycloak.models.UserFederationProviderFactory;
|
||||
import org.keycloak.models.UserFederationProviderModel;
|
||||
|
@ -12,6 +13,7 @@ import org.keycloak.models.utils.DefaultAuthenticationFlows;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.naming.directory.SearchControls;
|
||||
|
||||
|
@ -43,26 +45,34 @@ public class MigrateTo1_3_0_Beta1 {
|
|||
Map<String, String> config = fedProvider.getConfig();
|
||||
|
||||
// Update config properties for LDAP federation provider
|
||||
if (config.get(LDAPConstants.SEARCH_SCOPE) == null) {
|
||||
config.put(LDAPConstants.SEARCH_SCOPE, String.valueOf(SearchControls.SUBTREE_SCOPE));
|
||||
}
|
||||
|
||||
String usersDn = config.remove("userDnSuffix");
|
||||
if (usersDn != null && config.get(LDAPConstants.USERS_DN) == null) {
|
||||
config.put(LDAPConstants.USERS_DN, usersDn);
|
||||
}
|
||||
|
||||
String rdnLdapAttribute = config.get(LDAPConstants.USERNAME_LDAP_ATTRIBUTE);
|
||||
if (rdnLdapAttribute != null) {
|
||||
if (rdnLdapAttribute.equalsIgnoreCase(LDAPConstants.SAM_ACCOUNT_NAME)) {
|
||||
String usernameLdapAttribute = config.get(LDAPConstants.USERNAME_LDAP_ATTRIBUTE);
|
||||
if (usernameLdapAttribute != null && config.get(LDAPConstants.RDN_LDAP_ATTRIBUTE) == null) {
|
||||
if (usernameLdapAttribute.equalsIgnoreCase(LDAPConstants.SAM_ACCOUNT_NAME)) {
|
||||
config.put(LDAPConstants.RDN_LDAP_ATTRIBUTE, LDAPConstants.CN);
|
||||
} else {
|
||||
config.put(LDAPConstants.RDN_LDAP_ATTRIBUTE, rdnLdapAttribute);
|
||||
config.put(LDAPConstants.RDN_LDAP_ATTRIBUTE, usernameLdapAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.get(LDAPConstants.UUID_LDAP_ATTRIBUTE) == null) {
|
||||
String uuidAttrName = LDAPConstants.getUuidAttributeName(config.get(LDAPConstants.VENDOR));
|
||||
config.put(LDAPConstants.UUID_LDAP_ATTRIBUTE, uuidAttrName);
|
||||
}
|
||||
|
||||
realm.updateUserFederationProvider(fedProvider);
|
||||
|
||||
// Create default mappers for LDAP
|
||||
Set<UserFederationMapperModel> mappers = realm.getUserFederationMappersByFederationProvider(fedProvider.getId());
|
||||
if (mappers.isEmpty()) {
|
||||
UserFederationProviderFactory ldapFactory = (UserFederationProviderFactory) session.getKeycloakSessionFactory().getProviderFactory(UserFederationProvider.class, LDAPConstants.LDAP_PROVIDER);
|
||||
if (ldapFactory != null) {
|
||||
((UserFederationEventAwareProviderFactory) ldapFactory).onProviderModelCreated(realm, fedProvider);
|
||||
|
@ -70,4 +80,5 @@ public class MigrateTo1_3_0_Beta1 {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue