From 446cd3701f6f21021c88b70db6d179f00e83d0b7 Mon Sep 17 00:00:00 2001 From: Stan Silvert Date: Wed, 20 Jan 2016 14:23:37 -0500 Subject: [PATCH] KEYCLOAK-1280: i18n logging for org.keycloak.services.resources --- .../org/keycloak/services/ServicesLogger.java | 42 +++++++++++++++++++ .../resources/admin/AdminConsole.java | 26 +++++++++--- .../resources/admin/AdminEventBuilder.java | 28 ++++++++++--- .../services/resources/admin/AdminRoot.java | 22 ++++++++-- .../admin/AttackDetectionResource.java | 20 ++++++++- .../AuthenticationManagementResource.java | 26 +++++++++--- .../resources/admin/ClientResource.java | 20 ++++++++- .../admin/ClientRoleMappingsResource.java | 20 ++++++++- .../admin/ClientTemplateResource.java | 20 ++++++++- .../admin/ClientTemplatesResource.java | 26 +++++++++--- .../resources/admin/ClientsResource.java | 28 ++++++++++--- .../resources/admin/GroupResource.java | 19 +++++++-- .../resources/admin/GroupsResource.java | 19 +++++++-- .../admin/IdentityProviderResource.java | 20 ++++++++- .../admin/ProtocolMappersResource.java | 24 +++++++++-- .../resources/admin/RealmAdminResource.java | 20 ++++++++- .../resources/admin/RealmsAdminResource.java | 28 ++++++++++--- .../resources/admin/RoleByIdResource.java | 22 ++++++++-- .../resources/admin/RoleMapperResource.java | 20 ++++++++- .../admin/UserFederationProviderResource.java | 24 +++++++++-- .../UserFederationProvidersResource.java | 28 ++++++++++--- .../resources/admin/UsersResource.java | 22 ++++++++-- 22 files changed, 448 insertions(+), 76 deletions(-) mode change 100755 => 100644 services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java mode change 100755 => 100644 services/src/main/java/org/keycloak/services/resources/admin/ClientTemplateResource.java mode change 100755 => 100644 services/src/main/java/org/keycloak/services/resources/admin/IdentityProviderResource.java mode change 100755 => 100644 services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java mode change 100755 => 100644 services/src/main/java/org/keycloak/services/resources/admin/RoleMapperResource.java diff --git a/services/src/main/java/org/keycloak/services/ServicesLogger.java b/services/src/main/java/org/keycloak/services/ServicesLogger.java index ec84a8083e..e0ff699fe1 100644 --- a/services/src/main/java/org/keycloak/services/ServicesLogger.java +++ b/services/src/main/java/org/keycloak/services/ServicesLogger.java @@ -28,9 +28,11 @@ import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageLogger; import static org.jboss.logging.Logger.Level.ERROR; +import static org.jboss.logging.Logger.Level.FATAL; import static org.jboss.logging.Logger.Level.INFO; import static org.jboss.logging.Logger.Level.WARN; import org.keycloak.email.EmailException; +import org.keycloak.events.EventListenerProvider; import org.keycloak.models.ModelDuplicateException; @@ -351,4 +353,44 @@ public interface ServicesLogger extends BasicLogger { @LogMessage(level = WARN) @Message(id=78, value="Rejected attempt to create initial user as user is already created") void initialUserAlreadyCreated(); + + @LogMessage(level = WARN) + @Message(id=79, value="Locale not specified for messages.json") + void localeNotSpecified(); + + @LogMessage(level = WARN) + @Message(id=80, value="Message bundle not found for language code '%s'") + void msgBundleNotFound(String lang); + + @LogMessage(level = FATAL) + @Message(id=81, value="Message bundle not found for language code 'en'") + void msgBundleNotFoundForEn(); + + @LogMessage(level = ERROR) + @Message(id=82, value="Admin Events enabled, but no event store provider configured") + void noEventStoreProvider(); + + @LogMessage(level = ERROR) + @Message(id=83, value="Event listener '%s' registered, but provider not found") + void providerNotFound(String id); + + @LogMessage(level = ERROR) + @Message(id=84, value="Failed to save event") + void failedToSaveEvent(@Cause Throwable t); + + @LogMessage(level = ERROR) + @Message(id=85, value="Failed to send type to %s") + void failedToSendType(@Cause Throwable t, EventListenerProvider listener); + + @LogMessage(level = INFO) + @Message(id=86, value="Added 'kerberos' to required realm credentials") + void addedKerberosToRealmCredentials(); + + @LogMessage(level = INFO) + @Message(id=87, value="Syncing data for mapper '%s' of type '%s'. Direction: %s") + void syncingDataForMapper(String modelName, String mapperType, String direction); + + @LogMessage(level = ERROR) + @Message(id=88, value="Failed to send execute actions email") + void failedToSendActionsEmail(@Cause EmailException e); } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java b/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java old mode 100755 new mode 100644 index bf1a69bae7..2f9d14a917 --- a/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java @@ -1,7 +1,22 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; import com.fasterxml.jackson.annotation.JsonProperty; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.HttpRequest; import org.jboss.resteasy.spi.HttpResponse; @@ -21,6 +36,7 @@ import org.keycloak.models.RealmModel; import org.keycloak.models.RoleModel; import org.keycloak.models.UserModel; import org.keycloak.protocol.oidc.OIDCLoginProtocolService; +import org.keycloak.services.ServicesLogger; import org.keycloak.services.managers.AppAuthManager; import org.keycloak.services.managers.ClientManager; import org.keycloak.services.managers.AuthenticationManager; @@ -48,7 +64,7 @@ import javax.ws.rs.QueryParam; * @version $Revision: 1 $ */ public class AdminConsole { - protected static final Logger logger = Logger.getLogger(AdminConsole.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; @Context protected UriInfo uriInfo; @@ -302,18 +318,18 @@ public class AdminConsole { @Produces(MediaType.APPLICATION_JSON) public Properties getMessages(@QueryParam("lang") String lang) { if (lang == null) { - logger.warn("Locale not specified for messages.json"); + logger.localeNotSpecified(); lang = "en"; } try { Properties msgs = getTheme().getMessages("admin-messages", Locale.forLanguageTag(lang)); if (msgs.isEmpty()) { - logger.warn("Message bundle not found for language code '" + lang + "'"); + logger.msgBundleNotFound(lang); msgs = getTheme().getMessages("admin-messages", Locale.ENGLISH); } - if (msgs.isEmpty()) logger.fatal("Message bundle not found for language code 'en'"); + if (msgs.isEmpty()) logger.msgBundleNotFoundForEn(); return msgs; } catch (IOException e) { diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AdminEventBuilder.java b/services/src/main/java/org/keycloak/services/resources/admin/AdminEventBuilder.java index ea88a7d9b5..89b4fbd115 100644 --- a/services/src/main/java/org/keycloak/services/resources/admin/AdminEventBuilder.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AdminEventBuilder.java @@ -1,10 +1,25 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; import java.io.IOException; import java.util.LinkedList; import java.util.List; -import org.jboss.logging.Logger; import org.keycloak.common.ClientConnection; import org.keycloak.events.EventListenerProvider; import org.keycloak.events.EventStoreProvider; @@ -15,6 +30,7 @@ import org.keycloak.models.ClientModel; import org.keycloak.models.KeycloakSession; import org.keycloak.models.RealmModel; import org.keycloak.models.UserModel; +import org.keycloak.services.ServicesLogger; import org.keycloak.util.JsonSerialization; import org.keycloak.common.util.Time; @@ -22,7 +38,7 @@ import javax.ws.rs.core.UriInfo; public class AdminEventBuilder { - private static final Logger log = Logger.getLogger(AdminEventBuilder.class); + private static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; private EventStoreProvider store; private List listeners; @@ -38,7 +54,7 @@ public class AdminEventBuilder { if (store != null) { this.store = store; } else { - log.error("Admin Events enabled, but no event store provider configured"); + logger.noEventStoreProvider(); } } @@ -49,7 +65,7 @@ public class AdminEventBuilder { if (listener != null) { listeners.add(listener); } else { - log.error("Event listener '" + id + "' registered, but provider not found"); + logger.providerNotFound(id); } } } @@ -199,7 +215,7 @@ public class AdminEventBuilder { try { store.onEvent(adminEvent, includeRepresentation); } catch (Throwable t) { - log.error("Failed to save event", t); + logger.failedToSaveEvent(t); } } @@ -208,7 +224,7 @@ public class AdminEventBuilder { try { l.onEvent(adminEvent, includeRepresentation); } catch (Throwable t) { - log.error("Failed to send type to " + l, t); + logger.failedToSendType(t, l); } } } 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 4b9a65c631..d29ffe7921 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 @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.spi.HttpRequest; import org.jboss.resteasy.spi.HttpResponse; import org.jboss.resteasy.spi.NoLogWebApplicationException; @@ -17,6 +32,7 @@ import org.keycloak.models.RealmModel; import org.keycloak.protocol.oidc.TokenManager; import org.keycloak.representations.AccessToken; import org.keycloak.services.ForbiddenException; +import org.keycloak.services.ServicesLogger; import org.keycloak.services.managers.AppAuthManager; import org.keycloak.services.managers.AuthenticationManager; import org.keycloak.services.managers.RealmManager; @@ -40,7 +56,7 @@ import javax.ws.rs.core.UriInfo; */ @Path("/admin") public class AdminRoot { - protected static final Logger logger = Logger.getLogger(AdminRoot.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; @Context protected UriInfo uriInfo; @@ -189,7 +205,7 @@ public class AdminRoot { } Cors.add(request).allowedOrigins(auth.getToken()).allowedMethods("GET", "PUT", "POST", "DELETE").auth().build(response); - + RealmsAdminResource adminResource = new RealmsAdminResource(auth, tokenManager); ResteasyProviderFactory.getInstance().injectProperties(adminResource); return adminResource; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AttackDetectionResource.java b/services/src/main/java/org/keycloak/services/resources/admin/AttackDetectionResource.java index c2fb26fd86..ee9b046ae7 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/AttackDetectionResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AttackDetectionResource.java @@ -1,12 +1,28 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.keycloak.common.ClientConnection; import org.keycloak.events.admin.OperationType; import org.keycloak.models.KeycloakSession; import org.keycloak.models.RealmModel; import org.keycloak.models.UsernameLoginFailureModel; +import org.keycloak.services.ServicesLogger; import org.keycloak.services.managers.BruteForceProtector; import javax.ws.rs.DELETE; @@ -28,7 +44,7 @@ import java.util.Map; * @version $Revision: 1 $ */ public class AttackDetectionResource { - protected static final Logger logger = Logger.getLogger(AttackDetectionResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; protected RealmAuth auth; protected RealmModel realm; private AdminEventBuilder adminEvent; 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 9ff6807c6d..0837a6765a 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 @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.BadRequestException; import org.jboss.resteasy.spi.NotFoundException; @@ -23,6 +38,7 @@ import org.keycloak.provider.ProviderConfigProperty; import org.keycloak.provider.ProviderFactory; import org.keycloak.representations.idm.ConfigPropertyRepresentation; import org.keycloak.services.ErrorResponse; +import org.keycloak.services.ServicesLogger; import org.keycloak.utils.CredentialHelper; import javax.ws.rs.Consumes; @@ -57,7 +73,7 @@ public class AuthenticationManagementResource { @Context private UriInfo uriInfo; - private static Logger logger = Logger.getLogger(AuthenticationManagementResource.class); + private static ServicesLogger logger = ServicesLogger.ROOT_LOGGER; public AuthenticationManagementResource(RealmModel realm, KeycloakSession session, RealmAuth auth, AdminEventBuilder adminEvent) { this.realm = realm; @@ -276,7 +292,7 @@ public class AuthenticationManagementResource { @Consumes(MediaType.APPLICATION_JSON) public Response createFlow(AuthenticationFlowModel model) { this.auth.requireManage(); - + if (model.getAlias() == null || model.getAlias().isEmpty()) { return ErrorResponse.exists("Failed to create flow with empty alias name"); } @@ -715,12 +731,12 @@ public class AuthenticationManagementResource { if (parentFlow.isBuiltIn()) { throw new BadRequestException("It is illegal to remove execution from a built in flow"); } - + if(model.getFlowId() != null) { AuthenticationFlowModel nonTopLevelFlow = realm.getAuthenticationFlowById(model.getFlowId()); realm.removeAuthenticationFlow(nonTopLevelFlow); } - + realm.removeAuthenticatorExecution(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 6a26b85ba5..e38f186108 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 @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.BadRequestException; import org.jboss.resteasy.spi.NotFoundException; @@ -23,6 +38,7 @@ import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.CredentialRepresentation; import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.representations.idm.UserSessionRepresentation; +import org.keycloak.services.ServicesLogger; import org.keycloak.services.clientregistration.ClientRegistrationTokenUtils; import org.keycloak.services.managers.ClientManager; import org.keycloak.services.managers.RealmManager; @@ -62,7 +78,7 @@ import static java.lang.Boolean.TRUE; * @version $Revision: 1 $ */ public class ClientResource { - protected static final Logger logger = Logger.getLogger(ClientResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; protected RealmModel realm; private RealmAuth auth; private AdminEventBuilder adminEvent; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ClientRoleMappingsResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ClientRoleMappingsResource.java index 9f5188c5e0..fc045cd30c 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ClientRoleMappingsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ClientRoleMappingsResource.java @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.keycloak.events.admin.OperationType; @@ -10,6 +25,7 @@ import org.keycloak.models.RoleMapperModel; import org.keycloak.models.RoleModel; import org.keycloak.models.utils.ModelToRepresentation; import org.keycloak.representations.idm.RoleRepresentation; +import org.keycloak.services.ServicesLogger; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -30,7 +46,7 @@ import java.util.Set; * @version $Revision: 1 $ */ public class ClientRoleMappingsResource { - protected static final Logger logger = Logger.getLogger(ClientRoleMappingsResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; protected RealmModel realm; protected RealmAuth auth; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ClientTemplateResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ClientTemplateResource.java old mode 100755 new mode 100644 index c67c04d3f2..5b3028076e --- a/services/src/main/java/org/keycloak/services/resources/admin/ClientTemplateResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ClientTemplateResource.java @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.events.admin.OperationType; @@ -12,6 +27,7 @@ import org.keycloak.models.utils.ModelToRepresentation; import org.keycloak.models.utils.RepresentationToModel; import org.keycloak.representations.idm.ClientTemplateRepresentation; import org.keycloak.services.ErrorResponse; +import org.keycloak.services.ServicesLogger; import org.keycloak.services.resources.KeycloakApplication; import javax.ws.rs.Consumes; @@ -33,7 +49,7 @@ import javax.ws.rs.core.UriInfo; * @version $Revision: 1 $ */ public class ClientTemplateResource { - protected static final Logger logger = Logger.getLogger(ClientTemplateResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; protected RealmModel realm; private RealmAuth auth; private AdminEventBuilder adminEvent; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ClientTemplatesResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ClientTemplatesResource.java index e3c6387b41..daa23f1c19 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ClientTemplatesResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ClientTemplatesResource.java @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; @@ -13,6 +28,7 @@ import org.keycloak.models.utils.ModelToRepresentation; import org.keycloak.models.utils.RepresentationToModel; import org.keycloak.representations.idm.ClientTemplateRepresentation; import org.keycloak.services.ErrorResponse; +import org.keycloak.services.ServicesLogger; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -34,7 +50,7 @@ import java.util.List; * @version $Revision: 1 $ */ public class ClientTemplatesResource { - protected static final Logger logger = Logger.getLogger(RealmAdminResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; protected RealmModel realm; private RealmAuth auth; private AdminEventBuilder adminEvent; @@ -46,7 +62,7 @@ public class ClientTemplatesResource { this.realm = realm; this.auth = auth; this.adminEvent = adminEvent; - + auth.init(RealmAuth.Resource.CLIENT); } @@ -96,9 +112,9 @@ public class ClientTemplatesResource { try { ClientTemplateModel clientModel = RepresentationToModel.createClientTemplate(session, realm, rep); - + adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo, clientModel.getId()).representation(rep).success(); - + return Response.created(uriInfo.getAbsolutePathBuilder().path(clientModel.getId()).build()).build(); } catch (ModelDuplicateException e) { return ErrorResponse.exists("Client Template " + rep.getName() + " already exists"); 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 8b5decd4b3..78a4597aac 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 @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; @@ -12,6 +27,7 @@ import org.keycloak.models.RealmModel; import org.keycloak.models.utils.ModelToRepresentation; import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.services.ErrorResponse; +import org.keycloak.services.ServicesLogger; import org.keycloak.services.managers.ClientManager; import javax.ws.rs.Consumes; @@ -35,11 +51,11 @@ import java.util.List; * @version $Revision: 1 $ */ public class ClientsResource { - protected static final Logger logger = Logger.getLogger(RealmAdminResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; protected RealmModel realm; private RealmAuth auth; private AdminEventBuilder adminEvent; - + @Context protected KeycloakSession session; @@ -47,7 +63,7 @@ public class ClientsResource { this.realm = realm; this.auth = auth; this.adminEvent = adminEvent; - + auth.init(RealmAuth.Resource.CLIENT); } @@ -96,9 +112,9 @@ public class ClientsResource { try { ClientModel clientModel = ClientManager.createClient(session, realm, rep, true); - + adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo, clientModel.getId()).representation(rep).success(); - + return Response.created(uriInfo.getAbsolutePathBuilder().path(clientModel.getId()).build()).build(); } catch (ModelDuplicateException e) { return ErrorResponse.exists("Client " + rep.getClientId() + " already exists"); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/GroupResource.java b/services/src/main/java/org/keycloak/services/resources/admin/GroupResource.java index 4fe413045a..8dddacd457 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/GroupResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/GroupResource.java @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; @@ -36,8 +51,6 @@ import java.util.Set; */ public class GroupResource { - private static Logger logger = Logger.getLogger(GroupResource.class); - private final RealmModel realm; private final KeycloakSession session; private final RealmAuth auth; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/GroupsResource.java b/services/src/main/java/org/keycloak/services/resources/admin/GroupsResource.java index 67e4970b14..cc48796c58 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/GroupsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/GroupsResource.java @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; @@ -28,8 +43,6 @@ import java.util.List; */ public class GroupsResource { - private static Logger logger = Logger.getLogger(GroupsResource.class); - private final RealmModel realm; private final KeycloakSession session; private final RealmAuth auth; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/IdentityProviderResource.java b/services/src/main/java/org/keycloak/services/resources/admin/IdentityProviderResource.java old mode 100755 new mode 100644 index 4b166478b0..8b4adca386 --- a/services/src/main/java/org/keycloak/services/resources/admin/IdentityProviderResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/IdentityProviderResource.java @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.keycloak.broker.provider.IdentityProvider; @@ -24,6 +39,7 @@ import org.keycloak.representations.idm.IdentityProviderMapperRepresentation; import org.keycloak.representations.idm.IdentityProviderMapperTypeRepresentation; import org.keycloak.representations.idm.IdentityProviderRepresentation; import org.keycloak.services.ErrorResponse; +import org.keycloak.services.ServicesLogger; import org.keycloak.broker.social.SocialIdentityProvider; import javax.ws.rs.Consumes; @@ -51,7 +67,7 @@ import java.util.Map; */ public class IdentityProviderResource { - private static Logger logger = Logger.getLogger(IdentityProviderResource.class); + private static ServicesLogger logger = ServicesLogger.ROOT_LOGGER; private final RealmAuth auth; private final RealmModel realm; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ProtocolMappersResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ProtocolMappersResource.java index b966a17618..3258fc2736 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ProtocolMappersResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ProtocolMappersResource.java @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.keycloak.events.admin.OperationType; @@ -12,6 +27,7 @@ import org.keycloak.models.utils.ModelToRepresentation; import org.keycloak.models.utils.RepresentationToModel; import org.keycloak.representations.idm.ProtocolMapperRepresentation; import org.keycloak.services.ErrorResponse; +import org.keycloak.services.ServicesLogger; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -36,12 +52,12 @@ import java.util.List; * @version $Revision: 1 $ */ public class ProtocolMappersResource { - protected static final Logger logger = Logger.getLogger(ProtocolMappersResource.class); - + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; + protected ProtocolMapperContainerModel client; protected RealmAuth auth; - + protected AdminEventBuilder adminEvent; @Context diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java old mode 100755 new mode 100644 index e282ef09c9..516ba28b1d --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.BadRequestException; import org.jboss.resteasy.spi.NotFoundException; @@ -38,6 +53,7 @@ import org.keycloak.services.managers.AuthenticationManager; import org.keycloak.services.managers.LDAPConnectionTestManager; import org.keycloak.services.managers.RealmManager; import org.keycloak.services.managers.ResourceAdminManager; +import org.keycloak.services.ServicesLogger; import org.keycloak.services.managers.UsersSyncManager; import org.keycloak.services.ErrorResponse; import org.keycloak.timer.TimerProvider; @@ -75,7 +91,7 @@ import org.keycloak.representations.idm.PartialImportRepresentation; * @version $Revision: 1 $ */ public class RealmAdminResource { - protected static final Logger logger = Logger.getLogger(RealmAdminResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; protected RealmAuth auth; protected RealmModel realm; private TokenManager tokenManager; 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 1656fab855..c7cd924699 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 @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; @@ -18,6 +33,7 @@ import org.keycloak.services.ForbiddenException; import org.keycloak.services.managers.RealmManager; import org.keycloak.services.resources.KeycloakApplication; import org.keycloak.services.ErrorResponse; +import org.keycloak.services.ServicesLogger; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -43,16 +59,16 @@ import java.util.List; * @version $Revision: 1 $ */ public class RealmsAdminResource { - protected static final Logger logger = Logger.getLogger(RealmsAdminResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; protected AdminAuth auth; protected TokenManager tokenManager; @Context protected KeycloakSession session; - + @Context protected KeycloakApplication keycloak; - + @Context protected ClientConnection clientConnection; @@ -132,7 +148,7 @@ public class RealmsAdminResource { URI location = AdminRoot.realmsUrl(uriInfo).path(realm.getName()).build(); logger.debugv("imported realm success, sending back: {0}", location.toString()); - + return Response.created(location).build(); } catch (ModelDuplicateException e) { return ErrorResponse.exists("Realm " + rep.getRealm() + " already exists"); @@ -177,7 +193,7 @@ public class RealmsAdminResource { } else { realmAuth = new RealmAuth(auth, realm.getClientByClientId(realmManager.getRealmAdminClientId(auth.getRealm()))); } - + AdminEventBuilder adminEvent = new AdminEventBuilder(realm, auth, session, clientConnection); session.getContext().setRealm(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 1482cabe3f..2e82be4216 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 @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.keycloak.events.admin.OperationType; @@ -10,6 +25,7 @@ import org.keycloak.models.RealmModel; import org.keycloak.models.RoleModel; import org.keycloak.models.UserModel; import org.keycloak.representations.idm.RoleRepresentation; +import org.keycloak.services.ServicesLogger; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -33,7 +49,7 @@ import java.util.Set; * @version $Revision: 1 $ */ public class RoleByIdResource extends RoleResource { - protected static final Logger logger = Logger.getLogger(RoleByIdResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; private final RealmModel realm; private final RealmAuth auth; private AdminEventBuilder adminEvent; @@ -226,7 +242,7 @@ public class RoleByIdResource extends RoleResource { RoleModel role = getRoleModel(id); auth.requireManage(); deleteComposites(roles, role); - + adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).representation(roles).success(); } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RoleMapperResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RoleMapperResource.java old mode 100755 new mode 100644 index 202ac3add9..c6ae9da673 --- a/services/src/main/java/org/keycloak/services/resources/admin/RoleMapperResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RoleMapperResource.java @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.keycloak.common.ClientConnection; @@ -14,6 +29,7 @@ import org.keycloak.models.utils.ModelToRepresentation; import org.keycloak.representations.idm.ClientMappingsRepresentation; import org.keycloak.representations.idm.MappingsRepresentation; import org.keycloak.representations.idm.RoleRepresentation; +import org.keycloak.services.ServicesLogger; import org.keycloak.services.managers.RealmManager; import javax.ws.rs.Consumes; @@ -40,7 +56,7 @@ import java.util.Set; * @version $Revision: 1 $ */ public class RoleMapperResource { - protected static final Logger logger = Logger.getLogger(RoleMapperResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; protected RealmModel realm; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/UserFederationProviderResource.java b/services/src/main/java/org/keycloak/services/resources/admin/UserFederationProviderResource.java index 29402474df..d398e8a75b 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/UserFederationProviderResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/UserFederationProviderResource.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; import java.util.Collections; @@ -21,7 +37,6 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.keycloak.events.admin.OperationType; @@ -46,6 +61,7 @@ import org.keycloak.representations.idm.UserFederationMapperRepresentation; import org.keycloak.representations.idm.UserFederationMapperTypeRepresentation; import org.keycloak.representations.idm.UserFederationProviderRepresentation; import org.keycloak.services.ErrorResponseException; +import org.keycloak.services.ServicesLogger; import org.keycloak.services.managers.UsersSyncManager; import org.keycloak.timer.TimerProvider; @@ -54,7 +70,7 @@ import org.keycloak.timer.TimerProvider; */ public class UserFederationProviderResource { - protected static final Logger logger = Logger.getLogger(UserFederationProviderResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; private final KeycloakSession session; private final RealmModel realm; @@ -93,7 +109,7 @@ public class UserFederationProviderResource { new UsersSyncManager().refreshPeriodicSyncForProvider(session.getKeycloakSessionFactory(), session.getProvider(TimerProvider.class), model, realm.getId()); boolean kerberosCredsAdded = UserFederationProvidersResource.checkKerberosCredential(session, realm, model); if (kerberosCredsAdded) { - logger.info("Added 'kerberos' to required realm credentials"); + logger.addedKerberosToRealmCredentials(); } adminEvent.operation(OperationType.UPDATE).resourcePath(uriInfo).representation(rep).success(); @@ -335,7 +351,7 @@ public class UserFederationProviderResource { UserFederationProviderFactory providerFactory = (UserFederationProviderFactory) session.getKeycloakSessionFactory().getProviderFactory(UserFederationProvider.class, providerModel.getProviderName()); UserFederationProvider federationProvider = providerFactory.getInstance(session, providerModel); - logger.infof("Syncing data for mapper '%s' of type '%s'. Direction: %s", mapperModel.getName(), mapperModel.getFederationMapperType(), direction); + logger.syncingDataForMapper(mapperModel.getName(), mapperModel.getFederationMapperType(), direction); UserFederationSyncResult syncResult; if ("fedToKeycloak".equals(direction)) { 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 1c390ad5ac..dd97f794e1 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 @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; @@ -20,6 +35,7 @@ import org.keycloak.representations.idm.ConfigPropertyRepresentation; import org.keycloak.representations.idm.CredentialRepresentation; import org.keycloak.representations.idm.UserFederationProviderFactoryRepresentation; import org.keycloak.representations.idm.UserFederationProviderRepresentation; +import org.keycloak.services.ServicesLogger; import org.keycloak.services.managers.UsersSyncManager; import org.keycloak.timer.TimerProvider; import org.keycloak.utils.CredentialHelper; @@ -46,12 +62,12 @@ import java.util.List; * @version $Revision: 1 $ */ public class UserFederationProvidersResource { - protected static final Logger logger = Logger.getLogger(UserFederationProvidersResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; protected RealmModel realm; protected RealmAuth auth; - + protected AdminEventBuilder adminEvent; @Context @@ -64,7 +80,7 @@ public class UserFederationProvidersResource { this.auth = auth; this.realm = realm; this.adminEvent = adminEvent; - + auth.init(RealmAuth.Resource.USER); } @@ -165,10 +181,10 @@ public class UserFederationProvidersResource { new UsersSyncManager().refreshPeriodicSyncForProvider(session.getKeycloakSessionFactory(), session.getProvider(TimerProvider.class), model, realm.getId()); boolean kerberosCredsAdded = checkKerberosCredential(session, realm, model); if (kerberosCredsAdded) { - logger.info("Added 'kerberos' to required realm credentials"); + logger.addedKerberosToRealmCredentials(); } - + adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo).representation(rep).success(); return Response.created(uriInfo.getAbsolutePathBuilder().path(model.getId()).build()).build(); 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 77a925c268..d77f0a99e0 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 @@ -1,6 +1,21 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.resources.admin; -import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.BadRequestException; import org.jboss.resteasy.spi.NotFoundException; @@ -43,6 +58,7 @@ import org.keycloak.services.managers.AuthenticationManager; import org.keycloak.services.managers.ClientSessionCode; import org.keycloak.services.managers.UserManager; import org.keycloak.services.ErrorResponse; +import org.keycloak.services.ServicesLogger; import org.keycloak.services.Urls; import javax.ws.rs.Consumes; @@ -85,7 +101,7 @@ import org.keycloak.common.util.Time; * @version $Revision: 1 $ */ public class UsersResource { - protected static final Logger logger = Logger.getLogger(UsersResource.class); + protected static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; protected RealmModel realm; @@ -804,7 +820,7 @@ public class UsersResource { return Response.ok().build(); } catch (EmailException e) { - logger.error("Failed to send execute actions email", e); + logger.failedToSendActionsEmail(e); return ErrorResponse.error("Failed to send execute actions email", Response.Status.INTERNAL_SERVER_ERROR); } }