Search in sources :

Example 6 with SearchRequest

use of org.gluu.oxtrust.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;
}
Also used : Response(javax.ws.rs.core.Response) SearchRequest(org.gluu.oxtrust.model.scim2.SearchRequest)

Example 7 with SearchRequest

use of org.gluu.oxtrust.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;
}
Also used : Response(javax.ws.rs.core.Response) SearchRequest(org.gluu.oxtrust.model.scim2.SearchRequest)

Example 8 with SearchRequest

use of org.gluu.oxtrust.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();
}
Also used : SearchRequest(org.gluu.oxtrust.model.scim2.SearchRequest) QueryParam(javax.ws.rs.QueryParam) Annotation(java.lang.annotation.Annotation) AroundInvoke(javax.interceptor.AroundInvoke)

Example 9 with SearchRequest

use of org.gluu.oxtrust.model.scim2.SearchRequest in project oxTrust by GluuFederation.

the class FidoDeviceWebService method searchDevicesPost.

@Path("/.search")
@POST
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8", MediaType.APPLICATION_JSON + "; charset=utf-8" })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
@ApiOperation(value = "Search devices POST /.search", notes = "Returns a list of devices (https://tools.ietf.org/html/rfc7644#section-3.4.3)", response = ListResponse.class)
public Response searchDevicesPost(@HeaderParam("Authorization") String authorization, @QueryParam(OxTrustConstants.QUERY_PARAMETER_TEST_MODE_OAUTH2_TOKEN) final String token, @QueryParam("userId") final String userId, @ApiParam(value = "SearchRequest", required = true) SearchRequest searchRequest) throws Exception {
    try {
        log.info("IN FidoDeviceWebService.searchDevicesPost()...");
        // Authorization check is done in searchDevices()
        Response response = searchDevices(authorization, token, userId, searchRequest.getFilter(), searchRequest.getStartIndex(), searchRequest.getCount(), searchRequest.getSortBy(), searchRequest.getSortOrder(), searchRequest.getAttributesArray());
        URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/FidoDevices/.search");
        log.info("LEAVING FidoDeviceWebService.searchDevicesPost()...");
        return Response.fromResponse(response).location(location).build();
    } catch (EntryPersistenceException epe) {
        log.error("Error in searchDevicesPost", epe);
        epe.printStackTrace();
        return getErrorResponse(Response.Status.NOT_FOUND, ErrorScimType.INVALID_VALUE, "Resource not found");
    } catch (Exception e) {
        log.error("Error in searchDevicesPost", e);
        e.printStackTrace();
        return getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.INVALID_FILTER, INTERNAL_SERVER_ERROR_MESSAGE);
    }
}
Also used : VirtualListViewResponse(org.xdi.ldap.model.VirtualListViewResponse) ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) URI(java.net.URI) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) DuplicateEntryException(org.gluu.site.ldap.exception.DuplicateEntryException) Path(javax.ws.rs.Path) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation)

Example 10 with SearchRequest

use of org.gluu.oxtrust.model.scim2.SearchRequest in project oxTrust by GluuFederation.

the class UserWebService method searchUsersPost.

@Path("/.search")
@POST
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8", MediaType.APPLICATION_JSON + "; charset=utf-8" })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
@ApiOperation(value = "Search users POST /.search", notes = "Returns a list of users (https://tools.ietf.org/html/rfc7644#section-3.4.3)", response = ListResponse.class)
public Response searchUsersPost(@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 UserWebService.searchUsersPost()...");
        // Authorization check is done in searchUsers()
        Response response = searchUsers(authorization, token, searchRequest.getFilter(), searchRequest.getStartIndex(), searchRequest.getCount(), searchRequest.getSortBy(), searchRequest.getSortOrder(), searchRequest.getAttributesArray());
        URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/Users/.search");
        log.info("LEAVING UserWebService.searchUsersPost()...");
        return Response.fromResponse(response).location(location).build();
    } catch (EntryPersistenceException ex) {
        log.error("Error in searchUsersPost", ex);
        ex.printStackTrace();
        return getErrorResponse(Response.Status.NOT_FOUND, ErrorScimType.INVALID_VALUE, "Resource not found");
    } catch (Exception ex) {
        log.error("Error in searchUsersPost", ex);
        ex.printStackTrace();
        return getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.INVALID_FILTER, INTERNAL_SERVER_ERROR_MESSAGE);
    }
}
Also used : ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) VirtualListViewResponse(org.xdi.ldap.model.VirtualListViewResponse) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) URI(java.net.URI) PersonRequiredFieldsException(org.gluu.oxtrust.exception.PersonRequiredFieldsException) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) DuplicateEntryException(org.gluu.site.ldap.exception.DuplicateEntryException) Path(javax.ws.rs.Path) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation)

Aggregations

Response (javax.ws.rs.core.Response)13 ListResponse (org.gluu.oxtrust.model.scim2.ListResponse)9 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)7 URI (java.net.URI)7 DefaultValue (javax.ws.rs.DefaultValue)6 HeaderParam (javax.ws.rs.HeaderParam)6 POST (javax.ws.rs.POST)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 SearchRequest (org.gluu.oxtrust.model.scim2.SearchRequest)6 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)4 RefAdjusted (org.gluu.oxtrust.service.scim2.interceptor.RefAdjusted)4 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)3 Consumes (javax.ws.rs.Consumes)3 SCIMException (org.gluu.oxtrust.model.exception.SCIMException)3 ListViewResponse (org.gluu.persist.model.ListViewResponse)3 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)3 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)3 VirtualListViewResponse (org.xdi.ldap.model.VirtualListViewResponse)3 Annotation (java.lang.annotation.Annotation)1