Examples of UserIndexKey


Examples of org.onebusaway.users.model.UserIndexKey

  @Cacheable
  @Override
  public Map<String, Object> isLoggingEnabledForUser(
      @CacheableArgument(keyProperty = "userIndexKey") IndexedUserDetails details) {
   
    UserIndexKey key = details.getUserIndexKey();
    UserIndex userIndex = _userService.getUserIndexForId(key);
    if (userIndex == null)
      return null;
    User user = userIndex.getUser();
    for (UserIndex index : user.getUserIndices()) {
      UserIndexKey id = index.getId();
      if (id.getType().equals("tccStudyId")) {
        Map<String, Object> entry = new HashMap<String, Object>();
        entry.put("tccStudyId", id.getValue());
        entry.put("credentials", index.getCredentials());
        return entry;
      }
    }
    return null;
View Full Code Here

Examples of org.onebusaway.users.model.UserIndexKey

  protected Authentication createAuthentication() {

    UUID uuid = UUID.randomUUID();
    UUID credentials = UUID.randomUUID();

    UserIndexKey principal = new UserIndexKey(UserIndexTypes.WEB,
        uuid.toString());
    IndexedUserDetails details = _userDetailsService.getOrCreateUserForIndexKey(
        principal, credentials.toString(), true);

    return new DefaultUserAuthenticationToken(details);
View Full Code Here

Examples of org.onebusaway.users.model.UserIndexKey

  @Override
  public IndexedUserDetails handleLogin(String type, String id,
      String credentials, boolean isAnonymous, boolean registerIfNewUser) {

    UserIndexKey key = new UserIndexKey(type, id);
    UserIndex index = _userService.getUserIndexForId(key);
    boolean exists = index != null;

    // New user?
    if (!exists) {
View Full Code Here

Examples of org.onebusaway.users.model.UserIndexKey

  @Override
  public IndexedUserDetails handleRegistration(String type, String id,
      String credentials, boolean isAnonymous) {

    UserIndexKey key = new UserIndexKey(type, id);
    UserIndex index = _userService.getOrCreateUserForIndexKey(key, credentials,
        isAnonymous);

    User oldUser = _currentUserStrategy.getCurrentUser(false);
    if (oldUser != null && _userService.isAnonymous(oldUser))
View Full Code Here

Examples of org.onebusaway.users.model.UserIndexKey

  public IndexedUserDetails handleAddAccount(String type, String id,
      String credentials, boolean isAnonymous) {

    User currentUser = _currentUserStrategy.getCurrentUser(false);

    UserIndexKey key = new UserIndexKey(type, id);
    UserIndex index = _userService.getUserIndexForId(key);
    boolean exists = index != null;

    // New user?
    if (exists) {
View Full Code Here

Examples of org.onebusaway.users.model.UserIndexKey

    this.key = key;
  }

  @PostConstruct
  public void execute() {
    UserIndexKey userIndexKey = new UserIndexKey(UserIndexTypes.API_KEY, key);
    UserIndex userIndex = _userService.getOrCreateUserForIndexKey(userIndexKey,
        key, false);
    _userPropertiesService.authorizeApi(userIndex.getUser(), 0);
  }
View Full Code Here

Examples of org.onebusaway.users.model.UserIndexKey

    User user = new User();
    user.setCreationTime(new Date());
    user.setProperties(new UserPropertiesV2());
    user.getRoles().add(userRole);

    UserIndexKey key = new UserIndexKey("phone", "2065551234");

    UserIndex index = new UserIndex();
    index.setId(key);
    index.setUser(user);
    user.getUserIndices().add(index);
View Full Code Here

Examples of org.onebusaway.users.model.UserIndexKey

    User userA = new User();
    userA.setCreationTime(new Date());
    userA.setProperties(new UserPropertiesV2());

    UserIndex index = new UserIndex();
    index.setId(new UserIndexKey("test", "A"));
    index.setUser(userA);
    userA.getUserIndices().add(index);

    _dao.saveOrUpdateUser(userA);
View Full Code Here

Examples of org.onebusaway.users.model.UserIndexKey

      UserIndexRegistrationService registration = Mockito.mock(UserIndexRegistrationService.class);
      _service.setUserIndexRegistrationService(registration);

      String code = _service.registerPhoneNumber(user, "+12065551234");

      UserIndexKey key = new UserIndexKey(UserIndexTypes.PHONE_NUMBER,
          "12065551234");
      Mockito.verify(registration).setRegistrationForUserIndexKey(key, 1234,
          code);

      int codeAsNumber = Integer.parseInt(code);
View Full Code Here

Examples of org.onebusaway.users.model.UserIndexKey

  @Test
  public void testCompletePhoneNumberRegistration() {

    User userA = createUser(1234);

    UserIndexKey key = new UserIndexKey(UserIndexTypes.PHONE_NUMBER,
        "12065551234");

    UserDao userDao = Mockito.mock(UserDao.class);
    _service.setUserDao(userDao);

    Mockito.when(userDao.getUserForId(1234)).thenReturn(userA);

    UserIndex migratedIndex = new UserIndex();
    migratedIndex.setId(key);
    migratedIndex.setUser(userA);
    migratedIndex.setCredentials("");
    Mockito.when(userDao.getUserIndexForId(key)).thenReturn(migratedIndex);

    UserIndexRegistrationService registrationService = Mockito.mock(UserIndexRegistrationService.class);
    _service.setUserIndexRegistrationService(registrationService);

    UserRegistration registration = new UserRegistration(1234, "5555");
    Mockito.when(registrationService.getRegistrationForUserIndexKey(key)).thenReturn(
        registration);

    UserPropertiesService userPropertiesService = Mockito.mock(UserPropertiesService.class);
    _service.setUserPropertiesService(userPropertiesService);

    User userB = createUser(1235);
    UserIndex index = createUserIndex(key.getType(), key.getValue(), userB);

    UserIndex updated = _service.completePhoneNumberRegistration(index, "5554");
    assertTrue(updated == null);

    updated = _service.completePhoneNumberRegistration(index, "5555");
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.