diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/UserAdapter.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/UserAdapter.java index 5d154a6a52..b8945bd55d 100755 --- a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/UserAdapter.java +++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/UserAdapter.java @@ -404,4 +404,21 @@ public class UserAdapter implements UserModel { return updated.revokeConsentForClient(clientId); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || !(o instanceof UserModel)) return false; + + UserModel that = (UserModel) o; + return that.getId().equals(getId()); + } + + @Override + public int hashCode() { + return getId().hashCode(); + } + + + + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationExecutionEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationExecutionEntity.java index 988cce1ec6..71ecd94afe 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationExecutionEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationExecutionEntity.java @@ -142,4 +142,23 @@ public class AuthenticationExecutionEntity { public void setAuthenticatorConfig(String authenticatorConfig) { this.authenticatorConfig = authenticatorConfig; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof AuthenticationExecutionEntity)) return false; + + AuthenticationExecutionEntity that = (AuthenticationExecutionEntity) o; + + if (!id.equals(that.getId())) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationFlowEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationFlowEntity.java index 67a4b92ab2..886dd4328c 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationFlowEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationFlowEntity.java @@ -131,4 +131,23 @@ public class AuthenticationFlowEntity { public void setBuiltIn(boolean builtIn) { this.builtIn = builtIn; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof AuthenticationFlowEntity)) return false; + + AuthenticationFlowEntity that = (AuthenticationFlowEntity) o; + + if (!id.equals(that.getId())) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticatorConfigEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticatorConfigEntity.java index f09c489afc..a35c03e4f9 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticatorConfigEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticatorConfigEntity.java @@ -86,4 +86,23 @@ public class AuthenticatorConfigEntity { public void setConfig(Map config) { this.config = config; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof AuthenticatorConfigEntity)) return false; + + AuthenticatorConfigEntity that = (AuthenticatorConfigEntity) o; + + if (!id.equals(that.getId())) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientEntity.java index 6ae08fe2b2..848401a688 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientEntity.java @@ -454,4 +454,23 @@ public class ClientEntity { public void setUseTemplateMappers(boolean useTemplateMappers) { this.useTemplateMappers = useTemplateMappers; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof ClientEntity)) return false; + + ClientEntity that = (ClientEntity) o; + + if (!id.equals(that.getId())) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientIdentityProviderMappingEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientIdentityProviderMappingEntity.java index 369819d21a..de625d7d2a 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientIdentityProviderMappingEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientIdentityProviderMappingEntity.java @@ -118,7 +118,8 @@ public class ClientIdentityProviderMappingEntity { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (o == null) return false; + if (!(o instanceof ClientIdentityProviderMappingEntity)) return false; ClientIdentityProviderMappingEntity key = (ClientIdentityProviderMappingEntity) o; @@ -135,4 +136,6 @@ public class ClientIdentityProviderMappingEntity { result = 31 * result + (identityProvider != null ? identityProvider.hashCode() : 0); return result; } + + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientTemplateEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientTemplateEntity.java index eb987ee2bf..1f27816529 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientTemplateEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientTemplateEntity.java @@ -221,4 +221,23 @@ public class ClientTemplateEntity { public void setBearerOnly(boolean bearerOnly) { this.bearerOnly = bearerOnly; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof ClientTemplateEntity)) return false; + + ClientTemplateEntity that = (ClientTemplateEntity) o; + + if (!id.equals(that.getId())) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/CredentialEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/CredentialEntity.java index ce3d21c164..4e54c51d87 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/CredentialEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/CredentialEntity.java @@ -167,4 +167,23 @@ public class CredentialEntity { public void setPeriod(int period) { this.period = period; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof CredentialEntity)) return false; + + CredentialEntity that = (CredentialEntity) o; + + if (!id.equals(that.getId())) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/FederatedIdentityEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/FederatedIdentityEntity.java index e7e96dadba..4bafe7cae8 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/FederatedIdentityEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/FederatedIdentityEntity.java @@ -157,4 +157,27 @@ public class FederatedIdentityEntity { } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof FederatedIdentityEntity)) return false; + + FederatedIdentityEntity key = (FederatedIdentityEntity) o; + + if (identityProvider != null ? !identityProvider.equals(key.identityProvider) : key.identityProvider != null) + return false; + if (user != null ? !user.getId().equals(key.user != null ? key.user.getId() : null) : key.user != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = user != null ? user.getId().hashCode() : 0; + result = 31 * result + (identityProvider != null ? identityProvider.hashCode() : 0); + return result; + } + + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/GroupAttributeEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/GroupAttributeEntity.java index 1867f1d94c..b784d8222b 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/GroupAttributeEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/GroupAttributeEntity.java @@ -84,4 +84,23 @@ public class GroupAttributeEntity { public void setGroup(GroupEntity group) { this.group = group; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof GroupAttributeEntity)) return false; + + GroupAttributeEntity that = (GroupAttributeEntity) o; + + if (!id.equals(that.getId())) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/GroupEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/GroupEntity.java index 7cf856ec3f..420929abc6 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/GroupEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/GroupEntity.java @@ -107,6 +107,7 @@ public class GroupEntity { public boolean equals(Object o) { if (this == o) return true; if (o == null) return false; + if (!(o instanceof GroupEntity)) return false; GroupEntity that = (GroupEntity) o; diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/GroupRoleMappingEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/GroupRoleMappingEntity.java index f67a270d23..796d29db8a 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/GroupRoleMappingEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/GroupRoleMappingEntity.java @@ -114,4 +114,26 @@ public class GroupRoleMappingEntity { return result; } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof GroupRoleMappingEntity)) return false; + + GroupRoleMappingEntity key = (GroupRoleMappingEntity) o; + + if (!roleId.equals(key.roleId)) return false; + if (!group.equals(key.group)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = group.hashCode(); + result = 31 * result + roleId.hashCode(); + return result; + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/IdentityProviderEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/IdentityProviderEntity.java index 2ff318d537..607466349e 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/IdentityProviderEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/IdentityProviderEntity.java @@ -178,4 +178,23 @@ public class IdentityProviderEntity { public void setTrustEmail(boolean trustEmail) { this.trustEmail = trustEmail; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof IdentityProviderEntity)) return false; + + IdentityProviderEntity that = (IdentityProviderEntity) o; + + if (!internalId.equals(that.internalId)) return false; + + return true; + } + + @Override + public int hashCode() { + return internalId.hashCode(); + } + } \ No newline at end of file diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/IdentityProviderMapperEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/IdentityProviderMapperEntity.java index abbfe33540..a7afa8d50f 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/IdentityProviderMapperEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/IdentityProviderMapperEntity.java @@ -110,7 +110,8 @@ public class IdentityProviderMapperEntity { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (o == null) return false; + if (!(o instanceof IdentityProviderMapperEntity)) return false; IdentityProviderMapperEntity that = (IdentityProviderMapperEntity) o; diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/MigrationModelEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/MigrationModelEntity.java index a6bb6e853a..148d00950f 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/MigrationModelEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/MigrationModelEntity.java @@ -57,4 +57,23 @@ public class MigrationModelEntity { public void setVersion(String version) { this.version = version; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof MigrationModelEntity)) return false; + + MigrationModelEntity that = (MigrationModelEntity) o; + + if (!id.equals(that.id)) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ProtocolMapperEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ProtocolMapperEntity.java index eb111cf804..bb51ad963d 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ProtocolMapperEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ProtocolMapperEntity.java @@ -142,7 +142,8 @@ public class ProtocolMapperEntity { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (o == null) return false; + if (!(o instanceof ProtocolMapperEntity)) return false; ProtocolMapperEntity that = (ProtocolMapperEntity) o; diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmAttributeEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmAttributeEntity.java index f515e5be88..0e02f23da4 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmAttributeEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmAttributeEntity.java @@ -119,4 +119,26 @@ public class RealmAttributeEntity { } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof RealmAttributeEntity)) return false; + + RealmAttributeEntity key = (RealmAttributeEntity) o; + + if (name != null ? !name.equals(key.name) : key.name != null) return false; + if (realm != null ? !realm.getId().equals(key.realm != null ? key.realm.getId() : null) : key.realm != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = realm != null ? realm.getId().hashCode() : 0; + result = 31 * result + (name != null ? name.hashCode() : 0); + return result; + } + + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java index d55f6481a0..da639d470d 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java @@ -769,5 +769,24 @@ public class RealmEntity { public void setClientTemplates(Collection clientTemplates) { this.clientTemplates = clientTemplates; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof RealmEntity)) return false; + + RealmEntity that = (RealmEntity) o; + + if (!id.equals(that.getId())) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RequiredActionProviderEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RequiredActionProviderEntity.java index 21f467bc65..95d3373ddb 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RequiredActionProviderEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RequiredActionProviderEntity.java @@ -132,4 +132,23 @@ public class RequiredActionProviderEntity { public void setName(String name) { this.name = name; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof RequiredActionProviderEntity)) return false; + + RequiredActionProviderEntity that = (RequiredActionProviderEntity) o; + + if (!id.equals(that.getId())) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RequiredCredentialEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RequiredCredentialEntity.java index 714345bd6e..6a692f8816 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RequiredCredentialEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RequiredCredentialEntity.java @@ -134,4 +134,26 @@ public class RequiredCredentialEntity { } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof RequiredCredentialEntity)) return false; + + RequiredCredentialEntity key = (RequiredCredentialEntity) o; + + if (realm != null ? !realm.getId().equals(key.realm != null ? key.realm.getId() : null) : key.realm != null) return false; + if (type != null ? !type.equals(key.type) : key.type != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = realm != null ? realm.getId().hashCode() : 0; + result = 31 * result + (type != null ? type.hashCode() : 0); + return result; + } + + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java index a51bd7190b..1b96caef93 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java @@ -167,6 +167,7 @@ public class RoleEntity { @Override public boolean equals(Object o) { if (this == o) return true; + if (o == null) return false; if (!(o instanceof RoleEntity)) return false; RoleEntity that = (RoleEntity) o; diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ScopeMappingEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ScopeMappingEntity.java index 3488dd70c2..21e7bc7c39 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ScopeMappingEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ScopeMappingEntity.java @@ -113,4 +113,26 @@ public class ScopeMappingEntity { } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof ScopeMappingEntity)) return false; + + ScopeMappingEntity key = (ScopeMappingEntity) o; + + if (client != null ? !client.getId().equals(key.client != null ? key.client.getId() : null) : key.client != null) return false; + if (role != null ? !role.getId().equals(key.role != null ? key.role.getId() : null) : key.role != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = client != null ? client.getId().hashCode() : 0; + result = 31 * result + (role != null ? role.getId().hashCode() : 0); + return result; + } + + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/TemplateScopeMappingEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/TemplateScopeMappingEntity.java index 48d0c53936..0fea76e26a 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/TemplateScopeMappingEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/TemplateScopeMappingEntity.java @@ -113,4 +113,26 @@ public class TemplateScopeMappingEntity { } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!(o instanceof TemplateScopeMappingEntity)) return false; + + TemplateScopeMappingEntity key = (TemplateScopeMappingEntity) o; + + if (template != null ? !template.getId().equals(key.template != null ? key.template.getId() : null) : key.template != null) return false; + if (role != null ? !role.getId().equals(key.role != null ? key.role.getId() : null) : key.role != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = template != null ? template.getId().hashCode() : 0; + result = 31 * result + (role != null ? role.getId().hashCode() : 0); + return result; + } + + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserAttributeEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserAttributeEntity.java index a6d27730cd..e09c1bb64b 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserAttributeEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserAttributeEntity.java @@ -91,4 +91,23 @@ public class UserAttributeEntity { this.user = user; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof UserAttributeEntity)) return false; + + UserAttributeEntity that = (UserAttributeEntity) o; + + if (!id.equals(that.getId())) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserConsentEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserConsentEntity.java old mode 100644 new mode 100755 index be223feae1..a349d801a8 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserConsentEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserConsentEntity.java @@ -105,4 +105,23 @@ public class UserConsentEntity { public void setGrantedProtocolMappers(Collection grantedProtocolMappers) { this.grantedProtocolMappers = grantedProtocolMappers; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof UserConsentEntity)) return false; + + UserConsentEntity that = (UserConsentEntity) o; + + if (!id.equals(that.getId())) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserConsentProtocolMapperEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserConsentProtocolMapperEntity.java old mode 100644 new mode 100755 index aaf9e2f11a..151340cbe7 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserConsentProtocolMapperEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserConsentProtocolMapperEntity.java @@ -73,7 +73,8 @@ public class UserConsentProtocolMapperEntity { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (o == null) return false; + if (!(o instanceof UserConsentProtocolMapperEntity)) return false; UserConsentProtocolMapperEntity that = (UserConsentProtocolMapperEntity)o; Key myKey = new Key(this.userConsent, this.protocolMapperId); @@ -129,4 +130,6 @@ public class UserConsentProtocolMapperEntity { return result; } } + + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserConsentRoleEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserConsentRoleEntity.java old mode 100644 new mode 100755 index 041b5a7042..08cc2b240c --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserConsentRoleEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserConsentRoleEntity.java @@ -72,7 +72,8 @@ public class UserConsentRoleEntity { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (o == null) return false; + if (!(o instanceof UserConsentRoleEntity)) return false; UserConsentRoleEntity that = (UserConsentRoleEntity)o; Key myKey = new Key(this.userConsent, this.roleId); diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserEntity.java index 207ff67c39..b1c8c046ab 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserEntity.java @@ -232,7 +232,8 @@ public class UserEntity { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (o == null) return false; + if (!(o instanceof UserEntity)) return false; UserEntity that = (UserEntity) o; diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserFederationMapperEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserFederationMapperEntity.java old mode 100644 new mode 100755 index 5aebea5ce4..54989f2d6f --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserFederationMapperEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserFederationMapperEntity.java @@ -114,7 +114,8 @@ public class UserFederationMapperEntity { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (o == null ) return false; + if (!(o instanceof UserFederationMapperEntity)) return false; UserFederationMapperEntity that = (UserFederationMapperEntity) o; diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserFederationProviderEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserFederationProviderEntity.java index bfb28a7e4b..7b841ca364 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserFederationProviderEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserFederationProviderEntity.java @@ -137,4 +137,23 @@ public class UserFederationProviderEntity { public void setLastSync(int lastSync) { this.lastSync = lastSync; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof UserFederationProviderEntity)) return false; + + UserFederationProviderEntity that = (UserFederationProviderEntity) o; + + if (!id.equals(that.getId())) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserGroupMembershipEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserGroupMembershipEntity.java index 01115bd159..9be73a9029 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserGroupMembershipEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserGroupMembershipEntity.java @@ -116,4 +116,26 @@ public class UserGroupMembershipEntity { return result; } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof UserGroupMembershipEntity)) return false; + + UserGroupMembershipEntity key = (UserGroupMembershipEntity) o; + + if (!groupId.equals(key.groupId)) return false; + if (!user.equals(key.user)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = user.hashCode(); + result = 31 * result + groupId.hashCode(); + return result; + } + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserRequiredActionEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserRequiredActionEntity.java index 2c746fcaf4..4938be02e1 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserRequiredActionEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserRequiredActionEntity.java @@ -110,4 +110,26 @@ public class UserRequiredActionEntity { } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof UserRequiredActionEntity)) return false; + + UserRequiredActionEntity key = (UserRequiredActionEntity) o; + + if (action != key.action) return false; + if (user != null ? !user.getId().equals(key.user != null ? key.user.getId() : null) : key.user != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = user != null ? user.getId().hashCode() : 0; + result = 31 * result + (action != null ? action.hashCode() : 0); + return result; + } + + } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserRoleMappingEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserRoleMappingEntity.java index ddf8dd158c..7f5db60110 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserRoleMappingEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserRoleMappingEntity.java @@ -117,4 +117,26 @@ public class UserRoleMappingEntity { return result; } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof UserRoleMappingEntity)) return false; + + UserRoleMappingEntity key = (UserRoleMappingEntity) o; + + if (!roleId.equals(key.roleId)) return false; + if (!user.equals(key.user)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = user.hashCode(); + result = 31 * result + roleId.hashCode(); + return result; + } + } diff --git a/server-spi/src/main/java/org/keycloak/models/entities/AbstractIdentifiableEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/AbstractIdentifiableEntity.java old mode 100644 new mode 100755 index badc2da1e9..3040a952f7 --- a/server-spi/src/main/java/org/keycloak/models/entities/AbstractIdentifiableEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/AbstractIdentifiableEntity.java @@ -24,7 +24,7 @@ package org.keycloak.models.entities; */ public class AbstractIdentifiableEntity { - private String id; + protected String id; public String getId() { return id; diff --git a/server-spi/src/main/java/org/keycloak/models/entities/AuthenticationExecutionEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/AuthenticationExecutionEntity.java index 63e878b7cb..fcbc5ae842 100755 --- a/server-spi/src/main/java/org/keycloak/models/entities/AuthenticationExecutionEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/AuthenticationExecutionEntity.java @@ -24,24 +24,15 @@ import org.keycloak.models.AuthenticationExecutionModel; * @author Bill Burke * @version $Revision: 1 $ */ -public class AuthenticationExecutionEntity { - protected String id; +public class AuthenticationExecutionEntity extends AbstractIdentifiableEntity { protected String authenticator; - private String authenticatorConfig; + protected String authenticatorConfig; protected String flowId; protected AuthenticationExecutionModel.Requirement requirement; protected int priority; - private boolean userSetupAllowed; - private boolean authenticatorFlow; - private String parentFlow; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } + protected boolean userSetupAllowed; + protected boolean authenticatorFlow; + protected String parentFlow; public String getAuthenticator() { return authenticator; diff --git a/server-spi/src/main/java/org/keycloak/models/entities/AuthenticationFlowEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/AuthenticationFlowEntity.java index 6b3fe6b3ce..1eb84286b6 100755 --- a/server-spi/src/main/java/org/keycloak/models/entities/AuthenticationFlowEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/AuthenticationFlowEntity.java @@ -24,23 +24,14 @@ import java.util.List; * @author Bill Burke * @version $Revision: 1 $ */ -public class AuthenticationFlowEntity { - protected String id; +public class AuthenticationFlowEntity extends AbstractIdentifiableEntity { protected String alias; protected String description; protected String providerId; - private boolean topLevel; - private boolean builtIn; + protected boolean topLevel; + protected boolean builtIn; List executions = new ArrayList(); - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - public String getAlias() { return alias; } diff --git a/server-spi/src/main/java/org/keycloak/models/entities/AuthenticatorConfigEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/AuthenticatorConfigEntity.java index ca8dcb10aa..7211c9e199 100755 --- a/server-spi/src/main/java/org/keycloak/models/entities/AuthenticatorConfigEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/AuthenticatorConfigEntity.java @@ -23,18 +23,9 @@ import java.util.Map; * @author Bill Burke * @version $Revision: 1 $ */ -public class AuthenticatorConfigEntity { - protected String id; +public class AuthenticatorConfigEntity extends AbstractIdentifiableEntity{ protected String alias; - private Map config; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } + protected Map config; public String getAlias() { return alias; diff --git a/server-spi/src/main/java/org/keycloak/models/entities/ClientEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/ClientEntity.java index 16e9e8135d..75496dc8de 100755 --- a/server-spi/src/main/java/org/keycloak/models/entities/ClientEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/ClientEntity.java @@ -27,48 +27,48 @@ import java.util.Map; */ public class ClientEntity extends AbstractIdentifiableEntity { - private String clientId; - private String name; - private String description; - private String realmId; - private boolean enabled; - private String clientAuthenticatorType; - private String secret; - private String registrationToken; - private String protocol; - private int notBefore; - private boolean publicClient; - private boolean fullScopeAllowed; - private boolean frontchannelLogout; + protected String clientId; + protected String name; + protected String description; + protected String realmId; + protected boolean enabled; + protected String clientAuthenticatorType; + protected String secret; + protected String registrationToken; + protected String protocol; + protected int notBefore; + protected boolean publicClient; + protected boolean fullScopeAllowed; + protected boolean frontchannelLogout; - private boolean surrogateAuthRequired; - private String managementUrl; - private String rootUrl; - private String baseUrl; - private boolean bearerOnly; - private boolean consentRequired; - private boolean standardFlowEnabled; - private boolean implicitFlowEnabled; - private boolean directAccessGrantsEnabled; - private boolean serviceAccountsEnabled; - private int nodeReRegistrationTimeout; + protected boolean surrogateAuthRequired; + protected String managementUrl; + protected String rootUrl; + protected String baseUrl; + protected boolean bearerOnly; + protected boolean consentRequired; + protected boolean standardFlowEnabled; + protected boolean implicitFlowEnabled; + protected boolean directAccessGrantsEnabled; + protected boolean serviceAccountsEnabled; + protected int nodeReRegistrationTimeout; // We are using names of defaultRoles (not ids) - private List defaultRoles = new ArrayList(); + protected List defaultRoles = new ArrayList(); - private Map registeredNodes; + protected Map registeredNodes; - private Map attributes = new HashMap(); + protected Map attributes = new HashMap(); - private List webOrigins = new ArrayList(); - private List redirectUris = new ArrayList(); - private List scopeIds = new ArrayList(); - private List identityProviders = new ArrayList(); - private List protocolMappers = new ArrayList(); - private String clientTemplate; - private boolean useTemplateConfig; - private boolean useTemplateScope; - private boolean useTemplateMappers; + protected List webOrigins = new ArrayList(); + protected List redirectUris = new ArrayList(); + protected List scopeIds = new ArrayList(); + protected List identityProviders = new ArrayList(); + protected List protocolMappers = new ArrayList(); + protected String clientTemplate; + protected boolean useTemplateConfig; + protected boolean useTemplateScope; + protected boolean useTemplateMappers; public String getClientId() { return clientId; diff --git a/server-spi/src/main/java/org/keycloak/models/entities/ClientIdentityProviderMappingEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/ClientIdentityProviderMappingEntity.java index 16a90e07b9..70f0ea65d6 100755 --- a/server-spi/src/main/java/org/keycloak/models/entities/ClientIdentityProviderMappingEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/ClientIdentityProviderMappingEntity.java @@ -19,18 +19,9 @@ package org.keycloak.models.entities; /** * @author pedroigor */ -public class ClientIdentityProviderMappingEntity { +public class ClientIdentityProviderMappingEntity extends AbstractIdentifiableEntity { - private String id; - private boolean retrieveToken; - - public String getId() { - return this.id; - } - - public void setId(String id) { - this.id = id; - } + protected boolean retrieveToken; public boolean isRetrieveToken() { return this.retrieveToken; diff --git a/server-spi/src/main/java/org/keycloak/models/entities/ClientTemplateEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/ClientTemplateEntity.java index 4cb9cc05e8..b70345ecb9 100755 --- a/server-spi/src/main/java/org/keycloak/models/entities/ClientTemplateEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/ClientTemplateEntity.java @@ -27,22 +27,22 @@ import java.util.Map; */ public class ClientTemplateEntity extends AbstractIdentifiableEntity { - private String name; - private String description; - private String realmId; - private String protocol; - private boolean fullScopeAllowed; - private boolean bearerOnly; - private boolean consentRequired; - private boolean standardFlowEnabled; - private boolean implicitFlowEnabled; - private boolean directAccessGrantsEnabled; - private boolean serviceAccountsEnabled; - private boolean publicClient; - private boolean frontchannelLogout; - private List scopeIds = new ArrayList<>(); - private List protocolMappers = new ArrayList<>(); - private Map attributes = new HashMap<>(); + protected String name; + protected String description; + protected String realmId; + protected String protocol; + protected boolean fullScopeAllowed; + protected boolean bearerOnly; + protected boolean consentRequired; + protected boolean standardFlowEnabled; + protected boolean implicitFlowEnabled; + protected boolean directAccessGrantsEnabled; + protected boolean serviceAccountsEnabled; + protected boolean publicClient; + protected boolean frontchannelLogout; + protected List scopeIds = new ArrayList<>(); + protected List protocolMappers = new ArrayList<>(); + protected Map attributes = new HashMap<>(); public String getName() { return name; diff --git a/server-spi/src/main/java/org/keycloak/models/entities/CredentialEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/CredentialEntity.java index 4b279a2a81..ef1932e2e0 100755 --- a/server-spi/src/main/java/org/keycloak/models/entities/CredentialEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/CredentialEntity.java @@ -20,30 +20,21 @@ package org.keycloak.models.entities; /** * @author Marek Posolda */ -public class CredentialEntity { +public class CredentialEntity extends AbstractIdentifiableEntity { - private String id; - private String type; - private String value; - private String device; - private byte[] salt; - private int hashIterations; - private Long createdDate; - private UserEntity user; - private int counter; - private String algorithm; - private int digits; - private int period; + protected String type; + protected String value; + protected String device; + protected byte[] salt; + protected int hashIterations; + protected Long createdDate; + protected UserEntity user; + protected int counter; + protected String algorithm; + protected int digits; + protected int period; - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - public String getType() { return type; } diff --git a/server-spi/src/main/java/org/keycloak/models/entities/IdentityProviderEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/IdentityProviderEntity.java index eb98e483af..e23198e696 100755 --- a/server-spi/src/main/java/org/keycloak/models/entities/IdentityProviderEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/IdentityProviderEntity.java @@ -133,4 +133,21 @@ public class IdentityProviderEntity { public void setTrustEmail(boolean trustEmail) { this.trustEmail = trustEmail; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof IdentityProviderEntity)) return false; + + IdentityProviderEntity that = (IdentityProviderEntity) o; + + if (!internalId.equals(that.internalId)) return false; + + return true; + } + + @Override + public int hashCode() { + return internalId.hashCode(); + } } diff --git a/server-spi/src/main/java/org/keycloak/models/entities/IdentityProviderMapperEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/IdentityProviderMapperEntity.java index 4f38fe6acc..64c300634e 100755 --- a/server-spi/src/main/java/org/keycloak/models/entities/IdentityProviderMapperEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/IdentityProviderMapperEntity.java @@ -23,21 +23,12 @@ import java.util.Map; * @author Bill Burke * @version $Revision: 1 $ */ -public class IdentityProviderMapperEntity { - protected String id; +public class IdentityProviderMapperEntity extends AbstractIdentifiableEntity { protected String name; protected String identityProviderAlias; protected String identityProviderMapper; protected Map config; - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - public String getName() { return name; } diff --git a/server-spi/src/main/java/org/keycloak/models/entities/PersistentUserSessionEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/PersistentUserSessionEntity.java old mode 100644 new mode 100755 index c54fa47286..53f7e1a846 --- a/server-spi/src/main/java/org/keycloak/models/entities/PersistentUserSessionEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/PersistentUserSessionEntity.java @@ -22,23 +22,14 @@ import java.util.List; /** * @author Marek Posolda */ -public class PersistentUserSessionEntity { +public class PersistentUserSessionEntity extends AbstractIdentifiableEntity { - private String id; private String realmId; private String userId; private int lastSessionRefresh; private String data; private List clientSessions; - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - public String getRealmId() { return realmId; } diff --git a/server-spi/src/main/java/org/keycloak/models/entities/ProtocolMapperEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/ProtocolMapperEntity.java index 07533a0d27..0661d5abc3 100755 --- a/server-spi/src/main/java/org/keycloak/models/entities/ProtocolMapperEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/ProtocolMapperEntity.java @@ -23,8 +23,7 @@ import java.util.Map; * @author Bill Burke * @version $Revision: 1 $ */ -public class ProtocolMapperEntity { - protected String id; +public class ProtocolMapperEntity extends AbstractIdentifiableEntity { protected String name; protected String protocol; protected String protocolMapper; @@ -32,14 +31,6 @@ public class ProtocolMapperEntity { protected String consentText; protected Map config; - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - public String getName() { return name; } diff --git a/server-spi/src/main/java/org/keycloak/models/entities/RequiredActionProviderEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/RequiredActionProviderEntity.java index cae314c4b7..eef6b36c64 100755 --- a/server-spi/src/main/java/org/keycloak/models/entities/RequiredActionProviderEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/RequiredActionProviderEntity.java @@ -23,8 +23,7 @@ import java.util.Map; * @author Bill Burke * @version $Revision: 1 $ */ -public class RequiredActionProviderEntity { - protected String id; +public class RequiredActionProviderEntity extends AbstractIdentifiableEntity { protected String alias; protected String name; protected String providerId; @@ -32,14 +31,6 @@ public class RequiredActionProviderEntity { protected boolean defaultAction; private Map config; - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - public String getAlias() { return alias; } diff --git a/server-spi/src/main/java/org/keycloak/models/entities/UserFederationMapperEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/UserFederationMapperEntity.java old mode 100644 new mode 100755 index 4ce5ad5999..cc5775ed3d --- a/server-spi/src/main/java/org/keycloak/models/entities/UserFederationMapperEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/UserFederationMapperEntity.java @@ -22,22 +22,13 @@ import java.util.Map; /** * @author Marek Posolda */ -public class UserFederationMapperEntity { +public class UserFederationMapperEntity extends AbstractIdentifiableEntity { - protected String id; protected String name; protected String federationProviderId; protected String federationMapperType; protected Map config; - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - public String getName() { return name; } diff --git a/server-spi/src/main/java/org/keycloak/models/entities/UserFederationProviderEntity.java b/server-spi/src/main/java/org/keycloak/models/entities/UserFederationProviderEntity.java index 99843a3002..dfa2636646 100755 --- a/server-spi/src/main/java/org/keycloak/models/entities/UserFederationProviderEntity.java +++ b/server-spi/src/main/java/org/keycloak/models/entities/UserFederationProviderEntity.java @@ -23,8 +23,7 @@ import java.util.Map; * @author Bill Burke * @version $Revision: 1 $ */ -public class UserFederationProviderEntity { - protected String id; +public class UserFederationProviderEntity extends AbstractIdentifiableEntity { protected String providerName; protected Map config; protected int priority; @@ -34,14 +33,6 @@ public class UserFederationProviderEntity { private int lastSync; - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - public String getProviderName() { return providerName; }