use of org.keycloak.models.AuthenticatorConfigModel in project keycloak by keycloak.
the class RepresentationToModel method toModel.
private static AuthenticationExecutionModel toModel(RealmModel realm, AuthenticationFlowModel parentFlow, AuthenticationExecutionExportRepresentation rep) {
AuthenticationExecutionModel model = new AuthenticationExecutionModel();
if (rep.getAuthenticatorConfig() != null) {
AuthenticatorConfigModel config = realm.getAuthenticatorConfigByAlias(rep.getAuthenticatorConfig());
model.setAuthenticatorConfig(config.getId());
}
model.setAuthenticator(rep.getAuthenticator());
model.setAuthenticatorFlow(rep.isAuthenticatorFlow());
if (rep.getFlowAlias() != null) {
AuthenticationFlowModel flow = realm.getFlowByAlias(rep.getFlowAlias());
model.setFlowId(flow.getId());
}
model.setPriority(rep.getPriority());
try {
model.setRequirement(AuthenticationExecutionModel.Requirement.valueOf(rep.getRequirement()));
model.setParentFlow(parentFlow.getId());
} catch (IllegalArgumentException iae) {
// retro-compatible for previous OPTIONAL being changed to CONDITIONAL
if ("OPTIONAL".equals(rep.getRequirement())) {
MigrateTo8_0_0.migrateOptionalAuthenticationExecution(realm, parentFlow, model, false);
}
}
return model;
}
use of org.keycloak.models.AuthenticatorConfigModel in project keycloak by keycloak.
the class RepresentationToModel method toModel.
public static AuthenticationExecutionModel toModel(RealmModel realm, AuthenticationExecutionRepresentation rep) {
AuthenticationExecutionModel model = new AuthenticationExecutionModel();
model.setId(rep.getId());
model.setFlowId(rep.getFlowId());
model.setAuthenticator(rep.getAuthenticator());
model.setPriority(rep.getPriority());
model.setParentFlow(rep.getParentFlow());
model.setAuthenticatorFlow(rep.isAuthenticatorFlow());
model.setRequirement(AuthenticationExecutionModel.Requirement.valueOf(rep.getRequirement()));
if (rep.getAuthenticatorConfig() != null) {
AuthenticatorConfigModel cfg = realm.getAuthenticatorConfigByAlias(rep.getAuthenticatorConfig());
model.setAuthenticatorConfig(cfg.getId());
}
return model;
}
use of org.keycloak.models.AuthenticatorConfigModel in project keycloak by keycloak.
the class KcSamlDefaultIdpTest method configureFlow.
private void configureFlow(String defaultIdpValue) {
String newFlowAlias;
HashMap<String, String> defaultIdpConfig = new HashMap<String, String>();
if (defaultIdpValue != null && !defaultIdpValue.isEmpty()) {
defaultIdpConfig.put(IdentityProviderAuthenticatorFactory.DEFAULT_PROVIDER, defaultIdpValue);
newFlowAlias = "Browser - Default IdP " + defaultIdpValue;
} else
newFlowAlias = "Browser - Default IdP OFF";
testingClient.server("consumer").run(session -> FlowUtil.inCurrentRealm(session).copyBrowserFlow(newFlowAlias));
testingClient.server("consumer").run(session -> {
List<AuthenticationExecutionModel> executions = FlowUtil.inCurrentRealm(session).selectFlow(newFlowAlias).getExecutions();
int index = IntStream.range(0, executions.size()).filter(t -> IdentityProviderAuthenticatorFactory.PROVIDER_ID.equals(executions.get(t).getAuthenticator())).findFirst().orElse(-1);
assertTrue("Identity Provider Redirector execution not found", index >= 0);
FlowUtil.inCurrentRealm(session).selectFlow(newFlowAlias).updateExecution(index, config -> {
AuthenticatorConfigModel authConfig = new AuthenticatorConfigModel();
authConfig.setId(UUID.randomUUID().toString());
authConfig.setAlias("cfg" + authConfig.getId().hashCode());
authConfig.setConfig(defaultIdpConfig);
session.getContext().getRealm().addAuthenticatorConfig(authConfig);
config.setAuthenticatorConfig(authConfig.getId());
}).defineAsBrowserFlow();
});
}
Aggregations