Search in sources :

Example 1 with BrokerLinkEntity

use of org.keycloak.storage.jpa.entity.BrokerLinkEntity in project keycloak by keycloak.

the class JpaUserFederatedStorageProvider method addFederatedIdentity.

@Override
public void addFederatedIdentity(RealmModel realm, String userId, FederatedIdentityModel link) {
    createIndex(realm, userId);
    BrokerLinkEntity entity = new BrokerLinkEntity();
    entity.setRealmId(realm.getId());
    entity.setUserId(userId);
    entity.setBrokerUserId(link.getUserId());
    entity.setIdentityProvider(link.getIdentityProvider());
    entity.setToken(link.getToken());
    entity.setBrokerUserName(link.getUserName());
    entity.setStorageProviderId(new StorageId(userId).getProviderId());
    em.persist(entity);
}
Also used : BrokerLinkEntity(org.keycloak.storage.jpa.entity.BrokerLinkEntity) StorageId(org.keycloak.storage.StorageId)

Example 2 with BrokerLinkEntity

use of org.keycloak.storage.jpa.entity.BrokerLinkEntity in project keycloak by keycloak.

the class JpaUserFederatedStorageProvider method updateFederatedIdentity.

@Override
public void updateFederatedIdentity(RealmModel realm, String userId, FederatedIdentityModel model) {
    createIndex(realm, userId);
    BrokerLinkEntity entity = getBrokerLinkEntity(realm, userId, model.getIdentityProvider());
    if (entity == null)
        return;
    entity.setBrokerUserName(model.getUserName());
    entity.setBrokerUserId(model.getUserId());
    entity.setToken(model.getToken());
    em.persist(entity);
    em.flush();
}
Also used : BrokerLinkEntity(org.keycloak.storage.jpa.entity.BrokerLinkEntity)

Example 3 with BrokerLinkEntity

use of org.keycloak.storage.jpa.entity.BrokerLinkEntity in project keycloak by keycloak.

the class JpaUserFederatedStorageProvider method removeFederatedIdentity.

@Override
public boolean removeFederatedIdentity(RealmModel realm, String userId, String socialProvider) {
    BrokerLinkEntity entity = getBrokerLinkEntity(realm, userId, socialProvider);
    if (entity == null)
        return false;
    em.remove(entity);
    return true;
}
Also used : BrokerLinkEntity(org.keycloak.storage.jpa.entity.BrokerLinkEntity)

Aggregations

BrokerLinkEntity (org.keycloak.storage.jpa.entity.BrokerLinkEntity)3 StorageId (org.keycloak.storage.StorageId)1