fix problems
This commit is contained in:
parent
b3eadcc990
commit
d74d93a522
10 changed files with 85 additions and 50 deletions
|
@ -12,7 +12,7 @@ public class AuthenticationExecutionRepresentation implements Serializable {
|
||||||
|
|
||||||
private String authenticatorConfig;
|
private String authenticatorConfig;
|
||||||
private String authenticator;
|
private String authenticator;
|
||||||
private String flowId;
|
private String flowAlias;
|
||||||
private boolean autheticatorFlow;
|
private boolean autheticatorFlow;
|
||||||
private String requirement;
|
private String requirement;
|
||||||
private boolean userSetupAllowed;
|
private boolean userSetupAllowed;
|
||||||
|
@ -63,12 +63,12 @@ public class AuthenticationExecutionRepresentation implements Serializable {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getFlowId() {
|
public String getFlowAlias() {
|
||||||
return flowId;
|
return flowAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlowId(String flowId) {
|
public void setFlowAlias(String flowId) {
|
||||||
this.flowId = flowId;
|
this.flowAlias = flowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,7 +10,6 @@ import java.util.List;
|
||||||
public class AuthenticationFlowRepresentation implements Serializable {
|
public class AuthenticationFlowRepresentation implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String id;
|
|
||||||
private String alias;
|
private String alias;
|
||||||
private String description;
|
private String description;
|
||||||
private String providerId;
|
private String providerId;
|
||||||
|
@ -18,14 +17,6 @@ public class AuthenticationFlowRepresentation implements Serializable {
|
||||||
private boolean builtIn;
|
private boolean builtIn;
|
||||||
protected List<AuthenticationExecutionRepresentation> authenticationExecutions;
|
protected List<AuthenticationExecutionRepresentation> authenticationExecutions;
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAlias() {
|
public String getAlias() {
|
||||||
return alias;
|
return alias;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,19 +11,10 @@ import java.util.Map;
|
||||||
public class AuthenticatorConfigRepresentation implements Serializable {
|
public class AuthenticatorConfigRepresentation implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String id;
|
|
||||||
private String alias;
|
private String alias;
|
||||||
private Map<String, String> config = new HashMap<String, String>();
|
private Map<String, String> config = new HashMap<String, String>();
|
||||||
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAlias() {
|
public String getAlias() {
|
||||||
return alias;
|
return alias;
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,7 @@ public interface RealmModel extends RoleContainerModel {
|
||||||
void updateAuthenticatorConfig(AuthenticatorConfigModel model);
|
void updateAuthenticatorConfig(AuthenticatorConfigModel model);
|
||||||
void removeAuthenticatorConfig(AuthenticatorConfigModel model);
|
void removeAuthenticatorConfig(AuthenticatorConfigModel model);
|
||||||
AuthenticatorConfigModel getAuthenticatorConfigById(String id);
|
AuthenticatorConfigModel getAuthenticatorConfigById(String id);
|
||||||
|
AuthenticatorConfigModel getAuthenticatorConfigByAlias(String alias);
|
||||||
|
|
||||||
List<RequiredActionProviderModel> getRequiredActionProviders();
|
List<RequiredActionProviderModel> getRequiredActionProviders();
|
||||||
RequiredActionProviderModel addRequiredActionProvider(RequiredActionProviderModel model);
|
RequiredActionProviderModel addRequiredActionProvider(RequiredActionProviderModel model);
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.keycloak.representations.idm.UserFederationMapperRepresentation;
|
||||||
import org.keycloak.representations.idm.UserFederationProviderRepresentation;
|
import org.keycloak.representations.idm.UserFederationProviderRepresentation;
|
||||||
import org.keycloak.representations.idm.UserRepresentation;
|
import org.keycloak.representations.idm.UserRepresentation;
|
||||||
import org.keycloak.representations.idm.UserSessionRepresentation;
|
import org.keycloak.representations.idm.UserSessionRepresentation;
|
||||||
import org.keycloak.util.MultivaluedHashMap;
|
|
||||||
import org.keycloak.util.Time;
|
import org.keycloak.util.Time;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -199,11 +198,7 @@ public class ModelToRepresentation {
|
||||||
rep.setAuthenticationFlows(new LinkedList<AuthenticationFlowRepresentation>());
|
rep.setAuthenticationFlows(new LinkedList<AuthenticationFlowRepresentation>());
|
||||||
rep.setAuthenticatorConfig(new LinkedList<AuthenticatorConfigRepresentation>());
|
rep.setAuthenticatorConfig(new LinkedList<AuthenticatorConfigRepresentation>());
|
||||||
for (AuthenticationFlowModel model : realm.getAuthenticationFlows()) {
|
for (AuthenticationFlowModel model : realm.getAuthenticationFlows()) {
|
||||||
AuthenticationFlowRepresentation flowRep = toRepresentation(model);
|
AuthenticationFlowRepresentation flowRep = toRepresentation(realm, model);
|
||||||
flowRep.setAuthenticationExecutions(new LinkedList<AuthenticationExecutionRepresentation>());
|
|
||||||
for (AuthenticationExecutionModel execution : realm.getAuthenticationExecutions(model.getId())) {
|
|
||||||
flowRep.getAuthenticationExecutions().add(toRepresentation(execution));
|
|
||||||
}
|
|
||||||
rep.getAuthenticationFlows().add(flowRep);
|
rep.getAuthenticationFlows().add(flowRep);
|
||||||
}
|
}
|
||||||
for (AuthenticatorConfigModel model : realm.getAuthenticatorConfigs()) {
|
for (AuthenticatorConfigModel model : realm.getAuthenticatorConfigs()) {
|
||||||
|
@ -430,24 +425,33 @@ public class ModelToRepresentation {
|
||||||
return consentRep;
|
return consentRep;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AuthenticationFlowRepresentation toRepresentation(AuthenticationFlowModel model) {
|
public static AuthenticationFlowRepresentation toRepresentation(RealmModel realm, AuthenticationFlowModel model) {
|
||||||
AuthenticationFlowRepresentation rep = new AuthenticationFlowRepresentation();
|
AuthenticationFlowRepresentation rep = new AuthenticationFlowRepresentation();
|
||||||
rep.setBuiltIn(model.isBuiltIn());
|
rep.setBuiltIn(model.isBuiltIn());
|
||||||
rep.setTopLevel(model.isTopLevel());
|
rep.setTopLevel(model.isTopLevel());
|
||||||
rep.setProviderId(model.getProviderId());
|
rep.setProviderId(model.getProviderId());
|
||||||
rep.setId(model.getId());
|
|
||||||
rep.setAlias(model.getAlias());
|
rep.setAlias(model.getAlias());
|
||||||
rep.setDescription(model.getDescription());
|
rep.setDescription(model.getDescription());
|
||||||
|
rep.setAuthenticationExecutions(new LinkedList<AuthenticationExecutionRepresentation>());
|
||||||
|
for (AuthenticationExecutionModel execution : realm.getAuthenticationExecutions(model.getId())) {
|
||||||
|
rep.getAuthenticationExecutions().add(toRepresentation(realm, execution));
|
||||||
|
}
|
||||||
return rep;
|
return rep;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AuthenticationExecutionRepresentation toRepresentation(AuthenticationExecutionModel model) {
|
public static AuthenticationExecutionRepresentation toRepresentation(RealmModel realm, AuthenticationExecutionModel model) {
|
||||||
AuthenticationExecutionRepresentation rep = new AuthenticationExecutionRepresentation();
|
AuthenticationExecutionRepresentation rep = new AuthenticationExecutionRepresentation();
|
||||||
rep.setAuthenticatorConfig(model.getAuthenticatorConfig());
|
if (model.getAuthenticatorConfig() != null) {
|
||||||
|
AuthenticatorConfigModel config = realm.getAuthenticatorConfigById(model.getAuthenticatorConfig());
|
||||||
|
rep.setAuthenticatorConfig(config.getAlias());
|
||||||
|
}
|
||||||
rep.setAuthenticator(model.getAuthenticator());
|
rep.setAuthenticator(model.getAuthenticator());
|
||||||
rep.setAutheticatorFlow(model.isAutheticatorFlow());
|
rep.setAutheticatorFlow(model.isAutheticatorFlow());
|
||||||
rep.setFlowId(model.getFlowId());
|
if (model.getFlowId() != null) {
|
||||||
|
AuthenticationFlowModel flow = realm.getAuthenticationFlowById(model.getFlowId());
|
||||||
|
rep.setFlowAlias(flow.getAlias());
|
||||||
|
}
|
||||||
rep.setPriority(model.getPriority());
|
rep.setPriority(model.getPriority());
|
||||||
rep.setUserSetupAllowed(model.isUserSetupAllowed());
|
rep.setUserSetupAllowed(model.isUserSetupAllowed());
|
||||||
rep.setRequirement(model.getRequirement().name());
|
rep.setRequirement(model.getRequirement().name());
|
||||||
|
@ -456,7 +460,6 @@ public class ModelToRepresentation {
|
||||||
|
|
||||||
public static AuthenticatorConfigRepresentation toRepresentation(AuthenticatorConfigModel model) {
|
public static AuthenticatorConfigRepresentation toRepresentation(AuthenticatorConfigModel model) {
|
||||||
AuthenticatorConfigRepresentation rep = new AuthenticatorConfigRepresentation();
|
AuthenticatorConfigRepresentation rep = new AuthenticatorConfigRepresentation();
|
||||||
rep.setId(model.getId());
|
|
||||||
rep.setAlias(model.getAlias());
|
rep.setAlias(model.getAlias());
|
||||||
rep.setConfig(model.getConfig());
|
rep.setConfig(model.getConfig());
|
||||||
return rep;
|
return rep;
|
||||||
|
|
|
@ -303,20 +303,23 @@ public class RepresentationToModel {
|
||||||
// assume this is an old version being imported
|
// assume this is an old version being imported
|
||||||
DefaultAuthenticationFlows.addFlows(newRealm);
|
DefaultAuthenticationFlows.addFlows(newRealm);
|
||||||
} else {
|
} else {
|
||||||
for (AuthenticationFlowRepresentation flowRep : rep.getAuthenticationFlows()) {
|
|
||||||
AuthenticationFlowModel model = toModel(flowRep);
|
|
||||||
model = newRealm.addAuthenticationFlow(model);
|
|
||||||
for (AuthenticationExecutionRepresentation exeRep : flowRep.getAuthenticationExecutions()) {
|
|
||||||
AuthenticationExecutionModel execution = toModel(exeRep);
|
|
||||||
execution.setParentFlow(model.getId());
|
|
||||||
newRealm.addAuthenticatorExecution(execution);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (AuthenticatorConfigRepresentation configRep : rep.getAuthenticatorConfig()) {
|
for (AuthenticatorConfigRepresentation configRep : rep.getAuthenticatorConfig()) {
|
||||||
AuthenticatorConfigModel model = toModel(configRep);
|
AuthenticatorConfigModel model = toModel(configRep);
|
||||||
newRealm.addAuthenticatorConfig(model);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1044,19 +1047,24 @@ public class RepresentationToModel {
|
||||||
model.setBuiltIn(rep.isBuiltIn());
|
model.setBuiltIn(rep.isBuiltIn());
|
||||||
model.setTopLevel(rep.isTopLevel());
|
model.setTopLevel(rep.isTopLevel());
|
||||||
model.setProviderId(rep.getProviderId());
|
model.setProviderId(rep.getProviderId());
|
||||||
model.setId(rep.getId());
|
|
||||||
model.setAlias(rep.getAlias());
|
model.setAlias(rep.getAlias());
|
||||||
model.setDescription(rep.getDescription());
|
model.setDescription(rep.getDescription());
|
||||||
return model;
|
return model;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AuthenticationExecutionModel toModel(AuthenticationExecutionRepresentation rep) {
|
public static AuthenticationExecutionModel toModel(RealmModel realm, AuthenticationExecutionRepresentation rep) {
|
||||||
AuthenticationExecutionModel model = new AuthenticationExecutionModel();
|
AuthenticationExecutionModel model = new AuthenticationExecutionModel();
|
||||||
model.setAuthenticatorConfig(rep.getAuthenticatorConfig());
|
if (rep.getAuthenticatorConfig() != null) {
|
||||||
|
AuthenticatorConfigModel config = realm.getAuthenticatorConfigByAlias(rep.getAuthenticatorConfig());
|
||||||
|
model.setAuthenticatorConfig(config.getId());
|
||||||
|
}
|
||||||
model.setAuthenticator(rep.getAuthenticator());
|
model.setAuthenticator(rep.getAuthenticator());
|
||||||
model.setAutheticatorFlow(rep.isAutheticatorFlow());
|
model.setAutheticatorFlow(rep.isAutheticatorFlow());
|
||||||
model.setFlowId(rep.getFlowId());
|
if (rep.getFlowAlias() != null) {
|
||||||
|
AuthenticationFlowModel flow = realm.getFlowByAlias(rep.getFlowAlias());
|
||||||
|
model.setFlowId(flow.getId());
|
||||||
|
}
|
||||||
model.setPriority(rep.getPriority());
|
model.setPriority(rep.getPriority());
|
||||||
model.setUserSetupAllowed(rep.isUserSetupAllowed());
|
model.setUserSetupAllowed(rep.isUserSetupAllowed());
|
||||||
model.setRequirement(AuthenticationExecutionModel.Requirement.valueOf(rep.getRequirement()));
|
model.setRequirement(AuthenticationExecutionModel.Requirement.valueOf(rep.getRequirement()));
|
||||||
|
@ -1065,7 +1073,6 @@ public class RepresentationToModel {
|
||||||
|
|
||||||
public static AuthenticatorConfigModel toModel(AuthenticatorConfigRepresentation rep) {
|
public static AuthenticatorConfigModel toModel(AuthenticatorConfigRepresentation rep) {
|
||||||
AuthenticatorConfigModel model = new AuthenticatorConfigModel();
|
AuthenticatorConfigModel model = new AuthenticatorConfigModel();
|
||||||
model.setId(rep.getId());
|
|
||||||
model.setAlias(rep.getAlias());
|
model.setAlias(rep.getAlias());
|
||||||
model.setConfig(rep.getConfig());
|
model.setConfig(rep.getConfig());
|
||||||
return model;
|
return model;
|
||||||
|
|
|
@ -1398,6 +1398,17 @@ public class RealmAdapter implements RealmModel {
|
||||||
return authenticators;
|
return authenticators;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuthenticatorConfigModel getAuthenticatorConfigByAlias(String alias) {
|
||||||
|
for (AuthenticatorConfigModel config : getAuthenticatorConfigs()) {
|
||||||
|
if (config.getAlias().equals(alias)) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthenticatorConfigModel addAuthenticatorConfig(AuthenticatorConfigModel model) {
|
public AuthenticatorConfigModel addAuthenticatorConfig(AuthenticatorConfigModel model) {
|
||||||
AuthenticatorConfigEntity auth = new AuthenticatorConfigEntity();
|
AuthenticatorConfigEntity auth = new AuthenticatorConfigEntity();
|
||||||
|
|
|
@ -1035,6 +1035,17 @@ public class RealmAdapter implements RealmModel {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuthenticatorConfigModel getAuthenticatorConfigByAlias(String alias) {
|
||||||
|
for (AuthenticatorConfigModel config : getAuthenticatorConfigs()) {
|
||||||
|
if (config.getAlias().equals(alias)) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthenticationFlowModel addAuthenticationFlow(AuthenticationFlowModel model) {
|
public AuthenticationFlowModel addAuthenticationFlow(AuthenticationFlowModel model) {
|
||||||
getDelegateForUpdate();
|
getDelegateForUpdate();
|
||||||
|
|
|
@ -1537,6 +1537,15 @@ public class RealmAdapter implements RealmModel {
|
||||||
return null;
|
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) {
|
protected AuthenticationFlowModel entityToModel(AuthenticationFlowEntity entity) {
|
||||||
AuthenticationFlowModel model = new AuthenticationFlowModel();
|
AuthenticationFlowModel model = new AuthenticationFlowModel();
|
||||||
|
|
|
@ -1477,6 +1477,17 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
return authenticators;
|
return authenticators;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuthenticatorConfigModel getAuthenticatorConfigByAlias(String alias) {
|
||||||
|
for (AuthenticatorConfigModel config : getAuthenticatorConfigs()) {
|
||||||
|
if (config.getAlias().equals(alias)) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthenticatorConfigModel addAuthenticatorConfig(AuthenticatorConfigModel model) {
|
public AuthenticatorConfigModel addAuthenticatorConfig(AuthenticatorConfigModel model) {
|
||||||
AuthenticatorConfigEntity auth = new AuthenticatorConfigEntity();
|
AuthenticatorConfigEntity auth = new AuthenticatorConfigEntity();
|
||||||
|
|
Loading…
Reference in a new issue