Question

I would like to re-distribute events in the IS management console. For example if I add/change/delete a user or a role I would like to re-send these updates to other consumers. The only way I found until now is the UMListenerServiceComponent. It looks like I can define my own UserStoreManagerListener and register it at the UMListenerServiceComponent.

The following example is from https://svn.wso2.org/repos/wso2/branches/carbon/3.2.0/core/org.wso2.carbon.user.core/3.2.3/src/main/java/org/wso2/carbon/user/core/jdbc/JDBCUserStoreManager.java

In this case the action of adding a user is triggering the registered listeners.

public void addUser(String userName, Object credential, String[] roleList,
        Map<String, String> claims, String profileName, boolean requirePasswordChange)
        throws UserStoreException {

    for (UserStoreManagerListener listener : UMListenerServiceComponent
            .getUserStoreManagerListeners()) {
        if (!listener.addUser(userName, credential, roleList, claims, profileName, this)) {
            return;
        }
    }
    // persist the user info. in the database.
    persistUser(userName, credential, roleList, claims, profileName, requirePasswordChange);

}

My question is how can I implement and register this kind of listeners? Or is there an easier way? Thanks in advance!

Was it helpful?

Solution

Problem solved!
Downloaded the identity-manager version which is used for the wso2IS 4.6.0: http://svn.wso2.org/repos/wso2/carbon/platform/branches/turing/components/identity/org.wso2.carbon.identity.mgt/4.2.1 The class IdentityMgtServiceComponent is registering the IdentityMgtEventListener as an service in the Osgi-Context.

IdentityMgtServiceComponent:

protected void activate(ComponentContext context) {
        listener = new IdentityMgtEventListener();
        serviceRegistration = context.getBundleContext().registerService(
                UserOperationEventListener.class.getName(), listener, null);

Finally I copied this pattern and wrote my own bundle with an extension of AbstractUserOperationEventListener and activated it via a bundle-loader-class.
All the pre/post add/delete actions are triggered fine.
Hope this helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top