Examples of UserDTO


Examples of org.multibit.mbm.client.interfaces.rest.api.user.UserDto

    // Arrange
    final CartDto expectedCart = new CartDto();
    expectedCart.setItemTotal("2");

    final UserDto clientUser = new UserDto();
    clientUser.setApiKey("apiKey");
    clientUser.setSecretKey("secretKey");

    URI expectedUri = URI.create("http://localhost:8080/mbm/cart");

    // Test-specific JerseyClient behaviour
    when(client.resource(expectedUri))
View Full Code Here

Examples of org.multibit.mbm.client.interfaces.rest.api.user.UserDto

public class InMemorySessionTokenCacheTest {

  @Test
  public void testGetBySessionToken() throws Exception {

    UserDto expectedClientUser = createClientUser();

    InMemorySessionTokenCache
      .INSTANCE
      .put(
        expectedClientUser.getSessionToken(),
        expectedClientUser);

    Optional<UserDto> clientUserOptional = InMemorySessionTokenCache
      .INSTANCE
      .getBySessionToken(Optional.of(expectedClientUser.getSessionToken()));

    assertTrue(clientUserOptional.isPresent());

    assertEquals(expectedClientUser, clientUserOptional.get());
View Full Code Here

Examples of org.multibit.mbm.client.interfaces.rest.api.user.UserDto

  }

  @Test
  public void testPut_WithExpiry() throws Exception {

    UserDto expectedClientUser = createClientUser();

    InMemorySessionTokenCache
      .INSTANCE
      .reset(100, TimeUnit.MILLISECONDS)
      .put(
        expectedClientUser.getSessionToken(),
        expectedClientUser);

    // Allow time for expiry
    Thread.sleep(200);

    Optional<UserDto> clientUserOptional = InMemorySessionTokenCache
      .INSTANCE
      .getBySessionToken(Optional.of(expectedClientUser.getSessionToken()));

    assertFalse(clientUserOptional.isPresent());

  }
View Full Code Here

Examples of org.multibit.mbm.client.interfaces.rest.api.user.UserDto

  @Test
  public void testPut_WithActivityPreventingExpiry() throws Exception {

    int duration = 200;

    UserDto expectedClientUser = createClientUser();

    InMemorySessionTokenCache
      .INSTANCE
      .reset(duration, TimeUnit.MILLISECONDS)
      .put(
        expectedClientUser.getSessionToken(),
        expectedClientUser);

    // Wait for a duration within the expiry time
    Thread.sleep(duration / 2);

    // This should reset the cache expiry giving the entry longer life
    Optional<UserDto> clientUserOptional = InMemorySessionTokenCache
      .INSTANCE
      .getBySessionToken(Optional.of(expectedClientUser.getSessionToken()));

    assertTrue("Unexpected expiry of client user (early expiration)", clientUserOptional.isPresent());

    // Wait for a duration that now extends beyond the original expiry time
    Thread.sleep(duration * 3 / 4);

    // This should again reset the cache expiry giving the entry longer life
    clientUserOptional = InMemorySessionTokenCache
      .INSTANCE
      .getBySessionToken(Optional.of(expectedClientUser.getSessionToken()));

    assertTrue("Unexpected expiry of client user (refresh failed)", clientUserOptional.isPresent());

    // Wait for a duration that now extends beyond the refreshed expiry time
    Thread.sleep(duration * 2);

    // This should again reset the cache expiry giving the entry longer life
    clientUserOptional = InMemorySessionTokenCache
      .INSTANCE
      .getBySessionToken(Optional.of(expectedClientUser.getSessionToken()));

    assertFalse("Unexpected presence of client user (late expiration)",clientUserOptional.isPresent());

  }
View Full Code Here

Examples of org.multibit.mbm.client.interfaces.rest.api.user.UserDto

  }

  private UserDto createClientUser() {

    UserDto clientUser = new UserDto();

    clientUser.setApiKey("apiKey");
    clientUser.setUsername("username");
    clientUser.setCachedAuthorities(new Authority[]{Authority.ROLE_CUSTOMER});
    clientUser.setPasswordDigest("passwordDigest");
    clientUser.setSecretKey("secretKey");
    clientUser.setSessionToken(UUID.randomUUID());

    return clientUser;
  }
View Full Code Here

Examples of org.multibit.mbm.client.interfaces.rest.api.user.UserDto

    // Read the HAL
    ReadableRepresentation rr = unmarshalHal(hal);

    Map<String, Object> properties = rr.getProperties();

    UserDto clientUser = new UserDto();
    String apiKey = (String) properties.get("api_key");
    String secretKey = (String) properties.get("secret_key");

    if ("".equals(apiKey) || "".equals(secretKey)) {
      return Optional.absent();
    }

    // Must assume that the registration was successful
    // Using the credentials later would mean failed authentication anyway
    clientUser.setApiKey(apiKey);
    clientUser.setSecretKey(secretKey);
    clientUser.setCachedAuthorities(new Authority[] {Authority.ROLE_CUSTOMER});

    return Optional.of(clientUser);
  }
View Full Code Here

Examples of org.multibit.mbm.client.interfaces.rest.api.user.UserDto

    // Read the HAL
    ReadableRepresentation rr = unmarshalHal(hal);

    Map<String, Object> properties = rr.getProperties();

    UserDto clientUser = new UserDto();
    String apiKey = (String) properties.get("api_key");
    String secretKey = (String) properties.get("secret_key");

    if ("".equals(apiKey) || "".equals(secretKey)) {
      return Optional.absent();
    }

    // Must assume that the registration was successful
    // Using the credentials later would mean failed authentication anyway
    clientUser.setApiKey(apiKey);
    clientUser.setSecretKey(secretKey);
    clientUser.setCachedAuthorities(new Authority[]{Authority.ROLE_PUBLIC});

    return Optional.of(clientUser);
  }
View Full Code Here

Examples of org.multibit.mbm.client.interfaces.rest.api.user.UserDto

    // Read the HAL
    ReadableRepresentation rr = unmarshalHal(hal);

    Map<String, Object> properties = rr.getProperties();

    UserDto clientUser = new UserDto();
    String apiKey = (String) properties.get("api_key");
    String secretKey = (String) properties.get("secret_key");

    if ("".equals(apiKey) || "".equals(secretKey)) {
      return Optional.absent();
    }

    // Must assume that the authentication was successful
    // Using the credentials later would mean failed authentication anyway
    clientUser.setApiKey(apiKey);
    clientUser.setSecretKey(secretKey);
    clientUser.setCachedAuthorities(new Authority[] {Authority.ROLE_CUSTOMER});

    return Optional.of(clientUser);
  }
View Full Code Here

Examples of org.multibit.mbm.client.interfaces.rest.api.user.UserDto

    // Read the HAL
    ReadableRepresentation rr = unmarshalHal(hal);

    Map<String, Object> properties = rr.getProperties();

    UserDto clientUser = new UserDto();
    String apiKey = (String) properties.get("api_key");
    String secretKey = (String) properties.get("secret_key");

    if ("".equals(apiKey) || "".equals(secretKey)) {
      return Optional.absent();
    }

    // Must assume that the authentication was successful
    // Using the credentials later would mean failed authentication anyway
    clientUser.setApiKey(apiKey);
    clientUser.setSecretKey(secretKey);
    clientUser.setCachedAuthorities(new Authority[] {Authority.ROLE_CUSTOMER});

    return Optional.of(clientUser);
  }
View Full Code Here

Examples of org.sonar.core.user.UserDto

  @Override
  public void grantUserRole(Resource resource, String login, String role) {
    if (resource.getId() != null) {
      DbSession session = myBatis.openSession(false);
      try {
        UserDto user = session.getMapper(UserMapper.class).selectUserByLogin(login);
        if (user != null) {
          permissionFacade.deleteUserPermission(Long.valueOf(resource.getId()), user.getId(), role, session);
          permissionFacade.insertUserPermission(Long.valueOf(resource.getId()), user.getId(), role, session);
          session.commit();
        }
      } finally {
        MyBatis.closeQuietly(session);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.