예제 #1
0
 private void reEncrypt(Document doc, UnlockedKeySet ownerKeySet) {
   try {
     final byte[] body = doc.decryptBody(ownerKeySet);
     doc.encryptAndSetBody(ownerKeySet, randomProvider.get(), body);
   } catch (CryptographicException e) {
     throw new RuntimeException(e);
   }
 }
예제 #2
0
  @DELETE
  @Transactional
  public Response deleteLink(
      @Context Credentials credentials,
      @PathParam("user_id") String userId,
      @PathParam("name") String name,
      @PathParam("reader_id") String readerId) {

    final Session session = credentials.buildSession(userDAO, userId);
    final User reader = findUser(readerId);
    final Document doc = findDocument(session.getUser(), name);

    doc.unlinkUser(reader);
    reEncrypt(doc, session.getKeySet());

    documentDAO.saveOrUpdate(doc);

    return Response.noContent().build();
  }