diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java b/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java index 8b7712d6c9..7fbc340418 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java @@ -1,6 +1,5 @@ package org.keycloak.models.jpa; -import org.bouncycastle.openssl.PEMWriter; import org.keycloak.models.RoleContainerModel; import org.keycloak.models.jpa.entities.ApplicationEntity; import org.keycloak.models.jpa.entities.CredentialEntity; @@ -15,7 +14,6 @@ import org.keycloak.models.jpa.entities.UserRoleMappingEntity; import org.keycloak.models.jpa.entities.UserScopeMappingEntity; import org.keycloak.models.utils.KeycloakModelUtils; import org.keycloak.models.utils.Pbkdf2PasswordEncoder; -import org.keycloak.util.PemUtils; import org.keycloak.models.ApplicationModel; import org.keycloak.models.OAuthClientModel; import org.keycloak.models.PasswordPolicy; @@ -29,8 +27,7 @@ import org.keycloak.models.utils.TimeBasedOTP; import javax.persistence.EntityManager; import javax.persistence.TypedQuery; -import java.io.IOException; -import java.io.StringWriter; + import java.security.PrivateKey; import java.security.PublicKey; import java.util.ArrayList; @@ -285,7 +282,7 @@ public class RealmAdapter implements RealmModel { @Override public List getRequiredApplicationCredentials() { List requiredCredentialModels = new ArrayList(); - Collection entities = realm.getRequiredApplicationCredentials(); + Collection entities = realm.getRequiredAppCredentials(); if (entities == null) return requiredCredentialModels; for (RequiredCredentialEntity entity : entities) { RequiredCredentialModel model = new RequiredCredentialModel(); @@ -301,7 +298,7 @@ public class RealmAdapter implements RealmModel { @Override public List getRequiredOAuthClientCredentials() { List requiredCredentialModels = new ArrayList(); - Collection entities = realm.getRequiredOAuthClientCredentials(); + Collection entities = realm.getRequiredOAuthClCredentials(); if (entities == null) return requiredCredentialModels; for (RequiredCredentialEntity entity : entities) { RequiredCredentialModel model = new RequiredCredentialModel(); @@ -321,7 +318,7 @@ public class RealmAdapter implements RealmModel { entity.setType(model.getType()); entity.setFormLabel(model.getFormLabel()); em.persist(entity); - realm.getRequiredOAuthClientCredentials().add(entity); + realm.getRequiredOAuthClCredentials().add(entity); em.flush(); } @@ -339,7 +336,7 @@ public class RealmAdapter implements RealmModel { entity.setType(model.getType()); entity.setFormLabel(model.getFormLabel()); em.persist(entity); - realm.getRequiredApplicationCredentials().add(entity); + realm.getRequiredAppCredentials().add(entity); em.flush(); } @@ -352,7 +349,7 @@ public class RealmAdapter implements RealmModel { @Override public void updateRequiredOAuthClientCredentials(Set creds) { - Collection relationships = realm.getRequiredOAuthClientCredentials(); + Collection relationships = realm.getRequiredOAuthClCredentials(); if (relationships == null) relationships = new ArrayList(); Set already = new HashSet(); @@ -378,7 +375,7 @@ public class RealmAdapter implements RealmModel { @Override public void updateRequiredApplicationCredentials(Set creds) { - Collection relationships = realm.getRequiredApplicationCredentials(); + Collection relationships = realm.getRequiredAppCredentials(); if (relationships == null) relationships = new ArrayList(); Set already = new HashSet(); diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ApplicationEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ApplicationEntity.java index 5da99fceff..e44da8b9ff 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ApplicationEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ApplicationEntity.java @@ -37,7 +37,7 @@ public class ApplicationEntity { Collection roles = new ArrayList(); @OneToMany(fetch = FetchType.LAZY, cascade ={CascadeType.REMOVE}, orphanRemoval = true) - @JoinTable(name="APPLICATION_DEFAULT_ROLES") + @JoinTable(name="ApplicationDefaultRoles") Collection defaultRoles = new ArrayList(); public String getId() { diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ApplicationRoleEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ApplicationRoleEntity.java index 61a850c316..71343f7eda 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ApplicationRoleEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ApplicationRoleEntity.java @@ -16,7 +16,7 @@ import javax.persistence.NamedQuery; @Entity public class ApplicationRoleEntity extends RoleEntity { @ManyToOne - @JoinTable(name = "APPLICATION_ROLE") + @JoinTable(name = "ApplicationRole") private ApplicationEntity application; public ApplicationEntity getApplication() { 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 4bfbcffb81..e6967e37b0 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 @@ -38,6 +38,8 @@ public class RealmEntity { protected boolean verifyEmail; protected boolean resetPasswordAllowed; protected boolean social; + + @Column(name="updateProfileOnInitSocLogin") protected boolean updateProfileOnInitialSocialLogin; protected String passwordPolicy; @@ -54,16 +56,16 @@ public class RealmEntity { protected String accountTheme; @OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true) - @JoinTable(name="USER_REQUIRED_CREDENTIALS") + @JoinTable(name="User_RequiredCreds") Collection requiredCredentials = new ArrayList(); @OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true) - @JoinTable(name="APPLICATION_REQUIRED_CREDENTIALS") - Collection requiredApplicationCredentials = new ArrayList(); + @JoinTable(name="App_RequiredCreds") + Collection requiredAppCredentials = new ArrayList(); @OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true) - @JoinTable(name="OAUTH_CLIENT_REQUIRED_CREDENTIALS") - Collection requiredOAuthClientCredentials = new ArrayList(); + @JoinTable(name="OAuthClient_RequiredCreds") + Collection requiredOAuthClCredentials = new ArrayList(); @OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true) Collection applications = new ArrayList(); @@ -84,7 +86,7 @@ public class RealmEntity { protected Map socialConfig = new HashMap(); @OneToMany(fetch = FetchType.LAZY, cascade ={CascadeType.REMOVE}, orphanRemoval = true) - @JoinTable(name="REALM_DEFAULT_ROLES") + @JoinTable(name="RealmDefaultRoles") Collection defaultRoles = new ArrayList(); public String getId() { @@ -207,20 +209,20 @@ public class RealmEntity { this.requiredCredentials = requiredCredentials; } - public Collection getRequiredApplicationCredentials() { - return requiredApplicationCredentials; + public Collection getRequiredAppCredentials() { + return requiredAppCredentials; } - public void setRequiredApplicationCredentials(Collection requiredApplicationCredentials) { - this.requiredApplicationCredentials = requiredApplicationCredentials; + public void setRequiredAppCredentials(Collection requiredAppCredentials) { + this.requiredAppCredentials = requiredAppCredentials; } - public Collection getRequiredOAuthClientCredentials() { - return requiredOAuthClientCredentials; + public Collection getRequiredOAuthClCredentials() { + return requiredOAuthClCredentials; } - public void setRequiredOAuthClientCredentials(Collection requiredOAuthClientCredentials) { - this.requiredOAuthClientCredentials = requiredOAuthClientCredentials; + public void setRequiredOAuthClCredentials(Collection requiredOAuthClCredentials) { + this.requiredOAuthClCredentials = requiredOAuthClCredentials; } public Collection getApplications() { 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 acb40c9d23..7e43ceab15 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 @@ -6,9 +6,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; -import javax.persistence.JoinTable; import javax.persistence.ManyToMany; -import javax.persistence.OneToMany; import java.util.ArrayList; import java.util.Collection; diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/SocialLinkEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/SocialLinkEntity.java index 9063948673..ab85191d33 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/SocialLinkEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/SocialLinkEntity.java @@ -2,14 +2,12 @@ package org.keycloak.models.jpa.entities; import javax.persistence.Entity; import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import org.hibernate.annotations.GenericGenerator; -import org.keycloak.models.jpa.utils.JpaIdGenerator; /** * @author Bill Burke @@ -27,8 +25,6 @@ public class SocialLinkEntity { @GeneratedValue(generator = "keycloak_generator") private String id; - private String str = JpaIdGenerator.class.getName(); - @ManyToOne private UserEntity user; 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 04af485bf8..58a92925a4 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 @@ -9,7 +9,6 @@ import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.MapKeyColumn; 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 6a9aec78bf..b5a7a2e41f 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 @@ -1,11 +1,6 @@ package org.keycloak.models.jpa.entities; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.ManyToOne; -import javax.persistence.MappedSuperclass; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery;