KEYCLOAK-18359 Default role migration is not performed correctly when empty realm id

This commit is contained in:
vramik 2021-06-07 22:30:54 +02:00 committed by Hynek Mlnařík
parent 74089a51b3
commit e3c76035b2
2 changed files with 3 additions and 10 deletions

View file

@ -84,13 +84,7 @@ public class JpaUpdate13_0_0_MigrateDefaultRoles extends CustomKeycloakTask {
ResultSet rs = statement.executeQuery()) {
while (rs.next()) {
String realmId = rs.getString(1);
if (realmId == null || realmId.trim().isEmpty()) {
continue;
}
realmIds.add(realmId);
realmIds.add(rs.getString(1));
}
} catch (Exception e) {

View file

@ -501,10 +501,9 @@ public class RealmManager {
*/
public RealmModel importRealm(RealmRepresentation rep, boolean skipUserDependent) {
String id = rep.getId();
if (id == null) {
if (id == null || id.trim().isEmpty()) {
id = KeycloakModelUtils.generateId();
}
else {
} else {
ReservedCharValidator.validate(id);
}
RealmModel realm = model.createRealm(id, rep.getRealm());