use of org.keycloak.models.AuthenticationExecutionModel 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