Search in sources :

Example 6 with UserOperationEventListener

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

the class IdentityUserNameResolverListener method doPostGetUserListOfRoleWithID.

@Override
public boolean doPostGetUserListOfRoleWithID(String roleName, List<User> userList, UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }
    List<String> returnUserNamesList = userList.stream().map(User::getUsername).collect(Collectors.toList());
    String[] returnUserNames = returnUserNamesList.toArray(new String[0]);
    for (UserOperationEventListener listener : getUserStoreManagerListeners()) {
        if (isNotAResolverListener(listener)) {
            if (!listener.doPostGetUserListOfRole(roleName, returnUserNames, userStoreManager)) {
                return false;
            }
        }
    }
    return true;
}
Also used : UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) AbstractIdentityUserOperationEventListener(org.wso2.carbon.identity.core.AbstractIdentityUserOperationEventListener)

Example 7 with UserOperationEventListener

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

the class IdentityUserNameResolverListener method doPreDeleteUserWithID.

@Override
public boolean doPreDeleteUserWithID(String userID, UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }
    String userName = getUserNameFromUserID(userID, (AbstractUserStoreManager) userStoreManager);
    if (userName == null) {
        return handleUserNameResolveFailure(userID, userStoreManager);
    }
    // Setting the thread-local to keep userName for doPostDeleteUserWithID listener.
    IdentityUtil.threadLocalProperties.get().put(DO_PRE_DELETE_USER_USER_NAME, userName);
    for (UserOperationEventListener listener : getUserStoreManagerListeners()) {
        if (isNotAResolverListener(listener)) {
            if (!listener.doPreDeleteUser(userName, userStoreManager)) {
                return false;
            }
        }
    }
    return true;
}
Also used : UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) AbstractIdentityUserOperationEventListener(org.wso2.carbon.identity.core.AbstractIdentityUserOperationEventListener)

Example 8 with UserOperationEventListener

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

the class IdentityUserNameResolverListener method doPreAuthenticateWithID.

@Override
public boolean doPreAuthenticateWithID(String preferredUserNameClaim, String preferredUserNameValue, Object credential, UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }
    String userName;
    String[] users = userStoreManager.getUserList(preferredUserNameClaim, preferredUserNameValue, null);
    if (users.length == 1) {
        userName = UserCoreUtil.removeDomainFromName(users[0]);
    } else {
        return true;
    }
    for (UserOperationEventListener listener : getUserStoreManagerListeners()) {
        if (isNotAResolverListener(listener)) {
            if (!listener.doPreAuthenticate(userName, credential, userStoreManager)) {
                return false;
            }
        }
    }
    return true;
}
Also used : UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) AbstractIdentityUserOperationEventListener(org.wso2.carbon.identity.core.AbstractIdentityUserOperationEventListener)

Example 9 with UserOperationEventListener

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

the class IdentityUserNameResolverListener method doPostAuthenticateWithID.

@Override
public boolean doPostAuthenticateWithID(List<LoginIdentifier> loginIdentifiers, AuthenticationResult authenticationResult, UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }
    String userName;
    boolean authenticated = authenticationResult.getAuthenticationStatus() == AuthenticationResult.AuthenticationStatus.SUCCESS;
    if (authenticated) {
        userName = authenticationResult.getAuthenticatedUser().get().getUsername();
    } else {
        return true;
    }
    for (UserOperationEventListener listener : getUserStoreManagerListeners()) {
        if (isNotAResolverListener(listener)) {
            if (!listener.doPostAuthenticate(userName, authenticated, userStoreManager)) {
                return false;
            }
        }
    }
    return true;
}
Also used : UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) AbstractIdentityUserOperationEventListener(org.wso2.carbon.identity.core.AbstractIdentityUserOperationEventListener)

Example 10 with UserOperationEventListener

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

the class IdentityUserNameResolverListener method doPostUpdateUserListOfInternalRoleWithID.

@Override
public boolean doPostUpdateUserListOfInternalRoleWithID(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.doPostUpdateUserListOfInternalRole(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)

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