Package com.wesabe.grendel.auth

Examples of com.wesabe.grendel.auth.Session


  public Response update(@Context Request request,@Context Credentials credentials,
    @PathParam("id") String id, UpdateUserRepresentation entity) throws CryptographicException {
   
    entity.validate();
   
    final Session session = credentials.buildSession(userDAO, id);
   
    checkPreconditions(request, session.getUser());
   
    final User user = session.getUser();
    final UnlockedKeySet keySet = session.getKeySet();
   
    user.setKeySet(
      keySet.relock(
        credentials.getPassword().toCharArray(),
        entity.getPassword(),
View Full Code Here


  @GET
  public LinkListRepresentation listLinks(@Context UriInfo uriInfo,
    @Context Credentials credentials, @PathParam("user_id") String userId,
    @PathParam("name") String documentName) {
   
    final Session session = credentials.buildSession(userDAO, userId);
   
    final Document doc = documentDAO.findByOwnerAndName(session.getUser(), documentName);
    if (doc == null) {
      throw new WebApplicationException(Status.NOT_FOUND);
    }
   
    return new LinkListRepresentation(uriInfo, doc);
View Full Code Here

  @Transactional
  public Response createLink(@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.linkUser(reader);
    reEncrypt(doc, session.getKeySet());
   
    documentDAO.saveOrUpdate(doc);
   
    return Response.noContent().build();
  }
View Full Code Here

  @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();
  }
View Full Code Here

  @GET
  public Response show(@Context Credentials credentials,
    @PathParam("user_id") String userId, @PathParam("owner_id") String ownerId,
    @PathParam("name") String name) {
   
    final Session session = credentials.buildSession(userDAO, userId);
    final User owner = findUser(ownerId);
    final Document doc = findDocument(owner, name);
   
    checkLinkage(doc, session.getUser());
   
    try {
      final byte[] body = doc.decryptBody(session.getKeySet());
      return Response.ok()
          .entity(body)
          .type(doc.getContentType())
          .cacheControl(CACHE_SETTINGS)
          .lastModified(doc.getModifiedAt().toDate())
View Full Code Here

  @Transactional
  public Response delete(@Context Credentials credentials,
    @PathParam("user_id") String userId, @PathParam("owner_id") String ownerId,
    @PathParam("name") String name) {
   
    final Session session = credentials.buildSession(userDAO, userId);
    final User owner = findUser(ownerId);
    final Document doc = findDocument(owner, name);
   
    checkLinkage(doc, session.getUser());
   
    doc.unlinkUser(session.getUser());
    documentDAO.saveOrUpdate(doc);
   
    return Response.noContent().build();
  }
View Full Code Here

TOP

Related Classes of com.wesabe.grendel.auth.Session

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.