public Response enroll(Developer developer) {
try {
this.identityManager = partitionManager.createIdentityManager();
this.relationshipManager = partitionManager.createRelationshipManager();
User user = new User(developer.getLoginName());
identityManager.add(user);
Calendar calendar = expirationDate();
Password password = new Password(developer.getPassword().toCharArray());
identityManager.updateCredential(user, password, new Date(), calendar.getTime());
Role developerRole = BasicModel.getRole(identityManager, UserRoles.DEVELOPER);
grantRoles(user, developerRole);
List<User> list = identityManager.createIdentityQuery(User.class)
.setParameter(User.LOGIN_NAME, user.getLoginName()).getResultList();
user = list.get(0);
developer.setId(user.getId());
} catch (IdentityManagementException ime) {
return Response.status(Response.Status.BAD_REQUEST).entity("Credential not available").build();
}