Search in sources :

Example 56 with NoCache

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

the class RealmAdminResource method getRealmEventsConfig.

/**
 * Get the events provider configuration
 *
 * Returns JSON object with events provider configuration
 *
 * @return
 */
@GET
@NoCache
@Path("events/config")
@Produces(MediaType.APPLICATION_JSON)
public RealmEventsConfigRepresentation getRealmEventsConfig() {
    auth.realm().requireViewEvents();
    RealmEventsConfigRepresentation config = ModelToRepresentation.toEventsConfigReprensetation(realm);
    if (config.getEnabledEventTypes() == null || config.getEnabledEventTypes().isEmpty()) {
        List<String> eventTypes = Arrays.stream(EventType.values()).filter(EventType::isSaveByDefault).map(EventType::name).collect(Collectors.toList());
        config.setEnabledEventTypes(eventTypes);
    }
    return config;
}
Also used : RealmEventsConfigRepresentation(org.keycloak.representations.idm.RealmEventsConfigRepresentation) EventType(org.keycloak.events.EventType) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 57 with NoCache

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

the class ClientRegistrationPolicyResource method getProviders.

/**
 * Base path for retrieve providers with the configProperties properly filled
 *
 * @return
 */
@Path("providers")
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public Stream<ComponentTypeRepresentation> getProviders() {
    return session.getKeycloakSessionFactory().getProviderFactoriesStream(ClientRegistrationPolicy.class).map((ProviderFactory factory) -> {
        ClientRegistrationPolicyFactory clientRegFactory = (ClientRegistrationPolicyFactory) factory;
        List<ProviderConfigProperty> configProps = clientRegFactory.getConfigProperties(session);
        ComponentTypeRepresentation rep = new ComponentTypeRepresentation();
        rep.setId(clientRegFactory.getId());
        rep.setHelpText(clientRegFactory.getHelpText());
        rep.setProperties(ModelToRepresentation.toRepresentation(configProps));
        return rep;
    });
}
Also used : ClientRegistrationPolicy(org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy) ComponentTypeRepresentation(org.keycloak.representations.idm.ComponentTypeRepresentation) ProviderFactory(org.keycloak.provider.ProviderFactory) ProviderConfigProperty(org.keycloak.provider.ProviderConfigProperty) ClientRegistrationPolicyFactory(org.keycloak.services.clientregistration.policy.ClientRegistrationPolicyFactory) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 58 with NoCache

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

the class ClientScopesResource method getClientScope.

/**
 * Base path for managing a specific client scope.
 *
 * @param id id of client scope (not name)
 * @return
 */
@Path("{id}")
@NoCache
public ClientScopeResource getClientScope(@PathParam("id") final String id) {
    auth.clients().requireListClientScopes();
    ClientScopeModel clientModel = realm.getClientScopeById(id);
    if (clientModel == null) {
        throw new NotFoundException("Could not find client scope");
    }
    ClientScopeResource clientResource = new ClientScopeResource(realm, auth, clientModel, session, adminEvent);
    ResteasyProviderFactory.getInstance().injectProperties(clientResource);
    return clientResource;
}
Also used : NotFoundException(javax.ws.rs.NotFoundException) ClientScopeModel(org.keycloak.models.ClientScopeModel) Path(javax.ws.rs.Path) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 59 with NoCache

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

the class GroupResource method getGroup.

/**
 * @return
 */
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public GroupRepresentation getGroup() {
    this.auth.groups().requireView(group);
    GroupRepresentation rep = ModelToRepresentation.toGroupHierarchy(group, true);
    rep.setAccess(auth.groups().getAccess(group));
    return rep;
}
Also used : GroupRepresentation(org.keycloak.representations.idm.GroupRepresentation) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 60 with NoCache

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

the class GroupResource method setManagementPermissionsEnabled.

/**
 * Return object stating whether client Authorization permissions have been initialized or not and a reference
 *
 * @return initialized manage permissions reference
 */
@Path("management/permissions")
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@NoCache
public ManagementPermissionReference setManagementPermissionsEnabled(ManagementPermissionReference ref) {
    auth.groups().requireManage(group);
    AdminPermissionManagement permissions = AdminPermissions.management(session, realm);
    permissions.groups().setPermissionsEnabled(group, ref.isEnabled());
    if (ref.isEnabled()) {
        return toMgmtRef(group, permissions);
    } else {
        return new ManagementPermissionReference();
    }
}
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) Consumes(javax.ws.rs.Consumes) NoCache(org.jboss.resteasy.annotations.cache.NoCache) PUT(javax.ws.rs.PUT)

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