Package com.commafeed.frontend.session

Examples of com.commafeed.frontend.session.SessionHelper


    Optional<User> user = apiKeyLogin();
    if (!user.isPresent()) {
      user = basicAuthenticationLogin();
    }
    if (!user.isPresent()) {
      user = cookieSessionLogin(new SessionHelper(request));
    }

    if (user.isPresent()) {
      if (user.get().hasRole(role)) {
        return user.get();
View Full Code Here


    String orderParam = req.getParameter(PARAM_READINGORDER);

    final Optional<User> user = new UnitOfWork<Optional<User>>(sessionFactory) {
      @Override
      protected Optional<User> runInSession() throws Exception {
        SessionHelper sessionHelper = new SessionHelper(req);
        Optional<User> loggedInUser = sessionHelper.getLoggedInUser();
        if (loggedInUser.isPresent()) {
          userService.performPostLoginActivities(loggedInUser.get());
        }
        return loggedInUser;
      }
View Full Code Here

    resp.setContentType("text/css");

    final Optional<User> user = new UnitOfWork<Optional<User>>(sessionFactory) {
      @Override
      protected Optional<User> runInSession() throws Exception {
        return new SessionHelper(req).getLoggedInUser();
      }
    }.run();
    if (!user.isPresent()) {
      return;
    }
View Full Code Here

  @Test
  public void cookie_login_should_perform_post_login_activities_if_user_is_logged_in() {
    User userInSession = new User();

    SessionHelper sessionHelper = mock(SessionHelper.class);
    when(sessionHelper.getLoggedInUser()).thenReturn(Optional.of(userInSession));

    PostLoginActivities postLoginActivities = mock(PostLoginActivities.class);

    UserService service = new UserService(null, null, null, null, null, postLoginActivities);
View Full Code Here

    // Create UserService partial mock
    UserService service = mock(UserService.class);
    when(service.login("user", "password")).thenReturn(absentUser);
   
    UserREST userREST = new UserREST(null, null, null, service, null, null, null);
    SessionHelper sessionHelper = mock(SessionHelper.class);
   
    LoginRequest req = new LoginRequest();
    req.setName("user");
    req.setPassword("password");
   
View Full Code Here

    LoginRequest req = new LoginRequest();
    req.setName("user");
    req.setPassword("password");
   
    UserREST userREST = new UserREST(null, null, null, service, null, null, null);
    SessionHelper sessionHelper = mock(SessionHelper.class);
   
    userREST.login(req, sessionHelper);
   
    verify(sessionHelper).setLoggedInUser(user);
  }
View Full Code Here

    req.setPassword("password");
    req.setEmail("test@test.com");
   
    InOrder inOrder = inOrder(service);
   
    SessionHelper sessionHelper = mock(SessionHelper.class);
    UserREST userREST = new UserREST(null, null, null, service, null, null, null);
   
    userREST.register(req, sessionHelper);
   
    inOrder.verify(service).register("user", "password", "test@test.com", Arrays.asList(Role.USER));
View Full Code Here

    RegistrationRequest req = new RegistrationRequest();
    req.setName("user");
    req.setPassword("password");
    req.setEmail("test@test.com");
   
    SessionHelper sessionHelper = mock(SessionHelper.class);
    UserREST userREST = new UserREST(null, null, null, service, null, null, null);
   
    userREST.register(req, sessionHelper);
   
    verify(sessionHelper).setLoggedInUser(user);
View Full Code Here

TOP

Related Classes of com.commafeed.frontend.session.SessionHelper

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.