Search in sources :

Example 1 with ProtocolMapperEntity

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);
}
Also used : ProtocolMapperEntity(org.keycloak.models.jpa.entities.ProtocolMapperEntity) ModelDuplicateException(org.keycloak.models.ModelDuplicateException)

Example 2 with ProtocolMapperEntity

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();
}
Also used : ProtocolMapperEntity(org.keycloak.models.jpa.entities.ProtocolMapperEntity)

Example 3 with ProtocolMapperEntity

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);
}
Also used : ProtocolMapperEntity(org.keycloak.models.jpa.entities.ProtocolMapperEntity) ModelDuplicateException(org.keycloak.models.ModelDuplicateException)

Example 4 with ProtocolMapperEntity

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);
    }
}
Also used : ProtocolMapperEntity(org.keycloak.models.jpa.entities.ProtocolMapperEntity)

Example 5 with ProtocolMapperEntity

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();
}
Also used : ProtocolMapperEntity(org.keycloak.models.jpa.entities.ProtocolMapperEntity)

Aggregations

ProtocolMapperEntity (org.keycloak.models.jpa.entities.ProtocolMapperEntity)6 ModelDuplicateException (org.keycloak.models.ModelDuplicateException)2