Search in sources :

Example 1 with AdminEventBuilder

use of org.keycloak.services.resources.admin.AdminEventBuilder in project keycloak by keycloak.

the class ProtectionService method createAdminEventBuilder.

private AdminEventBuilder createAdminEventBuilder(KeycloakIdentity identity, ResourceServer resourceServer) {
    RealmModel realm = authorization.getRealm();
    ClientModel client = realm.getClientById(resourceServer.getId());
    KeycloakSession keycloakSession = authorization.getKeycloakSession();
    UserModel serviceAccount = keycloakSession.users().getServiceAccount(client);
    AdminEventBuilder adminEvent = new AdminEventBuilder(realm, new AdminAuth(realm, identity.getAccessToken(), serviceAccount, client), keycloakSession, clientConnection);
    return adminEvent.realm(realm).authClient(client).authUser(serviceAccount);
}
Also used : RealmModel(org.keycloak.models.RealmModel) UserModel(org.keycloak.models.UserModel) AdminAuth(org.keycloak.services.resources.admin.AdminAuth) ClientModel(org.keycloak.models.ClientModel) KeycloakSession(org.keycloak.models.KeycloakSession) AdminEventBuilder(org.keycloak.services.resources.admin.AdminEventBuilder)

Aggregations

ClientModel (org.keycloak.models.ClientModel)1 KeycloakSession (org.keycloak.models.KeycloakSession)1 RealmModel (org.keycloak.models.RealmModel)1 UserModel (org.keycloak.models.UserModel)1 AdminAuth (org.keycloak.services.resources.admin.AdminAuth)1 AdminEventBuilder (org.keycloak.services.resources.admin.AdminEventBuilder)1