parent
6d683824a4
commit
6f7c62fc73
14 changed files with 69 additions and 82 deletions
|
@ -51,7 +51,7 @@ public class LdapServerCapabilitiesRealmAdminProvider implements AdminRealmResou
|
|||
|
||||
@Override
|
||||
public Object getResource(KeycloakSession session, RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
return new LdapServerCapabilitiesResource(realm, auth, adminEvent);
|
||||
return new LdapServerCapabilitiesResource(session, auth, adminEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.keycloak.services.resources.admin;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
import org.jboss.resteasy.annotations.cache.NoCache;
|
||||
import org.keycloak.common.ClientConnection;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
|
@ -30,7 +29,6 @@ import org.keycloak.services.resources.admin.permissions.AdminPermissionEvaluato
|
|||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
@ -42,27 +40,26 @@ import java.util.Set;
|
|||
* @version $Revision: 1 $
|
||||
*/
|
||||
public class LdapServerCapabilitiesResource {
|
||||
private static final Logger logger = Logger.getLogger(LdapServerCapabilitiesResource.class);
|
||||
|
||||
protected RealmModel realm;
|
||||
protected final RealmModel realm;
|
||||
|
||||
protected AdminPermissionEvaluator auth;
|
||||
protected final AdminPermissionEvaluator auth;
|
||||
|
||||
protected AdminEventBuilder adminEvent;
|
||||
protected final AdminEventBuilder adminEvent;
|
||||
|
||||
@Context
|
||||
protected ClientConnection clientConnection;
|
||||
protected final ClientConnection clientConnection;
|
||||
|
||||
@Context
|
||||
protected KeycloakSession session;
|
||||
protected final KeycloakSession session;
|
||||
|
||||
@Context
|
||||
protected HttpHeaders headers;
|
||||
protected final HttpHeaders headers;
|
||||
|
||||
public LdapServerCapabilitiesResource(RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
public LdapServerCapabilitiesResource(KeycloakSession session, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
this.session = session;
|
||||
this.auth = auth;
|
||||
this.realm = realm;
|
||||
this.realm = session.getContext().getRealm();
|
||||
this.adminEvent = adminEvent;
|
||||
this.clientConnection = session.getContext().getConnection();
|
||||
this.headers = session.getContext().getRequestHeaders();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TestLdapConnectionRealmAdminProvider implements AdminRealmResourceP
|
|||
|
||||
@Override
|
||||
public Object getResource(KeycloakSession session, RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
return new TestLdapConnectionResource(realm, auth);
|
||||
return new TestLdapConnectionResource(session, auth);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@ import org.keycloak.services.resources.admin.permissions.AdminPermissionEvaluato
|
|||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.FormParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
|
@ -41,16 +39,16 @@ import javax.ws.rs.core.Response;
|
|||
* @version $Revision: 1 $
|
||||
*/
|
||||
public class TestLdapConnectionResource {
|
||||
protected RealmModel realm;
|
||||
protected final RealmModel realm;
|
||||
|
||||
protected AdminPermissionEvaluator auth;
|
||||
protected final AdminPermissionEvaluator auth;
|
||||
|
||||
@Context
|
||||
protected KeycloakSession session;
|
||||
protected final KeycloakSession session;
|
||||
|
||||
public TestLdapConnectionResource(RealmModel realm, AdminPermissionEvaluator auth) {
|
||||
public TestLdapConnectionResource(KeycloakSession session, AdminPermissionEvaluator auth) {
|
||||
this.session = session;
|
||||
this.auth = auth;
|
||||
this.realm = realm;
|
||||
this.realm = session.getContext().getRealm();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,6 +54,6 @@ public class ClearKeysCacheRealmAdminProvider implements AdminRealmResourceProvi
|
|||
|
||||
@Override
|
||||
public Object getResource(KeycloakSession session, RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
return new ClearKeysCacheResource(session, realm, auth, adminEvent);
|
||||
return new ClearKeysCacheResource(session, auth, adminEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,18 +28,17 @@ import javax.ws.rs.core.Context;
|
|||
|
||||
public class ClearKeysCacheResource {
|
||||
|
||||
protected AdminPermissionEvaluator auth;
|
||||
protected RealmModel realm;
|
||||
private AdminEventBuilder adminEvent;
|
||||
protected final AdminPermissionEvaluator auth;
|
||||
protected final RealmModel realm;
|
||||
private final AdminEventBuilder adminEvent;
|
||||
|
||||
@Context
|
||||
protected KeycloakSession session;
|
||||
protected final KeycloakSession session;
|
||||
|
||||
public ClearKeysCacheResource(KeycloakSession session, RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
this.auth = auth;
|
||||
this.realm = realm;
|
||||
this.adminEvent = adminEvent;
|
||||
public ClearKeysCacheResource(KeycloakSession session, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
this.session = session;
|
||||
this.auth = auth;
|
||||
this.realm = session.getContext().getRealm();
|
||||
this.adminEvent = adminEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ClearRealmCacheRealmAdminProvider implements AdminRealmResourceProv
|
|||
|
||||
@Override
|
||||
public Object getResource(KeycloakSession session, RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
return new ClearRealmCacheResource(realm, auth, adminEvent);
|
||||
return new ClearRealmCacheResource(session, auth, adminEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,28 +20,26 @@ import org.keycloak.events.admin.OperationType;
|
|||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.cache.CacheRealmProvider;
|
||||
import org.keycloak.models.cache.UserCache;
|
||||
import org.keycloak.services.resources.admin.permissions.AdminPermissionEvaluator;
|
||||
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
/**
|
||||
* Clear user cache.
|
||||
*/
|
||||
public class ClearRealmCacheResource {
|
||||
protected RealmModel realm;
|
||||
protected final RealmModel realm;
|
||||
|
||||
protected AdminPermissionEvaluator auth;
|
||||
protected final AdminPermissionEvaluator auth;
|
||||
|
||||
protected AdminEventBuilder adminEvent;
|
||||
protected final AdminEventBuilder adminEvent;
|
||||
|
||||
@Context
|
||||
protected KeycloakSession session;
|
||||
protected final KeycloakSession session;
|
||||
|
||||
public ClearRealmCacheResource(RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
public ClearRealmCacheResource(KeycloakSession session, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
this.session = session;
|
||||
this.auth = auth;
|
||||
this.realm = realm;
|
||||
this.realm = session.getContext().getRealm();
|
||||
this.adminEvent = adminEvent;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ClearUserCacheRealmAdminProvider implements AdminRealmResourceProvi
|
|||
|
||||
@Override
|
||||
public Object getResource(KeycloakSession session, RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
return new ClearUserCacheResource(realm, auth, adminEvent);
|
||||
return new ClearUserCacheResource(session, auth, adminEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,24 +23,23 @@ import org.keycloak.models.cache.UserCache;
|
|||
import org.keycloak.services.resources.admin.permissions.AdminPermissionEvaluator;
|
||||
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
/**
|
||||
* Clear user cache.
|
||||
*/
|
||||
public class ClearUserCacheResource {
|
||||
protected RealmModel realm;
|
||||
protected final RealmModel realm;
|
||||
|
||||
protected AdminPermissionEvaluator auth;
|
||||
protected final AdminPermissionEvaluator auth;
|
||||
|
||||
protected AdminEventBuilder adminEvent;
|
||||
protected final AdminEventBuilder adminEvent;
|
||||
|
||||
@Context
|
||||
protected KeycloakSession session;
|
||||
protected final KeycloakSession session;
|
||||
|
||||
public ClearUserCacheResource(RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
public ClearUserCacheResource(KeycloakSession session, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
this.session = session;
|
||||
this.auth = auth;
|
||||
this.realm = realm;
|
||||
this.realm = session.getContext().getRealm();
|
||||
this.adminEvent = adminEvent;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.keycloak.services.resources.admin;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
import org.jboss.resteasy.annotations.cache.NoCache;
|
||||
import javax.ws.rs.NotFoundException;
|
||||
import org.keycloak.common.ClientConnection;
|
||||
|
@ -30,7 +29,6 @@ import javax.ws.rs.GET;
|
|||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
|
@ -42,27 +40,26 @@ import java.util.Map;
|
|||
* @version $Revision: 1 $
|
||||
*/
|
||||
public class ClientStorageProviderResource {
|
||||
private static final Logger logger = Logger.getLogger(ClientStorageProviderResource.class);
|
||||
|
||||
protected RealmModel realm;
|
||||
protected final RealmModel realm;
|
||||
|
||||
protected AdminPermissionEvaluator auth;
|
||||
protected final AdminPermissionEvaluator auth;
|
||||
|
||||
protected AdminEventBuilder adminEvent;
|
||||
protected final AdminEventBuilder adminEvent;
|
||||
|
||||
@Context
|
||||
protected ClientConnection clientConnection;
|
||||
protected final ClientConnection clientConnection;
|
||||
|
||||
@Context
|
||||
protected KeycloakSession session;
|
||||
protected final KeycloakSession session;
|
||||
|
||||
@Context
|
||||
protected HttpHeaders headers;
|
||||
protected final HttpHeaders headers;
|
||||
|
||||
public ClientStorageProviderResource(RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
public ClientStorageProviderResource(KeycloakSession session, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
this.session = session;
|
||||
this.auth = auth;
|
||||
this.realm = realm;
|
||||
this.realm = session.getContext().getRealm();
|
||||
this.adminEvent = adminEvent;
|
||||
this.clientConnection = session.getContext().getConnection();
|
||||
this.headers = session.getContext().getRequestHeaders();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,7 +51,7 @@ public class UserStorageProviderRealmAdminProvider implements AdminRealmResource
|
|||
|
||||
@Override
|
||||
public Object getResource(KeycloakSession session, RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
return new UserStorageProviderResource(realm, auth, adminEvent);
|
||||
return new UserStorageProviderResource(session, auth, adminEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ 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 java.util.HashMap;
|
||||
|
@ -54,25 +53,25 @@ import java.util.Map;
|
|||
public class UserStorageProviderResource {
|
||||
private static final Logger logger = Logger.getLogger(UserStorageProviderResource.class);
|
||||
|
||||
protected RealmModel realm;
|
||||
protected final RealmModel realm;
|
||||
|
||||
protected AdminPermissionEvaluator auth;
|
||||
protected final AdminPermissionEvaluator auth;
|
||||
|
||||
protected AdminEventBuilder adminEvent;
|
||||
protected final AdminEventBuilder adminEvent;
|
||||
|
||||
@Context
|
||||
protected ClientConnection clientConnection;
|
||||
protected final ClientConnection clientConnection;
|
||||
|
||||
@Context
|
||||
protected KeycloakSession session;
|
||||
protected final KeycloakSession session;
|
||||
|
||||
@Context
|
||||
protected HttpHeaders headers;
|
||||
protected final HttpHeaders headers;
|
||||
|
||||
public UserStorageProviderResource(RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
public UserStorageProviderResource(KeycloakSession session, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) {
|
||||
this.session = session;
|
||||
this.auth = auth;
|
||||
this.realm = realm;
|
||||
this.realm = session.getContext().getRealm();
|
||||
this.adminEvent = adminEvent;
|
||||
this.clientConnection = session.getContext().getConnection();
|
||||
this.headers = session.getContext().getRequestHeaders();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -103,7 +103,7 @@ public class PolicyService {
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@NoCache
|
||||
public Response create(String payload, @Context KeycloakSession session) {
|
||||
public Response create(String payload) {
|
||||
if (auth != null) {
|
||||
this.auth.realm().requireManageAuthorization();
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public class PolicyService {
|
|||
|
||||
representation.setId(policy.getId());
|
||||
|
||||
audit(representation, representation.getId(), OperationType.CREATE, session);
|
||||
audit(representation, representation.getId(), OperationType.CREATE, authorization.getKeycloakSession());
|
||||
|
||||
return Response.status(Status.CREATED).entity(representation).build();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue