创建 WSO2 自定义用户存储监听器

Create WSO2 Custom User Store Listener

未调用自定义用户存储侦听器。

遵循有关如何创建自定义用户存储侦听器的文档。

如何注册事件监听器 https://docs.wso2.com/display/IS560/Writing+a+Custom+Password+Validator

用户存储侦听器 https://docs.wso2.com/display/IS560/User+Store+Listeners

自定义监听器示例代码 https://svn.wso2.org/repos/wso2/people/asela/user-mgt/custom-listener/

事件侦听器 组织wso2.carbon.identity.governance.store.JDBCIdentityDataStore

    <!-- Enable this listener to call DeleteEventRecorders. -->
    <EventListener type="org.wso2.carbon.user.core.listener.UserOperationEventListener"
                   name="org.wso2.carbon.user.mgt.listeners.UserDeletionEventListener"
                   orderId="98" enable="false"/>
    <EventListener type="org.wso2.carbon.identity.core.handler.AbstractIdentityHandler"
                   name="org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.ConsentMgtPostAuthnHandler"
                   orderId="110" enable="true"/>

    <!-- Audit Loggers -->

    <!-- Old Audit Logger -->
    <EventListener type="org.wso2.carbon.user.core.listener.UserOperationEventListener"
                   name="org.wso2.carbon.user.mgt.listeners.UserMgtAuditLogger"
                   orderId="0" enable="false"/>

    <!-- New Audit Loggers-->
    <EventListener type="org.wso2.carbon.user.core.listener.UserOperationEventListener"
                   name="org.wso2.carbon.user.mgt.listeners.UserManagementAuditLogger"
                   orderId="1" enable="true"/>
    <EventListener type="org.wso2.carbon.user.core.listener.UserManagementErrorEventListener"
                   name="org.wso2.carbon.user.mgt.listeners.UserMgtFailureAuditLogger"
                   orderId="0" enable="true"/>

    <!-- OS Custom event handler-->
    <EventListener type="org.wso2.carbon.user.core.listener.UserOperationEventListener"
                   name="org.wso2.carbon.sample.user.operation.event.listener.SampleUserOperationEventListener"
                   orderId="49" enable="true"/>
</EventListeners>

这是 SampleUserOperationEventListener 代码。

public class SampleUserOperationEventListener 扩展了 AbstractUserOperationEventListener {

//private static Log log = LogFactory.getLog(SampleUserOperationEventListener.class);

private static final Log audit = CarbonConstants.AUDIT_LOG;
private static String AUDIT_MESSAGE = "Initiator : %s | Action : %s | Target : %s ";

@Override
public int getExecutionOrderId() {

    //This listener should execute before the IdentityMgtEventListener
    //Hence the number should be < 1357 (Execution order ID of IdentityMgtEventListener)
    return 49;
}

我期待它会调用自定义侦听器并在用户 activity 发生在 WSO2 管理控制台以及用户登录服务提供商时记录信息。

我没有找到任何 WSO2 调用这个监听器的地方。

我希望您将此自定义侦听器部署为 OSGI 包。如果此捆绑包成功激活,则应在发出用户创建请求时调用它。您不需要将其添加到 EventListners 下,添加到 dropins 文件夹即可。首先检查 bundle 是否被 OSGI 控制台激活。

步骤:

  1. 使用 -DosgiConsole 启动 wso2 身份服务器

./wso2server.sh -DosginConsole

  1. 服务器启动后输入以下命令。

ss soasecurity

3 这将给出一个包 ID 和包的工件名称。

b {bundle id}

这将给出捆绑包的状态,无论它是否被激活。如果没有激活。发生这种情况的原因很少。

  1. IS-5.6.0 中使用的碳内核版本是 4.4.32。但是在你的听众中你使用了 4.2.0。
  2. 检查您的捆绑包清单文件以获取正确的导入包和导出包详细信息

有关详细信息,请参阅此博客及其参考资料

https://medium.com/@inthiraj1994/user-operation-event-listener-for-wso2-server-8ce4765b8c95

如果您仍然遇到此问题,请告诉我。