commit
da2590819d
12 changed files with 405 additions and 16 deletions
|
@ -0,0 +1,87 @@
|
|||
package org.keycloak.representations.idm;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
*/
|
||||
public class AuthenticationExecutionRepresentation implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String authenticatorConfig;
|
||||
private String authenticator;
|
||||
private String flowAlias;
|
||||
private boolean autheticatorFlow;
|
||||
private String requirement;
|
||||
private boolean userSetupAllowed;
|
||||
private int priority;
|
||||
|
||||
public String getAuthenticatorConfig() {
|
||||
return authenticatorConfig;
|
||||
}
|
||||
|
||||
public void setAuthenticatorConfig(String authenticatorConfig) {
|
||||
this.authenticatorConfig = authenticatorConfig;
|
||||
}
|
||||
|
||||
public String getAuthenticator() {
|
||||
return authenticator;
|
||||
}
|
||||
|
||||
public void setAuthenticator(String authenticator) {
|
||||
this.authenticator = authenticator;
|
||||
}
|
||||
|
||||
public String getRequirement() {
|
||||
return requirement;
|
||||
}
|
||||
|
||||
public void setRequirement(String requirement) {
|
||||
this.requirement = requirement;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public boolean isUserSetupAllowed() {
|
||||
return userSetupAllowed;
|
||||
}
|
||||
|
||||
public void setUserSetupAllowed(boolean userSetupAllowed) {
|
||||
this.userSetupAllowed = userSetupAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this execution is a flow, this is the flowId pointing to an AuthenticationFlowModel
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getFlowAlias() {
|
||||
return flowAlias;
|
||||
}
|
||||
|
||||
public void setFlowAlias(String flowId) {
|
||||
this.flowAlias = flowId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the referenced authenticator a flow?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isAutheticatorFlow() {
|
||||
return autheticatorFlow;
|
||||
}
|
||||
|
||||
public void setAutheticatorFlow(boolean autheticatorFlow) {
|
||||
this.autheticatorFlow = autheticatorFlow;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package org.keycloak.representations.idm;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
*/
|
||||
public class AuthenticationFlowRepresentation implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String alias;
|
||||
private String description;
|
||||
private String providerId;
|
||||
private boolean topLevel;
|
||||
private boolean builtIn;
|
||||
protected List<AuthenticationExecutionRepresentation> authenticationExecutions;
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getProviderId() {
|
||||
return providerId;
|
||||
}
|
||||
|
||||
public void setProviderId(String providerId) {
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public boolean isTopLevel() {
|
||||
return topLevel;
|
||||
}
|
||||
|
||||
public void setTopLevel(boolean topLevel) {
|
||||
this.topLevel = topLevel;
|
||||
}
|
||||
|
||||
public boolean isBuiltIn() {
|
||||
return builtIn;
|
||||
}
|
||||
|
||||
public void setBuiltIn(boolean builtIn) {
|
||||
this.builtIn = builtIn;
|
||||
}
|
||||
|
||||
public List<AuthenticationExecutionRepresentation> getAuthenticationExecutions() {
|
||||
return authenticationExecutions;
|
||||
}
|
||||
|
||||
public void setAuthenticationExecutions(List<AuthenticationExecutionRepresentation> authenticationExecutions) {
|
||||
this.authenticationExecutions = authenticationExecutions;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.keycloak.representations.idm;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
*/
|
||||
public class AuthenticatorConfigRepresentation implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String alias;
|
||||
private Map<String, String> config = new HashMap<String, String>();
|
||||
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Map<String, String> getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(Map<String, String> config) {
|
||||
this.config = config;
|
||||
}
|
||||
}
|
|
@ -76,6 +76,8 @@ public class RealmRepresentation {
|
|||
protected Boolean internationalizationEnabled;
|
||||
protected Set<String> supportedLocales;
|
||||
protected String defaultLocale;
|
||||
protected List<AuthenticationFlowRepresentation> authenticationFlows;
|
||||
protected List<AuthenticatorConfigRepresentation> authenticatorConfig;
|
||||
|
||||
@Deprecated
|
||||
protected Boolean social;
|
||||
|
@ -626,5 +628,19 @@ public class RealmRepresentation {
|
|||
identityProviderMappers.add(rep);
|
||||
}
|
||||
|
||||
public List<AuthenticationFlowRepresentation> getAuthenticationFlows() {
|
||||
return authenticationFlows;
|
||||
}
|
||||
|
||||
public void setAuthenticationFlows(List<AuthenticationFlowRepresentation> authenticationFlows) {
|
||||
this.authenticationFlows = authenticationFlows;
|
||||
}
|
||||
|
||||
public List<AuthenticatorConfigRepresentation> getAuthenticatorConfig() {
|
||||
return authenticatorConfig;
|
||||
}
|
||||
|
||||
public void setAuthenticatorConfig(List<AuthenticatorConfigRepresentation> authenticatorConfig) {
|
||||
this.authenticatorConfig = authenticatorConfig;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,6 +198,7 @@ public interface RealmModel extends RoleContainerModel {
|
|||
void updateAuthenticatorConfig(AuthenticatorConfigModel model);
|
||||
void removeAuthenticatorConfig(AuthenticatorConfigModel model);
|
||||
AuthenticatorConfigModel getAuthenticatorConfigById(String id);
|
||||
AuthenticatorConfigModel getAuthenticatorConfigByAlias(String alias);
|
||||
|
||||
List<RequiredActionProviderModel> getRequiredActionProviders();
|
||||
RequiredActionProviderModel addRequiredActionProvider(RequiredActionProviderModel model);
|
||||
|
|
|
@ -20,9 +20,8 @@ public class DefaultAuthenticationFlows {
|
|||
public static final String LOGIN_FORMS_FLOW = "forms";
|
||||
|
||||
public static void addFlows(RealmModel realm) {
|
||||
browserFlow(realm);
|
||||
registrationFlow(realm);
|
||||
|
||||
if (realm.getFlowByAlias(BROWSER_FLOW) == null) browserFlow(realm);
|
||||
if (realm.getFlowByAlias(REGISTRATION_FLOW) == null) registrationFlow(realm);
|
||||
}
|
||||
|
||||
public static void registrationFlow(RealmModel realm) {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.keycloak.models.utils;
|
||||
|
||||
import org.keycloak.models.AuthenticationExecutionModel;
|
||||
import org.keycloak.models.AuthenticationFlowModel;
|
||||
import org.keycloak.models.AuthenticatorConfigModel;
|
||||
import org.keycloak.models.ClientModel;
|
||||
import org.keycloak.models.ClientSessionModel;
|
||||
import org.keycloak.models.FederatedIdentityModel;
|
||||
|
@ -17,6 +20,9 @@ import org.keycloak.models.UserFederationProviderModel;
|
|||
import org.keycloak.models.UserModel;
|
||||
import org.keycloak.models.UserSessionModel;
|
||||
|
||||
import org.keycloak.representations.idm.AuthenticationExecutionRepresentation;
|
||||
import org.keycloak.representations.idm.AuthenticationFlowRepresentation;
|
||||
import org.keycloak.representations.idm.AuthenticatorConfigRepresentation;
|
||||
import org.keycloak.representations.idm.ClientRepresentation;
|
||||
import org.keycloak.representations.idm.CredentialRepresentation;
|
||||
import org.keycloak.representations.idm.FederatedIdentityRepresentation;
|
||||
|
@ -31,7 +37,6 @@ import org.keycloak.representations.idm.UserFederationMapperRepresentation;
|
|||
import org.keycloak.representations.idm.UserFederationProviderRepresentation;
|
||||
import org.keycloak.representations.idm.UserRepresentation;
|
||||
import org.keycloak.representations.idm.UserSessionRepresentation;
|
||||
import org.keycloak.util.MultivaluedHashMap;
|
||||
import org.keycloak.util.Time;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -183,10 +188,26 @@ public class ModelToRepresentation {
|
|||
rep.setInternationalizationEnabled(realm.isInternationalizationEnabled());
|
||||
rep.getSupportedLocales().addAll(realm.getSupportedLocales());
|
||||
rep.setDefaultLocale(realm.getDefaultLocale());
|
||||
|
||||
if (internal) {
|
||||
exportAuthenticationFlows(realm, rep);
|
||||
}
|
||||
return rep;
|
||||
}
|
||||
|
||||
public static void exportAuthenticationFlows(RealmModel realm, RealmRepresentation rep) {
|
||||
rep.setAuthenticationFlows(new LinkedList<AuthenticationFlowRepresentation>());
|
||||
rep.setAuthenticatorConfig(new LinkedList<AuthenticatorConfigRepresentation>());
|
||||
for (AuthenticationFlowModel model : realm.getAuthenticationFlows()) {
|
||||
AuthenticationFlowRepresentation flowRep = toRepresentation(realm, model);
|
||||
rep.getAuthenticationFlows().add(flowRep);
|
||||
}
|
||||
for (AuthenticatorConfigModel model : realm.getAuthenticatorConfigs()) {
|
||||
rep.getAuthenticatorConfig().add(toRepresentation(model));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static RealmEventsConfigRepresentation toEventsConfigReprensetation(RealmModel realm) {
|
||||
RealmEventsConfigRepresentation rep = new RealmEventsConfigRepresentation();
|
||||
rep.setEventsEnabled(realm.isEventsEnabled());
|
||||
|
@ -404,4 +425,45 @@ public class ModelToRepresentation {
|
|||
return consentRep;
|
||||
}
|
||||
|
||||
public static AuthenticationFlowRepresentation toRepresentation(RealmModel realm, AuthenticationFlowModel model) {
|
||||
AuthenticationFlowRepresentation rep = new AuthenticationFlowRepresentation();
|
||||
rep.setBuiltIn(model.isBuiltIn());
|
||||
rep.setTopLevel(model.isTopLevel());
|
||||
rep.setProviderId(model.getProviderId());
|
||||
rep.setAlias(model.getAlias());
|
||||
rep.setDescription(model.getDescription());
|
||||
rep.setAuthenticationExecutions(new LinkedList<AuthenticationExecutionRepresentation>());
|
||||
for (AuthenticationExecutionModel execution : realm.getAuthenticationExecutions(model.getId())) {
|
||||
rep.getAuthenticationExecutions().add(toRepresentation(realm, execution));
|
||||
}
|
||||
return rep;
|
||||
|
||||
}
|
||||
|
||||
public static AuthenticationExecutionRepresentation toRepresentation(RealmModel realm, AuthenticationExecutionModel model) {
|
||||
AuthenticationExecutionRepresentation rep = new AuthenticationExecutionRepresentation();
|
||||
if (model.getAuthenticatorConfig() != null) {
|
||||
AuthenticatorConfigModel config = realm.getAuthenticatorConfigById(model.getAuthenticatorConfig());
|
||||
rep.setAuthenticatorConfig(config.getAlias());
|
||||
}
|
||||
rep.setAuthenticator(model.getAuthenticator());
|
||||
rep.setAutheticatorFlow(model.isAutheticatorFlow());
|
||||
if (model.getFlowId() != null) {
|
||||
AuthenticationFlowModel flow = realm.getAuthenticationFlowById(model.getFlowId());
|
||||
rep.setFlowAlias(flow.getAlias());
|
||||
}
|
||||
rep.setPriority(model.getPriority());
|
||||
rep.setUserSetupAllowed(model.isUserSetupAllowed());
|
||||
rep.setRequirement(model.getRequirement().name());
|
||||
return rep;
|
||||
}
|
||||
|
||||
public static AuthenticatorConfigRepresentation toRepresentation(AuthenticatorConfigModel model) {
|
||||
AuthenticatorConfigRepresentation rep = new AuthenticatorConfigRepresentation();
|
||||
rep.setAlias(model.getAlias());
|
||||
rep.setConfig(model.getConfig());
|
||||
return rep;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ import net.iharder.Base64;
|
|||
import org.jboss.logging.Logger;
|
||||
import org.keycloak.enums.SslRequired;
|
||||
import org.keycloak.migration.MigrationProvider;
|
||||
import org.keycloak.models.AuthenticationExecutionModel;
|
||||
import org.keycloak.models.AuthenticationFlowModel;
|
||||
import org.keycloak.models.AuthenticatorConfigModel;
|
||||
import org.keycloak.models.BrowserSecurityHeaders;
|
||||
import org.keycloak.models.ClaimMask;
|
||||
import org.keycloak.models.ClientModel;
|
||||
|
@ -23,6 +26,9 @@ import org.keycloak.models.UserFederationMapperModel;
|
|||
import org.keycloak.models.UserFederationProviderModel;
|
||||
import org.keycloak.models.UserModel;
|
||||
import org.keycloak.representations.idm.ApplicationRepresentation;
|
||||
import org.keycloak.representations.idm.AuthenticationExecutionRepresentation;
|
||||
import org.keycloak.representations.idm.AuthenticationFlowRepresentation;
|
||||
import org.keycloak.representations.idm.AuthenticatorConfigRepresentation;
|
||||
import org.keycloak.representations.idm.ClaimRepresentation;
|
||||
import org.keycloak.representations.idm.ClientRepresentation;
|
||||
import org.keycloak.representations.idm.CredentialRepresentation;
|
||||
|
@ -288,6 +294,33 @@ public class RepresentationToModel {
|
|||
if(rep.getDefaultLocale() != null){
|
||||
newRealm.setDefaultLocale(rep.getDefaultLocale());
|
||||
}
|
||||
|
||||
importAuthenticationFlows(newRealm, rep);
|
||||
}
|
||||
|
||||
public static void importAuthenticationFlows(RealmModel newRealm, RealmRepresentation rep) {
|
||||
if (rep.getAuthenticationFlows() == null) {
|
||||
// assume this is an old version being imported
|
||||
DefaultAuthenticationFlows.addFlows(newRealm);
|
||||
} else {
|
||||
for (AuthenticatorConfigRepresentation configRep : rep.getAuthenticatorConfig()) {
|
||||
AuthenticatorConfigModel model = toModel(configRep);
|
||||
newRealm.addAuthenticatorConfig(model);
|
||||
}
|
||||
for (AuthenticationFlowRepresentation flowRep : rep.getAuthenticationFlows()) {
|
||||
AuthenticationFlowModel model = toModel(flowRep);
|
||||
model = newRealm.addAuthenticationFlow(model);
|
||||
}
|
||||
for (AuthenticationFlowRepresentation flowRep : rep.getAuthenticationFlows()) {
|
||||
AuthenticationFlowModel model = newRealm.getFlowByAlias(flowRep.getAlias());
|
||||
for (AuthenticationExecutionRepresentation exeRep : flowRep.getAuthenticationExecutions()) {
|
||||
AuthenticationExecutionModel execution = toModel(newRealm, exeRep);
|
||||
execution.setParentFlow(model.getId());
|
||||
newRealm.addAuthenticatorExecution(execution);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void convertDeprecatedSocialProviders(RealmRepresentation rep) {
|
||||
|
@ -921,7 +954,7 @@ public class RepresentationToModel {
|
|||
}
|
||||
}
|
||||
}
|
||||
public static IdentityProviderModel toModel(IdentityProviderRepresentation representation) {
|
||||
public static IdentityProviderModel toModel(IdentityProviderRepresentation representation) {
|
||||
IdentityProviderModel identityProviderModel = new IdentityProviderModel();
|
||||
|
||||
identityProviderModel.setInternalId(representation.getInternalId());
|
||||
|
@ -1009,4 +1042,41 @@ public class RepresentationToModel {
|
|||
return consentModel;
|
||||
}
|
||||
|
||||
public static AuthenticationFlowModel toModel(AuthenticationFlowRepresentation rep) {
|
||||
AuthenticationFlowModel model = new AuthenticationFlowModel();
|
||||
model.setBuiltIn(rep.isBuiltIn());
|
||||
model.setTopLevel(rep.isTopLevel());
|
||||
model.setProviderId(rep.getProviderId());
|
||||
model.setAlias(rep.getAlias());
|
||||
model.setDescription(rep.getDescription());
|
||||
return model;
|
||||
|
||||
}
|
||||
|
||||
public static AuthenticationExecutionModel toModel(RealmModel realm, AuthenticationExecutionRepresentation rep) {
|
||||
AuthenticationExecutionModel model = new AuthenticationExecutionModel();
|
||||
if (rep.getAuthenticatorConfig() != null) {
|
||||
AuthenticatorConfigModel config = realm.getAuthenticatorConfigByAlias(rep.getAuthenticatorConfig());
|
||||
model.setAuthenticatorConfig(config.getId());
|
||||
}
|
||||
model.setAuthenticator(rep.getAuthenticator());
|
||||
model.setAutheticatorFlow(rep.isAutheticatorFlow());
|
||||
if (rep.getFlowAlias() != null) {
|
||||
AuthenticationFlowModel flow = realm.getFlowByAlias(rep.getFlowAlias());
|
||||
model.setFlowId(flow.getId());
|
||||
}
|
||||
model.setPriority(rep.getPriority());
|
||||
model.setUserSetupAllowed(rep.isUserSetupAllowed());
|
||||
model.setRequirement(AuthenticationExecutionModel.Requirement.valueOf(rep.getRequirement()));
|
||||
return model;
|
||||
}
|
||||
|
||||
public static AuthenticatorConfigModel toModel(AuthenticatorConfigRepresentation rep) {
|
||||
AuthenticatorConfigModel model = new AuthenticatorConfigModel();
|
||||
model.setAlias(rep.getAlias());
|
||||
model.setConfig(rep.getConfig());
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1278,7 +1278,8 @@ public class RealmAdapter implements RealmModel {
|
|||
@Override
|
||||
public AuthenticationFlowModel addAuthenticationFlow(AuthenticationFlowModel model) {
|
||||
AuthenticationFlowEntity entity = new AuthenticationFlowEntity();
|
||||
entity.setId(KeycloakModelUtils.generateId());
|
||||
String id = (model.getId() == null) ? KeycloakModelUtils.generateId(): model.getId();
|
||||
entity.setId(id);
|
||||
entity.setAlias(model.getAlias());
|
||||
entity.setDescription(model.getDescription());
|
||||
entity.setProviderId(model.getProviderId());
|
||||
|
@ -1339,7 +1340,8 @@ public class RealmAdapter implements RealmModel {
|
|||
@Override
|
||||
public AuthenticationExecutionModel addAuthenticatorExecution(AuthenticationExecutionModel model) {
|
||||
AuthenticationExecutionEntity entity = new AuthenticationExecutionEntity();
|
||||
entity.setId(KeycloakModelUtils.generateId());
|
||||
String id = (model.getId() == null) ? KeycloakModelUtils.generateId(): model.getId();
|
||||
entity.setId(id);
|
||||
entity.setAuthenticator(model.getAuthenticator());
|
||||
entity.setPriority(model.getPriority());
|
||||
entity.setRequirement(model.getRequirement());
|
||||
|
@ -1396,10 +1398,22 @@ public class RealmAdapter implements RealmModel {
|
|||
return authenticators;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticatorConfigModel getAuthenticatorConfigByAlias(String alias) {
|
||||
for (AuthenticatorConfigModel config : getAuthenticatorConfigs()) {
|
||||
if (config.getAlias().equals(alias)) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AuthenticatorConfigModel addAuthenticatorConfig(AuthenticatorConfigModel model) {
|
||||
AuthenticatorConfigEntity auth = new AuthenticatorConfigEntity();
|
||||
auth.setId(KeycloakModelUtils.generateId());
|
||||
String id = (model.getId() == null) ? KeycloakModelUtils.generateId(): model.getId();
|
||||
auth.setId(id);
|
||||
auth.setAlias(model.getAlias());
|
||||
auth.setConfig(model.getConfig());
|
||||
realm.getAuthenticatorConfigs().add(auth);
|
||||
|
|
|
@ -1035,6 +1035,17 @@ public class RealmAdapter implements RealmModel {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticatorConfigModel getAuthenticatorConfigByAlias(String alias) {
|
||||
for (AuthenticatorConfigModel config : getAuthenticatorConfigs()) {
|
||||
if (config.getAlias().equals(alias)) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AuthenticationFlowModel addAuthenticationFlow(AuthenticationFlowModel model) {
|
||||
getDelegateForUpdate();
|
||||
|
|
|
@ -1537,6 +1537,15 @@ public class RealmAdapter implements RealmModel {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticatorConfigModel getAuthenticatorConfigByAlias(String alias) {
|
||||
for (AuthenticatorConfigModel config : getAuthenticatorConfigs()) {
|
||||
if (config.getAlias().equals(alias)) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected AuthenticationFlowModel entityToModel(AuthenticationFlowEntity entity) {
|
||||
AuthenticationFlowModel model = new AuthenticationFlowModel();
|
||||
|
@ -1579,7 +1588,8 @@ public class RealmAdapter implements RealmModel {
|
|||
@Override
|
||||
public AuthenticationFlowModel addAuthenticationFlow(AuthenticationFlowModel model) {
|
||||
AuthenticationFlowEntity entity = new AuthenticationFlowEntity();
|
||||
entity.setId(KeycloakModelUtils.generateId());
|
||||
String id = (model.getId() == null) ? KeycloakModelUtils.generateId(): model.getId();
|
||||
entity.setId(id);
|
||||
entity.setAlias(model.getAlias());
|
||||
entity.setDescription(model.getDescription());
|
||||
entity.setProviderId(model.getProviderId());
|
||||
|
@ -1633,7 +1643,8 @@ public class RealmAdapter implements RealmModel {
|
|||
@Override
|
||||
public AuthenticationExecutionModel addAuthenticatorExecution(AuthenticationExecutionModel model) {
|
||||
AuthenticationExecutionEntity entity = new AuthenticationExecutionEntity();
|
||||
entity.setId(KeycloakModelUtils.generateId());
|
||||
String id = (model.getId() == null) ? KeycloakModelUtils.generateId(): model.getId();
|
||||
entity.setId(id);
|
||||
entity.setAuthenticator(model.getAuthenticator());
|
||||
entity.setPriority(model.getPriority());
|
||||
entity.setFlowId(model.getFlowId());
|
||||
|
@ -1678,7 +1689,8 @@ public class RealmAdapter implements RealmModel {
|
|||
@Override
|
||||
public AuthenticatorConfigModel addAuthenticatorConfig(AuthenticatorConfigModel model) {
|
||||
AuthenticatorConfigEntity auth = new AuthenticatorConfigEntity();
|
||||
auth.setId(KeycloakModelUtils.generateId());
|
||||
String id = (model.getId() == null) ? KeycloakModelUtils.generateId(): model.getId();
|
||||
auth.setId(id);
|
||||
auth.setAlias(model.getAlias());
|
||||
auth.setRealm(realm);
|
||||
auth.setConfig(model.getConfig());
|
||||
|
@ -1742,7 +1754,8 @@ public class RealmAdapter implements RealmModel {
|
|||
@Override
|
||||
public RequiredActionProviderModel addRequiredActionProvider(RequiredActionProviderModel model) {
|
||||
RequiredActionProviderEntity auth = new RequiredActionProviderEntity();
|
||||
auth.setId(KeycloakModelUtils.generateId());
|
||||
String id = (model.getId() == null) ? KeycloakModelUtils.generateId(): model.getId();
|
||||
auth.setId(id);
|
||||
auth.setAlias(model.getAlias());
|
||||
auth.setName(model.getName());
|
||||
auth.setRealm(realm);
|
||||
|
|
|
@ -1352,7 +1352,8 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
|||
@Override
|
||||
public AuthenticationFlowModel addAuthenticationFlow(AuthenticationFlowModel model) {
|
||||
AuthenticationFlowEntity entity = new AuthenticationFlowEntity();
|
||||
entity.setId(KeycloakModelUtils.generateId());
|
||||
String id = (model.getId() == null) ? KeycloakModelUtils.generateId(): model.getId();
|
||||
entity.setId(id);
|
||||
entity.setAlias(model.getAlias());
|
||||
entity.setDescription(model.getDescription());
|
||||
entity.setProviderId(model.getProviderId());
|
||||
|
@ -1414,7 +1415,8 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
|||
@Override
|
||||
public AuthenticationExecutionModel addAuthenticatorExecution(AuthenticationExecutionModel model) {
|
||||
AuthenticationExecutionEntity entity = new AuthenticationExecutionEntity();
|
||||
entity.setId(KeycloakModelUtils.generateId());
|
||||
String id = (model.getId() == null) ? KeycloakModelUtils.generateId(): model.getId();
|
||||
entity.setId(id);
|
||||
entity.setAuthenticator(model.getAuthenticator());
|
||||
entity.setPriority(model.getPriority());
|
||||
entity.setRequirement(model.getRequirement());
|
||||
|
@ -1475,10 +1477,22 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
|||
return authenticators;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticatorConfigModel getAuthenticatorConfigByAlias(String alias) {
|
||||
for (AuthenticatorConfigModel config : getAuthenticatorConfigs()) {
|
||||
if (config.getAlias().equals(alias)) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AuthenticatorConfigModel addAuthenticatorConfig(AuthenticatorConfigModel model) {
|
||||
AuthenticatorConfigEntity auth = new AuthenticatorConfigEntity();
|
||||
auth.setId(KeycloakModelUtils.generateId());
|
||||
String id = (model.getId() == null) ? KeycloakModelUtils.generateId(): model.getId();
|
||||
auth.setId(id);
|
||||
auth.setAlias(model.getAlias());
|
||||
auth.setConfig(model.getConfig());
|
||||
realm.getAuthenticatorConfigs().add(auth);
|
||||
|
|
Loading…
Reference in a new issue