Package com.wesabe.grendel.auth

Examples of com.wesabe.grendel.auth.Session


      verify(keySet).unlock("hah".toCharArray());
    }
   
    @Test
    public void itReturnsASessionWithTheUserAndKeySet() throws Exception {
      final Session session = creds.buildSession(userDAO);
     
      assertThat(session.getUser()).isEqualTo(user);
      assertThat(session.getKeySet()).isEqualTo(unlockedKeySet);
    }
View Full Code Here


      super.setup();
    }
   
    @Test
    public void itReturnsASessionWithTheUserAndKeySet() throws Exception {
      final Session session = creds.buildSession(userDAO, "woo");
     
      assertThat(session.getUser()).isEqualTo(user);
      assertThat(session.getKeySet()).isEqualTo(unlockedKeySet);
    }
View Full Code Here

      this.user = mock(User.class);
      this.modifiedAt = new DateTime(2010, 1, 3, 9, 51, 32, 0, DateTimeZone.UTC);
      when(user.getModifiedAt()).thenReturn(modifiedAt);
      when(user.getEtag()).thenReturn("user-bob-4");
     
      this.session = new Session(user, keySet);
     
      this.uriInfo = mock(UriInfo.class);
      when(uriInfo.getBaseUriBuilder()).thenAnswer(new Answer<UriBuilder>() {
        @Override
        public UriBuilder answer(InvocationOnMock invocation) throws Throwable {
View Full Code Here

    @Before
    public void setup() throws Exception {
      this.user = mock(User.class);
      this.keySet = mock(UnlockedKeySet.class);
     
      this.session = new Session(user, keySet);
    }
View Full Code Here

      when(document.isLinked(user)).thenReturn(true);
     
      this.documentDAO = mock(DocumentDAO.class);
      when(documentDAO.findByOwnerAndName(owner, "document1.txt")).thenReturn(document);
     
      this.session = new Session(user, keySet);
     
      this.credentials = mock(Credentials.class);
      when(credentials.buildSession(userDAO, "bob")).thenReturn(session);
     
      this.resource = new LinkedDocumentResource(userDAO, documentDAO);
View Full Code Here

   */
  @GET
  public Response show(@Context Request request, @Context Credentials credentials,
    @PathParam("user_id") String userId, @PathParam("name") String name) throws CryptographicException {
   
    final Session session = credentials.buildSession(userDAO, userId);
   
    final Document doc = documentDAO.findByOwnerAndName(session.getUser(), name);
   
    if (doc == null) {
      throw new WebApplicationException(Status.NOT_FOUND);
    }
   
    checkPreconditions(request, doc);
   
    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

  @DELETE
  @Transactional
  public Response delete(@Context Request request, @Context Credentials credentials,
    @PathParam("user_id") String userId, @PathParam("name") String name) {
   
    final Session session = credentials.buildSession(userDAO, userId);
    final Document doc = documentDAO.findByOwnerAndName(session.getUser(), name);
    if (doc == null) {
      throw new WebApplicationException(Status.NOT_FOUND);
    }
   
    checkPreconditions(request, doc);
View Full Code Here

  @Transactional
  public Response store(@Context Request request, @Context HttpHeaders headers,
    @Context Credentials credentials, @PathParam("user_id") String userId,
    @PathParam("name") String name, byte[] body) throws CryptographicException {
   
    final Session session = credentials.buildSession(userDAO, userId);
    Document doc = documentDAO.findByOwnerAndName(session.getUser(), name);
    if (doc == null) {
      doc = documentDAO.newDocument(session.getUser(), name, headers.getMediaType());
    } else {
      checkPreconditions(request, doc);
    }
   
    doc.setModifiedAt(new DateTime(DateTimeZone.UTC));
    doc.encryptAndSetBody(
      session.getKeySet(),
      randomProvider.get(),
      body
    );
   
    documentDAO.saveOrUpdate(doc);
View Full Code Here

  @GET
  public LinkedDocumentListRepresentation listDocuments(@Context UriInfo uriInfo,
    @Context Credentials credentials, @PathParam("id") String id) {
   
    final Session session = credentials.buildSession(userDAO, id);

    return new LinkedDocumentListRepresentation(uriInfo, session.getUser());
  }
View Full Code Here

 
  @GET
  public DocumentListRepresentation listDocuments(@Context UriInfo uriInfo,
    @Context Credentials credentials, @PathParam("id") String id) {
   
    final Session session = credentials.buildSession(userDAO, id);
   
    return new DocumentListRepresentation(uriInfo, session.getUser().getDocuments());
  }
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.