Skip to end of metadata
Go to start of metadata

The LoginSubscriptionManagerService API allows components to subscribe a callback, which can be called when a user login happen. The subscribe() method is exposed so that the LoginListeners can subscribe to LoginSubscriptionManagerService.

The triggerEvent() method in the LoginSubscriptionManagerService implementation (org.wso2.carbon.core.services.callback.LoginSubscriptionManagerServiceImpl) is called during a successful user login event, which then executes the onLogin() method of subscribed LoginListeners.

Shown below is how the onSuccessAdminLogin() method calls LoginSubscriptionManagerServiceImpl during a successful user login.

// trigger the callbacks subscribe to the login event
LoginSubscriptionManagerServiceImpl loginSubscriptionManagerServiceImpl = CarbonServicesServiceComponent
UserRegistry configRegistry = CarbonServicesServiceComponent.getRegistryService()
loginSubscriptionManagerServiceImpl.triggerEvent(configRegistry, username, tenantId, tenantDomain);

The subscribe() method of the LoginSubscriptionManagerService implementation adds login listeners to its list of subscribers.

public void subscribe(LoginListener listener) {

The triggerEvent() method constructs LoginEvent data with details of the logged in user to pass to onLogin() call of LoginListeners. The triggerEvent() implementation from LoginSubscriptionManagerService is shown below.  

public void triggerEvent(Registry configRegistry, String username, int tenantId, String tenantDomain) {
   for (int i = 0; i < subscriptions.size(); i ++) {
       LoginEvent event = new LoginEvent();
       subscriptions.get(i).onLogin(configRegistry, event);
  • No labels