use of org.keycloak.storage.jpa.entity.FederatedUserAttributeEntity in project keycloak by keycloak.
the class JpaUserFederatedStorageProvider method persistAttributeValue.
private void persistAttributeValue(RealmModel realm, String userId, String name, String value) {
FederatedUserAttributeEntity attr = new FederatedUserAttributeEntity();
attr.setId(KeycloakModelUtils.generateId());
attr.setName(name);
attr.setValue(value);
attr.setUserId(userId);
attr.setRealmId(realm.getId());
attr.setStorageProviderId(new StorageId(userId).getProviderId());
em.persist(attr);
}
use of org.keycloak.storage.jpa.entity.FederatedUserAttributeEntity in project keycloak by keycloak.
the class JpaUserFederatedStorageProvider method getAttributes.
@Override
public MultivaluedHashMap<String, String> getAttributes(RealmModel realm, String userId) {
TypedQuery<FederatedUserAttributeEntity> query = em.createNamedQuery("getFederatedAttributesByUser", FederatedUserAttributeEntity.class);
List<FederatedUserAttributeEntity> list = query.setParameter("userId", userId).setParameter("realmId", realm.getId()).getResultList();
MultivaluedHashMap<String, String> result = new MultivaluedHashMap<>();
for (FederatedUserAttributeEntity entity : list) {
result.add(entity.getName(), entity.getValue());
}
return result;
}
Aggregations