- Fix issues in legacy store

- Testsuite (switch undertow-embedded.version)
This commit is contained in:
Stefan Guilhen 2023-01-04 17:35:38 -03:00 committed by Václav Muzikář
parent cecd059af2
commit 384d7c17f7
19 changed files with 72 additions and 45 deletions

View file

@ -115,7 +115,7 @@ public class ResourceEntity {
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="resource", fetch = FetchType.LAZY)
@Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
private Collection<ResourceAttributeEntity> attributes;
private Collection<ResourceAttributeEntity> attributes = new LinkedList<>();
public String getId() {
return id;

View file

@ -224,7 +224,7 @@ public class JPAPermissionTicketStore implements PermissionTicketStore {
@Override
public List<PermissionTicket> find(RealmModel realm, ResourceServer resourceServer, Map<PermissionTicket.FilterOption, String> attributes, Integer firstResult, Integer maxResult) {
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<PermissionTicketEntity> querybuilder = builder.createQuery(PermissionTicketEntity.class);
CriteriaQuery<String> querybuilder = builder.createQuery(String.class);
Root<PermissionTicketEntity> root = querybuilder.from(PermissionTicketEntity.class);
querybuilder.select(root.get("id"));

View file

@ -141,7 +141,7 @@ public class JPAPolicyStore implements PolicyStore {
@Override
public List<Policy> find(RealmModel realm, ResourceServer resourceServer, Map<Policy.FilterOption, String[]> attributes, Integer firstResult, Integer maxResults) {
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<PolicyEntity> querybuilder = builder.createQuery(PolicyEntity.class);
CriteriaQuery<String> querybuilder = builder.createQuery(String.class);
Root<PolicyEntity> root = querybuilder.from(PolicyEntity.class);
List<Predicate> predicates = new ArrayList();
querybuilder.select(root.get("id"));

View file

@ -378,7 +378,7 @@ public class JpaRealmProvider implements RealmProvider, ClientProvider, ClientSc
throw new ModelException("Role not found or trying to remove role from incorrect realm");
}
String compositeRoleTable = JpaUtils.getTableNameForNativeQuery("COMPOSITE_ROLE", em);
em.createNativeQuery("delete from " + compositeRoleTable + " where CHILD_ROLE = :role").setParameter("role", roleEntity).executeUpdate();
em.createNativeQuery("delete from " + compositeRoleTable + " where CHILD_ROLE = :role").setParameter("role", roleEntity.getId()).executeUpdate();
em.createNamedQuery("deleteClientScopeRoleMappingByRole").setParameter("role", roleEntity).executeUpdate();
em.flush();

View file

@ -67,7 +67,7 @@ public class AuthenticationFlowEntity {
@OneToMany(fetch = FetchType.LAZY, cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "parentFlow")
Collection<AuthenticationExecutionEntity> executions;
Collection<AuthenticationExecutionEntity> executions = new LinkedList<>();
public String getId() {
return id;
}

View file

@ -107,7 +107,7 @@ public class ClientEntity {
protected Set<String> redirectUris;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "client")
protected Collection<ClientAttributeEntity> attributes;
protected Collection<ClientAttributeEntity> attributes = new LinkedList<>();
@ElementCollection
@MapKeyColumn(name="BINDING_NAME")
@ -116,7 +116,7 @@ public class ClientEntity {
protected Map<String, String> authFlowBindings;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "client")
Collection<ProtocolMapperEntity> protocolMappers;
Collection<ProtocolMapperEntity> protocolMappers = new LinkedList<>();
@Column(name="SURROGATE_AUTH_REQUIRED")
private boolean surrogateAuthRequired;

View file

@ -60,7 +60,7 @@ public class ClientScopeEntity {
@Column(name = "DESCRIPTION")
private String description;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "clientScope")
Collection<ProtocolMapperEntity> protocolMappers;
Collection<ProtocolMapperEntity> protocolMappers = new LinkedList<>();
@Column(name = "REALM_ID")
protected String realmId;
@ -69,7 +69,7 @@ public class ClientScopeEntity {
private String protocol;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "clientScope")
protected Collection<ClientScopeAttributeEntity> attributes;
protected Collection<ClientScopeAttributeEntity> attributes = new LinkedList<>();
@ElementCollection
@Column(name="ROLE_ID")

View file

@ -64,7 +64,7 @@ public class ComponentEntity {
protected String subType;
@OneToMany(fetch = FetchType.LAZY, cascade ={ CascadeType.ALL}, orphanRemoval = true, mappedBy = "component")
Set<ComponentConfigEntity> componentConfigs;
Set<ComponentConfigEntity> componentConfigs = new HashSet<>();
public String getId() {
return id;

View file

@ -68,7 +68,7 @@ public class GroupEntity {
@OneToMany(
cascade = CascadeType.REMOVE,
orphanRemoval = true, mappedBy="group")
protected Collection<GroupAttributeEntity> attributes;
protected Collection<GroupAttributeEntity> attributes = new LinkedList<>();
public String getId() {
return id;

View file

@ -137,16 +137,16 @@ public class RealmEntity {
protected String emailTheme;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm", fetch = FetchType.EAGER)
Collection<RealmAttributeEntity> attributes;
Collection<RealmAttributeEntity> attributes = new LinkedList<>();
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<RequiredCredentialEntity> requiredCredentials;
Collection<RequiredCredentialEntity> requiredCredentials = new LinkedList<>();
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
List<UserFederationProviderEntity> userFederationProviders;
List<UserFederationProviderEntity> userFederationProviders = new LinkedList<>();
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<UserFederationMapperEntity> userFederationMappers;
Collection<UserFederationMapperEntity> userFederationMappers = new LinkedList<>();
@ElementCollection
@MapKeyColumn(name="NAME")
@ -187,22 +187,22 @@ public class RealmEntity {
protected String defaultRoleId;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
protected List<IdentityProviderEntity> identityProviders;
protected List<IdentityProviderEntity> identityProviders = new LinkedList<>();
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<IdentityProviderMapperEntity> identityProviderMappers;
Collection<IdentityProviderMapperEntity> identityProviderMappers = new LinkedList<>();
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<AuthenticatorConfigEntity> authenticators;
Collection<AuthenticatorConfigEntity> authenticators = new LinkedList<>();
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<RequiredActionProviderEntity> requiredActionProviders;
Collection<RequiredActionProviderEntity> requiredActionProviders = new LinkedList<>();
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<AuthenticationFlowEntity> authenticationFlows;
Collection<AuthenticationFlowEntity> authenticationFlows = new LinkedList<>();
@OneToMany(fetch = FetchType.LAZY, cascade ={CascadeType.ALL}, orphanRemoval = true, mappedBy = "realm")
Set<ComponentEntity> components;
Set<ComponentEntity> components = new HashSet<>();
@Column(name="BROWSER_FLOW")
protected String browserFlow;
@ -239,7 +239,7 @@ public class RealmEntity {
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realmId")
@MapKey(name="locale")
Map<String, RealmLocalizationTextsEntity> realmLocalizationTexts;
Map<String, RealmLocalizationTextsEntity> realmLocalizationTexts = new HashMap<>();
public String getId() {
return id;

View file

@ -101,7 +101,7 @@ public class RoleEntity {
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="role")
@Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
protected List<RoleAttributeEntity> attributes;
protected List<RoleAttributeEntity> attributes = new LinkedList<>();
public String getId() {
return id;

View file

@ -73,7 +73,7 @@ public class UserConsentEntity {
protected String externalClientId;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "userConsent")
Collection<UserConsentClientScopeEntity> grantedClientScopes;
Collection<UserConsentClientScopeEntity> grantedClientScopes = new LinkedList<>();
@Column(name = "CREATED_DATE")
private Long createdDate;

View file

@ -94,22 +94,22 @@ public class UserEntity {
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user")
@Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
protected Collection<UserAttributeEntity> attributes;
protected Collection<UserAttributeEntity> attributes = new LinkedList<>();
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user")
@Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
protected Collection<UserRequiredActionEntity> requiredActions;
protected Collection<UserRequiredActionEntity> requiredActions = new LinkedList<>();
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user")
@Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
protected Collection<CredentialEntity> credentials;
protected Collection<CredentialEntity> credentials = new LinkedList<>();
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user")
@Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
protected Collection<FederatedIdentityEntity> federatedIdentities;
protected Collection<FederatedIdentityEntity> federatedIdentities = new LinkedList<>();
@Column(name="FEDERATION_LINK")
protected String federationLink;

View file

@ -15,10 +15,10 @@
~ limitations under the License.
-->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">
<persistence-unit name="keycloak-default" transaction-type="RESOURCE_LOCAL">
<class>org.keycloak.models.jpa.entities.ClientEntity</class>
<class>org.keycloak.models.jpa.entities.ClientAttributeEntity</class>

View file

@ -32,21 +32,9 @@
<groupId>org.infinispan</groupId>
<artifactId>infinispan-client-hotrod-jakarta</artifactId>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-commons-jakarta</artifactId>
<version>${infinispan.version}</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-query-dsl</artifactId>
<version>${infinispan.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>

32
pom.xml
View file

@ -975,11 +975,31 @@
<groupId>org.infinispan</groupId>
<artifactId>infinispan-cachestore-remote</artifactId>
<version>${infinispan.version}</version>
<exclusions>
<exclusion>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-commons</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-jboss-marshalling</artifactId>
<version>${infinispan.version}</version>
<exclusions>
<exclusion>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-commons</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
@ -1021,11 +1041,23 @@
<groupId>org.infinispan</groupId>
<artifactId>infinispan-query-jakarta</artifactId>
<version>${infinispan.version}</version>
<exclusions>
<exclusion>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-commons</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-remote-query-client</artifactId>
<version>${infinispan.version}</version>
<exclusions>
<exclusion>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-commons</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>

View file

@ -54,6 +54,7 @@
<arquillian-tomcat8-container-version>1.1.0.Final</arquillian-tomcat8-container-version>
<arquillian-tomcat9-container-version>1.1.0.Final</arquillian-tomcat9-container-version>
<undertow-embedded.version>1.0.0.Alpha2</undertow-embedded.version>
<!-- <undertow-embedded.version>1.0.0.Final-SNAPSHOT</undertow-embedded.version>-->
<version.org.wildfly.extras.creaper>1.6.1</version.org.wildfly.extras.creaper>
<appium.client.version>6.1.0</appium.client.version>

View file

@ -173,7 +173,7 @@
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-server-hotrod</artifactId>
<artifactId>infinispan-server-hotrod-jakarta</artifactId>
<version>${infinispan.version}</version>
</dependency>

View file

@ -1615,6 +1615,12 @@
</exclusions>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.12.18</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>