Search in sources :

Example 6 with IdentityProviderMapperModel

use of org.keycloak.models.IdentityProviderMapperModel 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)

Example 7 with IdentityProviderMapperModel

use of org.keycloak.models.IdentityProviderMapperModel in project keycloak by keycloak.

the class IdentityProviderResource method update.

/**
 * Update a mapper for the identity provider
 *
 * @param id Mapper id
 * @param rep
 */
@PUT
@NoCache
@Path("mappers/{id}")
@Consumes(MediaType.APPLICATION_JSON)
public void update(@PathParam("id") String id, IdentityProviderMapperRepresentation rep) {
    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");
    model = RepresentationToModel.toModel(rep);
    realm.updateIdentityProviderMapper(model);
    adminEvent.operation(OperationType.UPDATE).resource(ResourceType.IDENTITY_PROVIDER_MAPPER).resourcePath(session.getContext().getUri()).representation(rep).success();
}
Also used : NotFoundException(javax.ws.rs.NotFoundException) IdentityProviderMapperModel(org.keycloak.models.IdentityProviderMapperModel) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) NoCache(org.jboss.resteasy.annotations.cache.NoCache) PUT(javax.ws.rs.PUT)

Example 8 with IdentityProviderMapperModel

use of org.keycloak.models.IdentityProviderMapperModel in project keycloak by keycloak.

the class RepresentationToModel method toModel.

public static IdentityProviderMapperModel toModel(IdentityProviderMapperRepresentation rep) {
    IdentityProviderMapperModel model = new IdentityProviderMapperModel();
    model.setId(rep.getId());
    model.setName(rep.getName());
    model.setIdentityProviderAlias(rep.getIdentityProviderAlias());
    model.setIdentityProviderMapper(rep.getIdentityProviderMapper());
    model.setConfig(removeEmptyString(rep.getConfig()));
    return model;
}
Also used : IdentityProviderMapperModel(org.keycloak.models.IdentityProviderMapperModel)

Aggregations

IdentityProviderMapperModel (org.keycloak.models.IdentityProviderMapperModel)8 NotFoundException (javax.ws.rs.NotFoundException)4 Path (javax.ws.rs.Path)4 NoCache (org.jboss.resteasy.annotations.cache.NoCache)3 Consumes (javax.ws.rs.Consumes)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1 Produces (javax.ws.rs.Produces)1 BrokeredIdentityContext (org.keycloak.broker.provider.BrokeredIdentityContext)1 ConfigConstants (org.keycloak.broker.provider.ConfigConstants)1