Search in sources :

Example 26 with User

use of org.gluu.oxtrust.model.scim2.User in project openstack4j by ContainX.

the class KeystoneUserServiceTests method getUser_byName_byDomainId_NotExist_Test.

/**
     * returns null for an non-existing user when the user specified by name and domain.
     *
     * @throws Exception
     */
public void getUser_byName_byDomainId_NotExist_Test() throws Exception {
    respondWith(JSON_USER_GET_BYNAME_BYDOMAINID_NOT_EXIST);
    User user = osv3().identity().users().getByName(USER_NAME, USER_DOMAIN_ID);
    assertNull(user);
}
Also used : KeystoneUser(org.openstack4j.openstack.identity.v3.domain.KeystoneUser) User(org.openstack4j.model.identity.v3.User)

Example 27 with User

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

Example 28 with User

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

the class UserWebService method createUser.

/**
 */
@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 = "Create user", notes = "https://tools.ietf.org/html/rfc7644#section-3.3", response = UserResource.class)
public Response createUser(@ApiParam(value = "User", required = true) UserResource user, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList) {
    Response response;
    try {
        log.debug("Executing web service method. createUser");
        scim2UserService.createUser(user, endpointUrl);
        String json = resourceSerializer.serialize(user, attrsList, excludedAttrsList);
        response = Response.created(new URI(user.getMeta().getLocation())).entity(json).build();
    } catch (Exception e) {
        log.error("Failure at createUser method", e);
        response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
    }
    return response;
}
Also used : ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) ListViewResponse(org.gluu.persist.model.ListViewResponse) URI(java.net.URI) SCIMException(org.gluu.oxtrust.model.exception.SCIMException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) RefAdjusted(org.gluu.oxtrust.service.scim2.interceptor.RefAdjusted) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi)

Example 29 with User

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

the class UserWebService method deleteUser.

@Path("{id}")
@DELETE
@Produces({ MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT })
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@ProtectedApi
@ApiOperation(value = "Delete User", notes = "Delete User (https://tools.ietf.org/html/rfc7644#section-3.6)")
public Response deleteUser(@PathParam("id") String id) {
    Response response;
    try {
        log.debug("Executing web service method. deleteUser");
        // person cannot be null (check associated decorator method)
        GluuCustomPerson person = personService.getPersonByInum(id);
        scim2UserService.deleteUser(person);
        response = Response.noContent().build();
    } catch (Exception e) {
        log.error("Failure at deleteUser method", e);
        response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
    }
    return response;
}
Also used : ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) ListViewResponse(org.gluu.persist.model.ListViewResponse) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) SCIMException(org.gluu.oxtrust.model.exception.SCIMException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) Path(javax.ws.rs.Path) DefaultValue(javax.ws.rs.DefaultValue) DELETE(javax.ws.rs.DELETE) HeaderParam(javax.ws.rs.HeaderParam) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi)

Example 30 with User

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

the class ExtensionService method getResourceExtensions.

public List<Extension> getResourceExtensions(Class<? extends BaseScimResource> cls) {
    List<Extension> list = new ArrayList<Extension>();
    try {
        // Currently support one extension only for User Resource
        if (cls.equals(UserResource.class)) {
            Map<String, ExtensionField> fields = new HashMap<String, ExtensionField>();
            for (GluuAttribute attribute : attrService.getSCIMRelatedAttributes()) {
                if (attribute.getOxSCIMCustomAttribute().equals(ScimCustomAtribute.TRUE)) {
                    // first non-null check is needed because certain entries do not have the multivalue attribute set
                    boolean multi = attribute.getOxMultivaluedAttribute() != null && attribute.getOxMultivaluedAttribute().equals(OxMultivalued.TRUE);
                    ExtensionField field = new ExtensionField();
                    field.setDescription(attribute.getDescription());
                    field.setType(attribute.getDataType());
                    field.setMultiValued(multi);
                    field.setName(attribute.getName());
                    fields.put(attribute.getName(), field);
                }
            }
            Extension ext = new Extension(USER_EXT_SCHEMA_ID);
            ext.setFields(fields);
            ext.setName(USER_EXT_SCHEMA_NAME);
            ext.setDescription(USER_EXT_SCHEMA_DESCRIPTION);
            list.add(ext);
        }
    } catch (Exception e) {
        log.error("An error ocurred when building extension for {}", cls.getName());
        log.error(e.getMessage(), e);
    }
    return list;
}
Also used : Extension(org.gluu.oxtrust.model.scim2.extensions.Extension) ExtensionField(org.gluu.oxtrust.model.scim2.extensions.ExtensionField) GluuAttribute(org.xdi.model.GluuAttribute)

Aggregations

GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)18 User (org.gluu.oxtrust.model.scim2.User)17 ArrayList (java.util.ArrayList)13 Response (javax.ws.rs.core.Response)13 DefaultValue (javax.ws.rs.DefaultValue)12 HeaderParam (javax.ws.rs.HeaderParam)12 Produces (javax.ws.rs.Produces)12 URI (java.net.URI)11 ListResponse (org.gluu.oxtrust.model.scim2.ListResponse)11 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)10 ScimPatchUser (org.gluu.oxtrust.model.scim2.ScimPatchUser)10 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)10 User (org.openstack4j.model.identity.v3.User)10 Date (java.util.Date)9 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)8 PersonRequiredFieldsException (org.gluu.oxtrust.exception.PersonRequiredFieldsException)8 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)8 IOException (java.io.IOException)7 Map (java.util.Map)7 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)7