Skip to content

Commit

Permalink
Improve shared user operation event listener
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanChathusanda93 committed Sep 15, 2023
1 parent de84b00 commit 0c924c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class UserInvitationMgtConstants {
// Configurations
public static final String ORG_USER_INVITATION_USER_DOMAIN = "OrganizationUserInvitation.PrimaryUserDomain";
public static final String ORG_USER_INVITATION_DEFAULT_REDIRECT_URL =
"OrganizationUserInvitation.DefaultRedirectURL";
"OrganizationUserInvitation.DefaultAcceptURL";

/**
* Error messages for organization user invitation management related errors.
Expand Down Expand Up @@ -198,7 +198,10 @@ public enum ErrorMessage {
"Could not delete invited user association for user %s."),
ERROR_CODE_CHECK_USER_CLAIM_UPDATE_ALLOWED("10401",
"Unable to check whether the update is allowed.",
"Could not check whether the user claim update is allowed for user %s.");
"Could not check whether the user claim update is allowed for user %s."),
ERROR_CODE_MANAGED_ORG_CLAIM_UPDATE_NOT_ALLOWED("10402",
"Claim update not allowed.",
"Update the value for the claim %s is not allowed.");

private final String code;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@

import java.util.Map;

import static org.wso2.carbon.identity.organization.user.invitation.management.constant.UserInvitationMgtConstants.CLAIM_MANAGED_ORGANIZATION;
import static org.wso2.carbon.identity.organization.user.invitation.management.constant.UserInvitationMgtConstants.ErrorMessage.ERROR_CODE_CHECK_USER_CLAIM_UPDATE_ALLOWED;
import static org.wso2.carbon.identity.organization.user.invitation.management.constant.UserInvitationMgtConstants.ErrorMessage.ERROR_CODE_DELETE_INVITED_USER_ASSOCIATION;
import static org.wso2.carbon.identity.organization.user.invitation.management.constant.UserInvitationMgtConstants.ErrorMessage.ERROR_CODE_MANAGED_ORG_CLAIM_UPDATE_NOT_ALLOWED;

/**
* Organization shared user operation event listener.
Expand Down Expand Up @@ -73,6 +75,20 @@ public boolean doPreSetUserClaimValuesWithID(String userID, Map<String, String>
}
}

public boolean doPreSetUserClaimValueWithID(String userID, String claimURI, String claimValue, String profileName,
UserStoreManager userStoreManager) throws UserStoreException {

if (!isEnable() || userStoreManager == null) {
return true;
}
if (CLAIM_MANAGED_ORGANIZATION.equals(claimURI)) {
throw new UserStoreException(String.format(
ERROR_CODE_MANAGED_ORG_CLAIM_UPDATE_NOT_ALLOWED.getDescription(), CLAIM_MANAGED_ORGANIZATION),
ERROR_CODE_MANAGED_ORG_CLAIM_UPDATE_NOT_ALLOWED.getCode());
}
return true;
}

@Override
public boolean isEnable() {

Expand Down

0 comments on commit 0c924c9

Please sign in to comment.