use of org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation in project keycloak by keycloak.
the class AbstractKerberosTest method updateKerberosAuthExecutionRequirement.
public static AuthenticationExecutionModel.Requirement updateKerberosAuthExecutionRequirement(AuthenticationExecutionModel.Requirement requirement, RealmResource realmResource) {
Optional<AuthenticationExecutionInfoRepresentation> kerberosAuthExecutionOpt = realmResource.flows().getExecutions(DefaultAuthenticationFlows.BROWSER_FLOW).stream().filter(e -> e.getProviderId().equals(SpnegoAuthenticatorFactory.PROVIDER_ID)).findFirst();
Assert.assertTrue(kerberosAuthExecutionOpt.isPresent());
AuthenticationExecutionInfoRepresentation kerberosAuthExecution = kerberosAuthExecutionOpt.get();
String oldRequirementStr = kerberosAuthExecution.getRequirement();
AuthenticationExecutionModel.Requirement oldRequirement = AuthenticationExecutionModel.Requirement.valueOf(oldRequirementStr);
kerberosAuthExecution.setRequirement(requirement.name());
realmResource.flows().updateExecutions(DefaultAuthenticationFlows.BROWSER_FLOW, kerberosAuthExecution);
return oldRequirement;
}
use of org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation in project keycloak by keycloak.
the class KerberosLdapTest method testClientOverrideFlowUsingBrowserHttpChallenge.
@Test
public void testClientOverrideFlowUsingBrowserHttpChallenge() throws Exception {
List<AuthenticationExecutionInfoRepresentation> executions = testRealmResource().flows().getExecutions("http challenge");
for (AuthenticationExecutionInfoRepresentation execution : executions) {
if ("basic-auth".equals(execution.getProviderId())) {
execution.setRequirement("ALTERNATIVE");
testRealmResource().flows().updateExecutions("http challenge", execution);
}
if ("auth-spnego".equals(execution.getProviderId())) {
execution.setRequirement("ALTERNATIVE");
testRealmResource().flows().updateExecutions("http challenge", execution);
}
}
Map<String, String> flows = new HashMap<>();
AuthenticationFlowRepresentation flow = testRealmResource().flows().getFlows().stream().filter(flowRep -> flowRep.getAlias().equalsIgnoreCase("http challenge")).findAny().get();
flows.put(AuthenticationFlowBindings.BROWSER_BINDING, flow.getId());
ClientRepresentation client = testRealmResource().clients().findByClientId("kerberos-app-challenge").get(0);
client.setAuthenticationFlowBindingOverrides(flows);
testRealmResource().clients().get(client.getId()).update(client);
assertSuccessfulSpnegoLogin(client.getClientId(), "hnelson", "hnelson", "secret");
}
use of org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation in project keycloak by keycloak.
the class UserStorageRestTest method findKerberosExecution.
private AuthenticationExecutionInfoRepresentation findKerberosExecution() {
AuthenticationExecutionInfoRepresentation kerberosExecution = null;
List<AuthenticationExecutionInfoRepresentation> executionReps = realm.flows().getExecutions("browser");
kerberosExecution = AbstractAuthenticationTest.findExecutionByProvider("auth-spnego", executionReps);
Assert.assertNotNull(kerberosExecution);
return kerberosExecution;
}
use of org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation in project keycloak by keycloak.
the class ShiftExecutionTest method testShiftExecution.
@Test
public void testShiftExecution() {
// copy built-in flow so we get a new editable flow
HashMap<String, String> params = new HashMap<>();
params.put("newName", "Copy of browser");
Response response = authMgmtResource.copy("browser", params);
assertAdminEvents.assertEvent(REALM_NAME, OperationType.CREATE, AdminEventPaths.authCopyFlowPath("browser"), params, ResourceType.AUTH_FLOW);
try {
Assert.assertEquals("Copy flow", 201, response.getStatus());
} finally {
response.close();
}
// get executions
List<AuthenticationExecutionInfoRepresentation> executions = authMgmtResource.getExecutions("Copy of browser");
AuthenticationExecutionInfoRepresentation last = executions.get(executions.size() - 1);
AuthenticationExecutionInfoRepresentation oneButLast = executions.get(executions.size() - 2);
// Not possible to raisePriority of not-existent flow
try {
authMgmtResource.raisePriority("not-existent");
Assert.fail("Not expected to raise priority of not existent flow");
} catch (NotFoundException nfe) {
// Expected
}
// shift last execution up
authMgmtResource.raisePriority(last.getId());
assertAdminEvents.assertEvent(REALM_NAME, OperationType.UPDATE, AdminEventPaths.authRaiseExecutionPath(last.getId()), ResourceType.AUTH_EXECUTION);
List<AuthenticationExecutionInfoRepresentation> executions2 = authMgmtResource.getExecutions("Copy of browser");
AuthenticationExecutionInfoRepresentation last2 = executions2.get(executions.size() - 1);
AuthenticationExecutionInfoRepresentation oneButLast2 = executions2.get(executions.size() - 2);
Assert.assertEquals("Execution shifted up - N", last.getId(), oneButLast2.getId());
Assert.assertEquals("Execution shifted up - N-1", oneButLast.getId(), last2.getId());
// Not possible to lowerPriority of not-existent flow
try {
authMgmtResource.lowerPriority("not-existent");
Assert.fail("Not expected to raise priority of not existent flow");
} catch (NotFoundException nfe) {
// Expected
}
// shift one before last down
authMgmtResource.lowerPriority(oneButLast2.getId());
assertAdminEvents.assertEvent(REALM_NAME, OperationType.UPDATE, AdminEventPaths.authLowerExecutionPath(oneButLast2.getId()), ResourceType.AUTH_EXECUTION);
executions2 = authMgmtResource.getExecutions("Copy of browser");
last2 = executions2.get(executions.size() - 1);
oneButLast2 = executions2.get(executions.size() - 2);
Assert.assertEquals("Execution shifted down - N", last.getId(), last2.getId());
Assert.assertEquals("Execution shifted down - N-1", oneButLast.getId(), oneButLast2.getId());
}
use of org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation in project keycloak by keycloak.
the class AbstractAuthenticationTest method addExecInfo.
void addExecInfo(List<AuthenticationExecutionInfoRepresentation> target, String displayName, String providerId, Boolean configurable, int level, int index, String requirement, Boolean authFlow, String[] choices) {
AuthenticationExecutionInfoRepresentation exec = newExecInfo(displayName, providerId, configurable, level, index, requirement, authFlow, choices);
target.add(exec);
}
Aggregations