From a1cfc0a0ff45a8c5af09cbbc6cad382fee1e436c Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Wed, 2 Sep 2015 17:17:57 -0400 Subject: [PATCH] KEYCLOAK-1792 --- .../services/resources/admin/AdminRoot.java | 2 +- .../AuthenticationManagementResource.java | 6 +++--- .../resources/admin/ClientResource.java | 2 +- .../resources/admin/ClientsResource.java | 2 +- .../admin/IdentityProvidersResource.java | 2 +- .../resources/admin/RealmsAdminResource.java | 2 +- .../resources/admin/RoleByIdResource.java | 6 +++--- .../resources/admin/RoleContainerResource.java | 18 +++++++++--------- .../services/resources/admin/RoleResource.java | 4 ++-- .../admin/UserFederationProvidersResource.java | 2 +- .../resources/admin/UsersResource.java | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java b/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java index 97c147247c..d57e96ee32 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java @@ -101,7 +101,7 @@ public class AdminRoot { protected RealmModel locateRealm(String name, RealmManager realmManager) { RealmModel realm = realmManager.getRealmByName(name); if (realm == null) { - throw new NotFoundException("Realm " + name + " not found"); + throw new NotFoundException("Realm not found. Did you type in a bad URL?"); } return realm; } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java b/services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java index 2cb9137c8f..84ccb7deb7 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java @@ -782,7 +782,7 @@ public class AuthenticationManagementResource { public RequiredActionProviderRepresentation getRequiredAction(@PathParam("alias") String alias) { RequiredActionProviderModel model = realm.getRequiredActionProviderByAlias(alias); if (model == null) { - throw new NotFoundException("Failed to find required action: " + alias); + throw new NotFoundException("Failed to find required action"); } return toRepresentation(model); } @@ -795,7 +795,7 @@ public class AuthenticationManagementResource { this.auth.requireManage(); RequiredActionProviderModel model = realm.getRequiredActionProviderByAlias(alias); if (model == null) { - throw new NotFoundException("Failed to find required action: " + alias); + throw new NotFoundException("Failed to find required action"); } RequiredActionProviderModel update = new RequiredActionProviderModel(); update.setId(model.getId()); @@ -814,7 +814,7 @@ public class AuthenticationManagementResource { this.auth.requireManage(); RequiredActionProviderModel model = realm.getRequiredActionProviderByAlias(alias); if (model == null) { - throw new NotFoundException("Failed to find required action: " + alias); + throw new NotFoundException("Failed to find required action."); } realm.removeRequiredActionProvider(model); } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ClientResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ClientResource.java index b85aa39252..821f2793ee 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ClientResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ClientResource.java @@ -436,7 +436,7 @@ public class ClientResource { Integer time = client.getRegisteredNodes().get(node); if (time == null) { - throw new NotFoundException("Client does not have a node " + node); + throw new NotFoundException("Client does not have node "); } client.unregisterNode(node); adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success(); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ClientsResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ClientsResource.java index 77abf125b8..862aa0952b 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ClientsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ClientsResource.java @@ -112,7 +112,7 @@ public class ClientsResource { public ClientResource getClient(final @PathParam("id") String id) { ClientModel clientModel = realm.getClientById(id); if (clientModel == null) { - throw new NotFoundException("Could not find client: " + id); + throw new NotFoundException("Could not find client"); } session.getContext().setClient(clientModel); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/IdentityProvidersResource.java b/services/src/main/java/org/keycloak/services/resources/admin/IdentityProvidersResource.java index 9b5bebba02..8b2a0499e5 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/IdentityProvidersResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/IdentityProvidersResource.java @@ -155,7 +155,7 @@ public class IdentityProvidersResource { } if (identityProviderModel == null) { - throw new NotFoundException("Could not find identity provider: " + alias); + throw new NotFoundException("Could not find identity provider"); } IdentityProviderResource identityProviderResource = new IdentityProviderResource(this.auth, realm, session, identityProviderModel, adminEvent); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.java index 88117ca902..f2494c90ee 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.java @@ -208,7 +208,7 @@ public class RealmsAdminResource { @PathParam("realm") final String name) { RealmManager realmManager = new RealmManager(session); RealmModel realm = realmManager.getRealmByName(name); - if (realm == null) throw new NotFoundException("{realm} = " + name); + if (realm == null) throw new NotFoundException("Realm not found."); if (!auth.getRealm().equals(realmManager.getKeycloakAdminstrationRealm()) && !auth.getRealm().equals(realm)) { diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RoleByIdResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RoleByIdResource.java index 563d2ca885..bea5d5283c 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RoleByIdResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RoleByIdResource.java @@ -71,7 +71,7 @@ public class RoleByIdResource extends RoleResource { protected RoleModel getRoleModel(String id) { RoleModel roleModel = realm.getRoleById(id); if (roleModel == null) { - throw new NotFoundException("Could not find role with id: " + id); + throw new NotFoundException("Could not find role with id"); } RealmAuth.Resource r = null; @@ -183,7 +183,7 @@ public class RoleByIdResource extends RoleResource { auth.requireView(); ClientModel clientModel = realm.getClientById(client); if (clientModel == null) { - throw new NotFoundException("Could not find client: " + client); + throw new NotFoundException("Could not find client"); } return getClientRoleComposites(clientModel, role); } @@ -205,7 +205,7 @@ public class RoleByIdResource extends RoleResource { auth.requireView(); ClientModel clientModel = realm.getClientById(client); if (clientModel == null) { - throw new NotFoundException("Could not find client: " + client); + throw new NotFoundException("Could not find client"); } return getClientRoleComposites(clientModel, roleModel); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RoleContainerResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RoleContainerResource.java index 3c57672765..f267d15ef5 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RoleContainerResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RoleContainerResource.java @@ -107,7 +107,7 @@ public class RoleContainerResource extends RoleResource { RoleModel roleModel = roleContainer.getRole(roleName); if (roleModel == null) { - throw new NotFoundException("Could not find role: " + roleName); + throw new NotFoundException("Could not find role"); } return getRole(roleModel); @@ -127,7 +127,7 @@ public class RoleContainerResource extends RoleResource { RoleRepresentation rep = getRole(roleName); RoleModel role = roleContainer.getRole(roleName); if (role == null) { - throw new NotFoundException("Could not find role: " + roleName); + throw new NotFoundException("Could not find role"); } deleteRole(role); @@ -150,7 +150,7 @@ public class RoleContainerResource extends RoleResource { RoleModel role = roleContainer.getRole(roleName); if (role == null) { - throw new NotFoundException("Could not find role: " + roleName); + throw new NotFoundException("Could not find role"); } try { updateRole(rep, role); @@ -177,7 +177,7 @@ public class RoleContainerResource extends RoleResource { RoleModel role = roleContainer.getRole(roleName); if (role == null) { - throw new NotFoundException("Could not find role: " + roleName); + throw new NotFoundException("Could not find role"); } addComposites(adminEvent, uriInfo, roles, role); } @@ -197,7 +197,7 @@ public class RoleContainerResource extends RoleResource { RoleModel role = roleContainer.getRole(roleName); if (role == null) { - throw new NotFoundException("Could not find role: " + roleName); + throw new NotFoundException("Could not find role"); } return getRoleComposites(role); } @@ -217,7 +217,7 @@ public class RoleContainerResource extends RoleResource { RoleModel role = roleContainer.getRole(roleName); if (role == null) { - throw new NotFoundException("Could not find role: " + roleName); + throw new NotFoundException("Could not find role"); } return getRealmRoleComposites(role); } @@ -240,11 +240,11 @@ public class RoleContainerResource extends RoleResource { RoleModel role = roleContainer.getRole(roleName); if (role == null) { - throw new NotFoundException("Could not find role: " + roleName); + throw new NotFoundException("Could not find role"); } ClientModel clientModel = realm.getClientById(client); if (client == null) { - throw new NotFoundException("Could not find client: " + client); + throw new NotFoundException("Could not find client"); } return getClientRoleComposites(clientModel, role); @@ -267,7 +267,7 @@ public class RoleContainerResource extends RoleResource { RoleModel role = roleContainer.getRole(roleName); if (role == null) { - throw new NotFoundException("Could not find role: " + roleName); + throw new NotFoundException("Could not find role"); } deleteComposites(roles, role); adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success(); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RoleResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RoleResource.java index ded91930f9..827b817dd8 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RoleResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RoleResource.java @@ -44,7 +44,7 @@ public abstract class RoleResource { for (RoleRepresentation rep : roles) { RoleModel composite = realm.getRoleById(rep.getId()); if (composite == null) { - throw new NotFoundException("Could not find composite role: " + rep.getName()); + throw new NotFoundException("Could not find composite role"); } role.addCompositeRole(composite); @@ -88,7 +88,7 @@ public abstract class RoleResource { for (RoleRepresentation rep : roles) { RoleModel composite = realm.getRoleById(rep.getId()); if (composite == null) { - throw new NotFoundException("Could not find composite role: " + rep.getName()); + throw new NotFoundException("Could not find composite role"); } role.removeCompositeRole(composite); } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/UserFederationProvidersResource.java b/services/src/main/java/org/keycloak/services/resources/admin/UserFederationProvidersResource.java index 9438b59dcf..294e633874 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/UserFederationProvidersResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/UserFederationProvidersResource.java @@ -183,7 +183,7 @@ public class UserFederationProvidersResource { UserFederationProviderModel model = KeycloakModelUtils.findUserFederationProviderById(id, realm); if (model == null) { - throw new NotFoundException("Could not find federation provider with id: " + id); + throw new NotFoundException("Could not find federation provider"); } UserFederationProviderResource instanceResource = new UserFederationProviderResource(session, realm, this.auth, model, adminEvent); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java b/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java index 7aeabc21d7..e3e243788c 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java @@ -456,7 +456,7 @@ public class UsersResource { // Logout clientSessions for this user and client AuthenticationManager.backchannelUserFromClient(session, realm, user, client, uriInfo, headers); } else { - throw new NotFoundException("Consent not found for user " + id + " and client " + clientId); + throw new NotFoundException("Consent not found"); } adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success(); }