${rb.firstName}
diff --git a/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/model/RealmBean.java b/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/model/RealmBean.java
index f751cf9351..499474db11 100755
--- a/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/model/RealmBean.java
+++ b/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/model/RealmBean.java
@@ -30,39 +30,43 @@ import org.keycloak.representations.idm.CredentialRepresentation;
*/
public class RealmBean {
- private RealmModel realm;
+ private RealmModel realm;
- public RealmBean(RealmModel realmModel) {
- realm = realmModel;
- }
+ public RealmBean(RealmModel realmModel) {
+ realm = realmModel;
+ }
- public String getName() {
- return realm.getName();
- }
+ public String getName() {
+ return realm.getName();
+ }
- public boolean isIdentityFederationEnabled() {
- return realm.isIdentityFederationEnabled();
- }
+ public boolean isIdentityFederationEnabled() {
+ return realm.isIdentityFederationEnabled();
+ }
- public boolean isRegistrationAllowed() {
- return realm.isRegistrationAllowed();
- }
+ public boolean isRegistrationAllowed() {
+ return realm.isRegistrationAllowed();
+ }
- public boolean isResetPasswordAllowed() {
- return realm.isResetPasswordAllowed();
- }
+ public boolean isRegistrationEmailAsUsername() {
+ return realm.isRegistrationEmailAsUsername();
+ }
- public boolean isRememberMe() {
- return realm.isRememberMe();
- }
+ public boolean isResetPasswordAllowed() {
+ return realm.isResetPasswordAllowed();
+ }
- public boolean isPassword() {
- for (RequiredCredentialModel r : realm.getRequiredCredentials()) {
- if (r.getType().equals(CredentialRepresentation.PASSWORD)) {
- return true;
- }
- }
- return false;
- }
+ public boolean isRememberMe() {
+ return realm.isRememberMe();
+ }
+
+ public boolean isPassword() {
+ for (RequiredCredentialModel r : realm.getRequiredCredentials()) {
+ if (r.getType().equals(CredentialRepresentation.PASSWORD)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/model/api/src/main/java/org/keycloak/models/RealmModel.java b/model/api/src/main/java/org/keycloak/models/RealmModel.java
index 4212e3babf..b1781bd706 100755
--- a/model/api/src/main/java/org/keycloak/models/RealmModel.java
+++ b/model/api/src/main/java/org/keycloak/models/RealmModel.java
@@ -1,8 +1,5 @@
package org.keycloak.models;
-import org.keycloak.enums.SslRequired;
-import org.keycloak.provider.ProviderEvent;
-
import java.security.Key;
import java.security.PrivateKey;
import java.security.PublicKey;
@@ -11,233 +8,272 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.keycloak.enums.SslRequired;
+import org.keycloak.provider.ProviderEvent;
+
/**
* @author
Bill Burke
* @version $Revision: 1 $
*/
public interface RealmModel extends RoleContainerModel {
- interface RealmCreationEvent extends ProviderEvent {
- RealmModel getCreatedRealm();
- }
- interface ClientCreationEvent extends ProviderEvent {
- ClientModel getCreatedClient();
- }
- interface ApplicationCreationEvent extends ClientCreationEvent {
- ApplicationModel getCreatedApplication();
- }
- interface OAuthClientCreationEvent extends ClientCreationEvent {
- OAuthClientModel getCreatedOAuthClient();
- }
+ interface RealmCreationEvent extends ProviderEvent {
+ RealmModel getCreatedRealm();
+ }
- String getId();
+ interface ClientCreationEvent extends ProviderEvent {
+ ClientModel getCreatedClient();
+ }
- String getName();
+ interface ApplicationCreationEvent extends ClientCreationEvent {
+ ApplicationModel getCreatedApplication();
+ }
- void setName(String name);
+ interface OAuthClientCreationEvent extends ClientCreationEvent {
+ OAuthClientModel getCreatedOAuthClient();
+ }
- boolean isEnabled();
+ String getId();
- void setEnabled(boolean enabled);
+ String getName();
- SslRequired getSslRequired();
+ void setName(String name);
- void setSslRequired(SslRequired sslRequired);
+ boolean isEnabled();
- boolean isRegistrationAllowed();
+ void setEnabled(boolean enabled);
- void setRegistrationAllowed(boolean registrationAllowed);
+ SslRequired getSslRequired();
- boolean isPasswordCredentialGrantAllowed();
+ void setSslRequired(SslRequired sslRequired);
- void setPasswordCredentialGrantAllowed(boolean passwordCredentialGrantAllowed);
+ boolean isRegistrationAllowed();
- boolean isRememberMe();
+ void setRegistrationAllowed(boolean registrationAllowed);
- void setRememberMe(boolean rememberMe);
+ public boolean isRegistrationEmailAsUsername();
- //--- brute force settings
- boolean isBruteForceProtected();
- void setBruteForceProtected(boolean value);
- int getMaxFailureWaitSeconds();
- void setMaxFailureWaitSeconds(int val);
- int getWaitIncrementSeconds();
- void setWaitIncrementSeconds(int val);
- int getMinimumQuickLoginWaitSeconds();
- void setMinimumQuickLoginWaitSeconds(int val);
- long getQuickLoginCheckMilliSeconds();
- void setQuickLoginCheckMilliSeconds(long val);
- int getMaxDeltaTimeSeconds();
- void setMaxDeltaTimeSeconds(int val);
- int getFailureFactor();
- void setFailureFactor(int failureFactor);
- //--- end brute force settings
+ public void setRegistrationEmailAsUsername(boolean registrationEmailAsUsername);
+ boolean isPasswordCredentialGrantAllowed();
- boolean isVerifyEmail();
+ void setPasswordCredentialGrantAllowed(boolean passwordCredentialGrantAllowed);
- void setVerifyEmail(boolean verifyEmail);
+ boolean isRememberMe();
- boolean isResetPasswordAllowed();
+ void setRememberMe(boolean rememberMe);
- void setResetPasswordAllowed(boolean resetPasswordAllowed);
+ // --- brute force settings
+ boolean isBruteForceProtected();
- int getSsoSessionIdleTimeout();
- void setSsoSessionIdleTimeout(int seconds);
+ void setBruteForceProtected(boolean value);
- int getSsoSessionMaxLifespan();
- void setSsoSessionMaxLifespan(int seconds);
+ int getMaxFailureWaitSeconds();
- int getAccessTokenLifespan();
+ void setMaxFailureWaitSeconds(int val);
- void setAccessTokenLifespan(int seconds);
+ int getWaitIncrementSeconds();
- int getAccessCodeLifespan();
+ void setWaitIncrementSeconds(int val);
- void setAccessCodeLifespan(int seconds);
+ int getMinimumQuickLoginWaitSeconds();
- int getAccessCodeLifespanUserAction();
+ void setMinimumQuickLoginWaitSeconds(int val);
- void setAccessCodeLifespanUserAction(int seconds);
+ long getQuickLoginCheckMilliSeconds();
- int getAccessCodeLifespanLogin();
+ void setQuickLoginCheckMilliSeconds(long val);
- void setAccessCodeLifespanLogin(int seconds);
+ int getMaxDeltaTimeSeconds();
- String getPublicKeyPem();
+ void setMaxDeltaTimeSeconds(int val);
- void setPublicKeyPem(String publicKeyPem);
+ int getFailureFactor();
- String getPrivateKeyPem();
+ void setFailureFactor(int failureFactor);
- void setPrivateKeyPem(String privateKeyPem);
+ // --- end brute force settings
- PublicKey getPublicKey();
+ boolean isVerifyEmail();
- void setPublicKey(PublicKey publicKey);
+ void setVerifyEmail(boolean verifyEmail);
- String getCodeSecret();
+ boolean isResetPasswordAllowed();
- Key getCodeSecretKey();
+ void setResetPasswordAllowed(boolean resetPasswordAllowed);
- void setCodeSecret(String codeSecret);
+ int getSsoSessionIdleTimeout();
- X509Certificate getCertificate();
- void setCertificate(X509Certificate certificate);
- String getCertificatePem();
- void setCertificatePem(String certificate);
+ void setSsoSessionIdleTimeout(int seconds);
- PrivateKey getPrivateKey();
+ int getSsoSessionMaxLifespan();
- void setPrivateKey(PrivateKey privateKey);
+ void setSsoSessionMaxLifespan(int seconds);
- List
getRequiredCredentials();
+ int getAccessTokenLifespan();
- void addRequiredCredential(String cred);
+ void setAccessTokenLifespan(int seconds);
- PasswordPolicy getPasswordPolicy();
+ int getAccessCodeLifespan();
- void setPasswordPolicy(PasswordPolicy policy);
+ void setAccessCodeLifespan(int seconds);
- RoleModel getRoleById(String id);
+ int getAccessCodeLifespanUserAction();
- List getDefaultRoles();
+ void setAccessCodeLifespanUserAction(int seconds);
- void addDefaultRole(String name);
+ int getAccessCodeLifespanLogin();
- void updateDefaultRoles(String[] defaultRoles);
+ void setAccessCodeLifespanLogin(int seconds);
- ClientModel findClient(String clientId);
+ String getPublicKeyPem();
- Map getApplicationNameMap();
+ void setPublicKeyPem(String publicKeyPem);
- List getApplications();
+ String getPrivateKeyPem();
- ApplicationModel addApplication(String name);
+ void setPrivateKeyPem(String privateKeyPem);
- ApplicationModel addApplication(String id, String name);
+ PublicKey getPublicKey();
- boolean removeApplication(String id);
+ void setPublicKey(PublicKey publicKey);
- ApplicationModel getApplicationById(String id);
- ApplicationModel getApplicationByName(String name);
+ String getCodeSecret();
- void updateRequiredCredentials(Set creds);
+ Key getCodeSecretKey();
- OAuthClientModel addOAuthClient(String name);
+ void setCodeSecret(String codeSecret);
- OAuthClientModel addOAuthClient(String id, String name);
+ X509Certificate getCertificate();
- OAuthClientModel getOAuthClient(String name);
- OAuthClientModel getOAuthClientById(String id);
- boolean removeOAuthClient(String id);
+ void setCertificate(X509Certificate certificate);
- List getOAuthClients();
+ String getCertificatePem();
- Map getBrowserSecurityHeaders();
- void setBrowserSecurityHeaders(Map headers);
+ void setCertificatePem(String certificate);
- Map getSmtpConfig();
+ PrivateKey getPrivateKey();
- void setSmtpConfig(Map smtpConfig);
+ void setPrivateKey(PrivateKey privateKey);
- List getIdentityProviders();
- IdentityProviderModel getIdentityProviderById(String identityProviderId);
- void addIdentityProvider(IdentityProviderModel identityProvider);
- void removeIdentityProviderById(String providerId);
- void updateIdentityProvider(IdentityProviderModel identityProvider);
+ List getRequiredCredentials();
- List getUserFederationProviders();
+ void addRequiredCredential(String cred);
- UserFederationProviderModel addUserFederationProvider(String providerName, Map config, int priority, String displayName, int fullSyncPeriod, int changedSyncPeriod, int lastSync);
- void updateUserFederationProvider(UserFederationProviderModel provider);
- void removeUserFederationProvider(UserFederationProviderModel provider);
- void setUserFederationProviders(List providers);
+ PasswordPolicy getPasswordPolicy();
- String getLoginTheme();
+ void setPasswordPolicy(PasswordPolicy policy);
- void setLoginTheme(String name);
+ RoleModel getRoleById(String id);
- String getAccountTheme();
+ List getDefaultRoles();
- void setAccountTheme(String name);
+ void addDefaultRole(String name);
- String getAdminTheme();
+ void updateDefaultRoles(String[] defaultRoles);
- void setAdminTheme(String name);
+ ClientModel findClient(String clientId);
- String getEmailTheme();
+ Map getApplicationNameMap();
- void setEmailTheme(String name);
+ List getApplications();
+ ApplicationModel addApplication(String name);
- /**
- * Time in seconds since epoc
- *
- * @return
- */
- int getNotBefore();
+ ApplicationModel addApplication(String id, String name);
- void setNotBefore(int notBefore);
+ boolean removeApplication(String id);
- boolean removeRoleById(String id);
+ ApplicationModel getApplicationById(String id);
- boolean isEventsEnabled();
+ ApplicationModel getApplicationByName(String name);
- void setEventsEnabled(boolean enabled);
+ void updateRequiredCredentials(Set creds);
- long getEventsExpiration();
+ OAuthClientModel addOAuthClient(String name);
- void setEventsExpiration(long expiration);
+ OAuthClientModel addOAuthClient(String id, String name);
- Set getEventsListeners();
+ OAuthClientModel getOAuthClient(String name);
- void setEventsListeners(Set listeners);
+ OAuthClientModel getOAuthClientById(String id);
- ApplicationModel getMasterAdminApp();
+ boolean removeOAuthClient(String id);
- void setMasterAdminApp(ApplicationModel app);
+ List getOAuthClients();
- ClientModel findClientById(String id);
+ Map getBrowserSecurityHeaders();
- boolean isIdentityFederationEnabled();
+ void setBrowserSecurityHeaders(Map headers);
+
+ Map getSmtpConfig();
+
+ void setSmtpConfig(Map smtpConfig);
+
+ List getIdentityProviders();
+
+ IdentityProviderModel getIdentityProviderById(String identityProviderId);
+
+ void addIdentityProvider(IdentityProviderModel identityProvider);
+
+ void removeIdentityProviderById(String providerId);
+
+ void updateIdentityProvider(IdentityProviderModel identityProvider);
+
+ List getUserFederationProviders();
+
+ UserFederationProviderModel addUserFederationProvider(String providerName, Map config, int priority,
+ String displayName, int fullSyncPeriod, int changedSyncPeriod, int lastSync);
+
+ void updateUserFederationProvider(UserFederationProviderModel provider);
+
+ void removeUserFederationProvider(UserFederationProviderModel provider);
+
+ void setUserFederationProviders(List providers);
+
+ String getLoginTheme();
+
+ void setLoginTheme(String name);
+
+ String getAccountTheme();
+
+ void setAccountTheme(String name);
+
+ String getAdminTheme();
+
+ void setAdminTheme(String name);
+
+ String getEmailTheme();
+
+ void setEmailTheme(String name);
+
+ /**
+ * Time in seconds since epoc
+ *
+ * @return
+ */
+ int getNotBefore();
+
+ void setNotBefore(int notBefore);
+
+ boolean removeRoleById(String id);
+
+ boolean isEventsEnabled();
+
+ void setEventsEnabled(boolean enabled);
+
+ long getEventsExpiration();
+
+ void setEventsExpiration(long expiration);
+
+ Set getEventsListeners();
+
+ void setEventsListeners(Set listeners);
+
+ ApplicationModel getMasterAdminApp();
+
+ void setMasterAdminApp(ApplicationModel app);
+
+ ClientModel findClientById(String id);
+
+ boolean isIdentityFederationEnabled();
}
diff --git a/model/api/src/main/java/org/keycloak/models/entities/RealmEntity.java b/model/api/src/main/java/org/keycloak/models/entities/RealmEntity.java
index 17792e57ef..203c0b9e2e 100755
--- a/model/api/src/main/java/org/keycloak/models/entities/RealmEntity.java
+++ b/model/api/src/main/java/org/keycloak/models/entities/RealmEntity.java
@@ -10,394 +10,402 @@ import java.util.Map;
*/
public class RealmEntity extends AbstractIdentifiableEntity {
- private String name;
- private boolean enabled;
- private String sslRequired;
- private boolean registrationAllowed;
- private boolean rememberMe;
- private boolean verifyEmail;
- private boolean passwordCredentialGrantAllowed;
- private boolean resetPasswordAllowed;
- private String passwordPolicy;
- //--- brute force settings
- private boolean bruteForceProtected;
- private int maxFailureWaitSeconds;
- private int minimumQuickLoginWaitSeconds;
- private int waitIncrementSeconds;
- private long quickLoginCheckMilliSeconds;
- private int maxDeltaTimeSeconds;
- private int failureFactor;
- //--- end brute force settings
-
- private int ssoSessionIdleTimeout;
- private int ssoSessionMaxLifespan;
- private int accessTokenLifespan;
- private int accessCodeLifespan;
- private int accessCodeLifespanUserAction;
- private int accessCodeLifespanLogin;
- private int notBefore;
-
- private String publicKeyPem;
- private String privateKeyPem;
- private String certificatePem;
- private String codeSecret;
-
- private String loginTheme;
- private String accountTheme;
- private String adminTheme;
- private String emailTheme;
-
- // We are using names of defaultRoles (not ids)
- private List defaultRoles = new ArrayList();
-
- private List requiredCredentials = new ArrayList();
- private List userFederationProviders = new ArrayList();
- private List identityProviders = new ArrayList();
-
- private Map browserSecurityHeaders = new HashMap();
- private Map smtpConfig = new HashMap();
- private Map socialConfig = new HashMap();
-
- private boolean eventsEnabled;
- private long eventsExpiration;
- private List eventsListeners = new ArrayList();
-
- private String adminAppId;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- public String getSslRequired() {
- return sslRequired;
- }
-
- public void setSslRequired(String sslRequired) {
- this.sslRequired = sslRequired;
- }
-
- public boolean isPasswordCredentialGrantAllowed() {
- return passwordCredentialGrantAllowed;
- }
-
- public void setPasswordCredentialGrantAllowed(boolean passwordCredentialGrantAllowed) {
- this.passwordCredentialGrantAllowed = passwordCredentialGrantAllowed;
- }
-
- public boolean isRegistrationAllowed() {
- return registrationAllowed;
- }
-
- public void setRegistrationAllowed(boolean registrationAllowed) {
- this.registrationAllowed = registrationAllowed;
- }
-
- public boolean isRememberMe() {
- return rememberMe;
- }
-
- public void setRememberMe(boolean rememberMe) {
- this.rememberMe = rememberMe;
- }
-
- public boolean isVerifyEmail() {
- return verifyEmail;
- }
-
- public void setVerifyEmail(boolean verifyEmail) {
- this.verifyEmail = verifyEmail;
- }
-
- public boolean isResetPasswordAllowed() {
- return resetPasswordAllowed;
- }
-
- public void setResetPasswordAllowed(boolean resetPasswordAllowed) {
- this.resetPasswordAllowed = resetPasswordAllowed;
- }
+ private String name;
+ private boolean enabled;
+ private String sslRequired;
+ private boolean registrationAllowed;
+ protected boolean registrationEmailAsUsername;
+ private boolean rememberMe;
+ private boolean verifyEmail;
+ private boolean passwordCredentialGrantAllowed;
+ private boolean resetPasswordAllowed;
+ private String passwordPolicy;
+ // --- brute force settings
+ private boolean bruteForceProtected;
+ private int maxFailureWaitSeconds;
+ private int minimumQuickLoginWaitSeconds;
+ private int waitIncrementSeconds;
+ private long quickLoginCheckMilliSeconds;
+ private int maxDeltaTimeSeconds;
+ private int failureFactor;
+ // --- end brute force settings
+
+ private int ssoSessionIdleTimeout;
+ private int ssoSessionMaxLifespan;
+ private int accessTokenLifespan;
+ private int accessCodeLifespan;
+ private int accessCodeLifespanUserAction;
+ private int accessCodeLifespanLogin;
+ private int notBefore;
+
+ private String publicKeyPem;
+ private String privateKeyPem;
+ private String certificatePem;
+ private String codeSecret;
+
+ private String loginTheme;
+ private String accountTheme;
+ private String adminTheme;
+ private String emailTheme;
+
+ // We are using names of defaultRoles (not ids)
+ private List defaultRoles = new ArrayList();
+
+ private List requiredCredentials = new ArrayList();
+ private List userFederationProviders = new ArrayList();
+ private List identityProviders = new ArrayList();
+
+ private Map browserSecurityHeaders = new HashMap();
+ private Map smtpConfig = new HashMap();
+ private Map socialConfig = new HashMap();
+
+ private boolean eventsEnabled;
+ private long eventsExpiration;
+ private List eventsListeners = new ArrayList();
+
+ private String adminAppId;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getSslRequired() {
+ return sslRequired;
+ }
+
+ public void setSslRequired(String sslRequired) {
+ this.sslRequired = sslRequired;
+ }
+
+ public boolean isPasswordCredentialGrantAllowed() {
+ return passwordCredentialGrantAllowed;
+ }
+
+ public void setPasswordCredentialGrantAllowed(boolean passwordCredentialGrantAllowed) {
+ this.passwordCredentialGrantAllowed = passwordCredentialGrantAllowed;
+ }
+
+ public boolean isRegistrationAllowed() {
+ return registrationAllowed;
+ }
+
+ public void setRegistrationAllowed(boolean registrationAllowed) {
+ this.registrationAllowed = registrationAllowed;
+ }
+
+ public boolean isRegistrationEmailAsUsername() {
+ return registrationEmailAsUsername;
+ }
+
+ public void setRegistrationEmailAsUsername(boolean registrationEmailAsUsername) {
+ this.registrationEmailAsUsername = registrationEmailAsUsername;
+ }
+
+ public boolean isRememberMe() {
+ return rememberMe;
+ }
+
+ public void setRememberMe(boolean rememberMe) {
+ this.rememberMe = rememberMe;
+ }
+
+ public boolean isVerifyEmail() {
+ return verifyEmail;
+ }
+
+ public void setVerifyEmail(boolean verifyEmail) {
+ this.verifyEmail = verifyEmail;
+ }
- public String getPasswordPolicy() {
- return passwordPolicy;
- }
-
- public void setPasswordPolicy(String passwordPolicy) {
- this.passwordPolicy = passwordPolicy;
- }
+ public boolean isResetPasswordAllowed() {
+ return resetPasswordAllowed;
+ }
- public boolean isBruteForceProtected() {
- return bruteForceProtected;
- }
+ public void setResetPasswordAllowed(boolean resetPasswordAllowed) {
+ this.resetPasswordAllowed = resetPasswordAllowed;
+ }
- public void setBruteForceProtected(boolean bruteForceProtected) {
- this.bruteForceProtected = bruteForceProtected;
- }
+ public String getPasswordPolicy() {
+ return passwordPolicy;
+ }
- public int getMaxFailureWaitSeconds() {
- return maxFailureWaitSeconds;
- }
+ public void setPasswordPolicy(String passwordPolicy) {
+ this.passwordPolicy = passwordPolicy;
+ }
- public void setMaxFailureWaitSeconds(int maxFailureWaitSeconds) {
- this.maxFailureWaitSeconds = maxFailureWaitSeconds;
- }
+ public boolean isBruteForceProtected() {
+ return bruteForceProtected;
+ }
- public int getMinimumQuickLoginWaitSeconds() {
- return minimumQuickLoginWaitSeconds;
- }
+ public void setBruteForceProtected(boolean bruteForceProtected) {
+ this.bruteForceProtected = bruteForceProtected;
+ }
- public void setMinimumQuickLoginWaitSeconds(int minimumQuickLoginWaitSeconds) {
- this.minimumQuickLoginWaitSeconds = minimumQuickLoginWaitSeconds;
- }
+ public int getMaxFailureWaitSeconds() {
+ return maxFailureWaitSeconds;
+ }
- public int getWaitIncrementSeconds() {
- return waitIncrementSeconds;
- }
+ public void setMaxFailureWaitSeconds(int maxFailureWaitSeconds) {
+ this.maxFailureWaitSeconds = maxFailureWaitSeconds;
+ }
- public void setWaitIncrementSeconds(int waitIncrementSeconds) {
- this.waitIncrementSeconds = waitIncrementSeconds;
- }
+ public int getMinimumQuickLoginWaitSeconds() {
+ return minimumQuickLoginWaitSeconds;
+ }
- public long getQuickLoginCheckMilliSeconds() {
- return quickLoginCheckMilliSeconds;
- }
+ public void setMinimumQuickLoginWaitSeconds(int minimumQuickLoginWaitSeconds) {
+ this.minimumQuickLoginWaitSeconds = minimumQuickLoginWaitSeconds;
+ }
- public void setQuickLoginCheckMilliSeconds(long quickLoginCheckMilliSeconds) {
- this.quickLoginCheckMilliSeconds = quickLoginCheckMilliSeconds;
- }
+ public int getWaitIncrementSeconds() {
+ return waitIncrementSeconds;
+ }
- public int getMaxDeltaTimeSeconds() {
- return maxDeltaTimeSeconds;
- }
+ public void setWaitIncrementSeconds(int waitIncrementSeconds) {
+ this.waitIncrementSeconds = waitIncrementSeconds;
+ }
- public void setMaxDeltaTimeSeconds(int maxDeltaTimeSeconds) {
- this.maxDeltaTimeSeconds = maxDeltaTimeSeconds;
- }
+ public long getQuickLoginCheckMilliSeconds() {
+ return quickLoginCheckMilliSeconds;
+ }
- public int getFailureFactor() {
- return failureFactor;
- }
+ public void setQuickLoginCheckMilliSeconds(long quickLoginCheckMilliSeconds) {
+ this.quickLoginCheckMilliSeconds = quickLoginCheckMilliSeconds;
+ }
- public void setFailureFactor(int failureFactor) {
- this.failureFactor = failureFactor;
- }
+ public int getMaxDeltaTimeSeconds() {
+ return maxDeltaTimeSeconds;
+ }
- public int getSsoSessionIdleTimeout() {
- return ssoSessionIdleTimeout;
- }
+ public void setMaxDeltaTimeSeconds(int maxDeltaTimeSeconds) {
+ this.maxDeltaTimeSeconds = maxDeltaTimeSeconds;
+ }
- public void setSsoSessionIdleTimeout(int ssoSessionIdleTimeout) {
- this.ssoSessionIdleTimeout = ssoSessionIdleTimeout;
- }
+ public int getFailureFactor() {
+ return failureFactor;
+ }
- public int getSsoSessionMaxLifespan() {
- return ssoSessionMaxLifespan;
- }
+ public void setFailureFactor(int failureFactor) {
+ this.failureFactor = failureFactor;
+ }
- public void setSsoSessionMaxLifespan(int ssoSessionMaxLifespan) {
- this.ssoSessionMaxLifespan = ssoSessionMaxLifespan;
- }
+ public int getSsoSessionIdleTimeout() {
+ return ssoSessionIdleTimeout;
+ }
- public int getAccessTokenLifespan() {
- return accessTokenLifespan;
- }
+ public void setSsoSessionIdleTimeout(int ssoSessionIdleTimeout) {
+ this.ssoSessionIdleTimeout = ssoSessionIdleTimeout;
+ }
- public void setAccessTokenLifespan(int accessTokenLifespan) {
- this.accessTokenLifespan = accessTokenLifespan;
- }
+ public int getSsoSessionMaxLifespan() {
+ return ssoSessionMaxLifespan;
+ }
- public int getAccessCodeLifespan() {
- return accessCodeLifespan;
- }
+ public void setSsoSessionMaxLifespan(int ssoSessionMaxLifespan) {
+ this.ssoSessionMaxLifespan = ssoSessionMaxLifespan;
+ }
- public void setAccessCodeLifespan(int accessCodeLifespan) {
- this.accessCodeLifespan = accessCodeLifespan;
- }
+ public int getAccessTokenLifespan() {
+ return accessTokenLifespan;
+ }
- public int getAccessCodeLifespanUserAction() {
- return accessCodeLifespanUserAction;
- }
+ public void setAccessTokenLifespan(int accessTokenLifespan) {
+ this.accessTokenLifespan = accessTokenLifespan;
+ }
- public void setAccessCodeLifespanUserAction(int accessCodeLifespanUserAction) {
- this.accessCodeLifespanUserAction = accessCodeLifespanUserAction;
- }
- public int getAccessCodeLifespanLogin() {
- return accessCodeLifespanLogin;
- }
+ public int getAccessCodeLifespan() {
+ return accessCodeLifespan;
+ }
- public void setAccessCodeLifespanLogin(int accessCodeLifespanLogin) {
- this.accessCodeLifespanLogin = accessCodeLifespanLogin;
- }
+ public void setAccessCodeLifespan(int accessCodeLifespan) {
+ this.accessCodeLifespan = accessCodeLifespan;
+ }
- public int getNotBefore() {
- return notBefore;
- }
+ public int getAccessCodeLifespanUserAction() {
+ return accessCodeLifespanUserAction;
+ }
- public void setNotBefore(int notBefore) {
- this.notBefore = notBefore;
- }
+ public void setAccessCodeLifespanUserAction(int accessCodeLifespanUserAction) {
+ this.accessCodeLifespanUserAction = accessCodeLifespanUserAction;
+ }
- public String getPublicKeyPem() {
- return publicKeyPem;
- }
+ public int getAccessCodeLifespanLogin() {
+ return accessCodeLifespanLogin;
+ }
- public void setPublicKeyPem(String publicKeyPem) {
- this.publicKeyPem = publicKeyPem;
- }
+ public void setAccessCodeLifespanLogin(int accessCodeLifespanLogin) {
+ this.accessCodeLifespanLogin = accessCodeLifespanLogin;
+ }
- public String getPrivateKeyPem() {
- return privateKeyPem;
- }
+ public int getNotBefore() {
+ return notBefore;
+ }
- public void setPrivateKeyPem(String privateKeyPem) {
- this.privateKeyPem = privateKeyPem;
- }
+ public void setNotBefore(int notBefore) {
+ this.notBefore = notBefore;
+ }
- public String getCodeSecret() {
- return codeSecret;
- }
+ public String getPublicKeyPem() {
+ return publicKeyPem;
+ }
- public void setCodeSecret(String codeSecret) {
- this.codeSecret = codeSecret;
- }
+ public void setPublicKeyPem(String publicKeyPem) {
+ this.publicKeyPem = publicKeyPem;
+ }
- public String getLoginTheme() {
- return loginTheme;
- }
+ public String getPrivateKeyPem() {
+ return privateKeyPem;
+ }
- public void setLoginTheme(String loginTheme) {
- this.loginTheme = loginTheme;
- }
+ public void setPrivateKeyPem(String privateKeyPem) {
+ this.privateKeyPem = privateKeyPem;
+ }
- public String getAccountTheme() {
- return accountTheme;
- }
+ public String getCodeSecret() {
+ return codeSecret;
+ }
- public void setAccountTheme(String accountTheme) {
- this.accountTheme = accountTheme;
- }
+ public void setCodeSecret(String codeSecret) {
+ this.codeSecret = codeSecret;
+ }
- public String getAdminTheme() {
- return adminTheme;
- }
+ public String getLoginTheme() {
+ return loginTheme;
+ }
- public void setAdminTheme(String adminTheme) {
- this.adminTheme = adminTheme;
- }
+ public void setLoginTheme(String loginTheme) {
+ this.loginTheme = loginTheme;
+ }
- public String getEmailTheme() {
- return emailTheme;
- }
-
- public void setEmailTheme(String emailTheme) {
- this.emailTheme = emailTheme;
- }
-
- public List getDefaultRoles() {
- return defaultRoles;
- }
-
- public void setDefaultRoles(List defaultRoles) {
- this.defaultRoles = defaultRoles;
- }
-
- public List getRequiredCredentials() {
- return requiredCredentials;
- }
-
- public void setRequiredCredentials(List requiredCredentials) {
- this.requiredCredentials = requiredCredentials;
- }
-
- public Map getBrowserSecurityHeaders() {
- return browserSecurityHeaders;
- }
-
- public void setBrowserSecurityHeaders(Map browserSecurityHeaders) {
- this.browserSecurityHeaders = browserSecurityHeaders;
- }
-
- public Map getSmtpConfig() {
- return smtpConfig;
- }
-
- public void setSmtpConfig(Map smtpConfig) {
- this.smtpConfig = smtpConfig;
- }
+ public String getAccountTheme() {
+ return accountTheme;
+ }
- public Map getSocialConfig() {
- return socialConfig;
- }
+ public void setAccountTheme(String accountTheme) {
+ this.accountTheme = accountTheme;
+ }
- public void setSocialConfig(Map socialConfig) {
- this.socialConfig = socialConfig;
- }
+ public String getAdminTheme() {
+ return adminTheme;
+ }
- public boolean isEventsEnabled() {
- return eventsEnabled;
- }
+ public void setAdminTheme(String adminTheme) {
+ this.adminTheme = adminTheme;
+ }
- public void setEventsEnabled(boolean eventsEnabled) {
- this.eventsEnabled = eventsEnabled;
- }
+ public String getEmailTheme() {
+ return emailTheme;
+ }
- public long getEventsExpiration() {
- return eventsExpiration;
- }
+ public void setEmailTheme(String emailTheme) {
+ this.emailTheme = emailTheme;
+ }
- public void setEventsExpiration(long eventsExpiration) {
- this.eventsExpiration = eventsExpiration;
- }
+ public List getDefaultRoles() {
+ return defaultRoles;
+ }
- public List getEventsListeners() {
- return eventsListeners;
- }
+ public void setDefaultRoles(List defaultRoles) {
+ this.defaultRoles = defaultRoles;
+ }
- public void setEventsListeners(List eventsListeners) {
- this.eventsListeners = eventsListeners;
- }
+ public List getRequiredCredentials() {
+ return requiredCredentials;
+ }
- public String getAdminAppId() {
- return adminAppId;
- }
+ public void setRequiredCredentials(List requiredCredentials) {
+ this.requiredCredentials = requiredCredentials;
+ }
- public void setAdminAppId(String adminAppId) {
- this.adminAppId = adminAppId;
- }
+ public Map getBrowserSecurityHeaders() {
+ return browserSecurityHeaders;
+ }
- public List getUserFederationProviders() {
- return userFederationProviders;
- }
+ public void setBrowserSecurityHeaders(Map browserSecurityHeaders) {
+ this.browserSecurityHeaders = browserSecurityHeaders;
+ }
- public void setUserFederationProviders(List userFederationProviders) {
- this.userFederationProviders = userFederationProviders;
- }
+ public Map getSmtpConfig() {
+ return smtpConfig;
+ }
- public List getIdentityProviders() {
- return identityProviders;
- }
+ public void setSmtpConfig(Map smtpConfig) {
+ this.smtpConfig = smtpConfig;
+ }
- public void setIdentityProviders(List identityProviders) {
- this.identityProviders = identityProviders;
- }
+ public Map getSocialConfig() {
+ return socialConfig;
+ }
- public String getCertificatePem() {
- return certificatePem;
- }
+ public void setSocialConfig(Map socialConfig) {
+ this.socialConfig = socialConfig;
+ }
- public void setCertificatePem(String certificatePem) {
- this.certificatePem = certificatePem;
- }
+ public boolean isEventsEnabled() {
+ return eventsEnabled;
+ }
+
+ public void setEventsEnabled(boolean eventsEnabled) {
+ this.eventsEnabled = eventsEnabled;
+ }
+
+ public long getEventsExpiration() {
+ return eventsExpiration;
+ }
+
+ public void setEventsExpiration(long eventsExpiration) {
+ this.eventsExpiration = eventsExpiration;
+ }
+
+ public List getEventsListeners() {
+ return eventsListeners;
+ }
+
+ public void setEventsListeners(List eventsListeners) {
+ this.eventsListeners = eventsListeners;
+ }
+
+ public String getAdminAppId() {
+ return adminAppId;
+ }
+
+ public void setAdminAppId(String adminAppId) {
+ this.adminAppId = adminAppId;
+ }
+
+ public List getUserFederationProviders() {
+ return userFederationProviders;
+ }
+
+ public void setUserFederationProviders(List userFederationProviders) {
+ this.userFederationProviders = userFederationProviders;
+ }
+
+ public List getIdentityProviders() {
+ return identityProviders;
+ }
+
+ public void setIdentityProviders(List identityProviders) {
+ this.identityProviders = identityProviders;
+ }
+
+ public String getCertificatePem() {
+ return certificatePem;
+ }
+
+ public void setCertificatePem(String certificatePem) {
+ this.certificatePem = certificatePem;
+ }
}
-
-
diff --git a/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java b/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java
index d0963dfb4f..834475e120 100755
--- a/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java
+++ b/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java
@@ -1,5 +1,13 @@
package org.keycloak.models.utils;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.keycloak.models.ApplicationModel;
import org.keycloak.models.ClaimMask;
import org.keycloak.models.ClientIdentityProviderMappingModel;
@@ -31,337 +39,331 @@ import org.keycloak.representations.idm.UserFederationProviderRepresentation;
import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.representations.idm.UserSessionRepresentation;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
/**
* @author Bill Burke
* @version $Revision: 1 $
*/
public class ModelToRepresentation {
- public static UserRepresentation toRepresentation(UserModel user) {
- UserRepresentation rep = new UserRepresentation();
- rep.setId(user.getId());
- rep.setUsername(user.getUsername());
- rep.setLastName(user.getLastName());
- rep.setFirstName(user.getFirstName());
- rep.setEmail(user.getEmail());
- rep.setEnabled(user.isEnabled());
- rep.setEmailVerified(user.isEmailVerified());
- rep.setTotp(user.isTotp());
- rep.setFederationLink(user.getFederationLink());
+ public static UserRepresentation toRepresentation(UserModel user) {
+ UserRepresentation rep = new UserRepresentation();
+ rep.setId(user.getId());
+ rep.setUsername(user.getUsername());
+ rep.setLastName(user.getLastName());
+ rep.setFirstName(user.getFirstName());
+ rep.setEmail(user.getEmail());
+ rep.setEnabled(user.isEnabled());
+ rep.setEmailVerified(user.isEmailVerified());
+ rep.setTotp(user.isTotp());
+ rep.setFederationLink(user.getFederationLink());
- List reqActions = new ArrayList();
- for (UserModel.RequiredAction ra : user.getRequiredActions()){
- reqActions.add(ra.name());
- }
+ List reqActions = new ArrayList();
+ for (UserModel.RequiredAction ra : user.getRequiredActions()) {
+ reqActions.add(ra.name());
+ }
- rep.setRequiredActions(reqActions);
+ rep.setRequiredActions(reqActions);
- if (user.getAttributes() != null && !user.getAttributes().isEmpty()) {
- Map attrs = new HashMap();
- attrs.putAll(user.getAttributes());
- rep.setAttributes(attrs);
- }
- return rep;
- }
+ if (user.getAttributes() != null && !user.getAttributes().isEmpty()) {
+ Map attrs = new HashMap();
+ attrs.putAll(user.getAttributes());
+ rep.setAttributes(attrs);
+ }
+ return rep;
+ }
- public static RoleRepresentation toRepresentation(RoleModel role) {
- RoleRepresentation rep = new RoleRepresentation();
- rep.setId(role.getId());
- rep.setName(role.getName());
- rep.setDescription(role.getDescription());
- rep.setComposite(role.isComposite());
- return rep;
- }
+ public static RoleRepresentation toRepresentation(RoleModel role) {
+ RoleRepresentation rep = new RoleRepresentation();
+ rep.setId(role.getId());
+ rep.setName(role.getName());
+ rep.setDescription(role.getDescription());
+ rep.setComposite(role.isComposite());
+ return rep;
+ }
- public static RealmRepresentation toRepresentation(RealmModel realm, boolean internal) {
- RealmRepresentation rep = new RealmRepresentation();
- rep.setId(realm.getId());
- rep.setRealm(realm.getName());
- rep.setEnabled(realm.isEnabled());
- rep.setNotBefore(realm.getNotBefore());
- rep.setSslRequired(realm.getSslRequired().name().toLowerCase());
- rep.setPublicKey(realm.getPublicKeyPem());
- if (internal) {
- rep.setPrivateKey(realm.getPrivateKeyPem());
- String privateKeyPem = realm.getPrivateKeyPem();
- if (realm.getCertificatePem() == null && privateKeyPem != null) {
- KeycloakModelUtils.generateRealmCertificate(realm);
- }
- rep.setCodeSecret(realm.getCodeSecret());
- }
- rep.setCertificate(realm.getCertificatePem());
- rep.setPasswordCredentialGrantAllowed(realm.isPasswordCredentialGrantAllowed());
- rep.setRegistrationAllowed(realm.isRegistrationAllowed());
- rep.setRememberMe(realm.isRememberMe());
- rep.setBruteForceProtected(realm.isBruteForceProtected());
- rep.setMaxFailureWaitSeconds(realm.getMaxFailureWaitSeconds());
- rep.setMinimumQuickLoginWaitSeconds(realm.getMinimumQuickLoginWaitSeconds());
- rep.setWaitIncrementSeconds(realm.getWaitIncrementSeconds());
- rep.setQuickLoginCheckMilliSeconds(realm.getQuickLoginCheckMilliSeconds());
- rep.setMaxDeltaTimeSeconds(realm.getMaxDeltaTimeSeconds());
- rep.setFailureFactor(realm.getFailureFactor());
- rep.setVerifyEmail(realm.isVerifyEmail());
- rep.setResetPasswordAllowed(realm.isResetPasswordAllowed());
- rep.setAccessTokenLifespan(realm.getAccessTokenLifespan());
- rep.setSsoSessionIdleTimeout(realm.getSsoSessionIdleTimeout());
- rep.setSsoSessionMaxLifespan(realm.getSsoSessionMaxLifespan());
- rep.setAccessCodeLifespan(realm.getAccessCodeLifespan());
- rep.setAccessCodeLifespanUserAction(realm.getAccessCodeLifespanUserAction());
- rep.setAccessCodeLifespanLogin(realm.getAccessCodeLifespanLogin());
- rep.setSmtpServer(realm.getSmtpConfig());
- rep.setBrowserSecurityHeaders(realm.getBrowserSecurityHeaders());
- rep.setAccountTheme(realm.getAccountTheme());
- rep.setLoginTheme(realm.getLoginTheme());
- rep.setAdminTheme(realm.getAdminTheme());
- rep.setEmailTheme(realm.getEmailTheme());
- if (realm.getPasswordPolicy() != null) {
- rep.setPasswordPolicy(realm.getPasswordPolicy().toString());
- }
+ public static RealmRepresentation toRepresentation(RealmModel realm, boolean internal) {
+ RealmRepresentation rep = new RealmRepresentation();
+ rep.setId(realm.getId());
+ rep.setRealm(realm.getName());
+ rep.setEnabled(realm.isEnabled());
+ rep.setNotBefore(realm.getNotBefore());
+ rep.setSslRequired(realm.getSslRequired().name().toLowerCase());
+ rep.setPublicKey(realm.getPublicKeyPem());
+ if (internal) {
+ rep.setPrivateKey(realm.getPrivateKeyPem());
+ String privateKeyPem = realm.getPrivateKeyPem();
+ if (realm.getCertificatePem() == null && privateKeyPem != null) {
+ KeycloakModelUtils.generateRealmCertificate(realm);
+ }
+ rep.setCodeSecret(realm.getCodeSecret());
+ }
+ rep.setCertificate(realm.getCertificatePem());
+ rep.setPasswordCredentialGrantAllowed(realm.isPasswordCredentialGrantAllowed());
+ rep.setRegistrationAllowed(realm.isRegistrationAllowed());
+ rep.setRegistrationEmailAsUsername(realm.isRegistrationEmailAsUsername());
+ rep.setRememberMe(realm.isRememberMe());
+ rep.setBruteForceProtected(realm.isBruteForceProtected());
+ rep.setMaxFailureWaitSeconds(realm.getMaxFailureWaitSeconds());
+ rep.setMinimumQuickLoginWaitSeconds(realm.getMinimumQuickLoginWaitSeconds());
+ rep.setWaitIncrementSeconds(realm.getWaitIncrementSeconds());
+ rep.setQuickLoginCheckMilliSeconds(realm.getQuickLoginCheckMilliSeconds());
+ rep.setMaxDeltaTimeSeconds(realm.getMaxDeltaTimeSeconds());
+ rep.setFailureFactor(realm.getFailureFactor());
+ rep.setVerifyEmail(realm.isVerifyEmail());
+ rep.setResetPasswordAllowed(realm.isResetPasswordAllowed());
+ rep.setAccessTokenLifespan(realm.getAccessTokenLifespan());
+ rep.setSsoSessionIdleTimeout(realm.getSsoSessionIdleTimeout());
+ rep.setSsoSessionMaxLifespan(realm.getSsoSessionMaxLifespan());
+ rep.setAccessCodeLifespan(realm.getAccessCodeLifespan());
+ rep.setAccessCodeLifespanUserAction(realm.getAccessCodeLifespanUserAction());
+ rep.setAccessCodeLifespanLogin(realm.getAccessCodeLifespanLogin());
+ rep.setSmtpServer(realm.getSmtpConfig());
+ rep.setBrowserSecurityHeaders(realm.getBrowserSecurityHeaders());
+ rep.setAccountTheme(realm.getAccountTheme());
+ rep.setLoginTheme(realm.getLoginTheme());
+ rep.setAdminTheme(realm.getAdminTheme());
+ rep.setEmailTheme(realm.getEmailTheme());
+ if (realm.getPasswordPolicy() != null) {
+ rep.setPasswordPolicy(realm.getPasswordPolicy().toString());
+ }
- List defaultRoles = realm.getDefaultRoles();
- if (!defaultRoles.isEmpty()) {
- List roleStrings = new ArrayList();
- roleStrings.addAll(defaultRoles);
- rep.setDefaultRoles(roleStrings);
- }
+ List defaultRoles = realm.getDefaultRoles();
+ if (!defaultRoles.isEmpty()) {
+ List roleStrings = new ArrayList();
+ roleStrings.addAll(defaultRoles);
+ rep.setDefaultRoles(roleStrings);
+ }
- List requiredCredentialModels = realm.getRequiredCredentials();
- if (requiredCredentialModels.size() > 0) {
- rep.setRequiredCredentials(new HashSet());
- for (RequiredCredentialModel cred : requiredCredentialModels) {
- rep.getRequiredCredentials().add(cred.getType());
- }
- }
+ List requiredCredentialModels = realm.getRequiredCredentials();
+ if (requiredCredentialModels.size() > 0) {
+ rep.setRequiredCredentials(new HashSet());
+ for (RequiredCredentialModel cred : requiredCredentialModels) {
+ rep.getRequiredCredentials().add(cred.getType());
+ }
+ }
- List fedProviderModels = realm.getUserFederationProviders();
- if (fedProviderModels.size() > 0) {
- List fedProviderReps = new ArrayList();
- for (UserFederationProviderModel model : fedProviderModels) {
- UserFederationProviderRepresentation fedProvRep = toRepresentation(model);
- fedProviderReps.add(fedProvRep);
- }
- rep.setUserFederationProviders(fedProviderReps);
- }
+ List fedProviderModels = realm.getUserFederationProviders();
+ if (fedProviderModels.size() > 0) {
+ List fedProviderReps = new ArrayList();
+ for (UserFederationProviderModel model : fedProviderModels) {
+ UserFederationProviderRepresentation fedProvRep = toRepresentation(model);
+ fedProviderReps.add(fedProvRep);
+ }
+ rep.setUserFederationProviders(fedProviderReps);
+ }
- for (IdentityProviderModel provider : realm.getIdentityProviders()) {
- rep.addIdentityProvider(toRepresentation(provider));
- }
+ for (IdentityProviderModel provider : realm.getIdentityProviders()) {
+ rep.addIdentityProvider(toRepresentation(provider));
+ }
- return rep;
- }
+ return rep;
+ }
- public static RealmEventsConfigRepresentation toEventsConfigReprensetation(RealmModel realm) {
- RealmEventsConfigRepresentation rep = new RealmEventsConfigRepresentation();
- rep.setEventsEnabled(realm.isEventsEnabled());
+ public static RealmEventsConfigRepresentation toEventsConfigReprensetation(RealmModel realm) {
+ RealmEventsConfigRepresentation rep = new RealmEventsConfigRepresentation();
+ rep.setEventsEnabled(realm.isEventsEnabled());
- if (realm.getEventsExpiration() != 0) {
- rep.setEventsExpiration(realm.getEventsExpiration());
- }
+ if (realm.getEventsExpiration() != 0) {
+ rep.setEventsExpiration(realm.getEventsExpiration());
+ }
- if (realm.getEventsListeners() != null) {
- rep.setEventsListeners(new LinkedList(realm.getEventsListeners()));
- }
- return rep;
- }
+ if (realm.getEventsListeners() != null) {
+ rep.setEventsListeners(new LinkedList(realm.getEventsListeners()));
+ }
+ return rep;
+ }
- public static CredentialRepresentation toRepresentation(UserCredentialModel cred) {
- CredentialRepresentation rep = new CredentialRepresentation();
- rep.setType(CredentialRepresentation.SECRET);
- rep.setValue(cred.getValue());
- return rep;
- }
+ public static CredentialRepresentation toRepresentation(UserCredentialModel cred) {
+ CredentialRepresentation rep = new CredentialRepresentation();
+ rep.setType(CredentialRepresentation.SECRET);
+ rep.setValue(cred.getValue());
+ return rep;
+ }
- public static ClaimRepresentation toRepresentation(ClientModel model) {
- ClaimRepresentation rep = new ClaimRepresentation();
- rep.setAddress(ClaimMask.hasAddress(model.getAllowedClaimsMask()));
- rep.setEmail(ClaimMask.hasEmail(model.getAllowedClaimsMask()));
- rep.setGender(ClaimMask.hasGender(model.getAllowedClaimsMask()));
- rep.setLocale(ClaimMask.hasLocale(model.getAllowedClaimsMask()));
- rep.setName(ClaimMask.hasName(model.getAllowedClaimsMask()));
- rep.setPhone(ClaimMask.hasPhone(model.getAllowedClaimsMask()));
- rep.setPicture(ClaimMask.hasPicture(model.getAllowedClaimsMask()));
- rep.setProfile(ClaimMask.hasProfile(model.getAllowedClaimsMask()));
- rep.setWebsite(ClaimMask.hasWebsite(model.getAllowedClaimsMask()));
- rep.setUsername(ClaimMask.hasUsername(model.getAllowedClaimsMask()));
- return rep;
- }
+ public static ClaimRepresentation toRepresentation(ClientModel model) {
+ ClaimRepresentation rep = new ClaimRepresentation();
+ rep.setAddress(ClaimMask.hasAddress(model.getAllowedClaimsMask()));
+ rep.setEmail(ClaimMask.hasEmail(model.getAllowedClaimsMask()));
+ rep.setGender(ClaimMask.hasGender(model.getAllowedClaimsMask()));
+ rep.setLocale(ClaimMask.hasLocale(model.getAllowedClaimsMask()));
+ rep.setName(ClaimMask.hasName(model.getAllowedClaimsMask()));
+ rep.setPhone(ClaimMask.hasPhone(model.getAllowedClaimsMask()));
+ rep.setPicture(ClaimMask.hasPicture(model.getAllowedClaimsMask()));
+ rep.setProfile(ClaimMask.hasProfile(model.getAllowedClaimsMask()));
+ rep.setWebsite(ClaimMask.hasWebsite(model.getAllowedClaimsMask()));
+ rep.setUsername(ClaimMask.hasUsername(model.getAllowedClaimsMask()));
+ return rep;
+ }
- public static FederatedIdentityRepresentation toRepresentation(FederatedIdentityModel socialLink) {
- FederatedIdentityRepresentation rep = new FederatedIdentityRepresentation();
- rep.setUserName(socialLink.getUserName());
- rep.setIdentityProvider(socialLink.getIdentityProvider());
- rep.setUserId(socialLink.getUserId());
- return rep;
- }
+ public static FederatedIdentityRepresentation toRepresentation(FederatedIdentityModel socialLink) {
+ FederatedIdentityRepresentation rep = new FederatedIdentityRepresentation();
+ rep.setUserName(socialLink.getUserName());
+ rep.setIdentityProvider(socialLink.getIdentityProvider());
+ rep.setUserId(socialLink.getUserId());
+ return rep;
+ }
- public static UserSessionRepresentation toRepresentation(UserSessionModel session) {
- UserSessionRepresentation rep = new UserSessionRepresentation();
- rep.setId(session.getId());
- rep.setStart(((long)session.getStarted()) * 1000L);
- rep.setLastAccess(((long)session.getLastSessionRefresh())* 1000L);
- rep.setUser(session.getUser().getUsername());
- rep.setIpAddress(session.getIpAddress());
- for (ClientSessionModel clientSession : session.getClientSessions()) {
- ClientModel client = clientSession.getClient();
- if (client instanceof ApplicationModel) {
- rep.getApplications().put(client.getId(), client.getClientId());
- } else if (client instanceof OAuthClientModel) {
- rep.getClients().put(client.getId(), client.getClientId());
- }
- }
- return rep;
- }
+ public static UserSessionRepresentation toRepresentation(UserSessionModel session) {
+ UserSessionRepresentation rep = new UserSessionRepresentation();
+ rep.setId(session.getId());
+ rep.setStart(((long) session.getStarted()) * 1000L);
+ rep.setLastAccess(((long) session.getLastSessionRefresh()) * 1000L);
+ rep.setUser(session.getUser().getUsername());
+ rep.setIpAddress(session.getIpAddress());
+ for (ClientSessionModel clientSession : session.getClientSessions()) {
+ ClientModel client = clientSession.getClient();
+ if (client instanceof ApplicationModel) {
+ rep.getApplications().put(client.getId(), client.getClientId());
+ } else if (client instanceof OAuthClientModel) {
+ rep.getClients().put(client.getId(), client.getClientId());
+ }
+ }
+ return rep;
+ }
- public static ApplicationRepresentation toRepresentation(ApplicationModel applicationModel) {
- ApplicationRepresentation rep = new ApplicationRepresentation();
- rep.setId(applicationModel.getId());
- rep.setName(applicationModel.getName());
- rep.setEnabled(applicationModel.isEnabled());
- rep.setAdminUrl(applicationModel.getManagementUrl());
- rep.setPublicClient(applicationModel.isPublicClient());
- rep.setFrontchannelLogout(applicationModel.isFrontchannelLogout());
- rep.setProtocol(applicationModel.getProtocol());
- rep.setAttributes(applicationModel.getAttributes());
- rep.setFullScopeAllowed(applicationModel.isFullScopeAllowed());
- rep.setBearerOnly(applicationModel.isBearerOnly());
- rep.setSurrogateAuthRequired(applicationModel.isSurrogateAuthRequired());
- rep.setBaseUrl(applicationModel.getBaseUrl());
- rep.setNotBefore(applicationModel.getNotBefore());
- rep.setNodeReRegistrationTimeout(applicationModel.getNodeReRegistrationTimeout());
+ public static ApplicationRepresentation toRepresentation(ApplicationModel applicationModel) {
+ ApplicationRepresentation rep = new ApplicationRepresentation();
+ rep.setId(applicationModel.getId());
+ rep.setName(applicationModel.getName());
+ rep.setEnabled(applicationModel.isEnabled());
+ rep.setAdminUrl(applicationModel.getManagementUrl());
+ rep.setPublicClient(applicationModel.isPublicClient());
+ rep.setFrontchannelLogout(applicationModel.isFrontchannelLogout());
+ rep.setProtocol(applicationModel.getProtocol());
+ rep.setAttributes(applicationModel.getAttributes());
+ rep.setFullScopeAllowed(applicationModel.isFullScopeAllowed());
+ rep.setBearerOnly(applicationModel.isBearerOnly());
+ rep.setSurrogateAuthRequired(applicationModel.isSurrogateAuthRequired());
+ rep.setBaseUrl(applicationModel.getBaseUrl());
+ rep.setNotBefore(applicationModel.getNotBefore());
+ rep.setNodeReRegistrationTimeout(applicationModel.getNodeReRegistrationTimeout());
- Set redirectUris = applicationModel.getRedirectUris();
- if (redirectUris != null) {
- rep.setRedirectUris(new LinkedList(redirectUris));
- }
+ Set redirectUris = applicationModel.getRedirectUris();
+ if (redirectUris != null) {
+ rep.setRedirectUris(new LinkedList(redirectUris));
+ }
- Set webOrigins = applicationModel.getWebOrigins();
- if (webOrigins != null) {
- rep.setWebOrigins(new LinkedList(webOrigins));
- }
+ Set webOrigins = applicationModel.getWebOrigins();
+ if (webOrigins != null) {
+ rep.setWebOrigins(new LinkedList(webOrigins));
+ }
- if (!applicationModel.getDefaultRoles().isEmpty()) {
- rep.setDefaultRoles(applicationModel.getDefaultRoles().toArray(new String[0]));
- }
+ if (!applicationModel.getDefaultRoles().isEmpty()) {
+ rep.setDefaultRoles(applicationModel.getDefaultRoles().toArray(new String[0]));
+ }
- if (!applicationModel.getRegisteredNodes().isEmpty()) {
- rep.setRegisteredNodes(new HashMap(applicationModel.getRegisteredNodes()));
- }
+ if (!applicationModel.getRegisteredNodes().isEmpty()) {
+ rep.setRegisteredNodes(new HashMap(applicationModel.getRegisteredNodes()));
+ }
- if (!applicationModel.getIdentityProviders().isEmpty()) {
- rep.setIdentityProviders(toRepresentation(applicationModel.getIdentityProviders()));
- }
+ if (!applicationModel.getIdentityProviders().isEmpty()) {
+ rep.setIdentityProviders(toRepresentation(applicationModel.getIdentityProviders()));
+ }
- if (!applicationModel.getProtocolMappers().isEmpty()) {
- List mappings = new LinkedList();
- for (ProtocolMapperModel model : applicationModel.getProtocolMappers()) {
- mappings.add(toRepresentation(model));
- }
- rep.setProtocolMappers(mappings);
- }
+ if (!applicationModel.getProtocolMappers().isEmpty()) {
+ List mappings = new LinkedList();
+ for (ProtocolMapperModel model : applicationModel.getProtocolMappers()) {
+ mappings.add(toRepresentation(model));
+ }
+ rep.setProtocolMappers(mappings);
+ }
- return rep;
- }
+ return rep;
+ }
- private static List toRepresentation(List identityProviders) {
- ArrayList representations = new ArrayList();
+ private static List toRepresentation(
+ List identityProviders) {
+ ArrayList representations = new ArrayList();
- for (ClientIdentityProviderMappingModel model : identityProviders) {
- ClientIdentityProviderMappingRepresentation representation = new ClientIdentityProviderMappingRepresentation();
+ for (ClientIdentityProviderMappingModel model : identityProviders) {
+ ClientIdentityProviderMappingRepresentation representation = new ClientIdentityProviderMappingRepresentation();
- representation.setId(model.getIdentityProvider());
- representation.setRetrieveToken(model.isRetrieveToken());
+ representation.setId(model.getIdentityProvider());
+ representation.setRetrieveToken(model.isRetrieveToken());
- representations.add(representation);
- }
+ representations.add(representation);
+ }
- return representations;
- }
+ return representations;
+ }
- public static OAuthClientRepresentation toRepresentation(OAuthClientModel model) {
- OAuthClientRepresentation rep = new OAuthClientRepresentation();
- rep.setId(model.getId());
- rep.setName(model.getClientId());
- rep.setEnabled(model.isEnabled());
- rep.setPublicClient(model.isPublicClient());
- rep.setFrontchannelLogout(model.isFrontchannelLogout());
- rep.setProtocol(model.getProtocol());
- rep.setAttributes(model.getAttributes());
- rep.setFullScopeAllowed(model.isFullScopeAllowed());
- rep.setDirectGrantsOnly(model.isDirectGrantsOnly());
- Set redirectUris = model.getRedirectUris();
- if (redirectUris != null) {
- rep.setRedirectUris(new LinkedList(redirectUris));
- }
+ public static OAuthClientRepresentation toRepresentation(OAuthClientModel model) {
+ OAuthClientRepresentation rep = new OAuthClientRepresentation();
+ rep.setId(model.getId());
+ rep.setName(model.getClientId());
+ rep.setEnabled(model.isEnabled());
+ rep.setPublicClient(model.isPublicClient());
+ rep.setFrontchannelLogout(model.isFrontchannelLogout());
+ rep.setProtocol(model.getProtocol());
+ rep.setAttributes(model.getAttributes());
+ rep.setFullScopeAllowed(model.isFullScopeAllowed());
+ rep.setDirectGrantsOnly(model.isDirectGrantsOnly());
+ Set redirectUris = model.getRedirectUris();
+ if (redirectUris != null) {
+ rep.setRedirectUris(new LinkedList(redirectUris));
+ }
- Set webOrigins = model.getWebOrigins();
- if (webOrigins != null) {
- rep.setWebOrigins(new LinkedList(webOrigins));
- }
- rep.setNotBefore(model.getNotBefore());
+ Set webOrigins = model.getWebOrigins();
+ if (webOrigins != null) {
+ rep.setWebOrigins(new LinkedList(webOrigins));
+ }
+ rep.setNotBefore(model.getNotBefore());
- if (!model.getIdentityProviders().isEmpty()) {
- rep.setIdentityProviders(toRepresentation(model.getIdentityProviders()));
- }
+ if (!model.getIdentityProviders().isEmpty()) {
+ rep.setIdentityProviders(toRepresentation(model.getIdentityProviders()));
+ }
- if (!model.getProtocolMappers().isEmpty()) {
- List mappings = new LinkedList();
- for (ProtocolMapperModel mapper : model.getProtocolMappers()) {
- mappings.add(toRepresentation(mapper));
- }
- rep.setProtocolMappers(mappings);
- }
+ if (!model.getProtocolMappers().isEmpty()) {
+ List mappings = new LinkedList();
+ for (ProtocolMapperModel mapper : model.getProtocolMappers()) {
+ mappings.add(toRepresentation(mapper));
+ }
+ rep.setProtocolMappers(mappings);
+ }
- return rep;
- }
+ return rep;
+ }
- public static UserFederationProviderRepresentation toRepresentation(UserFederationProviderModel model) {
- UserFederationProviderRepresentation rep = new UserFederationProviderRepresentation();
- rep.setId(model.getId());
- rep.setConfig(model.getConfig());
- rep.setProviderName(model.getProviderName());
- rep.setPriority(model.getPriority());
- rep.setDisplayName(model.getDisplayName());
- rep.setFullSyncPeriod(model.getFullSyncPeriod());
- rep.setChangedSyncPeriod(model.getChangedSyncPeriod());
- rep.setLastSync(model.getLastSync());
- return rep;
- }
+ public static UserFederationProviderRepresentation toRepresentation(UserFederationProviderModel model) {
+ UserFederationProviderRepresentation rep = new UserFederationProviderRepresentation();
+ rep.setId(model.getId());
+ rep.setConfig(model.getConfig());
+ rep.setProviderName(model.getProviderName());
+ rep.setPriority(model.getPriority());
+ rep.setDisplayName(model.getDisplayName());
+ rep.setFullSyncPeriod(model.getFullSyncPeriod());
+ rep.setChangedSyncPeriod(model.getChangedSyncPeriod());
+ rep.setLastSync(model.getLastSync());
+ return rep;
+ }
- public static IdentityProviderRepresentation toRepresentation(IdentityProviderModel identityProviderModel) {
- IdentityProviderRepresentation providerRep = new IdentityProviderRepresentation();
+ public static IdentityProviderRepresentation toRepresentation(IdentityProviderModel identityProviderModel) {
+ IdentityProviderRepresentation providerRep = new IdentityProviderRepresentation();
- providerRep.setInternalId(identityProviderModel.getInternalId());
- providerRep.setProviderId(identityProviderModel.getProviderId());
- providerRep.setId(identityProviderModel.getId());
- providerRep.setName(identityProviderModel.getName());
- providerRep.setEnabled(identityProviderModel.isEnabled());
- providerRep.setStoreToken(identityProviderModel.isStoreToken());
- providerRep.setUpdateProfileFirstLogin(identityProviderModel.isUpdateProfileFirstLogin());
- providerRep.setAuthenticateByDefault(identityProviderModel.isAuthenticateByDefault());
- providerRep.setConfig(identityProviderModel.getConfig());
+ providerRep.setInternalId(identityProviderModel.getInternalId());
+ providerRep.setProviderId(identityProviderModel.getProviderId());
+ providerRep.setId(identityProviderModel.getId());
+ providerRep.setName(identityProviderModel.getName());
+ providerRep.setEnabled(identityProviderModel.isEnabled());
+ providerRep.setStoreToken(identityProviderModel.isStoreToken());
+ providerRep.setUpdateProfileFirstLogin(identityProviderModel.isUpdateProfileFirstLogin());
+ providerRep.setAuthenticateByDefault(identityProviderModel.isAuthenticateByDefault());
+ providerRep.setConfig(identityProviderModel.getConfig());
- return providerRep;
- }
+ return providerRep;
+ }
- public static ProtocolMapperRepresentation toRepresentation(ProtocolMapperModel model) {
- ProtocolMapperRepresentation rep = new ProtocolMapperRepresentation();
- rep.setId(model.getId());
- rep.setProtocol(model.getProtocol());
- Map config = new HashMap();
- config.putAll(model.getConfig());
- rep.setConfig(config);
- rep.setName(model.getName());
- rep.setProtocolMapper(model.getProtocolMapper());
- rep.setConsentText(model.getConsentText());
- rep.setConsentRequired(model.isConsentRequired());
- return rep;
- }
+ public static ProtocolMapperRepresentation toRepresentation(ProtocolMapperModel model) {
+ ProtocolMapperRepresentation rep = new ProtocolMapperRepresentation();
+ rep.setId(model.getId());
+ rep.setProtocol(model.getProtocol());
+ Map config = new HashMap();
+ config.putAll(model.getConfig());
+ rep.setConfig(config);
+ rep.setName(model.getName());
+ rep.setProtocolMapper(model.getProtocolMapper());
+ rep.setConsentText(model.getConsentText());
+ rep.setConsentRequired(model.isConsentRequired());
+ return rep;
+ }
}
diff --git a/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java b/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java
index 90b00dd196..3154ad4d8c 100755
--- a/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java
+++ b/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java
@@ -1,6 +1,16 @@
package org.keycloak.models.utils;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import net.iharder.Base64;
+
import org.jboss.logging.Logger;
import org.keycloak.enums.SslRequired;
import org.keycloak.models.ApplicationModel;
@@ -34,807 +44,904 @@ import org.keycloak.representations.idm.ScopeMappingRepresentation;
import org.keycloak.representations.idm.UserFederationProviderRepresentation;
import org.keycloak.representations.idm.UserRepresentation;
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
public class RepresentationToModel {
- private static Logger logger = Logger.getLogger(RepresentationToModel.class);
-
- public static void importRealm(KeycloakSession session, RealmRepresentation rep, RealmModel newRealm) {
- newRealm.setName(rep.getRealm());
- if (rep.isEnabled() != null) newRealm.setEnabled(rep.isEnabled());
- if (rep.isBruteForceProtected() != null) newRealm.setBruteForceProtected(rep.isBruteForceProtected());
- if (rep.getMaxFailureWaitSeconds() != null) newRealm.setMaxFailureWaitSeconds(rep.getMaxFailureWaitSeconds());
- if (rep.getMinimumQuickLoginWaitSeconds() != null) newRealm.setMinimumQuickLoginWaitSeconds(rep.getMinimumQuickLoginWaitSeconds());
- if (rep.getWaitIncrementSeconds() != null) newRealm.setWaitIncrementSeconds(rep.getWaitIncrementSeconds());
- if (rep.getQuickLoginCheckMilliSeconds() != null) newRealm.setQuickLoginCheckMilliSeconds(rep.getQuickLoginCheckMilliSeconds());
- if (rep.getMaxDeltaTimeSeconds() != null) newRealm.setMaxDeltaTimeSeconds(rep.getMaxDeltaTimeSeconds());
- if (rep.getFailureFactor() != null) newRealm.setFailureFactor(rep.getFailureFactor());
- if (rep.isEventsEnabled() != null) newRealm.setEventsEnabled(rep.isEventsEnabled());
- if (rep.getEventsExpiration() != null) newRealm.setEventsExpiration(rep.getEventsExpiration());
- if (rep.getEventsListeners() != null) newRealm.setEventsListeners(new HashSet(rep.getEventsListeners()));
-
- if (rep.getNotBefore() != null) newRealm.setNotBefore(rep.getNotBefore());
-
- if (rep.getAccessTokenLifespan() != null) newRealm.setAccessTokenLifespan(rep.getAccessTokenLifespan());
- else newRealm.setAccessTokenLifespan(300);
-
- if (rep.getSsoSessionIdleTimeout() != null) newRealm.setSsoSessionIdleTimeout(rep.getSsoSessionIdleTimeout());
- else newRealm.setSsoSessionIdleTimeout(1800);
- if (rep.getSsoSessionMaxLifespan() != null) newRealm.setSsoSessionMaxLifespan(rep.getSsoSessionMaxLifespan());
- else newRealm.setSsoSessionMaxLifespan(36000);
-
- if (rep.getAccessCodeLifespan() != null) newRealm.setAccessCodeLifespan(rep.getAccessCodeLifespan());
- else newRealm.setAccessCodeLifespan(60);
-
- if (rep.getAccessCodeLifespanUserAction() != null)
- newRealm.setAccessCodeLifespanUserAction(rep.getAccessCodeLifespanUserAction());
- else newRealm.setAccessCodeLifespanUserAction(300);
-
- if (rep.getAccessCodeLifespanLogin() != null)
- newRealm.setAccessCodeLifespanLogin(rep.getAccessCodeLifespanLogin());
- else newRealm.setAccessCodeLifespanLogin(1800);
-
- if (rep.getSslRequired() != null) newRealm.setSslRequired(SslRequired.valueOf(rep.getSslRequired().toUpperCase()));
- if (rep.isPasswordCredentialGrantAllowed() != null) newRealm.setPasswordCredentialGrantAllowed(rep.isPasswordCredentialGrantAllowed());
- if (rep.isRegistrationAllowed() != null) newRealm.setRegistrationAllowed(rep.isRegistrationAllowed());
- if (rep.isRememberMe() != null) newRealm.setRememberMe(rep.isRememberMe());
- if (rep.isVerifyEmail() != null) newRealm.setVerifyEmail(rep.isVerifyEmail());
- if (rep.isResetPasswordAllowed() != null) newRealm.setResetPasswordAllowed(rep.isResetPasswordAllowed());
- if (rep.getPrivateKey() == null || rep.getPublicKey() == null) {
- KeycloakModelUtils.generateRealmKeys(newRealm);
- } else {
- newRealm.setPrivateKeyPem(rep.getPrivateKey());
- newRealm.setPublicKeyPem(rep.getPublicKey());
- }
- if (rep.getCertificate() == null) {
- KeycloakModelUtils.generateRealmCertificate(newRealm);
- } else {
- newRealm.setCertificatePem(rep.getCertificate());
- }
- if (rep.getCodeSecret() == null) {
- newRealm.setCodeSecret(KeycloakModelUtils.generateCodeSecret());
- } else {
- newRealm.setCodeSecret(rep.getCodeSecret());
- }
-
- if (rep.getLoginTheme() != null) newRealm.setLoginTheme(rep.getLoginTheme());
- if (rep.getAccountTheme() != null) newRealm.setAccountTheme(rep.getAccountTheme());
- if (rep.getAdminTheme() != null) newRealm.setAdminTheme(rep.getAdminTheme());
- if (rep.getEmailTheme() != null) newRealm.setEmailTheme(rep.getEmailTheme());
-
- if (rep.getRequiredCredentials() != null) {
- for (String requiredCred : rep.getRequiredCredentials()) {
- addRequiredCredential(newRealm, requiredCred);
- }
- } else {
- addRequiredCredential(newRealm, CredentialRepresentation.PASSWORD);
- }
-
- if (rep.getPasswordPolicy() != null) newRealm.setPasswordPolicy(new PasswordPolicy(rep.getPasswordPolicy()));
-
- importIdentityProviders(rep, newRealm);
-
- if (rep.getApplications() != null) {
- Map appMap = createApplications(rep, newRealm);
- }
-
- if (rep.getRoles() != null) {
- if (rep.getRoles().getRealm() != null) { // realm roles
- for (RoleRepresentation roleRep : rep.getRoles().getRealm()) {
- createRole(newRealm, roleRep);
- }
- }
- if (rep.getRoles().getApplication() != null) {
- for (Map.Entry> entry : rep.getRoles().getApplication().entrySet()) {
- ApplicationModel app = newRealm.getApplicationByName(entry.getKey());
- if (app == null) {
- throw new RuntimeException("App doesn't exist in role definitions: " + entry.getKey());
- }
- for (RoleRepresentation roleRep : entry.getValue()) {
- // Application role may already exists (for example if it is defaultRole)
- RoleModel role = roleRep.getId()!=null ? app.addRole(roleRep.getId(), roleRep.getName()) : app.addRole(roleRep.getName());
- role.setDescription(roleRep.getDescription());
- }
- }
- }
- // now that all roles are created, re-iterate and set up composites
- if (rep.getRoles().getRealm() != null) { // realm roles
- for (RoleRepresentation roleRep : rep.getRoles().getRealm()) {
- RoleModel role = newRealm.getRole(roleRep.getName());
- addComposites(role, roleRep, newRealm);
- }
- }
- if (rep.getRoles().getApplication() != null) {
- for (Map.Entry> entry : rep.getRoles().getApplication().entrySet()) {
- ApplicationModel app = newRealm.getApplicationByName(entry.getKey());
- if (app == null) {
- throw new RuntimeException("App doesn't exist in role definitions: " + entry.getKey());
- }
- for (RoleRepresentation roleRep : entry.getValue()) {
- RoleModel role = app.getRole(roleRep.getName());
- addComposites(role, roleRep, newRealm);
- }
- }
- }
- }
-
- // Setup realm default roles
- if (rep.getDefaultRoles() != null) {
- for (String roleString : rep.getDefaultRoles()) {
- newRealm.addDefaultRole(roleString.trim());
- }
- }
- // Setup application default roles
- if (rep.getApplications() != null) {
- for (ApplicationRepresentation resourceRep : rep.getApplications()) {
- if (resourceRep.getDefaultRoles() != null) {
- ApplicationModel appModel = newRealm.getApplicationByName(resourceRep.getName());
- appModel.updateDefaultRoles(resourceRep.getDefaultRoles());
- }
- }
- }
-
- if (rep.getOauthClients() != null) {
- createOAuthClients(rep, newRealm);
- }
-
-
- // Now that all possible roles and applications are created, create scope mappings
-
- Map