use of org.keycloak.models.ProtocolMapperModel in project keycloak by keycloak.
the class ProtocolMappersResource method getMapperById.
/**
* Get mapper by id
*
* @param id Mapper id
* @return
*/
@GET
@NoCache
@Path("models/{id}")
@Produces(MediaType.APPLICATION_JSON)
public ProtocolMapperRepresentation getMapperById(@PathParam("id") String id) {
viewPermission.require();
ProtocolMapperModel model = client.getProtocolMapperById(id);
if (model == null)
throw new NotFoundException("Model not found");
return ModelToRepresentation.toRepresentation(model);
}
use of org.keycloak.models.ProtocolMapperModel in project keycloak by keycloak.
the class ProtocolMappersResource method createMapper.
/**
* Create multiple mappers
*/
@Path("add-models")
@POST
@NoCache
@Consumes(MediaType.APPLICATION_JSON)
public void createMapper(List<ProtocolMapperRepresentation> reps) {
managePermission.require();
ProtocolMapperModel model = null;
for (ProtocolMapperRepresentation rep : reps) {
model = RepresentationToModel.toModel(rep);
validateModel(model);
model = client.addProtocolMapper(model);
}
adminEvent.operation(OperationType.CREATE).resourcePath(session.getContext().getUri()).representation(reps).success();
}
use of org.keycloak.models.ProtocolMapperModel in project keycloak by keycloak.
the class ProtocolMappersResource method delete.
/**
* Delete the mapper
*
* @param id Mapper id
*/
@DELETE
@NoCache
@Path("models/{id}")
public void delete(@PathParam("id") String id) {
managePermission.require();
ProtocolMapperModel model = client.getProtocolMapperById(id);
if (model == null)
throw new NotFoundException("Model not found");
client.removeProtocolMapper(model);
adminEvent.operation(OperationType.DELETE).resourcePath(session.getContext().getUri()).success();
}
use of org.keycloak.models.ProtocolMapperModel in project keycloak by keycloak.
the class ProtocolMappersResource method createMapper.
/**
* Create a mapper
*
* @param rep
*/
@Path("models")
@POST
@NoCache
@Consumes(MediaType.APPLICATION_JSON)
public Response createMapper(ProtocolMapperRepresentation rep) {
managePermission.require();
ProtocolMapperModel model = null;
try {
model = RepresentationToModel.toModel(rep);
validateModel(model);
model = client.addProtocolMapper(model);
adminEvent.operation(OperationType.CREATE).resourcePath(session.getContext().getUri(), model.getId()).representation(rep).success();
} catch (ModelDuplicateException e) {
return ErrorResponse.exists("Protocol mapper exists with same name");
}
return Response.created(session.getContext().getUri().getAbsolutePathBuilder().path(model.getId()).build()).build();
}
use of org.keycloak.models.ProtocolMapperModel in project keycloak by keycloak.
the class ClientScopeAdapter method entityToModel.
protected ProtocolMapperModel entityToModel(ProtocolMapperEntity entity) {
ProtocolMapperModel mapping = new ProtocolMapperModel();
mapping.setId(entity.getId());
mapping.setName(entity.getName());
mapping.setProtocol(entity.getProtocol());
mapping.setProtocolMapper(entity.getProtocolMapper());
Map<String, String> config = new HashMap<String, String>();
if (entity.getConfig() != null)
config.putAll(entity.getConfig());
mapping.setConfig(config);
return mapping;
}
Aggregations