use of io.jans.scim.model.scim2.SearchRequest in project oxTrust by GluuFederation.
the class FidoDeviceWebServiceDecorator method searchDevices.
public Response searchDevices(String userId, String filter, Integer startIndex, Integer count, String sortBy, String sortOrder, String attrsList, String excludedAttrsList) {
SearchRequest searchReq = new SearchRequest();
Response response = prepareSearchRequest(searchReq.getSchemas(), filter, sortBy, sortOrder, startIndex, count, attrsList, excludedAttrsList, searchReq);
if (response == null) {
response = validateExistenceOfUser(userId);
if (response == null) {
response = service.searchDevices(userId, searchReq.getFilter(), searchReq.getStartIndex(), searchReq.getCount(), searchReq.getSortBy(), searchReq.getSortOrder(), searchReq.getAttributesStr(), searchReq.getExcludedAttributesStr());
}
}
return response;
}
use of io.jans.scim.model.scim2.SearchRequest in project oxTrust by GluuFederation.
the class GroupWebServiceDecorator method searchGroups.
public Response searchGroups(String filter, Integer startIndex, Integer count, String sortBy, String sortOrder, String attrsList, String excludedAttrsList) {
SearchRequest searchReq = new SearchRequest();
Response response = prepareSearchRequest(searchReq.getSchemas(), filter, sortBy, sortOrder, startIndex, count, attrsList, excludedAttrsList, searchReq);
if (response == null) {
response = service.searchGroups(searchReq.getFilter(), searchReq.getStartIndex(), searchReq.getCount(), searchReq.getSortBy(), searchReq.getSortOrder(), searchReq.getAttributesStr(), searchReq.getExcludedAttributesStr());
}
return response;
}
use of io.jans.scim.model.scim2.SearchRequest in project oxTrust by GluuFederation.
the class ReferenceURIInterceptor method manage.
@AroundInvoke
public Object manage(InvocationContext ctx) throws Exception {
Object[] params = ctx.getParameters();
Annotation[][] annotations = ctx.getMethod().getParameterAnnotations();
for (int i = 0; i < annotations.length; i++) {
// Iterate over annotations found at every parameter
for (Annotation annotation : annotations[i]) {
if (annotation instanceof QueryParam) {
String paramName = ((QueryParam) annotation).value();
if ((paramName.equals(QUERY_PARAM_FILTER) || paramName.equals(QUERY_PARAM_ATTRIBUTES) || paramName.equals(QUERY_PARAM_EXCLUDED_ATTRS))) {
log.trace("Removing '$' char (if any) from {} param", paramName);
params[i] = dropDollar(params[i]);
}
}
}
if (params[i] != null && params[i] instanceof SearchRequest) {
log.trace("Removing '$' char (if any) from SearchRequest object");
SearchRequest sr = (SearchRequest) params[i];
sr.setAttributes(dropDollar(sr.getAttributesStr()));
sr.setExcludedAttributes(dropDollar(sr.getExcludedAttributesStr()));
sr.setFilter(dropDollar(sr.getFilter()));
}
}
log.debug("ReferenceURIInterceptor. manage exit");
return ctx.proceed();
}
use of io.jans.scim.model.scim2.SearchRequest in project jans by JanssenProject.
the class Fido2DeviceWebService method doSearchDevices.
private Response doSearchDevices(String userId, String filter, Integer startIndex, Integer count, String sortBy, String sortOrder, String attrsList, String excludedAttrsList, String method) {
Response response;
try {
SearchRequest searchReq = new SearchRequest();
response = prepareSearchRequest(searchReq.getSchemas(), filter, sortBy, sortOrder, startIndex, count, attrsList, excludedAttrsList, searchReq);
if (response != null)
return response;
response = externalConstraintsService.applySearchCheck(searchReq, httpHeaders, uriInfo, method, fido2ResourceType);
if (response != null)
return response;
response = validateExistenceOfUser(userId);
if (response != null)
return response;
PagedResult<BaseScimResource> resources = searchDevices(userId, searchReq.getFilter(), translateSortByAttribute(Fido2DeviceResource.class, searchReq.getSortBy()), SortOrder.getByValue(searchReq.getSortOrder()), searchReq.getStartIndex(), searchReq.getCount());
String json = getListResponseSerialized(resources.getTotalEntriesCount(), searchReq.getStartIndex(), resources.getEntries(), searchReq.getAttributesStr(), searchReq.getExcludedAttributesStr(), searchReq.getCount() == 0);
response = Response.ok(json).location(new URI(endpointUrl)).build();
} catch (SCIMException e) {
log.error(e.getMessage(), e);
response = getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.INVALID_FILTER, e.getMessage());
} catch (Exception e) {
log.error("Failure at searchF2Devices method", e);
response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
}
return response;
}
use of io.jans.scim.model.scim2.SearchRequest in project jans by JanssenProject.
the class BaseScimWebService method prepareSearchRequest.
protected Response prepareSearchRequest(List<String> schemas, String filter, String sortBy, String sortOrder, Integer startIndex, Integer count, String attrsList, String excludedAttrsList, SearchRequest request) {
Response response = null;
if (schemas != null && schemas.size() == 1 && schemas.get(0).equals(SEARCH_REQUEST_SCHEMA_ID)) {
count = count == null ? getMaxCount() : count;
// Per spec, a negative value SHALL be interpreted as "0" for count
if (count < 0) {
count = 0;
}
if (count <= getMaxCount()) {
// SCIM searches are 1 indexed
startIndex = (startIndex == null || startIndex < 1) ? 1 : startIndex;
if (StringUtils.isEmpty(sortOrder) || !sortOrder.equals(SortOrder.DESCENDING.getValue())) {
sortOrder = SortOrder.ASCENDING.getValue();
}
request.setSchemas(schemas);
request.setAttributes(attrsList);
request.setExcludedAttributes(excludedAttrsList);
request.setFilter(filter);
request.setSortBy(sortBy);
request.setSortOrder(sortOrder);
request.setStartIndex(startIndex);
request.setCount(count);
} else {
response = getErrorResponse(BAD_REQUEST, ErrorScimType.TOO_MANY, "Maximum number of results per page is " + getMaxCount());
}
} else {
response = getErrorResponse(BAD_REQUEST, ErrorScimType.INVALID_SYNTAX, "Wrong schema(s) supplied in Search Request");
}
return response;
}
Aggregations