use of org.gluu.oxtrust.model.scim2.SearchRequest in project oxTrust by GluuFederation.
the class GroupWebService method searchGroupsPost.
@Path("/.search")
@POST
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
@ApiOperation(value = "Search group POST /.search", notes = "Returns a list of groups (https://tools.ietf.org/html/rfc7644#section-3.4.3)", response = ListResponse.class)
public Response searchGroupsPost(@HeaderParam("Authorization") String authorization, @QueryParam(OxTrustConstants.QUERY_PARAMETER_TEST_MODE_OAUTH2_TOKEN) final String token, @ApiParam(value = "SearchRequest", required = true) SearchRequest searchRequest) throws Exception {
try {
log.info("IN GroupWebService.searchGroupsPost()...");
// Authorization check is done in searchGroups()
Response response = searchGroups(authorization, token, searchRequest.getFilter(), searchRequest.getStartIndex(), searchRequest.getCount(), searchRequest.getSortBy(), searchRequest.getSortOrder(), searchRequest.getAttributesArray());
URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/Groups/.search");
log.info("LEAVING GroupWebService.searchGroupsPost()...");
return Response.fromResponse(response).location(location).build();
} catch (EntryPersistenceException ex) {
log.error("Error in searchGroupsPost", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.NOT_FOUND, ErrorScimType.INVALID_VALUE, "Resource not found");
} catch (Exception ex) {
log.error("Error in searchGroupsPost", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.INVALID_FILTER, INTERNAL_SERVER_ERROR_MESSAGE);
}
}
use of org.gluu.oxtrust.model.scim2.SearchRequest in project oxTrust by GluuFederation.
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()) {
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;
}
use of org.gluu.oxtrust.model.scim2.SearchRequest in project oxTrust by GluuFederation.
the class FidoDeviceWebService method searchDevicesPost.
@Path(SEARCH_SUFFIX)
@POST
@Consumes({ MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON })
@Produces({ MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT })
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@ProtectedApi
@RefAdjusted
@ApiOperation(value = "Search devices POST /.search", notes = "Returns a list of fido devices", response = ListResponse.class)
public Response searchDevicesPost(SearchRequest searchRequest, @QueryParam("userId") String userId) {
log.debug("Executing web service method. searchDevicesPost");
URI uri = null;
Response response = searchDevices(userId, searchRequest.getFilter(), searchRequest.getStartIndex(), searchRequest.getCount(), searchRequest.getSortBy(), searchRequest.getSortOrder(), searchRequest.getAttributesStr(), searchRequest.getExcludedAttributesStr());
try {
uri = new URI(endpointUrl + "/" + SEARCH_SUFFIX);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return Response.fromResponse(response).location(uri).build();
}
use of org.gluu.oxtrust.model.scim2.SearchRequest in project oxTrust by GluuFederation.
the class GroupWebService method searchGroupsPost.
@Path(SEARCH_SUFFIX)
@POST
@Consumes({ MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON })
@Produces({ MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT })
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@ProtectedApi
@RefAdjusted
@ApiOperation(value = "Search group POST /.search", notes = "Returns a list of groups (https://tools.ietf.org/html/rfc7644#section-3.4.3)", response = ListResponse.class)
public Response searchGroupsPost(@ApiParam(value = "SearchRequest", required = true) SearchRequest searchRequest) {
log.debug("Executing web service method. searchGroupsPost");
// Calling searchGroups here does not provoke that method's interceptor/decorator being called (only this one's)
URI uri = null;
Response response = searchGroups(searchRequest.getFilter(), searchRequest.getStartIndex(), searchRequest.getCount(), searchRequest.getSortBy(), searchRequest.getSortOrder(), searchRequest.getAttributesStr(), searchRequest.getExcludedAttributesStr());
try {
uri = new URI(endpointUrl + "/" + SEARCH_SUFFIX);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return Response.fromResponse(response).location(uri).build();
}
use of org.gluu.oxtrust.model.scim2.SearchRequest in project oxTrust by GluuFederation.
the class SearchResourcesWebService method getListResponseTree.
/**
* Returns a JsonNode with the response obtained from sending a POST to a search method given the SearchRequest passed
* @param index Determines the concrete search method to be executed: (0 - user; 1 - group; 2 - fido device)
* @param searchRequest
* @return
*/
private JsonNode getListResponseTree(int index, SearchRequest searchRequest) {
try {
log.debug("getListResponseTree. Resource type is: {}", ScimResourceUtil.getType(resourceClasses[index]));
Response r = null;
switch(index) {
case 0:
r = userWS.searchUsersPost(searchRequest);
break;
case 1:
r = groupWS.searchGroupsPost(searchRequest);
break;
case 2:
r = fidoWS.searchDevicesPost(searchRequest, null);
break;
}
if (r.getStatus() != OK.getStatusCode())
throw new Exception("Intermediate POST search returned " + r.getStatus());
// readEntity does not work here since data is not backed by an input stream, so we just get the raw entity
String jsonStr = r.getEntity().toString();
return mapper.readTree(jsonStr);
} catch (Exception e) {
log.error("Error in getListResponseTree {}", e.getMessage());
log.error(e.getMessage(), e);
return null;
}
}
Aggregations