Esempio n. 1
0
  @Override
  public void updateConsent(UserConsentModel consent) {
    String clientId = consent.getClient().getId();

    UserConsentEntity consentEntity = getGrantedConsentEntity(clientId);
    if (consentEntity == null) {
      throw new ModelException(
          "Consent not found for client [" + clientId + "] and user [" + user.getId() + "]");
    }

    updateGrantedConsentEntity(consentEntity, consent);
  }
Esempio n. 2
0
  @Override
  public void addConsent(UserConsentModel consent) {
    String clientId = consent.getClient().getId();

    UserConsentEntity consentEntity = getGrantedConsentEntity(clientId);
    if (consentEntity != null) {
      throw new ModelDuplicateException(
          "Consent already exists for client [" + clientId + "] and user [" + user.getId() + "]");
    }

    consentEntity = new UserConsentEntity();
    consentEntity.setId(KeycloakModelUtils.generateId());
    consentEntity.setUser(user);
    consentEntity.setClientId(clientId);
    em.persist(consentEntity);
    em.flush();

    updateGrantedConsentEntity(consentEntity, consent);
  }
Esempio n. 3
0
 @Override
 public String getId() {
   return user.getId();
 }