KEYCLOAK-1187

This commit is contained in:
Stian Thorgersen 2015-04-13 13:32:18 +02:00
parent 4fbbf39c51
commit 600353899a
10 changed files with 21 additions and 21 deletions

View file

@ -81,7 +81,7 @@ public class ImportUtils {
// We just imported master realm. All 'masterAdminApps' need to be refreshed
RealmModel adminRealm = realm;
for (RealmModel currentRealm : model.getRealms()) {
ClientModel masterApp = adminRealm.getClientByClientId(KeycloakModelUtils.getMasterRealmAdminApplicationName(currentRealm));
ClientModel masterApp = adminRealm.getClientByClientId(KeycloakModelUtils.getMasterRealmAdminApplicationClientId(currentRealm));
if (masterApp != null) {
currentRealm.setMasterAdminClient(masterApp);
} else {
@ -91,7 +91,7 @@ public class ImportUtils {
} else {
// Need to refresh masterApp for current realm
RealmModel adminRealm = model.getRealm(adminRealmId);
ClientModel masterApp = adminRealm.getClientByClientId(KeycloakModelUtils.getMasterRealmAdminApplicationName(realm));
ClientModel masterApp = adminRealm.getClientByClientId(KeycloakModelUtils.getMasterRealmAdminApplicationClientId(realm));
if (masterApp != null) {
realm.setMasterAdminClient(masterApp);
} else {
@ -119,7 +119,7 @@ public class ImportUtils {
}
adminRole.setDescription("${role_"+AdminRoles.ADMIN+"}");
ClientModel realmAdminApp = KeycloakModelUtils.createClient(adminRealm, KeycloakModelUtils.getMasterRealmAdminApplicationName(realm));
ClientModel realmAdminApp = KeycloakModelUtils.createClient(adminRealm, KeycloakModelUtils.getMasterRealmAdminApplicationClientId(realm));
realmAdminApp.setBearerOnly(true);
realm.setMasterAdminClient(realmAdminApp);

View file

@ -9,7 +9,7 @@ public class AdminRoles {
public static String ADMIN = "admin";
// for admin application local to each realm
// for admin client local to each realm
public static String REALM_ADMIN = "realm-admin";
public static String CREATE_REALM = "create-realm";

View file

@ -16,7 +16,7 @@ public interface ClientModel extends RoleContainerModel {
String PUBLIC_KEY = "publicKey";
String X509CERTIFICATE = "X509Certificate";
void updateApplication();
void updateClient();
String getId();

View file

@ -245,7 +245,7 @@ public final class KeycloakModelUtils {
}
}
public static String getMasterRealmAdminApplicationName(RealmModel realm) {
public static String getMasterRealmAdminApplicationClientId(RealmModel realm) {
return realm.getName() + "-realm";
}
}

View file

@ -517,7 +517,7 @@ public class RepresentationToModel {
* @return
*/
public static ClientModel createClient(KeycloakSession session, RealmModel realm, ClientRepresentation resourceRep, boolean addDefaultRoles) {
logger.debug("************ CREATE APPLICATION: {0}" + resourceRep.getClientId());
logger.debug("Create client: {0}" + resourceRep.getClientId());
ClientModel client = resourceRep.getId()!=null ? realm.addClient(resourceRep.getId(), resourceRep.getClientId()) : realm.addClient(resourceRep.getClientId());
if (resourceRep.isEnabled() != null) client.setEnabled(resourceRep.isEnabled());
@ -540,7 +540,7 @@ public class RepresentationToModel {
} else {
client.setNodeReRegistrationTimeout(-1);
}
client.updateApplication();
client.updateClient();
if (resourceRep.getNotBefore() != null) {
client.setNotBefore(resourceRep.getNotBefore());
@ -565,7 +565,7 @@ public class RepresentationToModel {
}
if (resourceRep.getWebOrigins() != null) {
for (String webOrigin : resourceRep.getWebOrigins()) {
logger.debugv("Application: {0} webOrigin: {1}", resourceRep.getClientId(), webOrigin);
logger.debugv("Client: {0} webOrigin: {1}", resourceRep.getClientId(), webOrigin);
client.addWebOrigin(webOrigin);
}
} else {
@ -580,7 +580,7 @@ public class RepresentationToModel {
if (uri.getPort() != -1) {
origin += ":" + uri.getPort();
}
logger.debugv("adding default application origin: {0}" , origin);
logger.debugv("adding default client origin: {0}" , origin);
origins.add(origin);
}
}
@ -627,7 +627,7 @@ public class RepresentationToModel {
if (rep.getBaseUrl() != null) resource.setBaseUrl(rep.getBaseUrl());
if (rep.isSurrogateAuthRequired() != null) resource.setSurrogateAuthRequired(rep.isSurrogateAuthRequired());
if (rep.getNodeReRegistrationTimeout() != null) resource.setNodeReRegistrationTimeout(rep.getNodeReRegistrationTimeout());
resource.updateApplication();
resource.updateClient();
if (rep.getProtocol() != null) resource.setProtocol(rep.getProtocol());
if (rep.getAttributes() != null) {
@ -725,7 +725,7 @@ public class RepresentationToModel {
for (ScopeMappingRepresentation mapping : mappings) {
ClientModel client = realm.getClientByClientId(mapping.getClient());
if (client == null) {
throw new RuntimeException("Unknown client specified in application scope mappings");
throw new RuntimeException("Unknown client specified in client scope mappings");
}
for (String roleString : mapping.getRoles()) {
RoleModel role = clientModel.getRole(roleString.trim());
@ -821,15 +821,15 @@ public class RepresentationToModel {
// Role mappings
public static void createClientRoleMappings(ClientModel applicationModel, UserModel user, List<String> roleNames) {
public static void createClientRoleMappings(ClientModel clientModel, UserModel user, List<String> roleNames) {
if (user == null) {
throw new RuntimeException("User not found");
}
for (String roleName : roleNames) {
RoleModel role = applicationModel.getRole(roleName.trim());
RoleModel role = clientModel.getRole(roleName.trim());
if (role == null) {
role = applicationModel.addRole(roleName.trim());
role = clientModel.addRole(roleName.trim());
}
user.grantRole(role);

View file

@ -62,7 +62,7 @@ public class ClientAdapter implements ClientModel {
}
@Override
public void updateApplication() {
public void updateClient() {
}
@Override

View file

@ -42,8 +42,8 @@ public class ClientAdapter implements ClientModel {
}
@Override
public void updateApplication() {
if (updated != null) updated.updateApplication();
public void updateClient() {
if (updated != null) updated.updateClient();
}
@Override

View file

@ -469,7 +469,7 @@ public class ClientAdapter implements ClientModel {
}
@Override
public void updateApplication() {
public void updateClient() {
em.flush();
}

View file

@ -46,7 +46,7 @@ public class ClientAdapter extends AbstractMongoAdapter<MongoClientEntity> imple
}
@Override
public void updateApplication() {
public void updateClient() {
updateMongoEntity();
}

View file

@ -48,7 +48,7 @@ public class ClientModelTest extends AbstractModelTest {
client.registerNode("node1", 10);
client.registerNode("10.20.30.40", 50);
client.updateApplication();
client.updateClient();
}
@Test