我有以下代码,当管理员在 keycloak UI 中创建或删除用户时会执行这些代码。通过 adminEvent 的帮助:http://www.keycloak.org/docs/3.0/server_admin/topics/events/admin.html创建 用户通过 adminEvent.getRepresentation() 返回用户详细信息。但是,当删除用户时,我返回一个空值。
这在删除角色、删除组或删除 user_session 时也是如此。(ResourceTypes)
我的问题是如何检索已删除的详细信息?
import org.keycloak.events.admin.AdminEvent;
import org.keycloak.models.UserModel;
public void handleResourceOperation(AdminEvent adminEvent, UserModel user) {
MQMessage queueMessage = new MQMessage();
queueMessage.setIpAddress(adminEvent.getAuthDetails().getIpAddress());
queueMessage.setUsername(user.getUsername());
switch (adminEvent.getOperationType()) {
case CREATE:
LOGGER.info("OPERATION : CREATE USER");
LOGGER.info("USER Representation : " + adminEvent.getRepresentation());
String[] split = adminEvent.getRepresentation().split(",");
queueMessage.setTransactionDetail("Created user " + split[0].substring(12));
sendQueueMessage(adminEvent, queueMessage);
break;
case DELETE:
LOGGER.info("OPERATION : DELETE USER");
LOGGER.info("USER Representation : " + adminEvent.getRepresentation());
queueMessage.setTransactionDetail("User has been deleted.");
sendQueueMessage(adminEvent, queueMessage);
break;
}