Skip to content

Commit

Permalink
fix(jans-scim): improper handling response of get user operation (#2420)
Browse files Browse the repository at this point in the history
* fix: prevent initialization error #2395

* docs: update docs
  • Loading branch information
jgomer2001 committed Sep 20, 2022
1 parent 2878bdd commit b9e00af
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 60 deletions.
2 changes: 1 addition & 1 deletion docs/developer/implementation-design/jans-scim.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
This file is a placeholder
This file is a placeholder.
Original file line number Diff line number Diff line change
Expand Up @@ -219,68 +219,10 @@ private String getStringDateFrom(String str) {

@PostConstruct
private void init() {
init(ScimResourcesUpdatedWebService.class);
ldapBackend = scimFilterParserService.isLdapBackend();
attributeDataTypes = new HashMap<>();
attributeService.getAllAttributes().forEach(ga -> attributeDataTypes.put(ga.getName(), ga.getDataType()));
}

/*
//Groups endpoint not necessary, but if needed, we need to guarantee first that excludeMetaLastMod is refreshed
//whenever the group is updated in GUI or via SCIM (or cust script)
//@Path("UpdatedGroups")
//@GET
@Produces(MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT)
@ProtectedApi
public Response groupsChangedAfter(@QueryParam("timeStamp") String isoDate) {
Response response;
log.debug("Executing web service method. groupsChangedAfter");
try {
String date = ZonedDateTime.parse(isoDate).format(DateTimeFormatter.ISO_INSTANT);
//In database, excludeMetaLastMod is just a string (not date)
Filter filter = Filter.createORFilter(
Filter.createNOTFilter(Filter.createPresenceFilter("jansMetaLastMod")),
Filter.createGreaterOrEqualFilter("jansMetaLastMod", date));
List<GluuGroup> list = entryManager.findEntries(groupService.getDnForGroup(null), GluuGroup.class, filter);
response = Response.ok(getGroupResultsAsJson(list)).build();
} catch (DateTimeParseException e) {
response = getErrorResponse(Response.Status.BAD_REQUEST, e.getMessage());
} catch (Exception e1) {
log.error("Failure at groupsChangedAfter method", e1);
response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e1.getMessage());
}
return response;
}
private String getGroupResultsAsJson(List<GluuGroup> list) throws Exception {
List<BaseScimResource> resources = new ArrayList<>();
long fresher = 0;
for (GluuGroup group : list) {
GroupResource jsScimGrp = new GroupResource();
scim2GroupService.transferAttributesToGroupResource(group, jsScimGrp, userWebService.getEndpointUrl(), groupWebService.getEndpointUrl());
resources.add(jsScimGrp);
String modified = group.getAttribute("jansMetaLastMod");
try {
if (modified != null) {
long updatedAt = ZonedDateTime.parse(modified).toInstant().toEpochMilli();
if (fresher < updatedAt) {
fresher = updatedAt;
}
}
} catch (Exception e) {
log.error("Error parsing supposed ISO date {}", modified);
}
}
return getResultsAsJson(resources, fresher);
}
*/

}

0 comments on commit b9e00af

Please sign in to comment.