use of org.keycloak.models.jpa.entities.ProtocolMapperEntity in project keycloak by keycloak.
the class ClientAdapter method addProtocolMapper.
@Override
public ProtocolMapperModel addProtocolMapper(ProtocolMapperModel model) {
if (getProtocolMapperByName(model.getProtocol(), model.getName()) != null) {
throw new ModelDuplicateException("Protocol mapper name must be unique per protocol");
}
String id = model.getId() != null ? model.getId() : KeycloakModelUtils.generateId();
ProtocolMapperEntity entity = new ProtocolMapperEntity();
entity.setId(id);
entity.setName(model.getName());
entity.setProtocol(model.getProtocol());
entity.setProtocolMapper(model.getProtocolMapper());
entity.setClient(this.entity);
entity.setConfig(model.getConfig());
em.persist(entity);
this.entity.getProtocolMappers().add(entity);
return entityToModel(entity);
}
use of org.keycloak.models.jpa.entities.ProtocolMapperEntity in project keycloak by keycloak.
the class ClientScopeAdapter method updateProtocolMapper.
@Override
public void updateProtocolMapper(ProtocolMapperModel mapping) {
ProtocolMapperEntity entity = getProtocolMapperEntity(mapping.getId());
entity.setProtocolMapper(mapping.getProtocolMapper());
if (entity.getConfig() == null) {
entity.setConfig(mapping.getConfig());
} else {
entity.getConfig().clear();
entity.getConfig().putAll(mapping.getConfig());
}
em.flush();
}
use of org.keycloak.models.jpa.entities.ProtocolMapperEntity in project keycloak by keycloak.
the class ClientScopeAdapter method addProtocolMapper.
@Override
public ProtocolMapperModel addProtocolMapper(ProtocolMapperModel model) {
if (getProtocolMapperByName(model.getProtocol(), model.getName()) != null) {
throw new ModelDuplicateException("Protocol mapper name must be unique per protocol");
}
String id = model.getId() != null ? model.getId() : KeycloakModelUtils.generateId();
ProtocolMapperEntity entity = new ProtocolMapperEntity();
entity.setId(id);
entity.setName(model.getName());
entity.setProtocol(model.getProtocol());
entity.setProtocolMapper(model.getProtocolMapper());
entity.setClientScope(this.entity);
entity.setConfig(model.getConfig());
em.persist(entity);
this.entity.getProtocolMappers().add(entity);
return entityToModel(entity);
}
use of org.keycloak.models.jpa.entities.ProtocolMapperEntity in project keycloak by keycloak.
the class ClientScopeAdapter method removeProtocolMapper.
@Override
public void removeProtocolMapper(ProtocolMapperModel mapping) {
ProtocolMapperEntity toDelete = getProtocolMapperEntity(mapping.getId());
if (toDelete != null) {
session.users().preRemove(mapping);
this.entity.getProtocolMappers().remove(toDelete);
em.remove(toDelete);
}
}
use of org.keycloak.models.jpa.entities.ProtocolMapperEntity in project keycloak by keycloak.
the class ClientAdapter method updateProtocolMapper.
@Override
public void updateProtocolMapper(ProtocolMapperModel mapping) {
ProtocolMapperEntity entity = getProtocolMapperEntity(mapping.getId());
entity.setProtocolMapper(mapping.getProtocolMapper());
if (entity.getConfig() == null) {
entity.setConfig(mapping.getConfig());
} else {
entity.getConfig().clear();
entity.getConfig().putAll(mapping.getConfig());
}
em.flush();
}
Aggregations