use of org.keycloak.models.RoleModel in project keycloak by keycloak.
the class RoleByIdResource method getRole.
/**
* Get a specific role's representation
*
* @param id id of role
* @return
*/
@Path("{role-id}")
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public RoleRepresentation getRole(@PathParam("role-id") final String id) {
RoleModel roleModel = getRoleModel(id);
auth.roles().requireView(roleModel);
return getRole(roleModel);
}
use of org.keycloak.models.RoleModel in project keycloak by keycloak.
the class RoleByIdResource method addComposites.
/**
* Make the role a composite role by associating some child roles
*
* @param id
* @param roles
*/
@Path("{role-id}/composites")
@POST
@Consumes(MediaType.APPLICATION_JSON)
public void addComposites(@PathParam("role-id") final String id, List<RoleRepresentation> roles) {
RoleModel role = getRoleModel(id);
auth.roles().requireManage(role);
addComposites(auth, adminEvent, session.getContext().getUri(), roles, role);
}
use of org.keycloak.models.RoleModel in project keycloak by keycloak.
the class RoleByIdResource method getRoleComposites.
/**
* Get role's children
*
* Returns a set of role's children provided the role is a composite.
*
* @param id
* @return
*/
@Path("{role-id}/composites")
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public Stream<RoleRepresentation> getRoleComposites(@PathParam("role-id") final String id, @QueryParam("search") final String search, @QueryParam("first") final Integer first, @QueryParam("max") final Integer max) {
if (logger.isDebugEnabled())
logger.debug("*** getRoleComposites: '" + id + "'");
RoleModel role = getRoleModel(id);
auth.roles().requireView(role);
if (search == null && first == null && max == null) {
return role.getCompositesStream().map(ModelToRepresentation::toBriefRepresentation);
}
return role.getCompositesStream(search, first, max).map(ModelToRepresentation::toBriefRepresentation);
}
use of org.keycloak.models.RoleModel in project keycloak by keycloak.
the class RoleByIdResource method getClientRoleComposites.
/**
* Get client-level roles for the client that are in the role's composite
*
* @param id
* @param clientUuid
* @return
*/
@Path("{role-id}/composites/clients/{clientUuid}")
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public Stream<RoleRepresentation> getClientRoleComposites(@PathParam("role-id") final String id, @PathParam("clientUuid") final String clientUuid) {
RoleModel role = getRoleModel(id);
auth.roles().requireView(role);
ClientModel clientModel = realm.getClientById(clientUuid);
if (clientModel == null) {
throw new NotFoundException("Could not find client");
}
return getClientRoleComposites(clientModel, role);
}
use of org.keycloak.models.RoleModel in project keycloak by keycloak.
the class RoleByIdResource method deleteComposites.
/**
* Remove a set of roles from the role's composite
*
* @param id Role id
* @param roles A set of roles to be removed
*/
@Path("{role-id}/composites")
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
public void deleteComposites(@PathParam("role-id") final String id, List<RoleRepresentation> roles) {
RoleModel role = getRoleModel(id);
auth.roles().requireManage(role);
deleteComposites(adminEvent, session.getContext().getUri(), roles, role);
}
Aggregations