@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof ClientModel)) return false; ClientModel that = (ClientModel) o; return that.getId().equals(getId()); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof ClientModel)) return false; ClientModel that = (ClientModel) o; return that.getId().equals(getId()); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof ClientModel)) return false; ClientModel that = (ClientModel) o; return that.getId().equals(getId()); }
@Override public void onClientRemoved(RealmModel realm, ClientModel client) { em.createNamedQuery("removeClientSessionNoteByClient").setParameter("realmId", realm.getId()).setParameter("clientId", client.getId()).executeUpdate(); em.createNamedQuery("removeClientSessionRoleByClient").setParameter("realmId", realm.getId()).setParameter("clientId", client.getId()).executeUpdate(); em.createNamedQuery("removeClientSessionProtMapperByClient").setParameter("realmId", realm.getId()).setParameter("clientId", client.getId()).executeUpdate(); em.createNamedQuery("removeClientSessionAuthStatusByClient").setParameter("realmId", realm.getId()).setParameter("clientId", client.getId()).executeUpdate(); em.createNamedQuery("removeClientUserSessionNoteByClient").setParameter("realmId", realm.getId()).setParameter("clientId", client.getId()).executeUpdate(); em.createNamedQuery("removeClientSessionByClient").setParameter("realmId", realm.getId()).setParameter("clientId", client.getId()).executeUpdate(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof ClientModel)) return false; ClientModel that = (ClientModel) o; return that.getId().equals(getId()); }
@Override public RoleModel getClientRole(RealmModel realm, ClientModel client, String name) { TypedQuery<String> query = em.createNamedQuery("getClientRoleIdByName", String.class); query.setParameter("name", name); query.setParameter("client", client.getId()); List<String> roles = query.getResultList(); if (roles.isEmpty()) return null; return session.realms().getRoleById(roles.get(0), realm); }
@Override public void setMasterAdminClient(ClientModel client) { ClientEntity appEntity = client !=null ? em.getReference(ClientEntity.class, client.getId()) : null; realm.setMasterAdminClient(appEntity); em.flush(); }
@Override public String getId() { if (isUpdated()) return updated.getId(); return cached.getId(); }
@Override public void setMasterAdminClient(ClientModel client) { String adminAppId = client != null ? client.getId() : null; realm.setMasterAdminClient(adminAppId); updateRealm(); }
@Override public ClientModel addClient(String id, String clientId) { getDelegateForUpdate(); ClientModel app = updated.addClient(id, clientId); cacheSession.registerApplicationInvalidation(app.getId()); return app; }
@Override public UserModel getServiceAccount(ClientModel client) { // Just an attempt to find the user from cache by default serviceAccount username UserModel user = findServiceAccount(client); if (user != null && user.getServiceAccountClientLink() != null && user.getServiceAccountClientLink().equals(client.getId())) { return user; } return getDelegate().getServiceAccount(client); }
public CachedUserConsent(UserConsentModel consentModel) { this.clientDbId = consentModel.getClient().getId(); for (ClientScopeModel clientScope : consentModel.getGrantedClientScopes()) { this.clientScopeIds.add(clientScope.getId()); } this.createdDate = consentModel.getCreatedDate(); this.lastUpdatedDate = consentModel.getLastUpdatedDate(); }
@Override public RoleModel addClientRole(RealmModel realm, ClientModel client, String id, String name) { RoleModel role = getRealmDelegate().addClientRole(realm, client, id, name); addedRole(role.getId(), client.getId()); return role; }
@Override public void updateConsent(RealmModel realm, String userId, UserConsentModel consent) { String clientId = consent.getClient().getId(); UserConsentEntity consentEntity = getGrantedConsentEntity(userId, clientId); if (consentEntity == null) { throw new ModelException("Consent not found for client [" + clientId + "] and user [" + userId + "]"); } updateGrantedConsentEntity(consentEntity, consent); }
public static ClientRemovedEvent create(ClientModel client) { ClientRemovedEvent event = new ClientRemovedEvent(); event.realmId = client.getRealm().getId(); event.clientUuid = client.getId(); event.clientId = client.getClientId(); event.clientRoles = new HashMap<>(); for (RoleModel clientRole : client.getRoles()) { event.clientRoles.put(clientRole.getId(), clientRole.getName()); } return event; }
@Override public void updateConsent(RealmModel realm, String userId, UserConsentModel consent) { createIndex(realm, userId); String clientId = consent.getClient().getId(); FederatedUserConsentEntity consentEntity = getGrantedConsentEntity(userId, clientId); if (consentEntity == null) { throw new ModelException("Consent not found for client [" + clientId + "] and user [" + userId + "]"); } updateGrantedConsentEntity(consentEntity, consent); }
@Override public void updateConsent(RealmModel realm, String userId, UserConsentModel consent) { String clientId = consent.getClient().getId(); MongoUserConsentEntity consentEntity = getConsentEntityByClientId(userId, clientId); if (consentEntity == null) { throw new ModelException("Consent not found for client [" + clientId + "] and user [" + userId + "]"); } else { fillEntityFromModel(consent, consentEntity); getMongoStore().updateEntity(consentEntity, invocationContext); } }
@Override public ClientSessionModel createClientSession(RealmModel realm, ClientModel client) { ClientSessionEntity entity = new ClientSessionEntity(); entity.setId(KeycloakModelUtils.generateId()); entity.setTimestamp(Time.currentTime()); entity.setClientId(client.getId()); entity.setRealmId(realm.getId()); em.persist(entity); return new ClientSessionAdapter(session, em, realm, entity); }
@Override public ClientSessionModel createClientSession(RealmModel realm, ClientModel client) { ClientSessionEntity entity = new ClientSessionEntity(); entity.setId(KeycloakModelUtils.generateId()); entity.setTimestamp(Time.currentTime()); entity.setClientId(client.getId()); entity.setRealmId(realm.getId()); clientSessions.put(entity.getId(), entity); return new ClientSessionAdapter(session, this, realm, entity); }
protected long getUserSessionsCount(RealmModel realm, ClientModel client, boolean offline) { Cache<String, SessionEntityWrapper<UserSessionEntity>> cache = getCache(offline); cache = CacheDecorators.skipCacheLoaders(cache); final String clientUuid = client.getId(); return cache.entrySet().stream() .filter(UserSessionPredicate.create(realm.getId()).client(clientUuid)) .count(); }