Search in sources :

Example 91 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class RoleContainerResource method getClientRoleComposites.

/**
 * Get client-level roles for the client that are in the role's composite
 *
 * @param roleName role's name (not id!)
 * @param clientUuid
 * @return
 */
@Path("{role-name}/composites/clients/{clientUuid}")
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public Stream<RoleRepresentation> getClientRoleComposites(@PathParam("role-name") final String roleName, @PathParam("clientUuid") final String clientUuid) {
    auth.roles().requireView(roleContainer);
    RoleModel role = roleContainer.getRole(roleName);
    if (role == null) {
        throw new NotFoundException("Could not find role");
    }
    ClientModel clientModel = realm.getClientById(clientUuid);
    if (clientModel == null) {
        throw new NotFoundException("Could not find client");
    }
    return getClientRoleComposites(clientModel, role);
}
Also used : ClientModel(org.keycloak.models.ClientModel) NotFoundException(javax.ws.rs.NotFoundException) RoleModel(org.keycloak.models.RoleModel) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 92 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class RoleContainerResource method getRole.

/**
 * Get a role by name
 *
 * @param roleName role's name (not id!)
 * @return
 */
@Path("{role-name}")
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public RoleRepresentation getRole(@PathParam("role-name") final String roleName) {
    auth.roles().requireView(roleContainer);
    RoleModel roleModel = roleContainer.getRole(roleName);
    if (roleModel == null) {
        throw new NotFoundException("Could not find role");
    }
    return getRole(roleModel);
}
Also used : NotFoundException(javax.ws.rs.NotFoundException) RoleModel(org.keycloak.models.RoleModel) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 93 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class RoleContainerResource method getUsersInRole.

/**
 * Returns a stream of users that have the specified role name.
 *
 * @param roleName the role name.
 * @param firstResult first result to return. Ignored if negative or {@code null}.
 * @param maxResults maximum number of results to return. Ignored if negative or {@code null}.
 * @return a non-empty {@code Stream} of users.
 */
@Path("{role-name}/users")
@GET
@Produces(MediaType.APPLICATION_JSON)
@NoCache
public Stream<UserRepresentation> getUsersInRole(@PathParam("role-name") final String roleName, @QueryParam("first") Integer firstResult, @QueryParam("max") Integer maxResults) {
    auth.roles().requireView(roleContainer);
    firstResult = firstResult != null ? firstResult : 0;
    maxResults = maxResults != null ? maxResults : Constants.DEFAULT_MAX_RESULTS;
    RoleModel role = roleContainer.getRole(roleName);
    if (role == null) {
        throw new NotFoundException("Could not find role");
    }
    return session.users().getRoleMembersStream(realm, role, firstResult, maxResults).map(user -> ModelToRepresentation.toRepresentation(session, realm, user));
}
Also used : NotFoundException(javax.ws.rs.NotFoundException) RoleModel(org.keycloak.models.RoleModel) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 94 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class IdentityProviderResource method getManagementPermissions.

/**
 * Return object stating whether client Authorization permissions have been initialized or not and a reference
 *
 * @return
 */
@Path("management/permissions")
@GET
@Produces(MediaType.APPLICATION_JSON)
@NoCache
public ManagementPermissionReference getManagementPermissions() {
    this.auth.realm().requireViewIdentityProviders();
    AdminPermissionManagement permissions = AdminPermissions.management(session, realm);
    if (!permissions.idps().isPermissionsEnabled(identityProviderModel)) {
        return new ManagementPermissionReference();
    }
    return toMgmtRef(identityProviderModel, permissions);
}
Also used : ManagementPermissionReference(org.keycloak.representations.idm.ManagementPermissionReference) AdminPermissionManagement(org.keycloak.services.resources.admin.permissions.AdminPermissionManagement) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 95 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class IdentityProviderResource method delete.

/**
 * Delete a mapper for the identity provider
 *
 * @param id Mapper id
 */
@DELETE
@NoCache
@Path("mappers/{id}")
public void delete(@PathParam("id") String id) {
    this.auth.realm().requireManageIdentityProviders();
    if (identityProviderModel == null) {
        throw new javax.ws.rs.NotFoundException();
    }
    IdentityProviderMapperModel model = realm.getIdentityProviderMapperById(id);
    if (model == null)
        throw new NotFoundException("Model not found");
    realm.removeIdentityProviderMapper(model);
    adminEvent.operation(OperationType.DELETE).resource(ResourceType.IDENTITY_PROVIDER_MAPPER).resourcePath(session.getContext().getUri()).success();
}
Also used : NotFoundException(javax.ws.rs.NotFoundException) IdentityProviderMapperModel(org.keycloak.models.IdentityProviderMapperModel) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Aggregations

NoCache (org.jboss.resteasy.annotations.cache.NoCache)152 Path (javax.ws.rs.Path)128 Produces (javax.ws.rs.Produces)100 GET (javax.ws.rs.GET)82 NotFoundException (javax.ws.rs.NotFoundException)67 POST (javax.ws.rs.POST)49 Consumes (javax.ws.rs.Consumes)48 PUT (javax.ws.rs.PUT)24 DELETE (javax.ws.rs.DELETE)23 HashMap (java.util.HashMap)20 RoleModel (org.keycloak.models.RoleModel)18 UserModel (org.keycloak.models.UserModel)18 BadRequestException (javax.ws.rs.BadRequestException)17 Response (javax.ws.rs.core.Response)16 ErrorResponseException (org.keycloak.services.ErrorResponseException)16 ClientModel (org.keycloak.models.ClientModel)15 AuthenticationFlowModel (org.keycloak.models.AuthenticationFlowModel)14 RealmModel (org.keycloak.models.RealmModel)14 List (java.util.List)12 Map (java.util.Map)12