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 authenticator;
|
||||
private String flowId;
|
||||
private String flowAlias;
|
||||
private boolean autheticatorFlow;
|
||||
private String requirement;
|
||||
private boolean userSetupAllowed;
|
||||
|
@ -63,12 +63,12 @@ public class AuthenticationExecutionRepresentation implements Serializable {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public String getFlowId() {
|
||||
return flowId;
|
||||
public String getFlowAlias() {
|
||||
return flowAlias;
|
||||
}
|
||||
|
||||
public void setFlowId(String flowId) {
|
||||
this.flowId = flowId;
|
||||
public void setFlowAlias(String flowId) {
|
||||
this.flowAlias = flowId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.util.List;
|
|||
public class AuthenticationFlowRepresentation implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
private String alias;
|
||||
private String description;
|
||||
private String providerId;
|
||||
|
@ -18,14 +17,6 @@ public class AuthenticationFlowRepresentation implements Serializable {
|
|||
private boolean builtIn;
|
||||
protected List<AuthenticationExecutionRepresentation> authenticationExecutions;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
|
|
@ -11,19 +11,10 @@ import java.util.Map;
|
|||
public class AuthenticatorConfigRepresentation implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
private String alias;
|
||||
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() {
|
||||
return alias;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -37,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;
|
||||
|
@ -199,11 +198,7 @@ public class ModelToRepresentation {
|
|||
rep.setAuthenticationFlows(new LinkedList<AuthenticationFlowRepresentation>());
|
||||
rep.setAuthenticatorConfig(new LinkedList<AuthenticatorConfigRepresentation>());
|
||||
for (AuthenticationFlowModel model : realm.getAuthenticationFlows()) {
|
||||
AuthenticationFlowRepresentation flowRep = toRepresentation(model);
|
||||
flowRep.setAuthenticationExecutions(new LinkedList<AuthenticationExecutionRepresentation>());
|
||||
for (AuthenticationExecutionModel execution : realm.getAuthenticationExecutions(model.getId())) {
|
||||
flowRep.getAuthenticationExecutions().add(toRepresentation(execution));
|
||||
}
|
||||
AuthenticationFlowRepresentation flowRep = toRepresentation(realm, model);
|
||||
rep.getAuthenticationFlows().add(flowRep);
|
||||
}
|
||||
for (AuthenticatorConfigModel model : realm.getAuthenticatorConfigs()) {
|
||||
|
@ -430,24 +425,33 @@ public class ModelToRepresentation {
|
|||
return consentRep;
|
||||
}
|
||||
|
||||
public static AuthenticationFlowRepresentation toRepresentation(AuthenticationFlowModel model) {
|
||||
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.setId(model.getId());
|
||||
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(AuthenticationExecutionModel model) {
|
||||
public static AuthenticationExecutionRepresentation toRepresentation(RealmModel realm, AuthenticationExecutionModel model) {
|
||||
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.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.setUserSetupAllowed(model.isUserSetupAllowed());
|
||||
rep.setRequirement(model.getRequirement().name());
|
||||
|
@ -456,7 +460,6 @@ public class ModelToRepresentation {
|
|||
|
||||
public static AuthenticatorConfigRepresentation toRepresentation(AuthenticatorConfigModel model) {
|
||||
AuthenticatorConfigRepresentation rep = new AuthenticatorConfigRepresentation();
|
||||
rep.setId(model.getId());
|
||||
rep.setAlias(model.getAlias());
|
||||
rep.setConfig(model.getConfig());
|
||||
return rep;
|
||||
|
|
|
@ -303,19 +303,22 @@ public class RepresentationToModel {
|
|||
// assume this is an old version being imported
|
||||
DefaultAuthenticationFlows.addFlows(newRealm);
|
||||
} 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()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1044,19 +1047,24 @@ public class RepresentationToModel {
|
|||
model.setBuiltIn(rep.isBuiltIn());
|
||||
model.setTopLevel(rep.isTopLevel());
|
||||
model.setProviderId(rep.getProviderId());
|
||||
model.setId(rep.getId());
|
||||
model.setAlias(rep.getAlias());
|
||||
model.setDescription(rep.getDescription());
|
||||
return model;
|
||||
|
||||
}
|
||||
|
||||
public static AuthenticationExecutionModel toModel(AuthenticationExecutionRepresentation rep) {
|
||||
public static AuthenticationExecutionModel toModel(RealmModel realm, AuthenticationExecutionRepresentation rep) {
|
||||
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.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.setUserSetupAllowed(rep.isUserSetupAllowed());
|
||||
model.setRequirement(AuthenticationExecutionModel.Requirement.valueOf(rep.getRequirement()));
|
||||
|
@ -1065,7 +1073,6 @@ public class RepresentationToModel {
|
|||
|
||||
public static AuthenticatorConfigModel toModel(AuthenticatorConfigRepresentation rep) {
|
||||
AuthenticatorConfigModel model = new AuthenticatorConfigModel();
|
||||
model.setId(rep.getId());
|
||||
model.setAlias(rep.getAlias());
|
||||
model.setConfig(rep.getConfig());
|
||||
return model;
|
||||
|
|
|
@ -1398,6 +1398,17 @@ 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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1477,6 +1477,17 @@ 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();
|
||||
|
|
Loading…
Reference in a new issue