use of org.keycloak.representations.adapters.action.GlobalRequestResult in project keycloak by keycloak.
the class ClientTest method nodes.
@Test
public void nodes() {
testingClient.testApp().clearAdminActions();
ClientRepresentation client = createAppClient();
String id = client.getId();
String myhost = suiteContext.getAuthServerInfo().getContextRoot().getHost();
realm.clients().get(id).registerNode(Collections.singletonMap("node", myhost));
realm.clients().get(id).registerNode(Collections.singletonMap("node", "invalid"));
assertAdminEvents.assertEvent(realmId, OperationType.CREATE, AdminEventPaths.clientNodePath(id, myhost), ResourceType.CLUSTER_NODE);
assertAdminEvents.assertEvent(realmId, OperationType.CREATE, AdminEventPaths.clientNodePath(id, "invalid"), ResourceType.CLUSTER_NODE);
GlobalRequestResult result = realm.clients().get(id).testNodesAvailable();
assertEquals(1, result.getSuccessRequests().size());
assertEquals(1, result.getFailedRequests().size());
assertAdminEvents.assertEvent(realmId, OperationType.ACTION, AdminEventPaths.clientTestNodesAvailablePath(id), result, ResourceType.CLUSTER_NODE);
TestAvailabilityAction testAvailable = testingClient.testApp().getTestAvailable();
assertEquals("test-app", testAvailable.getResource());
assertEquals(2, realm.clients().get(id).toRepresentation().getRegisteredNodes().size());
realm.clients().get(id).unregisterNode("invalid");
assertAdminEvents.assertEvent(realmId, OperationType.DELETE, AdminEventPaths.clientNodePath(id, "invalid"), ResourceType.CLUSTER_NODE);
assertEquals(1, realm.clients().get(id).toRepresentation().getRegisteredNodes().size());
}
use of org.keycloak.representations.adapters.action.GlobalRequestResult in project keycloak by keycloak.
the class ResourceAdminManager method logoutAll.
// Methods for logout all
public GlobalRequestResult logoutAll(RealmModel realm) {
realm.setNotBefore(Time.currentTime());
GlobalRequestResult finalResult = new GlobalRequestResult();
AtomicInteger counter = new AtomicInteger(0);
realm.getClientsStream().forEach(c -> {
try {
counter.getAndIncrement();
GlobalRequestResult currentResult = logoutClient(realm, c, realm.getNotBefore());
finalResult.addAll(currentResult);
} catch (ModelIllegalStateException ex) {
// currently, GlobalRequestResult doesn't allow for information about clients that we were unable to retrieve.
logger.warn("unable to retrieve client information for logout, skipping resource", ex);
}
});
logger.debugv("logging out {0} resources ", counter);
return finalResult;
}
use of org.keycloak.representations.adapters.action.GlobalRequestResult in project keycloak by keycloak.
the class ResourceAdminManager method logoutClient.
protected GlobalRequestResult logoutClient(RealmModel realm, ClientModel resource, int notBefore) {
if (!resource.isEnabled()) {
return new GlobalRequestResult();
}
List<String> mgmtUrls = getAllManagementUrls(resource);
if (mgmtUrls.isEmpty()) {
logger.debug("No management URL or no registered cluster nodes for the client " + resource.getClientId());
return new GlobalRequestResult();
}
if (logger.isDebugEnabled())
logger.debug("Send logoutClient for URLs: " + mgmtUrls);
// Propagate this to all hosts
GlobalRequestResult result = new GlobalRequestResult();
for (String mgmtUrl : mgmtUrls) {
if (sendLogoutRequest(realm, resource, null, null, notBefore, mgmtUrl) != null) {
result.addSuccessRequest(mgmtUrl);
} else {
result.addFailedRequest(mgmtUrl);
}
}
return result;
}
use of org.keycloak.representations.adapters.action.GlobalRequestResult in project keycloak by keycloak.
the class ResourceAdminManager method pushRevocationPolicy.
protected GlobalRequestResult pushRevocationPolicy(RealmModel realm, ClientModel resource, int notBefore) {
List<String> mgmtUrls = getAllManagementUrls(resource);
if (mgmtUrls.isEmpty()) {
logger.debugf("No management URL or no registered cluster nodes for the client %s", resource.getClientId());
return new GlobalRequestResult();
}
if (logger.isDebugEnabled())
logger.debug("Sending push revocation to URLS: " + mgmtUrls);
// Propagate this to all hosts
GlobalRequestResult result = new GlobalRequestResult();
for (String mgmtUrl : mgmtUrls) {
if (sendPushRevocationPolicyRequest(realm, resource, notBefore, mgmtUrl)) {
result.addSuccessRequest(mgmtUrl);
} else {
result.addFailedRequest(mgmtUrl);
}
}
return result;
}
use of org.keycloak.representations.adapters.action.GlobalRequestResult in project keycloak by keycloak.
the class RealmTest method pushNotBefore.
// NOTE: clearKeysCache tested in KcOIDCBrokerWithSignatureTest
@Test
public void pushNotBefore() {
setupTestAppAndUser();
int time = Time.currentTime() - 60;
RealmRepresentation rep = realm.toRepresentation();
rep.setNotBefore(time);
realm.update(rep);
assertAdminEvents.assertEvent(realmId, OperationType.UPDATE, Matchers.nullValue(String.class), rep, ResourceType.REALM);
GlobalRequestResult globalRequestResult = realm.pushRevocation();
assertAdminEvents.assertEvent(realmId, OperationType.ACTION, "push-revocation", globalRequestResult, ResourceType.REALM);
assertThat(globalRequestResult.getSuccessRequests(), containsInAnyOrder(oauth.AUTH_SERVER_ROOT + "/realms/master/app/admin"));
assertNull(globalRequestResult.getFailedRequests());
PushNotBeforeAction adminPushNotBefore = testingClient.testApp().getAdminPushNotBefore();
assertEquals(time, adminPushNotBefore.getNotBefore());
}
Aggregations