Skip to content

Instantly share code, notes, and snippets.

@girirajsharma
Last active August 29, 2015 14:06
Show Gist options
  • Save girirajsharma/191e7f34a07bc6f16b2e to your computer and use it in GitHub Desktop.
Save girirajsharma/191e7f34a07bc6f16b2e to your computer and use it in GitHub Desktop.
/*Existing Implementation of REST Endpoints:
UserEndpoint
//Create an user
Reads JSON representation of user from a file SCIMUser.json, parses it into
SCIMUser object(includes lot of details about scimuser) and
populates PL IDM User object with basic information(id, loginName, firstName, lastName)
with the help of SCIMUser and stores user it in identityManager. Sends back String representation
of SCIMUser as JSON.
//Retrieve a User
Retrieves PL IDM User from identityManager of the desired id via IdentityQuery.
Populates the basic info (id, loginName, firstName,
lastName) of PL IDM User into newly created SCIMUser object
(SCIMUser object lacks other required information).
Sends back String representation of SCIMUser as JSON.
SCIMUser is mapped to IDM User for storage. Since, IDM User is able to store only basic info about SCIMUser,
we aren't able to retrieve all the details about SCIMUser while retrieving it from identityManager.
Current Implementation/Idea:
SCIMUser will be changed to SCIMUserType which will extend AbstractIdentityType.
SCIMUserType will act as identity model for storage in identityManager.
SCIMUserType will be same as CertificateType model in PKI*/
//-------------------------------------------------------------------------------------------
//POJO Class JSON Parser/Writer
/*Parser
Q ]] SCIMUser is a POJO/bean class. If SCIMUser is an
custom identity model(extends AbstractIdentityTYpe), will the parser work ??? I hope it will work. */
public SCIMUser parseUser(InputStream is) throws SCIMParsingException {
try {
return mapper.readValue(is, SCIMUser.class);
} catch (JsonParseException e) {
throw new SCIMParsingException(e);
} catch (JsonMappingException e) {
throw new SCIMParsingException(e);
} catch (IOException e) {
throw new SCIMParsingException(e);
}
}
/* Writer
Q ]] scimObject is object of SCIMUser class which is a POJO/bean class.
If SCIMUser is custom identity model(extends AbstractIdentityType),
will the writer work ??? I hope it will work. */
private String jsonify(Object scimObject) throws SCIMWriterException {
try {
StringWriter stringWriter = new StringWriter();
JsonGenerator jg = jsonFactory.createJsonGenerator(stringWriter);
objectMapper.writeValue(jg, scimObject);
return stringWriter.toString();
} catch (JsonGenerationException e) {
throw new SCIMWriterException(e);
} catch (JsonMappingException e) {
throw new SCIMWriterException(e);
} catch (IOException e) {
throw new SCIMWriterException(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment