Search in sources :

Example 1 with UserOperationEventListener

use of org.wso2.carbon.user.core.listener.UserOperationEventListener in project carbon-identity-framework by wso2.

the class IdPManagementServiceComponent method activate.

@Activate
protected void activate(ComponentContext ctxt) {
    try {
        BundleContext bundleCtx = ctxt.getBundleContext();
        TenantManagementListener idPMgtTenantMgtListener = new TenantManagementListener();
        ServiceRegistration tenantMgtListenerSR = bundleCtx.registerService(TenantMgtListener.class.getName(), idPMgtTenantMgtListener, null);
        if (tenantMgtListenerSR != null) {
            log.debug("Identity Provider Management - TenantMgtListener registered");
        } else {
            log.error("Identity Provider Management - TenantMgtListener could not be registered");
        }
        ServiceRegistration userOperationListenerSR = bundleCtx.registerService(UserOperationEventListener.class.getName(), new UserStoreListener(), null);
        if (userOperationListenerSR != null) {
            log.debug("Identity Provider Management - UserOperationEventListener registered");
        } else {
            log.error("Identity Provider Management - UserOperationEventListener could not be registered");
        }
        ServiceRegistration auditLoggerSR = bundleCtx.registerService(IdentityProviderMgtListener.class.getName(), new IDPMgtAuditLogger(), null);
        if (auditLoggerSR != null) {
            log.debug("Identity Provider Management - Audit Logger registered");
        } else {
            log.error("Identity Provider Management - Error while registering Audit Logger");
        }
        ServiceRegistration idPNameResolverListener = bundleCtx.registerService(IdentityProviderMgtListener.class.getName(), new IdentityProviderNameResolverListener(), null);
        if (idPNameResolverListener != null) {
            if (log.isDebugEnabled()) {
                log.debug("Identity Provider Name Resolver Listener registered.");
            }
        } else {
            log.error("Identity Provider Management - Error while registering Identity Provider Name Resolver " + "Listener.");
        }
        setIdentityProviderMgtListenerService(new IdPMgtValidationListener());
        CacheBackedIdPMgtDAO dao = new CacheBackedIdPMgtDAO(new IdPManagementDAO());
        if (dao.getIdPByName(null, IdentityApplicationConstants.RESIDENT_IDP_RESERVED_NAME, IdentityTenantUtil.getTenantId(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME), MultitenantConstants.SUPER_TENANT_DOMAIN_NAME) == null) {
            addSuperTenantIdp();
        }
        bundleCtx.registerService(IdpManager.class, IdentityProviderManager.getInstance(), null);
        ServiceRegistration idpClaimMetadataMgtListener = bundleCtx.registerService(ClaimMetadataMgtListener.class.getName(), new IdentityProviderClaimMgtListener(), null);
        if (idpClaimMetadataMgtListener != null) {
            if (log.isDebugEnabled()) {
                log.debug("Identity Provider Claim Metadata Management Listener registered.");
            }
        } else {
            log.error("Identity Provider Management - Error while registering Identity Provider Claim Metadata " + "Management Listener.");
        }
        buildFileBasedIdPList();
        cleanUpRemovedIdps();
        log.debug("Identity Provider Management bundle is activated");
    } catch (Throwable e) {
        log.error("Error while activating Identity Provider Management bundle", e);
    }
}
Also used : IdentityProviderNameResolverListener(org.wso2.carbon.idp.mgt.listener.IdentityProviderNameResolverListener) UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) CacheBackedIdPMgtDAO(org.wso2.carbon.idp.mgt.dao.CacheBackedIdPMgtDAO) IdPManagementDAO(org.wso2.carbon.idp.mgt.dao.IdPManagementDAO) IdentityProviderMgtListener(org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener) ClaimMetadataMgtListener(org.wso2.carbon.identity.claim.metadata.mgt.listener.ClaimMetadataMgtListener) TenantMgtListener(org.wso2.carbon.stratos.common.listeners.TenantMgtListener) IdentityProviderClaimMgtListener(org.wso2.carbon.idp.mgt.listener.IdentityProviderClaimMgtListener) IDPMgtAuditLogger(org.wso2.carbon.idp.mgt.listener.IDPMgtAuditLogger) IdPMgtValidationListener(org.wso2.carbon.idp.mgt.listener.IdPMgtValidationListener) BundleContext(org.osgi.framework.BundleContext) ServiceRegistration(org.osgi.framework.ServiceRegistration) Activate(org.osgi.service.component.annotations.Activate)

Example 2 with UserOperationEventListener

use of org.wso2.carbon.user.core.listener.UserOperationEventListener in project carbon-identity-framework by wso2.

the class IdentityMgtServiceComponent method activate.

@Activate
protected void activate(ComponentContext context) {
    Dictionary<String, String> props = new Hashtable<String, String>();
    props.put(CarbonConstants.AXIS2_CONFIG_SERVICE, AxisObserver.class.getName());
    context.getBundleContext().registerService(AxisObserver.class.getName(), new IdentityMgtDeploymentInterceptor(), props);
    init();
    if (log.isDebugEnabled()) {
        log.debug("Identity Management Listener is enabled");
    }
    ServiceRegistration serviceRegistration = context.getBundleContext().registerService(UserOperationEventListener.class.getName(), new IdentityMgtEventListener(), null);
    if (serviceRegistration != null) {
        if (log.isDebugEnabled()) {
            log.debug("Identity Management - UserOperationEventListener registered.");
        }
    } else {
        log.error("Identity Management - UserOperationEventListener could not be registered.");
    }
    UserOperationsNotificationListener notificationListener = new UserOperationsNotificationListener();
    ServiceRegistration userOperationNotificationSR = context.getBundleContext().registerService(UserOperationEventListener.class.getName(), notificationListener, null);
    context.getBundleContext().registerService(TenantMgtListener.class.getName(), new TenantManagementListener(), null);
    context.getBundleContext().registerService(UserOperationEventListener.class.getName(), new UserSessionTerminationListener(), null);
    if (userOperationNotificationSR != null) {
        if (log.isDebugEnabled()) {
            log.debug("Identity Management - UserOperationNotificationListener registered.");
        }
    } else {
        log.error("Identity Management - UserOperationNotificationListener could not be registered.");
    }
    ServiceRegistration identityUserIdResolverListener = context.getBundleContext().registerService(UserOperationEventListener.class.getName(), new IdentityUserIdResolverListener(), null);
    if (identityUserIdResolverListener != null) {
        if (log.isDebugEnabled()) {
            log.debug("Identity Management - IdentityUserIdResolverListener registered.");
        }
    } else {
        log.error("Identity Management - IdentityUserIdResolverListener could not be registered.");
    }
    ServiceRegistration identityUserNameResolverListener = context.getBundleContext().registerService(UserOperationEventListener.class.getName(), new IdentityUserNameResolverListener(), null);
    if (identityUserNameResolverListener != null) {
        if (log.isDebugEnabled()) {
            log.debug("Identity Management - IdentityUserNameResolverListener registered.");
        }
    } else {
        log.error("Identity Management - IdentityUserNameResolverListener could not be registered.");
    }
    if (log.isDebugEnabled()) {
        log.debug("Identity Management bundle is activated");
    }
    RegistryCleanUpService registryCleanUpService = new RegistryCleanUpService(IdentityMgtConfig.getInstance().getRegistryCleanUpPeriod(), IdentityMgtConfig.getInstance().getRegistryCleanUpPeriod());
    registryCleanUpService.activateCleanUp();
    // Set user session mapping enabled.
    IdentityMgtServiceDataHolder.getInstance().setUserSessionMappingEnabled(FrameworkUtils.isUserSessionMappingEnabled());
}
Also used : TenantManagementListener(org.wso2.carbon.identity.mgt.listener.TenantManagementListener) UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) UserSessionTerminationListener(org.wso2.carbon.identity.mgt.listener.UserSessionTerminationListener) IdentityUserIdResolverListener(org.wso2.carbon.identity.mgt.listener.IdentityUserIdResolverListener) Hashtable(java.util.Hashtable) TenantMgtListener(org.wso2.carbon.stratos.common.listeners.TenantMgtListener) UserOperationsNotificationListener(org.wso2.carbon.identity.mgt.listener.UserOperationsNotificationListener) IdentityMgtEventListener(org.wso2.carbon.identity.mgt.IdentityMgtEventListener) IdentityUserNameResolverListener(org.wso2.carbon.identity.mgt.listener.IdentityUserNameResolverListener) AxisObserver(org.apache.axis2.engine.AxisObserver) ServiceRegistration(org.osgi.framework.ServiceRegistration) RegistryCleanUpService(org.wso2.carbon.identity.mgt.store.RegistryCleanUpService) Activate(org.osgi.service.component.annotations.Activate)

Example 3 with UserOperationEventListener

use of org.wso2.carbon.user.core.listener.UserOperationEventListener in project carbon-identity-framework by wso2.

the class IdentityUserIdResolverListener method doPostUpdateUserListOfInternalRole.

@Override
public boolean doPostUpdateUserListOfInternalRole(String roleName, String[] deletedUsers, String[] newUsers, UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }
    String[] deletedUserIDs;
    try {
        deletedUserIDs = getUserIdsFromUserNames(deletedUsers, (AbstractUserStoreManager) userStoreManager);
    } catch (UserStoreException e) {
        // supported user store.
        if (log.isDebugEnabled()) {
            log.debug(e.getMessage(), e);
        }
        return true;
    }
    String[] newUserIDs;
    try {
        newUserIDs = getUserIdsFromUserNames(newUsers, (AbstractUserStoreManager) userStoreManager);
    } catch (UserStoreException e) {
        // supported user store.
        if (log.isDebugEnabled()) {
            log.debug(e.getMessage(), e);
        }
        return true;
    }
    for (UserOperationEventListener listener : getUserStoreManagerListeners()) {
        if (isNotAResolverListener(listener)) {
            if (!((UniqueIDUserOperationEventListener) listener).doPostUpdateUserListOfInternalRoleWithID(roleName, deletedUserIDs, newUserIDs, userStoreManager)) {
                return false;
            }
        }
    }
    return true;
}
Also used : UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) UniqueIDUserOperationEventListener(org.wso2.carbon.user.core.listener.UniqueIDUserOperationEventListener) AbstractIdentityUserOperationEventListener(org.wso2.carbon.identity.core.AbstractIdentityUserOperationEventListener) UserStoreException(org.wso2.carbon.user.core.UserStoreException) AbstractUserStoreManager(org.wso2.carbon.user.core.common.AbstractUserStoreManager)

Example 4 with UserOperationEventListener

use of org.wso2.carbon.user.core.listener.UserOperationEventListener in project carbon-identity-framework by wso2.

the class IdentityUserIdResolverListener method doPostGetUsersClaimValues.

@Override
public boolean doPostGetUsersClaimValues(String[] userNames, String[] claims, String profileName, UserClaimSearchEntry[] userClaimSearchEntries, UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }
    List<String> userIDsList = ((AbstractUserStoreManager) userStoreManager).getUserIDsFromUserNames(Arrays.asList(getDomainLessNames(userNames)));
    List<String> claimsList = Arrays.asList(claims);
    List<UniqueIDUserClaimSearchEntry> uniqueIDUserClaimSearchEntriesList = ((AbstractUserStoreManager) userStoreManager).getUniqueIDUserClaimSearchEntries(userClaimSearchEntries);
    for (UserOperationEventListener listener : getUserStoreManagerListeners()) {
        if (isNotAResolverListener(listener)) {
            if (!((UniqueIDUserOperationEventListener) listener).doPostGetUsersClaimValuesWithID(userIDsList, claimsList, profileName, uniqueIDUserClaimSearchEntriesList, userStoreManager)) {
                return false;
            }
        }
    }
    return true;
}
Also used : UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) UniqueIDUserOperationEventListener(org.wso2.carbon.user.core.listener.UniqueIDUserOperationEventListener) AbstractIdentityUserOperationEventListener(org.wso2.carbon.identity.core.AbstractIdentityUserOperationEventListener) UniqueIDUserClaimSearchEntry(org.wso2.carbon.user.core.model.UniqueIDUserClaimSearchEntry) AbstractUserStoreManager(org.wso2.carbon.user.core.common.AbstractUserStoreManager)

Example 5 with UserOperationEventListener

use of org.wso2.carbon.user.core.listener.UserOperationEventListener in project carbon-identity-framework by wso2.

the class IdentityUserIdResolverListener method doPreUpdateUserListOfRole.

@Override
public boolean doPreUpdateUserListOfRole(String roleName, String[] deletedUsers, String[] newUsers, UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }
    String[] deletedUserIDs;
    try {
        deletedUserIDs = getUserIdsFromUserNames(deletedUsers, (AbstractUserStoreManager) userStoreManager);
    } catch (UserStoreException e) {
        // supported user store.
        if (log.isDebugEnabled()) {
            log.debug(e.getMessage(), e);
        }
        return true;
    }
    String[] newUserIDs;
    try {
        newUserIDs = getUserIdsFromUserNames(newUsers, (AbstractUserStoreManager) userStoreManager);
    } catch (UserStoreException e) {
        // supported user store.
        if (log.isDebugEnabled()) {
            log.debug(e.getMessage(), e);
        }
        return true;
    }
    for (UserOperationEventListener listener : getUserStoreManagerListeners()) {
        if (isNotAResolverListener(listener)) {
            if (!((UniqueIDUserOperationEventListener) listener).doPreUpdateUserListOfRoleWithID(roleName, deletedUserIDs, newUserIDs, userStoreManager)) {
                return false;
            }
        }
    }
    return true;
}
Also used : UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) UniqueIDUserOperationEventListener(org.wso2.carbon.user.core.listener.UniqueIDUserOperationEventListener) AbstractIdentityUserOperationEventListener(org.wso2.carbon.identity.core.AbstractIdentityUserOperationEventListener) UserStoreException(org.wso2.carbon.user.core.UserStoreException) AbstractUserStoreManager(org.wso2.carbon.user.core.common.AbstractUserStoreManager)

Aggregations

UserOperationEventListener (org.wso2.carbon.user.core.listener.UserOperationEventListener)22 AbstractIdentityUserOperationEventListener (org.wso2.carbon.identity.core.AbstractIdentityUserOperationEventListener)19 AbstractUserStoreManager (org.wso2.carbon.user.core.common.AbstractUserStoreManager)9 UniqueIDUserOperationEventListener (org.wso2.carbon.user.core.listener.UniqueIDUserOperationEventListener)7 UserStoreException (org.wso2.carbon.user.core.UserStoreException)4 Activate (org.osgi.service.component.annotations.Activate)3 TenantMgtListener (org.wso2.carbon.stratos.common.listeners.TenantMgtListener)3 ServiceRegistration (org.osgi.framework.ServiceRegistration)2 User (org.wso2.carbon.user.core.common.User)2 UniqueIDUserClaimSearchEntry (org.wso2.carbon.user.core.model.UniqueIDUserClaimSearchEntry)2 HashSet (java.util.HashSet)1 Hashtable (java.util.Hashtable)1 AxisObserver (org.apache.axis2.engine.AxisObserver)1 BundleContext (org.osgi.framework.BundleContext)1 UserSessionException (org.wso2.carbon.identity.application.authentication.framework.exception.UserSessionException)1 ClaimMetadataMgtListener (org.wso2.carbon.identity.claim.metadata.mgt.listener.ClaimMetadataMgtListener)1 AbstractEventHandler (org.wso2.carbon.identity.event.handler.AbstractEventHandler)1 IdentityMgtEventListener (org.wso2.carbon.identity.mgt.IdentityMgtEventListener)1 IdentityUserIdResolverListener (org.wso2.carbon.identity.mgt.listener.IdentityUserIdResolverListener)1 IdentityUserNameResolverListener (org.wso2.carbon.identity.mgt.listener.IdentityUserNameResolverListener)1