NonLiteral user = getUserByUserName(name);
if (user == null) {
throw new UserNotExistsException(name);
}
LockableMGraph systemGraph = getSystemGraph();
GraphNode userGraphNode = new GraphNode(user, systemGraph);
Lock writeLock = userGraphNode.writeLock();
writeLock.lock();
try {
if (email != null) {
updateProperty(userGraphNode, FOAF.mbox, new UriRef("mailto:" + email));
}
if (password != null) {
try {
String pswSha1 = bytes2HexString(MessageDigest.getInstance("SHA1").digest(password.getBytes("UTF-8")));
updateProperty(userGraphNode, PERMISSION.passwordSha1, new PlainLiteralImpl(pswSha1));
} catch (UnsupportedEncodingException ex) {
throw new RuntimeException(ex);
} catch (NoSuchAlgorithmException ex) {
throw new RuntimeException(ex);
}
}
if (pathPrefix != null && pathPrefix.trim().length() != 0) {
updateProperty(userGraphNode, OSGI.agent_path_prefix,
new PlainLiteralImpl(pathPrefix));
}
if (!assignedRoles.isEmpty()) {
userGraphNode.deleteProperties(SIOC.has_function);
addRolesToUser(assignedRoles, (NonLiteral) userGraphNode.getNode());
//refresh the policy so it will recheck the permissions
Policy.getPolicy().refresh();
}
} finally {
writeLock.unlock();