@Consumes("application/x-www-form-urlencoded")
public Response post(@FormParam("name") String name,
@FormParam("attribute_names") List<String> attrNames,
@FormParam("admin") String adminId)
{
UserRecord admin = sm.getByToken(adminId);
if (admin == null) {
throw new NotFoundException("Invalid token " + adminId);
}
// check that the admin user is actually in the admin group
if (!isAdmin(admin.getUserId())) {
return Response.status(Response.Status.FORBIDDEN)
.entity("Only administrators can read")
.type("text/plain").build();
}
// now look up the user
UserRecord rec = sm.get(name);
if (rec == null) {
throw new NotFoundException("Unknown name " + name);
}
StringBuffer res = new StringBuffer(PREFIX + "name=" + name + "\n");
res.append(PREFIX + "type=user\n");
res.append(PREFIX + "attribute=\n");
Attributes attrs = rec.getAttributes();
logger.fine("Found " + attrs.size() +
" attributes for " + rec.getUserId());
NamingEnumeration attrEnum = attrs.getAll();
try {
while (attrEnum.hasMore()) {
Attribute attr = (Attribute) attrEnum.next();