Search in sources :

Example 51 with NoCache

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

the class IdentityProviderResource method getMapperTypes.

/**
 * Get mapper types for identity provider
 */
@GET
@Path("mapper-types")
@NoCache
public Map<String, IdentityProviderMapperTypeRepresentation> getMapperTypes() {
    this.auth.realm().requireViewIdentityProviders();
    if (identityProviderModel == null) {
        throw new javax.ws.rs.NotFoundException();
    }
    KeycloakSessionFactory sessionFactory = session.getKeycloakSessionFactory();
    return sessionFactory.getProviderFactoriesStream(IdentityProviderMapper.class).map(IdentityProviderMapper.class::cast).map(mapper -> Arrays.stream(mapper.getCompatibleProviders()).filter(type -> Objects.equals(IdentityProviderMapper.ANY_PROVIDER, type) || Objects.equals(identityProviderModel.getProviderId(), type)).map(type -> {
        IdentityProviderMapperTypeRepresentation rep = new IdentityProviderMapperTypeRepresentation();
        rep.setId(mapper.getId());
        rep.setCategory(mapper.getDisplayCategory());
        rep.setName(mapper.getDisplayType());
        rep.setHelpText(mapper.getHelpText());
        rep.setProperties(mapper.getConfigProperties().stream().map(ModelToRepresentation::toRepresentation).collect(Collectors.toList()));
        return rep;
    }).findFirst().orElse(null)).filter(Objects::nonNull).collect(Collectors.toMap(IdentityProviderMapperTypeRepresentation::getId, Function.identity()));
}
Also used : OperationType(org.keycloak.events.admin.OperationType) IdentityProviderRepresentation(org.keycloak.representations.idm.IdentityProviderRepresentation) PathParam(javax.ws.rs.PathParam) Arrays(java.util.Arrays) ResourceType(org.keycloak.events.admin.ResourceType) IdentityProviderFactory(org.keycloak.broker.provider.IdentityProviderFactory) Produces(javax.ws.rs.Produces) IdentityProviderMapperModel(org.keycloak.models.IdentityProviderMapperModel) GET(javax.ws.rs.GET) Logger(org.jboss.logging.Logger) Path(javax.ws.rs.Path) IdentityProviderMapperTypeRepresentation(org.keycloak.representations.idm.IdentityProviderMapperTypeRepresentation) Function(java.util.function.Function) RepresentationToModel(org.keycloak.models.utils.RepresentationToModel) ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) MediaType(javax.ws.rs.core.MediaType) UserModel(org.keycloak.models.UserModel) QueryParam(javax.ws.rs.QueryParam) Consumes(javax.ws.rs.Consumes) Map(java.util.Map) IdentityProviderMapperRepresentation(org.keycloak.representations.idm.IdentityProviderMapperRepresentation) AdminPermissionManagement(org.keycloak.services.resources.admin.permissions.AdminPermissionManagement) StripSecretsUtils(org.keycloak.models.utils.StripSecretsUtils) IdentityProvider(org.keycloak.broker.provider.IdentityProvider) IdentityProviderMapper(org.keycloak.broker.provider.IdentityProviderMapper) DELETE(javax.ws.rs.DELETE) BAD_REQUEST(javax.ws.rs.core.Response.Status.BAD_REQUEST) FederatedIdentityModel(org.keycloak.models.FederatedIdentityModel) AdminPermissions(org.keycloak.services.resources.admin.permissions.AdminPermissions) RealmModel(org.keycloak.models.RealmModel) POST(javax.ws.rs.POST) AdminPermissionEvaluator(org.keycloak.services.resources.admin.permissions.AdminPermissionEvaluator) KeycloakSession(org.keycloak.models.KeycloakSession) IdentityProviderModel(org.keycloak.models.IdentityProviderModel) Streams(com.google.common.collect.Streams) Collectors(java.util.stream.Collectors) NotFoundException(javax.ws.rs.NotFoundException) ManagementPermissionReference(org.keycloak.representations.idm.ManagementPermissionReference) Objects(java.util.Objects) SocialIdentityProvider(org.keycloak.broker.social.SocialIdentityProvider) ModelToRepresentation(org.keycloak.models.utils.ModelToRepresentation) Stream(java.util.stream.Stream) NoCache(org.jboss.resteasy.annotations.cache.NoCache) Response(javax.ws.rs.core.Response) KeycloakSessionFactory(org.keycloak.models.KeycloakSessionFactory) ModelDuplicateException(org.keycloak.models.ModelDuplicateException) PUT(javax.ws.rs.PUT) ErrorResponse(org.keycloak.services.ErrorResponse) IdentityProviderMapperTypeRepresentation(org.keycloak.representations.idm.IdentityProviderMapperTypeRepresentation) NotFoundException(javax.ws.rs.NotFoundException) KeycloakSessionFactory(org.keycloak.models.KeycloakSessionFactory) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 52 with NoCache

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

the class IdentityProviderResource 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) {
    this.auth.realm().requireManageIdentityProviders();
    AdminPermissionManagement permissions = AdminPermissions.management(session, realm);
    permissions.idps().setPermissionsEnabled(identityProviderModel, ref.isEnabled());
    if (ref.isEnabled()) {
        return toMgmtRef(identityProviderModel, 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)

Example 53 with NoCache

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

the class KeyResource method getKeyMetadata.

@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public KeysMetadataRepresentation getKeyMetadata() {
    auth.realm().requireViewRealm();
    KeysMetadataRepresentation keys = new KeysMetadataRepresentation();
    keys.setActive(new HashMap<>());
    List<KeysMetadataRepresentation.KeyMetadataRepresentation> realmKeys = session.keys().getKeysStream(realm).map(key -> {
        if (key.getStatus().isActive()) {
            if (!keys.getActive().containsKey(key.getAlgorithmOrDefault())) {
                keys.getActive().put(key.getAlgorithmOrDefault(), key.getKid());
            }
        }
        return toKeyMetadataRepresentation(key);
    }).collect(Collectors.toList());
    keys.setKeys(realmKeys);
    return keys;
}
Also used : KeysMetadataRepresentation(org.keycloak.representations.idm.KeysMetadataRepresentation) KeyWrapper(org.keycloak.crypto.KeyWrapper) RealmModel(org.keycloak.models.RealmModel) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) AdminPermissionEvaluator(org.keycloak.services.resources.admin.permissions.AdminPermissionEvaluator) KeycloakSession(org.keycloak.models.KeycloakSession) HashMap(java.util.HashMap) PemUtils(org.keycloak.common.util.PemUtils) Collectors(java.util.stream.Collectors) KeysMetadataRepresentation(org.keycloak.representations.idm.KeysMetadataRepresentation) MediaType(javax.ws.rs.core.MediaType) List(java.util.List) NoCache(org.jboss.resteasy.annotations.cache.NoCache) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 54 with NoCache

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

the class RealmAdminResource method getUserMgmtPermissions.

@NoCache
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("users-management-permissions")
public ManagementPermissionReference getUserMgmtPermissions() {
    auth.realm().requireViewRealm();
    AdminPermissionManagement permissions = AdminPermissions.management(session, realm);
    if (permissions.users().isPermissionsEnabled()) {
        return toUsersMgmtRef(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) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 55 with NoCache

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

the class RealmAdminResource method testLDAPConnection.

/**
 * Test LDAP connection
 *
 * @param action
 * @param connectionUrl
 * @param bindDn
 * @param bindCredential
 * @return
 */
@Path("testLDAPConnection")
@POST
@NoCache
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Deprecated
public Response testLDAPConnection(@FormParam("action") String action, @FormParam("connectionUrl") String connectionUrl, @FormParam("bindDn") String bindDn, @FormParam("bindCredential") String bindCredential, @FormParam("useTruststoreSpi") String useTruststoreSpi, @FormParam("connectionTimeout") String connectionTimeout, @FormParam("componentId") String componentId, @FormParam("startTls") String startTls) {
    auth.realm().requireManageRealm();
    TestLdapConnectionRepresentation config = new TestLdapConnectionRepresentation(action, connectionUrl, bindDn, bindCredential, useTruststoreSpi, connectionTimeout, startTls, LDAPConstants.AUTH_TYPE_SIMPLE);
    config.setComponentId(componentId);
    boolean result = LDAPServerCapabilitiesManager.testLDAP(config, session, realm);
    return result ? Response.noContent().build() : ErrorResponse.error("LDAP test error", Response.Status.BAD_REQUEST);
}
Also used : TestLdapConnectionRepresentation(org.keycloak.representations.idm.TestLdapConnectionRepresentation) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) 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