commit
82a7173dba
1 changed files with 10 additions and 8 deletions
|
@ -431,9 +431,16 @@ public class AuthenticationManagementResource {
|
||||||
execution.setRequirement(AuthenticationExecutionModel.Requirement.DISABLED);
|
execution.setRequirement(AuthenticationExecutionModel.Requirement.DISABLED);
|
||||||
execution.setAuthenticatorFlow(true);
|
execution.setAuthenticatorFlow(true);
|
||||||
execution.setAuthenticator(provider);
|
execution.setAuthenticator(provider);
|
||||||
|
execution.setPriority(getNextPriority(parentFlow));
|
||||||
|
|
||||||
realm.addAuthenticatorExecution(execution);
|
realm.addAuthenticatorExecution(execution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getNextPriority(AuthenticationFlowModel parentFlow) {
|
||||||
|
List<AuthenticationExecutionModel> executions = getSortedExecutions(parentFlow);
|
||||||
|
return executions.isEmpty() ? 0 : executions.get(executions.size() - 1).getPriority() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add new authentication execution to a flow
|
* Add new authentication execution to a flow
|
||||||
*
|
*
|
||||||
|
@ -453,12 +460,13 @@ public class AuthenticationManagementResource {
|
||||||
}
|
}
|
||||||
String provider = data.get("provider");
|
String provider = data.get("provider");
|
||||||
|
|
||||||
|
|
||||||
AuthenticationExecutionModel execution = new AuthenticationExecutionModel();
|
AuthenticationExecutionModel execution = new AuthenticationExecutionModel();
|
||||||
execution.setParentFlow(parentFlow.getId());
|
execution.setParentFlow(parentFlow.getId());
|
||||||
execution.setRequirement(AuthenticationExecutionModel.Requirement.DISABLED);
|
execution.setRequirement(AuthenticationExecutionModel.Requirement.DISABLED);
|
||||||
execution.setAuthenticatorFlow(false);
|
execution.setAuthenticatorFlow(false);
|
||||||
execution.setAuthenticator(provider);
|
execution.setAuthenticator(provider);
|
||||||
|
execution.setPriority(getNextPriority(parentFlow));
|
||||||
|
|
||||||
realm.addAuthenticatorExecution(execution);
|
realm.addAuthenticatorExecution(execution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,13 +591,7 @@ public class AuthenticationManagementResource {
|
||||||
if (parentFlow.isBuiltIn()) {
|
if (parentFlow.isBuiltIn()) {
|
||||||
throw new BadRequestException("It is illegal to add execution to a built in flow");
|
throw new BadRequestException("It is illegal to add execution to a built in flow");
|
||||||
}
|
}
|
||||||
int priority = 0;
|
model.setPriority(getNextPriority(parentFlow));
|
||||||
List<AuthenticationExecutionModel> executions = getSortedExecutions(parentFlow);
|
|
||||||
for (AuthenticationExecutionModel execution : executions) {
|
|
||||||
priority = execution.getPriority();
|
|
||||||
}
|
|
||||||
if (priority > 0) priority += 10;
|
|
||||||
model.setPriority(priority);
|
|
||||||
model = realm.addAuthenticatorExecution(model);
|
model = realm.addAuthenticatorExecution(model);
|
||||||
return Response.created(uriInfo.getAbsolutePathBuilder().path(model.getId()).build()).build();
|
return Response.created(uriInfo.getAbsolutePathBuilder().path(model.getId()).build()).build();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue