Removed admin audit events - need to rethink how to implement it
This commit is contained in:
1 parent
4a650e5417
commit
fcc2e0a9f0
35 files changed
+108
-551
No files matched your search
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+5
-40
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-3
@@ -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
|
||||
|
||||
+3
-13
@@ -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;
|
||||
|
||||
+1
-15
@@ -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);
|
||||
|
||||
+1
-20
@@ -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) {
|
||||
|
||||
+3
-32
@@ -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<String, String> 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<String, String> 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;
|
||||
}
|
||||
|
||||
+3
-18
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -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
|
||||
|
||||
+3
-18
@@ -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;
|
||||
|
||||
+29
-45
@@ -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);
|
||||
}
|
||||
}
|
||||
+10
-28
@@ -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<RealmRepresentation> 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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-30
@@ -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");
|
||||
|
||||
+3
-34
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user