diff --git a/broker/oidc/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProvider.java b/broker/oidc/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProvider.java index b4058b1409..ea2c905245 100755 --- a/broker/oidc/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProvider.java +++ b/broker/oidc/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProvider.java @@ -25,7 +25,6 @@ import org.keycloak.broker.provider.FederatedIdentity; import org.keycloak.broker.provider.IdentityBrokerException; import org.keycloak.events.Errors; import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventGroup; import org.keycloak.events.EventType; import org.keycloak.jose.jws.JWSInput; import org.keycloak.models.RealmModel; @@ -88,14 +87,14 @@ public class OIDCIdentityProvider extends AbstractOAuth2IdentityProvider details; public long getTime() { @@ -45,14 +41,6 @@ public class Event { public void setType(EventType type) { this.type = type; } - - public EventGroup getGroup() { - return group; - } - - public void setGroup(EventGroup group) { - this.group = group; - } public String getRealmId() { return realmId; @@ -102,14 +90,6 @@ public class Event { this.error = error; } - public String getRepresentation() { - return representation; - } - - public void setRepresentation(String representation) { - this.representation = representation; - } - public Map getDetails() { return details; } @@ -122,7 +102,6 @@ public class Event { Event clone = new Event(); clone.time = time; clone.type = type; - clone.group = group; clone.realmId = realmId; clone.clientId = clientId; clone.userId = userId; @@ -130,7 +109,6 @@ public class Event { clone.ipAddress = ipAddress; clone.error = error; clone.details = details != null ? new HashMap<>(details) : null; - clone.representation = representation; return clone; } diff --git a/events/api/src/main/java/org/keycloak/events/EventBuilder.java b/events/api/src/main/java/org/keycloak/events/EventBuilder.java index de8fcc8c67..4945989e9f 100644 --- a/events/api/src/main/java/org/keycloak/events/EventBuilder.java +++ b/events/api/src/main/java/org/keycloak/events/EventBuilder.java @@ -7,9 +7,7 @@ import org.keycloak.models.KeycloakSession; import org.keycloak.models.RealmModel; import org.keycloak.models.UserModel; import org.keycloak.models.UserSessionModel; -import org.keycloak.util.JsonSerialization; -import java.io.IOException; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -26,11 +24,10 @@ public class EventBuilder { private RealmModel realm; private Event event; - public EventBuilder(EventGroup group, RealmModel realm, KeycloakSession session, ClientConnection clientConnection) { + public EventBuilder(RealmModel realm, KeycloakSession session, ClientConnection clientConnection) { this.realm = realm; event = new Event(); - event.setGroup(group); if (realm.isEventsEnabled()) { EventStoreProvider store = session.getProvider(EventStoreProvider.class); @@ -126,18 +123,6 @@ public class EventBuilder { return this; } - public EventBuilder representation(Object value) { - if (value == null || value.equals("")) { - return this; - } - try { - event.setRepresentation(JsonSerialization.writeValueAsPrettyString(value)); - } catch (IOException e) { - throw new RuntimeException(e); - } - return this; - } - public EventBuilder removeDetail(String key) { if (event.getDetails() != null) { event.getDetails().remove(key); diff --git a/events/api/src/main/java/org/keycloak/events/EventGroup.java b/events/api/src/main/java/org/keycloak/events/EventGroup.java deleted file mode 100644 index f4ce2d38ee..0000000000 --- a/events/api/src/main/java/org/keycloak/events/EventGroup.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.keycloak.events; - -/** - * @author Giriraj Sharma - */ -public enum EventGroup { - - ADMIN, - USER - -} diff --git a/events/api/src/main/java/org/keycloak/events/EventType.java b/events/api/src/main/java/org/keycloak/events/EventType.java index d4638c2eb4..680a06e633 100755 --- a/events/api/src/main/java/org/keycloak/events/EventType.java +++ b/events/api/src/main/java/org/keycloak/events/EventType.java @@ -60,61 +60,7 @@ public enum EventType { IDENTITY_PROVIDER_RETRIEVE_TOKEN(false), IDENTITY_PROVIDER_RETRIEVE_TOKEN_ERROR(false), IDENTITY_PROVIDER_ACCCOUNT_LINKING(false), - IDENTITY_PROVIDER_ACCCOUNT_LINKING_ERROR(false), - - VIEW_REALM(false), - CREATE_REALM(false), - UPDATE_REALM(false), - DELETE_REALM(false), - - VIEW_APPLICATIONS(false), - VIEW_APPLICATION(false), - CREATE_APPLICATION(false), - UPDATE_APPLICATION(false), - DELETE_APPLICATION(false), - - VIEW_APPLICATION_USER_SESSIONS(false), - LOGOUT_APPLICATION_USERS(false), - LOGOUT_USER(false), - - REGISTER_APPLICATION_CLUSTER_NODE(false), - UNREGISTER_APPLICATION_CLUSTER_NODE(false), - - VIEW_CLIENT_CERTIFICATE(false), - UPDATE_CLIENT_CERTIFICATE(false), - - VIEW_IDENTITY_PROVIDERS(false), - VIEW_IDENTITY_PROVIDER(false), - CREATE_IDENTITY_PROVIDER(false), - UPDATE_IDENTITY_PROVIDER(false), - DELETE_IDENTITY_PROVIDER(false), - - VIEW_OAUTH_CLIENTS(false), - VIEW_OAUTH_CLIENT(false), - CREATE_OAUTH_CLIENT(false), - UPDATE_OAUTH_CLIENT(false), - DELETE_OAUTH_CLIENT(false), - - VIEW_ROLES(false), - VIEW_ROLE(false), - CREATE_ROLE(false), - UPDATE_ROLE(false), - DELETE_ROLE(false), - - VIEW_USERS(false), - VIEW_USER(false), - CREATE_USER(false), - UPDATE_USER(false), - DELETE_USER(false), - - VIEW_USER_SESSIONS(false), - LOGOUT_USER_SESSIONS(false), - - VIEW_FEDERATION_PROVIDERS(false), - VIEW_FEDERATION_PROVIDER(false), - CREATE_FEDERATION_PROVIDER(false), - UPDATE_FEDERATION_PROVIDER(false), - DELETE_FEDERATION_PROVIDER(false); + IDENTITY_PROVIDER_ACCCOUNT_LINKING_ERROR(false); private boolean saveByDefault; diff --git a/events/jpa/src/main/java/org/keycloak/events/jpa/EventEntity.java b/events/jpa/src/main/java/org/keycloak/events/jpa/EventEntity.java index e6ca8777c0..742779f199 100644 --- a/events/jpa/src/main/java/org/keycloak/events/jpa/EventEntity.java +++ b/events/jpa/src/main/java/org/keycloak/events/jpa/EventEntity.java @@ -22,9 +22,6 @@ public class EventEntity { @Column(name="TYPE") private String type; - - @Column(name="EVENT_GROUP") - private String group; @Column(name="REALM_ID") private String realmId; @@ -47,10 +44,6 @@ public class EventEntity { @Column(name="DETAILS_JSON", length = 2550) private String detailsJson; - @Column(name="REPRESENTATION") - @Lob - private String representation; - public String getId() { return id; } @@ -75,14 +68,6 @@ public class EventEntity { this.type = type; } - public String getGroup() { - return group; - } - - public void setGroup(String group) { - this.group = group; - } - public String getRealmId() { return realmId; } @@ -139,11 +124,4 @@ public class EventEntity { this.detailsJson = detailsJson; } - public String getRepresentation() { - return representation; - } - - public void setRepresentation(String representation) { - this.representation = representation; - } } diff --git a/events/jpa/src/main/java/org/keycloak/events/jpa/JpaEventStoreProvider.java b/events/jpa/src/main/java/org/keycloak/events/jpa/JpaEventStoreProvider.java index 08b432e693..8fca6ec361 100755 --- a/events/jpa/src/main/java/org/keycloak/events/jpa/JpaEventStoreProvider.java +++ b/events/jpa/src/main/java/org/keycloak/events/jpa/JpaEventStoreProvider.java @@ -4,13 +4,11 @@ import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.type.TypeReference; import org.jboss.logging.Logger; import org.keycloak.events.Event; -import org.keycloak.events.EventGroup; import org.keycloak.events.EventQuery; import org.keycloak.events.EventStoreProvider; import org.keycloak.events.EventType; import javax.persistence.EntityManager; - import java.io.IOException; import java.util.Map; import java.util.UUID; @@ -65,14 +63,12 @@ public class JpaEventStoreProvider implements EventStoreProvider { e.setId(UUID.randomUUID().toString()); e.setTime(o.getTime()); e.setType(o.getType().toString()); - e.setGroup(o.getGroup().toString()); e.setRealmId(o.getRealmId()); e.setClientId(o.getClientId()); e.setUserId(o.getUserId()); e.setSessionId(o.getSessionId()); e.setIpAddress(o.getIpAddress()); e.setError(o.getError()); - e.setRepresentation(o.getRepresentation()); try { e.setDetailsJson(mapper.writeValueAsString(o.getDetails())); } catch (IOException ex) { @@ -85,14 +81,12 @@ public class JpaEventStoreProvider implements EventStoreProvider { Event e = new Event(); e.setTime(o.getTime()); e.setType(EventType.valueOf(o.getType())); - e.setGroup(EventGroup.valueOf(o.getGroup())); e.setRealmId(o.getRealmId()); e.setClientId(o.getClientId()); e.setUserId(o.getUserId()); e.setSessionId(o.getSessionId()); e.setIpAddress(o.getIpAddress()); e.setError(o.getError()); - e.setRepresentation(o.getRepresentation()); try { Map details = mapper.readValue(o.getDetailsJson(), mapType); e.setDetails(details); diff --git a/events/mongo/src/main/java/org/keycloak/events/mongo/MongoEventStoreProvider.java b/events/mongo/src/main/java/org/keycloak/events/mongo/MongoEventStoreProvider.java index 50de4d7bba..65b6573b69 100755 --- a/events/mongo/src/main/java/org/keycloak/events/mongo/MongoEventStoreProvider.java +++ b/events/mongo/src/main/java/org/keycloak/events/mongo/MongoEventStoreProvider.java @@ -3,9 +3,7 @@ package org.keycloak.events.mongo; import com.mongodb.BasicDBObject; import com.mongodb.DBCollection; import com.mongodb.DBObject; - import org.keycloak.events.Event; -import org.keycloak.events.EventGroup; import org.keycloak.events.EventQuery; import org.keycloak.events.EventStoreProvider; import org.keycloak.events.EventType; @@ -49,7 +47,7 @@ public class MongoEventStoreProvider implements EventStoreProvider { @Override public void onEvent(Event event) { - events.insert(convert(event)); + events.insert(convert(event)); } @Override @@ -60,14 +58,12 @@ public class MongoEventStoreProvider implements EventStoreProvider { BasicDBObject e = new BasicDBObject(); e.put("time", o.getTime()); e.put("type", o.getType().toString()); - e.put("group", o.getGroup().toString()); e.put("realmId", o.getRealmId()); e.put("clientId", o.getClientId()); e.put("userId", o.getUserId()); e.put("sessionId", o.getSessionId()); e.put("ipAddress", o.getIpAddress()); e.put("error", o.getError()); - e.put("representation", o.getRepresentation()); BasicDBObject details = new BasicDBObject(); if (o.getDetails() != null) { @@ -84,14 +80,12 @@ public class MongoEventStoreProvider implements EventStoreProvider { Event e = new Event(); e.setTime(o.getLong("time")); e.setType(EventType.valueOf(o.getString("type"))); - e.setGroup(EventGroup.valueOf(o.getString("group"))); e.setRealmId(o.getString("realmId")); e.setClientId(o.getString("clientId")); e.setUserId(o.getString("userId")); e.setSessionId(o.getString("sessionId")); e.setIpAddress(o.getString("ipAddress")); e.setError(o.getString("error")); - e.setRepresentation(o.getString("representation")); BasicDBObject d = (BasicDBObject) o.get("details"); if (d != null) { diff --git a/events/mongo/src/main/java/org/keycloak/events/mongo/MongoEventStoreProviderFactory.java b/events/mongo/src/main/java/org/keycloak/events/mongo/MongoEventStoreProviderFactory.java index ecf21a4eba..db4adeb859 100755 --- a/events/mongo/src/main/java/org/keycloak/events/mongo/MongoEventStoreProviderFactory.java +++ b/events/mongo/src/main/java/org/keycloak/events/mongo/MongoEventStoreProviderFactory.java @@ -7,13 +7,9 @@ import org.keycloak.Config; import org.keycloak.connections.mongo.MongoConnectionProvider; import org.keycloak.events.EventStoreProvider; import org.keycloak.events.EventStoreProviderFactory; -import org.keycloak.events.EventType; import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; -import java.util.HashSet; -import java.util.Set; - /** * @author Stian Thorgersen */ diff --git a/events/syslog/src/main/java/org/keycloak/events/log/SysLoggingEventListenerProvider.java b/events/syslog/src/main/java/org/keycloak/events/log/SysLoggingEventListenerProvider.java index 32ed137bc6..05362868e9 100755 --- a/events/syslog/src/main/java/org/keycloak/events/log/SysLoggingEventListenerProvider.java +++ b/events/syslog/src/main/java/org/keycloak/events/log/SysLoggingEventListenerProvider.java @@ -1,12 +1,12 @@ package org.keycloak.events.log; -import java.util.Map; - import org.keycloak.events.Event; import org.keycloak.events.EventListenerProvider; import org.productivity.java.syslog4j.SyslogConstants; import org.productivity.java.syslog4j.SyslogIF; +import java.util.Map; + /** * @author Giriraj Sharma */ diff --git a/services/src/main/java/org/keycloak/protocol/oidc/endpoints/UserInfoEndpoint.java b/services/src/main/java/org/keycloak/protocol/oidc/endpoints/UserInfoEndpoint.java index c600df720b..e4f5c41d48 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/endpoints/UserInfoEndpoint.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/endpoints/UserInfoEndpoint.java @@ -25,7 +25,6 @@ import org.keycloak.OAuthErrorException; import org.keycloak.RSATokenVerifier; import org.keycloak.events.Details; import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventGroup; import org.keycloak.events.EventType; import org.keycloak.models.ClientModel; import org.keycloak.models.KeycloakSession; @@ -111,7 +110,7 @@ public class UserInfoEndpoint { } private Response issueUserInfo(String tokenString) { - EventBuilder event = new EventBuilder(EventGroup.USER, realm, session, clientConnection) + EventBuilder event = new EventBuilder(realm, session, clientConnection) .event(EventType.USER_INFO_REQUEST) .detail(Details.AUTH_METHOD, Details.VALIDATE_ACCESS_TOKEN); diff --git a/services/src/main/java/org/keycloak/services/managers/AuthenticationManager.java b/services/src/main/java/org/keycloak/services/managers/AuthenticationManager.java index 023dd3d7b7..5fc15bf7c1 100755 --- a/services/src/main/java/org/keycloak/services/managers/AuthenticationManager.java +++ b/services/src/main/java/org/keycloak/services/managers/AuthenticationManager.java @@ -9,7 +9,6 @@ import org.keycloak.VerificationException; import org.keycloak.broker.provider.IdentityProvider; import org.keycloak.events.Details; import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventGroup; import org.keycloak.events.EventType; import org.keycloak.jose.jws.JWSBuilder; import org.keycloak.login.LoginFormsProvider; @@ -46,10 +45,10 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import java.net.URI; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Set; -import java.util.Iterator; /** * Stateless object that manages authentication @@ -182,7 +181,7 @@ public class AuthenticationManager { expireRememberMeCookie(realm, uriInfo, connection); userSession.setState(UserSessionModel.State.LOGGED_OUT); String method = userSession.getNote(KEYCLOAK_LOGOUT_PROTOCOL); - EventBuilder event = new EventBuilder(EventGroup.USER, realm, session, connection); + EventBuilder event = new EventBuilder(realm, session, connection); LoginProtocol protocol = session.getProvider(LoginProtocol.class, method); protocol.setRealm(realm) .setHttpHeaders(headers) diff --git a/services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java b/services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java index 3f4180186e..4e05ad5926 100755 --- a/services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java +++ b/services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java @@ -29,7 +29,6 @@ import org.keycloak.broker.provider.IdentityProviderFactory; import org.keycloak.events.Details; import org.keycloak.events.Errors; import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventGroup; import org.keycloak.events.EventType; import org.keycloak.models.ClientModel; import org.keycloak.models.ClientSessionModel; @@ -59,8 +58,14 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; -import javax.ws.rs.core.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriInfo; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -109,7 +114,7 @@ public class IdentityBrokerService implements IdentityProvider.AuthenticationCal } public void init() { - this.event = new EventBuilder(EventGroup.USER, realmModel, session, clientConnection).event(EventType.IDENTITY_PROVIDER_LOGIN); + this.event = new EventBuilder(realmModel, session, clientConnection).event(EventType.IDENTITY_PROVIDER_LOGIN); } @GET diff --git a/services/src/main/java/org/keycloak/services/resources/LoginActionsService.java b/services/src/main/java/org/keycloak/services/resources/LoginActionsService.java index 186c0685b1..e2ad7f06a7 100755 --- a/services/src/main/java/org/keycloak/services/resources/LoginActionsService.java +++ b/services/src/main/java/org/keycloak/services/resources/LoginActionsService.java @@ -29,12 +29,20 @@ import org.keycloak.email.EmailProvider; import org.keycloak.events.Details; import org.keycloak.events.Errors; import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventGroup; import org.keycloak.events.EventType; import org.keycloak.jose.jws.JWSBuilder; import org.keycloak.login.LoginFormsProvider; -import org.keycloak.models.*; +import org.keycloak.models.ClientModel; +import org.keycloak.models.ClientSessionModel; +import org.keycloak.models.KeycloakSession; +import org.keycloak.models.ModelException; +import org.keycloak.models.PasswordPolicy; +import org.keycloak.models.RealmModel; +import org.keycloak.models.RequiredCredentialModel; +import org.keycloak.models.UserCredentialModel; +import org.keycloak.models.UserModel; import org.keycloak.models.UserModel.RequiredAction; +import org.keycloak.models.UserSessionModel; import org.keycloak.models.utils.KeycloakModelUtils; import org.keycloak.models.utils.TimeBasedOTP; import org.keycloak.protocol.LoginProtocol; @@ -538,7 +546,7 @@ public class LoginActionsService { AttributeFormDataProcessor.process(formData, realm, user); event.user(user).success(); - event = new EventBuilder(EventGroup.USER, realm, session, clientConnection); + event = new EventBuilder(realm, session, clientConnection); return processLogin(code, formData); } diff --git a/services/src/main/java/org/keycloak/services/resources/RealmsResource.java b/services/src/main/java/org/keycloak/services/resources/RealmsResource.java index a28839cd36..9d4325c01a 100755 --- a/services/src/main/java/org/keycloak/services/resources/RealmsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/RealmsResource.java @@ -5,7 +5,6 @@ import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.ClientConnection; import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventGroup; import org.keycloak.models.ApplicationModel; import org.keycloak.models.Constants; import org.keycloak.models.KeycloakSession; @@ -91,7 +90,7 @@ public class RealmsResource { // backward compatibility RealmManager realmManager = new RealmManager(session); RealmModel realm = locateRealm(name, realmManager); - EventBuilder event = new EventBuilder(EventGroup.USER, realm, session, clientConnection); + EventBuilder event = new EventBuilder(realm, session, clientConnection); AuthenticationManager authManager = new AuthenticationManager(protector); LoginProtocolFactory factory = (LoginProtocolFactory)session.getKeycloakSessionFactory().getProviderFactory(LoginProtocol.class, OIDCLoginProtocol.LOGIN_PROTOCOL); @@ -107,7 +106,7 @@ public class RealmsResource { final @PathParam("protocol") String protocol) { RealmManager realmManager = new RealmManager(session); RealmModel realm = locateRealm(name, realmManager); - EventBuilder event = new EventBuilder(EventGroup.USER, realm, session, clientConnection); + EventBuilder event = new EventBuilder(realm, session, clientConnection); AuthenticationManager authManager = new AuthenticationManager(protector); LoginProtocolFactory factory = (LoginProtocolFactory)session.getKeycloakSessionFactory().getProviderFactory(LoginProtocol.class, protocol); @@ -129,7 +128,7 @@ public class RealmsResource { public LoginActionsService getLoginActionsService(final @PathParam("realm") String name) { RealmManager realmManager = new RealmManager(session); RealmModel realm = locateRealm(name, realmManager); - EventBuilder event = new EventBuilder(EventGroup.USER, realm, session, clientConnection); + EventBuilder event = new EventBuilder(realm, session, clientConnection); AuthenticationManager authManager = new AuthenticationManager(protector); LoginActionsService service = new LoginActionsService(realm, authManager, event); ResteasyProviderFactory.getInstance().injectProperties(service); @@ -142,7 +141,7 @@ public class RealmsResource { public ClientsManagementService getClientsManagementService(final @PathParam("realm") String name) { RealmManager realmManager = new RealmManager(session); RealmModel realm = locateRealm(name, realmManager); - EventBuilder event = new EventBuilder(EventGroup.USER, realm, session, clientConnection); + EventBuilder event = new EventBuilder(realm, session, clientConnection); ClientsManagementService service = new ClientsManagementService(realm, event); ResteasyProviderFactory.getInstance().injectProperties(service); return service; @@ -168,7 +167,7 @@ public class RealmsResource { throw new NotFoundException("account management not enabled"); } - EventBuilder event = new EventBuilder(EventGroup.USER, realm, session, clientConnection); + EventBuilder event = new EventBuilder(realm, session, clientConnection); AccountService accountService = new AccountService(realm, application, event); ResteasyProviderFactory.getInstance().injectProperties(accountService); //resourceContext.initResource(accountService); 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 01ad41f76f..c049ac4abe 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 @@ -8,8 +8,6 @@ import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.jboss.resteasy.spi.UnauthorizedException; import org.keycloak.ClientConnection; -import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventGroup; import org.keycloak.jose.jws.JWSInput; import org.keycloak.models.ClientModel; import org.keycloak.models.KeycloakSession; @@ -29,7 +27,6 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; - import java.io.IOException; /** @@ -187,10 +184,7 @@ public class AdminRoot { Cors.add(request).allowedOrigins(auth.getToken()).allowedMethods("GET", "PUT", "POST", "DELETE").auth().build(response); - EventBuilder event = new EventBuilder(EventGroup.ADMIN, auth.getRealm(), session, clientConnection); - event.user(auth.getUser()).client(auth.getClient()); - - RealmsAdminResource adminResource = new RealmsAdminResource(auth, tokenManager, event); + RealmsAdminResource adminResource = new RealmsAdminResource(auth, tokenManager); ResteasyProviderFactory.getInstance().injectProperties(adminResource); return adminResource; } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ApplicationResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ApplicationResource.java index 0c8e21fe1a..0ee416c991 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ApplicationResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ApplicationResource.java @@ -5,9 +5,6 @@ import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.BadRequestException; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; -import org.keycloak.events.Details; -import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventType; import org.keycloak.models.ApplicationModel; import org.keycloak.models.KeycloakSession; import org.keycloak.models.ModelDuplicateException; @@ -43,7 +40,6 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -61,7 +57,6 @@ public class ApplicationResource { protected static final Logger logger = Logger.getLogger(ApplicationResource.class); protected RealmModel realm; private RealmAuth auth; - private EventBuilder event; protected ApplicationModel application; protected KeycloakSession session; @@ -72,15 +67,14 @@ public class ApplicationResource { protected KeycloakApplication keycloak; protected KeycloakApplication getKeycloakApplication() { - return (KeycloakApplication)keycloak; + return keycloak; } - public ApplicationResource(RealmModel realm, RealmAuth auth, ApplicationModel applicationModel, KeycloakSession session, EventBuilder event) { + public ApplicationResource(RealmModel realm, RealmAuth auth, ApplicationModel applicationModel, KeycloakSession session) { this.realm = realm; this.auth = auth; this.application = applicationModel; this.session = session; - this.event = event; auth.init(RealmAuth.Resource.APPLICATION); } @@ -89,7 +83,6 @@ public class ApplicationResource { public ProtocolMappersResource getProtocolMappers() { ProtocolMappersResource mappers = new ProtocolMappersResource(application, auth); ResteasyProviderFactory.getInstance().injectProperties(mappers); - //resourceContext.initResource(mappers); return mappers; } @@ -105,9 +98,6 @@ public class ApplicationResource { try { RepresentationToModel.updateApplication(rep, application); - - event.event(EventType.UPDATE_APPLICATION).representation(rep).success(); - return Response.noContent().build(); } catch (ModelDuplicateException e) { return Flows.errors().exists("Application " + rep.getName() + " already exists"); @@ -126,11 +116,7 @@ public class ApplicationResource { public ApplicationRepresentation getApplication() { auth.requireView(); - ApplicationRepresentation rep = ModelToRepresentation.toRepresentation(application); - - event.event(EventType.VIEW_APPLICATION).representation(rep).success(); - - return rep; + return ModelToRepresentation.toRepresentation(application); } /** @@ -140,7 +126,7 @@ public class ApplicationResource { */ @Path("certificates/{attr}") public ClientAttributeCertificateResource getCertficateResource(@PathParam("attr") String attributePrefix) { - return new ClientAttributeCertificateResource(realm, auth, application, session, attributePrefix, event); + return new ClientAttributeCertificateResource(realm, auth, application, session, attributePrefix); } @@ -189,10 +175,6 @@ public class ApplicationResource { @NoCache public void deleteApplication() { auth.requireManage(); - - ApplicationRepresentation rep = getApplication(); - event.event(EventType.DELETE_APPLICATION).representation(rep).success(); - new ApplicationManager(new RealmManager(session)).removeApplication(realm, application); } @@ -245,7 +227,7 @@ public class ApplicationResource { @Path("roles") public RoleContainerResource getRoleContainerResource() { - return new RoleContainerResource(realm, auth, application, event); + return new RoleContainerResource(realm, auth, application); } /** @@ -348,9 +330,6 @@ public class ApplicationResource { UserSessionRepresentation rep = ModelToRepresentation.toRepresentation(userSession); sessions.add(rep); } - - event.event(EventType.VIEW_APPLICATION_USER_SESSIONS).representation(sessions).success(); - return sessions; } @@ -362,9 +341,6 @@ public class ApplicationResource { @POST public GlobalRequestResult logoutAll() { auth.requireManage(); - - event.event(EventType.LOGOUT_APPLICATION_USERS).success(); - return new ResourceAdminManager().logoutApplication(uriInfo.getRequestUri(), realm, application); } @@ -380,9 +356,6 @@ public class ApplicationResource { if (user == null) { throw new NotFoundException("User not found"); } - - event.event(EventType.LOGOUT_USER).success(); - new ResourceAdminManager().logoutUserFromApplication(uriInfo.getRequestUri(), realm, application, user, session); } @@ -403,10 +376,6 @@ public class ApplicationResource { } if (logger.isDebugEnabled()) logger.debug("Register node: " + node); application.registerNode(node, Time.currentTime()); - - event.event(EventType.REGISTER_APPLICATION_CLUSTER_NODE) - .detail(Details.APPLICATION_CLUSTER_NODE, node) - .success(); } /** @@ -427,10 +396,6 @@ public class ApplicationResource { } application.unregisterNode(node); - - event.event(EventType.UNREGISTER_APPLICATION_CLUSTER_NODE) - .detail(Details.APPLICATION_CLUSTER_NODE, node) - .success(); } /** diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsByIdResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsByIdResource.java index 5c840656d4..fc93f017c3 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsByIdResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsByIdResource.java @@ -1,6 +1,5 @@ package org.keycloak.services.resources.admin; -import org.keycloak.events.EventBuilder; import org.keycloak.models.ApplicationModel; import org.keycloak.models.RealmModel; @@ -9,8 +8,8 @@ import org.keycloak.models.RealmModel; * @version $Revision: 1 $ */ public class ApplicationsByIdResource extends ApplicationsResource { - public ApplicationsByIdResource(RealmModel realm, RealmAuth auth, EventBuilder event) { - super(realm, auth, event); + public ApplicationsByIdResource(RealmModel realm, RealmAuth auth) { + super(realm, auth); } @Override diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsResource.java index 6bc6c2b249..13e70616d5 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsResource.java @@ -4,8 +4,6 @@ import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; -import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventType; import org.keycloak.models.ApplicationModel; import org.keycloak.models.KeycloakSession; import org.keycloak.models.ModelDuplicateException; @@ -25,7 +23,6 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import java.util.ArrayList; import java.util.List; @@ -39,15 +36,13 @@ public class ApplicationsResource { protected static final Logger logger = Logger.getLogger(RealmAdminResource.class); protected RealmModel realm; private RealmAuth auth; - private EventBuilder event; @Context protected KeycloakSession session; - public ApplicationsResource(RealmModel realm, RealmAuth auth, EventBuilder event) { + public ApplicationsResource(RealmModel realm, RealmAuth auth) { this.realm = realm; this.auth = auth; - this.event = event; auth.init(RealmAuth.Resource.APPLICATION); } @@ -76,9 +71,7 @@ public class ApplicationsResource { rep.add(app); } } - - event.event(EventType.VIEW_APPLICATIONS).representation(rep).success(); - + return rep; } @@ -96,9 +89,6 @@ public class ApplicationsResource { try { ApplicationModel applicationModel = RepresentationToModel.createApplication(session, realm, rep, true); - - event.event(EventType.CREATE_APPLICATION).representation(rep).success(); - return Response.created(uriInfo.getAbsolutePathBuilder().path(getApplicationPath(applicationModel)).build()).build(); } catch (ModelDuplicateException e) { return Flows.errors().exists("Application " + rep.getName() + " already exists"); @@ -121,7 +111,7 @@ public class ApplicationsResource { if (applicationModel == null) { throw new NotFoundException("Could not find application: " + name); } - ApplicationResource applicationResource = new ApplicationResource(realm, auth, applicationModel, session, event); + ApplicationResource applicationResource = new ApplicationResource(realm, auth, applicationModel, session); ResteasyProviderFactory.getInstance().injectProperties(applicationResource); //resourceContext.initResource(applicationResource); return applicationResource; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ClientAttributeCertificateResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ClientAttributeCertificateResource.java index e2f01e5a36..1140627af5 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ClientAttributeCertificateResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ClientAttributeCertificateResource.java @@ -23,7 +23,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -48,14 +47,13 @@ public class ClientAttributeCertificateResource { protected RealmModel realm; private RealmAuth auth; - private EventBuilder event; protected ClientModel client; protected KeycloakSession session; protected String attributePrefix; protected String privateAttribute; protected String certificateAttribute; - public ClientAttributeCertificateResource(RealmModel realm, RealmAuth auth, ClientModel client, KeycloakSession session, String attributePrefix, EventBuilder event) { + public ClientAttributeCertificateResource(RealmModel realm, RealmAuth auth, ClientModel client, KeycloakSession session, String attributePrefix) { this.realm = realm; this.auth = auth; this.client = client; @@ -63,7 +61,6 @@ public class ClientAttributeCertificateResource { this.attributePrefix = attributePrefix; this.privateAttribute = attributePrefix + "." + PRIVATE_KEY; this.certificateAttribute = attributePrefix + "." + X509CERTIFICATE; - this.event = event; } public static class ClientKeyPairInfo { @@ -99,9 +96,6 @@ public class ClientAttributeCertificateResource { ClientKeyPairInfo info = new ClientKeyPairInfo(); info.setCertificate(client.getAttribute(certificateAttribute)); info.setPrivateKey(client.getAttribute(privateAttribute)); - - event.event(EventType.VIEW_CLIENT_CERTIFICATE).representation(info).success(); - return info; } @@ -140,9 +134,6 @@ public class ClientAttributeCertificateResource { ClientKeyPairInfo info = new ClientKeyPairInfo(); info.setCertificate(client.getAttribute(certificateAttribute)); info.setPrivateKey(client.getAttribute(privateAttribute)); - - event.event(EventType.UPDATE_CLIENT_CERTIFICATE).representation(info).success(); - return info; } @@ -200,8 +191,6 @@ public class ClientAttributeCertificateResource { info.setCertificate(certPem); } - event.event(EventType.UPDATE_CLIENT_CERTIFICATE).representation(info).success(); - return info; } @@ -327,9 +316,6 @@ public class ClientAttributeCertificateResource { stream.flush(); stream.close(); byte[] rtn = stream.toByteArray(); - - event.event(EventType.VIEW_CLIENT_CERTIFICATE).representation(rtn).success(); - return rtn; } catch (Exception e) { throw new RuntimeException(e); 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 index 85726126e5..07444afbdc 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/IdentityProviderResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/IdentityProviderResource.java @@ -4,8 +4,6 @@ import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.keycloak.broker.provider.IdentityProvider; import org.keycloak.broker.provider.IdentityProviderFactory; -import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventType; import org.keycloak.models.ClientIdentityProviderMappingModel; import org.keycloak.models.ClientModel; import org.keycloak.models.FederatedIdentityModel; @@ -31,7 +29,6 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import java.util.ArrayList; import java.util.List; @@ -46,14 +43,12 @@ public class IdentityProviderResource { private final RealmModel realm; private final KeycloakSession session; private final IdentityProviderModel identityProviderModel; - private EventBuilder event; - public IdentityProviderResource(RealmAuth auth, RealmModel realm, KeycloakSession session, IdentityProviderModel identityProviderModel, EventBuilder event) { + public IdentityProviderResource(RealmAuth auth, RealmModel realm, KeycloakSession session, IdentityProviderModel identityProviderModel) { this.realm = realm; this.session = session; this.identityProviderModel = identityProviderModel; this.auth = auth; - this.event = event; } @GET @@ -62,10 +57,6 @@ public class IdentityProviderResource { public IdentityProviderRepresentation getIdentityProvider() { IdentityProviderRepresentation rep = ModelToRepresentation.toRepresentation(this.identityProviderModel); - event.event(EventType.VIEW_IDENTITY_PROVIDER) - .representation(rep) - .success(); - return rep; } @@ -74,16 +65,10 @@ public class IdentityProviderResource { public Response delete() { this.auth.requireManage(); - IdentityProviderRepresentation rep = getIdentityProvider(); - removeClientIdentityProviders(this.realm.getApplications(), this.identityProviderModel); removeClientIdentityProviders(this.realm.getOAuthClients(), this.identityProviderModel); this.realm.removeIdentityProviderByAlias(this.identityProviderModel.getAlias()); - - event.event(EventType.DELETE_IDENTITY_PROVIDER) - .representation(rep) - .success(); return Response.noContent().build(); } @@ -109,10 +94,6 @@ public class IdentityProviderResource { updateClientsAfterProviderAliasChange(this.realm.getOAuthClients(), oldProviderId, newProviderId); updateUsersAfterProviderAliasChange(this.session.users().getUsers(this.realm), oldProviderId, newProviderId); } - - event.event(EventType.UPDATE_IDENTITY_PROVIDER) - .representation(providerRep) - .success(); return Response.noContent().build(); } catch (ModelDuplicateException e) { 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 95dd7d4089..e59ee6e52e 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 @@ -8,8 +8,6 @@ import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.broker.provider.IdentityProvider; import org.keycloak.broker.provider.IdentityProviderFactory; -import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventType; import org.keycloak.models.IdentityProviderModel; import org.keycloak.models.KeycloakSession; import org.keycloak.models.ModelDuplicateException; @@ -32,7 +30,6 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -49,13 +46,11 @@ public class IdentityProvidersResource { private final RealmModel realm; private final KeycloakSession session; private RealmAuth auth; - private EventBuilder event; - public IdentityProvidersResource(RealmModel realm, KeycloakSession session, RealmAuth auth, EventBuilder event) { + public IdentityProvidersResource(RealmModel realm, KeycloakSession session, RealmAuth auth) { this.realm = realm; this.session = session; this.auth = auth; - this.event = event; this.auth.init(RealmAuth.Resource.IDENTITY_PROVIDER); } @@ -68,10 +63,6 @@ public class IdentityProvidersResource { IdentityProviderFactory providerFactory = getProviderFactorytById(providerId); if (providerFactory != null) { - event.event(EventType.VIEW_IDENTITY_PROVIDERS) - .representation(providerFactory) - .success(); - return Response.ok(providerFactory).build(); } @@ -90,11 +81,6 @@ public class IdentityProvidersResource { InputStream inputStream = file.getBody(InputStream.class, null); IdentityProviderFactory providerFactory = getProviderFactorytById(providerId); Map config = providerFactory.parseConfig(inputStream); - - event.event(EventType.CREATE_IDENTITY_PROVIDER) - .representation(config) - .success(); - return config; } @@ -116,11 +102,6 @@ public class IdentityProvidersResource { } IdentityProviderFactory providerFactory = getProviderFactorytById(providerId); Map config = providerFactory.parseConfig(inputStream); - - event.event(EventType.CREATE_IDENTITY_PROVIDER) - .representation(config) - .success(); - return config; } @@ -136,8 +117,6 @@ public class IdentityProvidersResource { for (IdentityProviderModel identityProviderModel : realm.getIdentityProviders()) { representations.add(ModelToRepresentation.toRepresentation(identityProviderModel)); } - - event.event(EventType.VIEW_IDENTITY_PROVIDERS).representation(representations).success(); return representations; } @@ -150,11 +129,7 @@ public class IdentityProvidersResource { try { this.realm.addIdentityProvider(RepresentationToModel.toModel(representation)); - - event.event(EventType.CREATE_IDENTITY_PROVIDER) - .representation(representation) - .success(); - + return Response.created(uriInfo.getAbsolutePathBuilder().path(representation.getProviderId()).build()).build(); } catch (ModelDuplicateException e) { return Flows.errors().exists("Identity Provider " + representation.getAlias() + " already exists"); @@ -177,12 +152,8 @@ public class IdentityProvidersResource { throw new NotFoundException("Could not find identity provider: " + alias); } - IdentityProviderResource identityProviderResource = new IdentityProviderResource(this.auth, realm, session, identityProviderModel, event); + IdentityProviderResource identityProviderResource = new IdentityProviderResource(this.auth, realm, session, identityProviderModel); ResteasyProviderFactory.getInstance().injectProperties(identityProviderResource); - - event.event(EventType.VIEW_IDENTITY_PROVIDER) - .representation(identityProviderResource) - .success(); return identityProviderResource; } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientResource.java b/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientResource.java index cc455c4ce1..b69fb83c29 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientResource.java @@ -4,8 +4,6 @@ import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; -import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventType; import org.keycloak.models.KeycloakSession; import org.keycloak.models.ModelDuplicateException; import org.keycloak.models.OAuthClientModel; @@ -33,7 +31,6 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import java.io.IOException; /** @@ -46,7 +43,6 @@ public class OAuthClientResource { protected static final Logger logger = Logger.getLogger(RealmAdminResource.class); protected RealmModel realm; private RealmAuth auth; - private EventBuilder event; protected OAuthClientModel oauthClient; protected KeycloakSession session; @Context @@ -59,12 +55,11 @@ public class OAuthClientResource { return (KeycloakApplication)application; } - public OAuthClientResource(RealmModel realm, RealmAuth auth, OAuthClientModel oauthClient, KeycloakSession session, EventBuilder event) { + public OAuthClientResource(RealmModel realm, RealmAuth auth, OAuthClientModel oauthClient, KeycloakSession session) { this.realm = realm; this.auth = auth; this.oauthClient = oauthClient; this.session = session; - this.event = event; auth.init(RealmAuth.Resource.CLIENT); } @@ -89,7 +84,7 @@ public class OAuthClientResource { */ @Path("certificates/{attr}") public ClientAttributeCertificateResource getCertficateResource(@PathParam("attr") String attributePrefix) { - return new ClientAttributeCertificateResource(realm, auth, oauthClient, session, attributePrefix, event); + return new ClientAttributeCertificateResource(realm, auth, oauthClient, session, attributePrefix); } @@ -107,8 +102,6 @@ public class OAuthClientResource { try { RepresentationToModel.updateOAuthClient(session, rep, oauthClient); - event.event(EventType.UPDATE_OAUTH_CLIENT).representation(rep).success(); - return Response.noContent().build(); } catch (ModelDuplicateException e) { return Flows.errors().exists("Client " + rep.getName() + " already exists"); @@ -126,11 +119,7 @@ public class OAuthClientResource { public OAuthClientRepresentation getOAuthClient() { auth.requireView(); - OAuthClientRepresentation rep = ModelToRepresentation.toRepresentation(oauthClient); - - event.event(EventType.VIEW_OAUTH_CLIENT).representation(rep).success(); - - return rep; + return ModelToRepresentation.toRepresentation(oauthClient); } /** @@ -162,10 +151,6 @@ public class OAuthClientResource { public void deleteOAuthClient() { auth.requireManage(); - OAuthClientRepresentation rep = getOAuthClient(); - - event.event(EventType.DELETE_OAUTH_CLIENT).representation(rep).success(); - new OAuthClientManager(new RealmManager(session)).removeClient(realm, oauthClient); } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientsByIdResource.java b/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientsByIdResource.java index 5f19949ff0..91a19db8fc 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientsByIdResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientsByIdResource.java @@ -1,6 +1,5 @@ package org.keycloak.services.resources.admin; -import org.keycloak.events.EventBuilder; import org.keycloak.models.KeycloakSession; import org.keycloak.models.OAuthClientModel; import org.keycloak.models.RealmModel; @@ -10,8 +9,8 @@ import org.keycloak.models.RealmModel; * @version $Revision: 1 $ */ public class OAuthClientsByIdResource extends OAuthClientsResource { - public OAuthClientsByIdResource(RealmModel realm, RealmAuth auth, KeycloakSession session, EventBuilder event) { - super(realm, auth, session, event); + public OAuthClientsByIdResource(RealmModel realm, RealmAuth auth, KeycloakSession session) { + super(realm, auth, session); } @Override diff --git a/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientsResource.java b/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientsResource.java index 4cd0ad1789..cac3d8af8d 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientsResource.java @@ -4,8 +4,6 @@ import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; -import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventType; import org.keycloak.models.KeycloakSession; import org.keycloak.models.ModelDuplicateException; import org.keycloak.models.OAuthClientModel; @@ -25,7 +23,6 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import java.util.ArrayList; import java.util.List; @@ -36,21 +33,13 @@ import java.util.List; public class OAuthClientsResource { protected static final Logger logger = Logger.getLogger(RealmAdminResource.class); protected RealmModel realm; - private EventBuilder event; protected KeycloakSession session; - - /* - @Context - protected ResourceContext resourceContext; - - */ private RealmAuth auth; - public OAuthClientsResource(RealmModel realm, RealmAuth auth, KeycloakSession session, EventBuilder event) { + public OAuthClientsResource(RealmModel realm, RealmAuth auth, KeycloakSession session) { this.auth = auth; this.realm = realm; this.session = session; - this.event = event; auth.init(RealmAuth.Resource.CLIENT); } @@ -77,9 +66,7 @@ public class OAuthClientsResource { rep.add(client); } } - - event.event(EventType.VIEW_OAUTH_CLIENTS).representation(rep).success(); - + return rep; } @@ -97,8 +84,6 @@ public class OAuthClientsResource { try { OAuthClientModel oauth = RepresentationToModel.createOAuthClient(session, rep, realm); - event.event(EventType.CREATE_OAUTH_CLIENT).representation(rep).success(); - return Response.created(uriInfo.getAbsolutePathBuilder().path(getClientPath(oauth)).build()).build(); } catch (ModelDuplicateException e) { return Flows.errors().exists("Client " + rep.getName() + " already exists"); @@ -123,7 +108,7 @@ public class OAuthClientsResource { if (oauth == null) { throw new NotFoundException("OAuth Client not found"); } - OAuthClientResource oAuthClientResource = new OAuthClientResource(realm, auth, oauth, session, event); + OAuthClientResource oAuthClientResource = new OAuthClientResource(realm, auth, oauth, session); ResteasyProviderFactory.getInstance().injectProperties(oAuthClientResource); //resourceContext.initResource(oAuthClientResource); return oAuthClientResource; 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 index 59b4d0b007..a019e6bc34 100755 --- 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,32 +1,11 @@ package org.keycloak.services.resources.admin; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -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.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.ClientConnection; import org.keycloak.events.Event; -import org.keycloak.events.EventBuilder; import org.keycloak.events.EventQuery; import org.keycloak.events.EventStoreProvider; import org.keycloak.events.EventType; @@ -53,6 +32,25 @@ import org.keycloak.services.managers.UsersSyncManager; import org.keycloak.services.resources.flows.Flows; import org.keycloak.timer.TimerProvider; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + /** * Base resource class for the admin REST api of one realm * @@ -64,7 +62,6 @@ public class RealmAdminResource { protected RealmAuth auth; protected RealmModel realm; private TokenManager tokenManager; - private EventBuilder event; @Context protected KeycloakSession session; @@ -78,11 +75,10 @@ public class RealmAdminResource { @Context protected HttpHeaders headers; - public RealmAdminResource(RealmAuth auth, RealmModel realm, TokenManager tokenManager, EventBuilder event) { + public RealmAdminResource(RealmAuth auth, RealmModel realm, TokenManager tokenManager) { this.auth = auth; this.realm = realm; this.tokenManager = tokenManager; - this.event = event; auth.init(RealmAuth.Resource.REALM); } @@ -105,7 +101,7 @@ public class RealmAdminResource { */ @Path("applications") public ApplicationsResource getApplications() { - ApplicationsResource applicationsResource = new ApplicationsResource(realm, auth, event); + ApplicationsResource applicationsResource = new ApplicationsResource(realm, auth); ResteasyProviderFactory.getInstance().injectProperties(applicationsResource); //resourceContext.initResource(applicationsResource); return applicationsResource; @@ -118,7 +114,7 @@ public class RealmAdminResource { */ @Path("applications-by-id") public ApplicationsByIdResource getApplicationsById() { - ApplicationsByIdResource applicationsResource = new ApplicationsByIdResource(realm, auth, event); + ApplicationsByIdResource applicationsResource = new ApplicationsByIdResource(realm, auth); ResteasyProviderFactory.getInstance().injectProperties(applicationsResource); //resourceContext.initResource(applicationsResource); return applicationsResource; @@ -131,7 +127,7 @@ public class RealmAdminResource { */ @Path("oauth-clients") public OAuthClientsResource getOAuthClients() { - OAuthClientsResource oauth = new OAuthClientsResource(realm, auth, session, event); + OAuthClientsResource oauth = new OAuthClientsResource(realm, auth, session); ResteasyProviderFactory.getInstance().injectProperties(oauth); //resourceContext.initResource(oauth); return oauth; @@ -144,7 +140,7 @@ public class RealmAdminResource { */ @Path("oauth-clients-by-id") public OAuthClientsByIdResource getOAuthClientsById() { - OAuthClientsByIdResource oauth = new OAuthClientsByIdResource(realm, auth, session, event); + OAuthClientsByIdResource oauth = new OAuthClientsByIdResource(realm, auth, session); ResteasyProviderFactory.getInstance().injectProperties(oauth); //resourceContext.initResource(oauth); return oauth; @@ -157,7 +153,7 @@ public class RealmAdminResource { */ @Path("roles") public RoleContainerResource getRoleContainerResource() { - return new RoleContainerResource(realm, auth, realm, event); + return new RoleContainerResource(realm, auth, realm); } /** @@ -180,18 +176,12 @@ public class RealmAdminResource { CacheUserProvider cache = (CacheUserProvider)session.userStorage(); rep.setUserCacheEnabled(cache.isEnabled()); } - - event.event(EventType.VIEW_REALM).representation(rep).success(); - return rep; } else { auth.requireAny(); RealmRepresentation rep = new RealmRepresentation(); rep.setRealm(realm.getName()); - - event.event(EventType.VIEW_REALM).representation(rep).success(); - return rep; } } @@ -227,8 +217,6 @@ public class RealmAdminResource { usersSyncManager.refreshPeriodicSyncForProvider(session.getKeycloakSessionFactory(), session.getProvider(TimerProvider.class), fedProvider, realm.getId()); } - event.event(EventType.UPDATE_REALM).representation(rep).success(); - return Response.noContent().build(); } catch (ModelDuplicateException e) { return Flows.errors().exists("Realm " + rep.getRealm() + " already exists"); @@ -243,13 +231,9 @@ public class RealmAdminResource { public void deleteRealm() { auth.requireManage(); - RealmRepresentation rep = getRealm(); - if (!new RealmManager(session).removeRealm(realm)) { throw new NotFoundException("Realm doesn't exist"); } - - event.event(EventType.DELETE_REALM).representation(rep).success(); } /** @@ -259,7 +243,7 @@ public class RealmAdminResource { */ @Path("users") public UsersResource users() { - UsersResource users = new UsersResource(realm, auth, tokenManager, event); + UsersResource users = new UsersResource(realm, auth, tokenManager); ResteasyProviderFactory.getInstance().injectProperties(users); //resourceContext.initResource(users); return users; @@ -267,7 +251,7 @@ public class RealmAdminResource { @Path("user-federation") public UserFederationResource userFederation() { - UserFederationResource fed = new UserFederationResource(realm, auth, event); + UserFederationResource fed = new UserFederationResource(realm, auth); ResteasyProviderFactory.getInstance().injectProperties(fed); //resourceContext.initResource(fed); return fed; @@ -280,7 +264,7 @@ public class RealmAdminResource { */ @Path("roles-by-id") public RoleByIdResource rolesById() { - RoleByIdResource resource = new RoleByIdResource(realm, auth, event); + RoleByIdResource resource = new RoleByIdResource(realm, auth); ResteasyProviderFactory.getInstance().injectProperties(resource); //resourceContext.initResource(resource); return resource; @@ -487,6 +471,6 @@ public class RealmAdminResource { @Path("identity-provider") public IdentityProvidersResource getIdentityProviderResource() { - return new IdentityProvidersResource(realm, session, this.auth, event); + return new IdentityProvidersResource(realm, session, this.auth); } } 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 5bf3120e38..07b29b2248 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 @@ -4,11 +4,9 @@ import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.plugins.providers.multipart.InputPart; import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; +import org.jboss.resteasy.spi.HttpRequest; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; -import org.keycloak.events.Details; -import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventType; import org.keycloak.models.AdminRoles; import org.keycloak.models.ApplicationModel; import org.keycloak.models.KeycloakSession; @@ -36,7 +34,6 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import java.io.IOException; import java.net.URI; import java.util.ArrayList; @@ -53,12 +50,16 @@ public class RealmsAdminResource { protected static final Logger logger = Logger.getLogger(RealmsAdminResource.class); protected AdminAuth auth; protected TokenManager tokenManager; - private EventBuilder event; - public RealmsAdminResource(AdminAuth auth, TokenManager tokenManager, EventBuilder event) { + @Context + protected KeycloakSession session; + + @Context + protected KeycloakApplication keycloak; + + public RealmsAdminResource(AdminAuth auth, TokenManager tokenManager) { this.auth = auth; this.tokenManager = tokenManager; - this.event = event; } public static final CacheControl noCache = new CacheControl(); @@ -67,17 +68,6 @@ public class RealmsAdminResource { noCache.setNoCache(true); } - /* - @Context - protected ResourceContext resourceContext; - */ - - @Context - protected KeycloakSession session; - - @Context - protected KeycloakApplication keycloak; - /** * Returns a list of realms. This list is filtered based on what realms the caller is allowed to view. * @@ -102,7 +92,6 @@ public class RealmsAdminResource { return reps; } - protected void addRealmRep(List reps, RealmModel realm, ApplicationModel realmManagementApplication) { if (auth.hasAppRole(realmManagementApplication, AdminRoles.MANAGE_REALM)) { reps.add(ModelToRepresentation.toRepresentation(realm, false)); @@ -140,11 +129,7 @@ public class RealmsAdminResource { URI location = AdminRoot.realmsUrl(uriInfo).path(realm.getName()).build(); logger.debugv("imported realm success, sending back: {0}", location.toString()); - - event.event(EventType.CREATE_REALM) - .representation(rep) - .success(); - + return Response.created(location).build(); } catch (ModelDuplicateException e) { return Flows.errors().exists("Realm " + rep.getRealm() + " already exists"); @@ -191,8 +176,6 @@ public class RealmsAdminResource { URI location = AdminRoot.realmsUrl(uriInfo).path(realm.getName()).build(); return Response.created(location).build(); } - - event.event(EventType.CREATE_REALM).representation(rep).success(); } return Response.noContent().build(); @@ -237,8 +220,7 @@ public class RealmsAdminResource { realmAuth = new RealmAuth(auth, realm.getApplicationByName(realmManager.getRealmAdminApplicationName(auth.getRealm()))); } - event.detail(Details.REALM, realm.getName()); - RealmAdminResource adminResource = new RealmAdminResource(realmAuth, realm, tokenManager, event); + RealmAdminResource adminResource = new RealmAdminResource(realmAuth, realm, tokenManager); ResteasyProviderFactory.getInstance().injectProperties(adminResource); //resourceContext.initResource(adminResource); return adminResource; 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 bab2f7ef80..41ede41307 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 @@ -3,8 +3,6 @@ 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.EventBuilder; -import org.keycloak.events.EventType; import org.keycloak.models.ApplicationModel; import org.keycloak.models.KeycloakSession; import org.keycloak.models.OAuthClientModel; @@ -22,7 +20,6 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; - import java.util.List; import java.util.Set; @@ -36,17 +33,15 @@ public class RoleByIdResource extends RoleResource { protected static final Logger logger = Logger.getLogger(RoleByIdResource.class); private final RealmModel realm; private final RealmAuth auth; - private EventBuilder event; @Context protected KeycloakSession session; - public RoleByIdResource(RealmModel realm, RealmAuth auth, EventBuilder event) { + public RoleByIdResource(RealmModel realm, RealmAuth auth) { super(realm); this.realm = realm; this.auth = auth; - this.event = event; } /** @@ -63,13 +58,7 @@ public class RoleByIdResource extends RoleResource { RoleModel roleModel = getRoleModel(id); auth.requireView(); - RoleRepresentation rep = getRole(roleModel); - - event.event(EventType.VIEW_ROLE) - .representation(rep) - .success(); - - return rep; + return getRole(roleModel); } protected RoleModel getRoleModel(String id) { @@ -102,14 +91,9 @@ public class RoleByIdResource extends RoleResource { @DELETE @NoCache public void deleteRole(final @PathParam("role-id") String id) { - RoleRepresentation rep = getRole(id); RoleModel role = getRoleModel(id); auth.requireManage(); deleteRole(role); - - event.event(EventType.DELETE_ROLE) - .representation(rep) - .success(); } /** @@ -125,10 +109,6 @@ public class RoleByIdResource extends RoleResource { RoleModel role = getRoleModel(id); auth.requireManage(); updateRole(rep, role); - - event.event(EventType.UPDATE_ROLE) - .representation(rep) - .success(); } /** @@ -144,12 +124,6 @@ public class RoleByIdResource extends RoleResource { RoleModel role = getRoleModel(id); auth.requireManage(); addComposites(roles, role); - - RoleRepresentation rep = getRole(id); - - event.event(EventType.UPDATE_ROLE) - .representation(rep) - .success(); } /** 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 9293d5c862..3ddeafb5b7 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 @@ -2,8 +2,6 @@ package org.keycloak.services.resources.admin; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.spi.NotFoundException; -import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventType; import org.keycloak.models.ApplicationModel; import org.keycloak.models.ModelDuplicateException; import org.keycloak.models.RealmModel; @@ -24,7 +22,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -37,14 +34,12 @@ public class RoleContainerResource extends RoleResource { private final RealmModel realm; private final RealmAuth auth; protected RoleContainerModel roleContainer; - private EventBuilder event; - public RoleContainerResource(RealmModel realm, RealmAuth auth, RoleContainerModel roleContainer, EventBuilder event) { + public RoleContainerResource(RealmModel realm, RealmAuth auth, RoleContainerModel roleContainer) { super(realm); this.realm = realm; this.auth = auth; this.roleContainer = roleContainer; - this.event = event; } /** @@ -63,9 +58,6 @@ public class RoleContainerResource extends RoleResource { for (RoleModel roleModel : roleModels) { roles.add(ModelToRepresentation.toRepresentation(roleModel)); } - - event.event(EventType.VIEW_ROLES).representation(roles).success(); - return roles; } @@ -84,11 +76,6 @@ public class RoleContainerResource extends RoleResource { try { RoleModel role = roleContainer.addRole(rep.getName()); role.setDescription(rep.getDescription()); - - event.event(EventType.CREATE_ROLE) - .representation(rep) - .success(); - return Response.created(uriInfo.getAbsolutePathBuilder().path(role.getName()).build()).build(); } catch (ModelDuplicateException e) { return Flows.errors().exists("Role with name " + rep.getName() + " already exists"); @@ -113,13 +100,7 @@ public class RoleContainerResource extends RoleResource { throw new NotFoundException("Could not find role: " + roleName); } - RoleRepresentation rep = getRole(roleModel); - - event.event(EventType.VIEW_ROLE) - .representation(rep) - .success(); - - return rep; + return getRole(roleModel); } /** @@ -139,10 +120,6 @@ public class RoleContainerResource extends RoleResource { throw new NotFoundException("Could not find role: " + roleName); } deleteRole(role); - - event.event(EventType.DELETE_ROLE) - .representation(rep) - .success(); } /** @@ -164,11 +141,6 @@ public class RoleContainerResource extends RoleResource { } try { updateRole(rep, role); - - event.event(EventType.UPDATE_ROLE) - .representation(rep) - .success(); - return Response.noContent().build(); } catch (ModelDuplicateException e) { return Flows.errors().exists("Role with name " + rep.getName() + " already exists"); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/UserFederationResource.java b/services/src/main/java/org/keycloak/services/resources/admin/UserFederationResource.java index 06a852316d..006124bc15 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/UserFederationResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/UserFederationResource.java @@ -3,6 +3,7 @@ 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.constants.KerberosConstants; import org.keycloak.models.KeycloakSession; import org.keycloak.models.RealmModel; import org.keycloak.models.RequiredCredentialModel; @@ -10,9 +11,6 @@ import org.keycloak.models.UserCredentialModel; import org.keycloak.models.UserFederationProvider; import org.keycloak.models.UserFederationProviderFactory; import org.keycloak.models.UserFederationProviderModel; -import org.keycloak.constants.KerberosConstants; -import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventType; import org.keycloak.models.utils.ModelToRepresentation; import org.keycloak.provider.ProviderFactory; import org.keycloak.representations.idm.UserFederationProviderFactoryRepresentation; @@ -32,7 +30,6 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import java.util.LinkedList; import java.util.List; @@ -49,18 +46,15 @@ public class UserFederationResource { protected RealmAuth auth; - private EventBuilder event; - @Context protected UriInfo uriInfo; @Context protected KeycloakSession session; - public UserFederationResource(RealmModel realm, RealmAuth auth, EventBuilder event) { + public UserFederationResource(RealmModel realm, RealmAuth auth) { this.auth = auth; this.realm = realm; - this.event = event; auth.init(RealmAuth.Resource.USER); } @@ -83,9 +77,6 @@ public class UserFederationResource { rep.setOptions(((UserFederationProviderFactory)factory).getConfigurationOptions()); providers.add(rep); } - - event.event(EventType.VIEW_FEDERATION_PROVIDERS).representation(providers).success(); - return providers; } @@ -107,9 +98,6 @@ public class UserFederationResource { UserFederationProviderFactoryRepresentation rep = new UserFederationProviderFactoryRepresentation(); rep.setId(factory.getId()); rep.setOptions(((UserFederationProviderFactory)factory).getConfigurationOptions()); - - event.event(EventType.VIEW_FEDERATION_PROVIDER).representation(rep).success(); - return rep; } throw new NotFoundException("Could not find provider"); @@ -134,11 +122,6 @@ public class UserFederationResource { rep.getFullSyncPeriod(), rep.getChangedSyncPeriod(), rep.getLastSync()); new UsersSyncManager().refreshPeriodicSyncForProvider(session.getKeycloakSessionFactory(), session.getProvider(TimerProvider.class), model, realm.getId()); checkKerberosCredential(model); - - event.event(EventType.CREATE_FEDERATION_PROVIDER) - .representation(rep) - .success(); - return Response.created(uriInfo.getAbsolutePathBuilder().path(model.getId()).build()).build(); } @@ -162,10 +145,6 @@ public class UserFederationResource { realm.updateUserFederationProvider(model); new UsersSyncManager().refreshPeriodicSyncForProvider(session.getKeycloakSessionFactory(), session.getProvider(TimerProvider.class), model, realm.getId()); checkKerberosCredential(model); - - event.event(EventType.UPDATE_FEDERATION_PROVIDER) - .representation(rep) - .success(); } /** @@ -181,13 +160,7 @@ public class UserFederationResource { auth.requireView(); for (UserFederationProviderModel model : realm.getUserFederationProviders()) { if (model.getId().equals(id)) { - UserFederationProviderRepresentation rep = ModelToRepresentation.toRepresentation(model); - - event.event(EventType.VIEW_FEDERATION_PROVIDER) - .representation(rep) - .success(); - - return rep; + return ModelToRepresentation.toRepresentation(model); } } @@ -208,10 +181,6 @@ public class UserFederationResource { UserFederationProviderModel model = new UserFederationProviderModel(id, null, null, -1, null, -1, -1, 0); realm.removeUserFederationProvider(model); new UsersSyncManager().removePeriodicSyncForProvider(session.getProvider(TimerProvider.class), model); - - event.event(EventType.DELETE_FEDERATION_PROVIDER) - .representation(rep) - .success(); } 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 3cc0895eed..ff5370ba47 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 @@ -7,9 +7,6 @@ import org.jboss.resteasy.spi.NotFoundException; import org.keycloak.ClientConnection; import org.keycloak.email.EmailException; import org.keycloak.email.EmailProvider; -import org.keycloak.events.Details; -import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventType; import org.keycloak.models.ApplicationModel; import org.keycloak.models.ClientModel; import org.keycloak.models.ClientSessionModel; @@ -58,7 +55,6 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -82,8 +78,6 @@ public class UsersResource { private TokenManager tokenManager; - private EventBuilder event; - @Context protected ClientConnection clientConnection; @@ -96,11 +90,10 @@ public class UsersResource { @Context protected HttpHeaders headers; - public UsersResource(RealmModel realm, RealmAuth auth, TokenManager tokenManager, EventBuilder event) { + public UsersResource(RealmModel realm, RealmAuth auth, TokenManager tokenManager) { this.auth = auth; this.realm = realm; this.tokenManager = tokenManager; - this.event = event; auth.init(RealmAuth.Resource.USER); } @@ -125,10 +118,6 @@ public class UsersResource { } updateUserFromRep(user, rep); - event.event(EventType.UPDATE_USER) - .representation(rep) - .success(); - if (session.getTransaction().isActive()) { session.getTransaction().commit(); } @@ -165,10 +154,6 @@ public class UsersResource { UserModel user = session.users().addUser(realm, rep.getUsername()); updateUserFromRep(user, rep); - event.event(EventType.CREATE_USER) - .representation(rep) - .success(); - if (session.getTransaction().isActive()) { session.getTransaction().commit(); } @@ -234,13 +219,7 @@ public class UsersResource { throw new NotFoundException("User not found"); } - UserRepresentation rep = ModelToRepresentation.toRepresentation(user); - - event.event(EventType.VIEW_USER) - .representation(rep) - .success(); - - return rep; + return ModelToRepresentation.toRepresentation(user); } /** @@ -265,11 +244,6 @@ public class UsersResource { UserSessionRepresentation rep = ModelToRepresentation.toRepresentation(session); reps.add(rep); } - - event.event(EventType.VIEW_USER_SESSIONS) - .representation(reps) - .success(); - return reps; } @@ -301,11 +275,6 @@ public class UsersResource { } } } - - event.event(EventType.VIEW_USER) - .representation(result) - .success(); - return result; } @@ -361,9 +330,6 @@ public class UsersResource { for (UserSessionModel userSession : userSessions) { AuthenticationManager.backchannelLogout(session, realm, userSession, uriInfo, clientConnection, headers); } - - event.event(EventType.LOGOUT_USER_SESSIONS) - .success(); } /** @@ -385,11 +351,6 @@ public class UsersResource { boolean removed = new UserManager(session).removeUser(realm, user); if (removed) { - - event.event(EventType.DELETE_USER) - .representation(rep) - .success(); - return Response.noContent().build(); } else { return Flows.errors().error("User couldn't be deleted", Response.Status.BAD_REQUEST); diff --git a/social/twitter/src/main/java/org/keycloak/social/twitter/TwitterIdentityProvider.java b/social/twitter/src/main/java/org/keycloak/social/twitter/TwitterIdentityProvider.java index 2e908541ec..fea19e9ded 100755 --- a/social/twitter/src/main/java/org/keycloak/social/twitter/TwitterIdentityProvider.java +++ b/social/twitter/src/main/java/org/keycloak/social/twitter/TwitterIdentityProvider.java @@ -29,7 +29,6 @@ import org.keycloak.broker.provider.AuthenticationRequest; import org.keycloak.broker.provider.FederatedIdentity; import org.keycloak.broker.provider.IdentityBrokerException; import org.keycloak.events.EventBuilder; -import org.keycloak.events.EventGroup; import org.keycloak.events.EventType; import org.keycloak.models.ClientModel; import org.keycloak.models.ClientSessionModel; @@ -156,7 +155,7 @@ public class TwitterIdentityProvider extends AbstractIdentityProvider