use of org.wso2.carbon.user.api.UserStoreManager 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;
}
use of org.wso2.carbon.user.api.UserStoreManager 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;
}
use of org.wso2.carbon.user.api.UserStoreManager 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;
}
use of org.wso2.carbon.user.api.UserStoreManager 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;
}
use of org.wso2.carbon.user.api.UserStoreManager 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;
}
Aggregations