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);
}
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;
}
}
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;
}
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;
}
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;
}
Aggregations