Search in sources :

Example 16 with UserOperationEventListener

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

the class IdentityUserIdResolverListener method doPostAuthenticate.

@Override
public boolean doPostAuthenticate(String userName, boolean authenticated, UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }
    String userID = ((AbstractUserStoreManager) userStoreManager).getUserIDFromUserName(userName);
    if (userID == null) {
        return handleUserIDResolveFailure(userName, userStoreManager);
    }
    AuthenticationResult authenticationResult;
    if (authenticated) {
        authenticationResult = new AuthenticationResult(AuthenticationResult.AuthenticationStatus.SUCCESS);
        User user = ((AbstractUserStoreManager) userStoreManager).getUser(userID, userName);
        authenticationResult.setAuthenticatedUser(user);
    } else {
        authenticationResult = new AuthenticationResult(AuthenticationResult.AuthenticationStatus.FAIL);
    }
    for (UserOperationEventListener listener : getUserStoreManagerListeners()) {
        if (isNotAResolverListener(listener)) {
            if (!((UniqueIDUserOperationEventListener) listener).doPostAuthenticateWithID(userID, authenticationResult, 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) User(org.wso2.carbon.user.core.common.User) AbstractUserStoreManager(org.wso2.carbon.user.core.common.AbstractUserStoreManager) AuthenticationResult(org.wso2.carbon.user.core.common.AuthenticationResult)

Example 17 with UserOperationEventListener

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

the class IdentityUserIdResolverListener method doPreDeleteUser.

@Override
public boolean doPreDeleteUser(String userName, UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }
    String userID = ((AbstractUserStoreManager) userStoreManager).getUserIDFromUserName(userName);
    if (userID == null) {
        return handleUserIDResolveFailure(userName, userStoreManager);
    }
    // Setting the thread-local to keep userID for doPostDeleteUserWithID listener.
    IdentityUtil.threadLocalProperties.get().put(DO_PRE_DELETE_USER_USER_ID, userID);
    for (UserOperationEventListener listener : getUserStoreManagerListeners()) {
        if (isNotAResolverListener(listener)) {
            if (!((UniqueIDUserOperationEventListener) listener).doPreDeleteUserWithID(userID, 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) AbstractUserStoreManager(org.wso2.carbon.user.core.common.AbstractUserStoreManager)

Example 18 with UserOperationEventListener

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

the class IdentityUserNameResolverListener method doPreUpdateUserListOfRoleWithID.

@Override
public boolean doPreUpdateUserListOfRoleWithID(String roleName, String[] deletedUserIDs, String[] newUserIDs, UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }
    String[] deletedUserNames = getUserNamesFromUserIDs(deletedUserIDs, (AbstractUserStoreManager) userStoreManager);
    String[] newUserNames = getUserNamesFromUserIDs(newUserIDs, (AbstractUserStoreManager) userStoreManager);
    for (UserOperationEventListener listener : getUserStoreManagerListeners()) {
        if (isNotAResolverListener(listener)) {
            if (!listener.doPreUpdateUserListOfRole(roleName, deletedUserNames, newUserNames, userStoreManager)) {
                return false;
            }
        }
    }
    return true;
}
Also used : UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) AbstractIdentityUserOperationEventListener(org.wso2.carbon.identity.core.AbstractIdentityUserOperationEventListener)

Example 19 with UserOperationEventListener

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

the class IdentityUserNameResolverListener method doPreUpdateUserListOfInternalRoleWithID.

@Override
public boolean doPreUpdateUserListOfInternalRoleWithID(String roleName, String[] deletedUserIDs, String[] newUserIDs, UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }
    String[] deletedUserNames = getUserNamesFromUserIDs(deletedUserIDs, (AbstractUserStoreManager) userStoreManager);
    String[] newUserNames = getUserNamesFromUserIDs(newUserIDs, (AbstractUserStoreManager) userStoreManager);
    for (UserOperationEventListener listener : getUserStoreManagerListeners()) {
        if (isNotAResolverListener(listener)) {
            if (!listener.doPreUpdateUserListOfInternalRole(roleName, deletedUserNames, newUserNames, userStoreManager)) {
                return false;
            }
        }
    }
    return true;
}
Also used : UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) AbstractIdentityUserOperationEventListener(org.wso2.carbon.identity.core.AbstractIdentityUserOperationEventListener)

Example 20 with UserOperationEventListener

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

the class IdentityUserNameResolverListener method doPostGetUsersClaimValuesWithID.

@Override
public boolean doPostGetUsersClaimValuesWithID(List<String> userIDs, List<String> claims, String profileName, List<UniqueIDUserClaimSearchEntry> uniqueIDUserClaimSearchEntries, UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }
    List<String> userNamesList = ((AbstractUserStoreManager) userStoreManager).getUserNamesFromUserIDs(userIDs);
    String[] userNames = userNamesList.toArray(new String[0]);
    List<UserClaimSearchEntry> userClaimSearchEntries = ((AbstractUserStoreManager) userStoreManager).getUserClaimSearchEntries(uniqueIDUserClaimSearchEntries);
    for (UserOperationEventListener listener : getUserStoreManagerListeners()) {
        if (isNotAResolverListener(listener)) {
            if (!listener.doPostGetUsersClaimValues(userNames, claims.toArray(new String[0]), profileName, userClaimSearchEntries.toArray(new UserClaimSearchEntry[0]))) {
                return false;
            }
        }
    }
    return true;
}
Also used : UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) AbstractIdentityUserOperationEventListener(org.wso2.carbon.identity.core.AbstractIdentityUserOperationEventListener) AbstractUserStoreManager(org.wso2.carbon.user.core.common.AbstractUserStoreManager) UniqueIDUserClaimSearchEntry(org.wso2.carbon.user.core.model.UniqueIDUserClaimSearchEntry) UserClaimSearchEntry(org.wso2.carbon.user.core.model.UserClaimSearchEntry)

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