Merge pull request #1468 from patriot1burke/master
required action import/export
This commit is contained in:
commit
a60ebb6210
3 changed files with 59 additions and 2 deletions
|
@ -46,6 +46,7 @@ public class RealmRepresentation {
|
||||||
protected String codeSecret;
|
protected String codeSecret;
|
||||||
protected RolesRepresentation roles;
|
protected RolesRepresentation roles;
|
||||||
protected List<String> defaultRoles;
|
protected List<String> defaultRoles;
|
||||||
|
@Deprecated
|
||||||
protected Set<String> requiredCredentials;
|
protected Set<String> requiredCredentials;
|
||||||
protected String passwordPolicy;
|
protected String passwordPolicy;
|
||||||
protected List<UserRepresentation> users;
|
protected List<UserRepresentation> users;
|
||||||
|
@ -78,6 +79,7 @@ public class RealmRepresentation {
|
||||||
protected String defaultLocale;
|
protected String defaultLocale;
|
||||||
protected List<AuthenticationFlowRepresentation> authenticationFlows;
|
protected List<AuthenticationFlowRepresentation> authenticationFlows;
|
||||||
protected List<AuthenticatorConfigRepresentation> authenticatorConfig;
|
protected List<AuthenticatorConfigRepresentation> authenticatorConfig;
|
||||||
|
protected List<RequiredActionProviderRepresentation> requiredActions;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected Boolean social;
|
protected Boolean social;
|
||||||
|
@ -187,11 +189,11 @@ public class RealmRepresentation {
|
||||||
scopeMappings.add(mapping);
|
scopeMappings.add(mapping);
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
@Deprecated
|
||||||
public Set<String> getRequiredCredentials() {
|
public Set<String> getRequiredCredentials() {
|
||||||
return requiredCredentials;
|
return requiredCredentials;
|
||||||
}
|
}
|
||||||
|
@Deprecated
|
||||||
public void setRequiredCredentials(Set<String> requiredCredentials) {
|
public void setRequiredCredentials(Set<String> requiredCredentials) {
|
||||||
this.requiredCredentials = requiredCredentials;
|
this.requiredCredentials = requiredCredentials;
|
||||||
}
|
}
|
||||||
|
@ -643,4 +645,12 @@ public class RealmRepresentation {
|
||||||
public void setAuthenticatorConfig(List<AuthenticatorConfigRepresentation> authenticatorConfig) {
|
public void setAuthenticatorConfig(List<AuthenticatorConfigRepresentation> authenticatorConfig) {
|
||||||
this.authenticatorConfig = authenticatorConfig;
|
this.authenticatorConfig = authenticatorConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RequiredActionProviderRepresentation> getRequiredActions() {
|
||||||
|
return requiredActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequiredActions(List<RequiredActionProviderRepresentation> requiredActions) {
|
||||||
|
this.requiredActions = requiredActions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.keycloak.models.IdentityProviderModel;
|
||||||
import org.keycloak.models.ModelException;
|
import org.keycloak.models.ModelException;
|
||||||
import org.keycloak.models.ProtocolMapperModel;
|
import org.keycloak.models.ProtocolMapperModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
|
import org.keycloak.models.RequiredActionProviderModel;
|
||||||
import org.keycloak.models.RequiredCredentialModel;
|
import org.keycloak.models.RequiredCredentialModel;
|
||||||
import org.keycloak.models.RoleModel;
|
import org.keycloak.models.RoleModel;
|
||||||
import org.keycloak.models.UserConsentModel;
|
import org.keycloak.models.UserConsentModel;
|
||||||
|
@ -31,6 +32,7 @@ import org.keycloak.representations.idm.IdentityProviderRepresentation;
|
||||||
import org.keycloak.representations.idm.ProtocolMapperRepresentation;
|
import org.keycloak.representations.idm.ProtocolMapperRepresentation;
|
||||||
import org.keycloak.representations.idm.RealmEventsConfigRepresentation;
|
import org.keycloak.representations.idm.RealmEventsConfigRepresentation;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
|
import org.keycloak.representations.idm.RequiredActionProviderRepresentation;
|
||||||
import org.keycloak.representations.idm.RoleRepresentation;
|
import org.keycloak.representations.idm.RoleRepresentation;
|
||||||
import org.keycloak.representations.idm.UserConsentRepresentation;
|
import org.keycloak.representations.idm.UserConsentRepresentation;
|
||||||
import org.keycloak.representations.idm.UserFederationMapperRepresentation;
|
import org.keycloak.representations.idm.UserFederationMapperRepresentation;
|
||||||
|
@ -193,6 +195,7 @@ public class ModelToRepresentation {
|
||||||
rep.setDefaultLocale(realm.getDefaultLocale());
|
rep.setDefaultLocale(realm.getDefaultLocale());
|
||||||
if (internal) {
|
if (internal) {
|
||||||
exportAuthenticationFlows(realm, rep);
|
exportAuthenticationFlows(realm, rep);
|
||||||
|
exportRequiredActions(realm, rep);
|
||||||
}
|
}
|
||||||
return rep;
|
return rep;
|
||||||
}
|
}
|
||||||
|
@ -210,6 +213,14 @@ public class ModelToRepresentation {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void exportRequiredActions(RealmModel realm, RealmRepresentation rep) {
|
||||||
|
rep.setRequiredActions(new LinkedList<RequiredActionProviderRepresentation>());
|
||||||
|
for (RequiredActionProviderModel model : realm.getRequiredActionProviders()) {
|
||||||
|
RequiredActionProviderRepresentation action = toRepresentation(model);
|
||||||
|
rep.getRequiredActions().add(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static RealmEventsConfigRepresentation toEventsConfigReprensetation(RealmModel realm) {
|
public static RealmEventsConfigRepresentation toEventsConfigReprensetation(RealmModel realm) {
|
||||||
RealmEventsConfigRepresentation rep = new RealmEventsConfigRepresentation();
|
RealmEventsConfigRepresentation rep = new RealmEventsConfigRepresentation();
|
||||||
|
@ -468,5 +479,20 @@ public class ModelToRepresentation {
|
||||||
return rep;
|
return rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RequiredActionProviderRepresentation toRepresentation(RequiredActionProviderModel model) {
|
||||||
|
RequiredActionProviderRepresentation rep = new RequiredActionProviderRepresentation();
|
||||||
|
rep.setAlias(model.getAlias());
|
||||||
|
rep.setDefaultAction(model.isDefaultAction());
|
||||||
|
rep.setEnabled(model.isEnabled());
|
||||||
|
rep.setConfig(model.getConfig());
|
||||||
|
rep.setName(model.getName());
|
||||||
|
rep.setProviderId(model.getProviderId());
|
||||||
|
return rep;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.keycloak.models.ModelException;
|
||||||
import org.keycloak.models.PasswordPolicy;
|
import org.keycloak.models.PasswordPolicy;
|
||||||
import org.keycloak.models.ProtocolMapperModel;
|
import org.keycloak.models.ProtocolMapperModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
|
import org.keycloak.models.RequiredActionProviderModel;
|
||||||
import org.keycloak.models.RoleModel;
|
import org.keycloak.models.RoleModel;
|
||||||
import org.keycloak.models.UserConsentModel;
|
import org.keycloak.models.UserConsentModel;
|
||||||
import org.keycloak.models.UserCredentialModel;
|
import org.keycloak.models.UserCredentialModel;
|
||||||
|
@ -38,6 +39,7 @@ import org.keycloak.representations.idm.IdentityProviderRepresentation;
|
||||||
import org.keycloak.representations.idm.OAuthClientRepresentation;
|
import org.keycloak.representations.idm.OAuthClientRepresentation;
|
||||||
import org.keycloak.representations.idm.ProtocolMapperRepresentation;
|
import org.keycloak.representations.idm.ProtocolMapperRepresentation;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
|
import org.keycloak.representations.idm.RequiredActionProviderRepresentation;
|
||||||
import org.keycloak.representations.idm.RoleRepresentation;
|
import org.keycloak.representations.idm.RoleRepresentation;
|
||||||
import org.keycloak.representations.idm.ScopeMappingRepresentation;
|
import org.keycloak.representations.idm.ScopeMappingRepresentation;
|
||||||
import org.keycloak.representations.idm.SocialLinkRepresentation;
|
import org.keycloak.representations.idm.SocialLinkRepresentation;
|
||||||
|
@ -297,6 +299,14 @@ public class RepresentationToModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
importAuthenticationFlows(newRealm, rep);
|
importAuthenticationFlows(newRealm, rep);
|
||||||
|
if (rep.getRequiredActions() != null) {
|
||||||
|
for (RequiredActionProviderRepresentation action : rep.getRequiredActions()) {
|
||||||
|
RequiredActionProviderModel model = toModel(action);
|
||||||
|
newRealm.addRequiredActionProvider(model);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DefaultRequiredActions.addActions(newRealm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void importAuthenticationFlows(RealmModel newRealm, RealmRepresentation rep) {
|
public static void importAuthenticationFlows(RealmModel newRealm, RealmRepresentation rep) {
|
||||||
|
@ -1075,5 +1085,16 @@ public class RepresentationToModel {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RequiredActionProviderModel toModel(RequiredActionProviderRepresentation rep) {
|
||||||
|
RequiredActionProviderModel model = new RequiredActionProviderModel();
|
||||||
|
model.setConfig(rep.getConfig());
|
||||||
|
model.setDefaultAction(rep.isDefaultAction());
|
||||||
|
model.setEnabled(rep.isEnabled());
|
||||||
|
model.setProviderId(rep.getProviderId());
|
||||||
|
model.setName(rep.getName());
|
||||||
|
model.setAlias(rep.getAlias());
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue