Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation for the count parameter #541

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ public Response getUser(@HeaderParam(SCIMProviderConstants.ACCEPT_HEADER) String
throw new FormatNotSupportedException(error);
}

// Validates the count parameter if exists.
if (count != null && IdentityUtil.isSCIM2UserMaxItemsPerPageEnabled()) {
count = validateCountParameter(count);
}

// obtain the user store manager
UserManager userManager = IdentitySCIMManager.getInstance().getUserManager();

Expand Down Expand Up @@ -392,4 +397,24 @@ private void removeAskPasswordConfirmationCodeThreadLocal() {
IdentityUtil.threadLocalProperties.get()
.remove(IdentityRecoveryConstants.AP_CONFIRMATION_CODE_THREAD_LOCAL_PROPERTY);
}

/**
* Validate the count query parameter.
*
* @param count Requested item count.
* @return Validated count parameter.
*/
private int validateCountParameter(Integer count) {

int maximumItemsPerPage = IdentityUtil.getMaximumItemPerPage();
if (count > maximumItemsPerPage) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Given limit exceeds the maximum limit. Therefore the limit is set to %s.",
maximumItemsPerPage));
}
return maximumItemsPerPage;
}

return count;
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
<inbound.auth.oauth.version>6.5.3</inbound.auth.oauth.version>
<commons-collections.version>3.2.0.wso2v1</commons-collections.version>
<carbon.kernel.version>4.10.2</carbon.kernel.version>
<identity.framework.version>7.0.105</identity.framework.version>
<identity.framework.version>7.0.112</identity.framework.version>
<junit.version>4.13.1</junit.version>
<commons.lang.version>20030203.000129</commons.lang.version>
<identity.governance.version>1.8.12</identity.governance.version>
Expand Down
Loading