Package com.opengamma.security.user

Examples of com.opengamma.security.user.User


   
    UserGroup group2 = new UserGroup(1L, "group2");
    group2.getAuthorities().add(new Authority(2L, "LiveData/Reuters/Equity/**"));
    userGroups.add(group2);
   
    User user = new User(null,
        "john",
        "pw",
        userGroups,
        new Date());
   
View Full Code Here


  //-------------------------------------------------------------------------
  @Override
  public UserDetails loadUserByUsername(String username)
    throws UsernameNotFoundException {
    User user = getUser(username);
    if (user == null) {
      throw new UsernameNotFoundException(username);
    }
    return user;
  }
View Full Code Here

  //-------------------------------------------------------------------------
  @Override
  public Map<LiveDataSpecification, Boolean> isEntitled(UserPrincipal userPrincipal, Collection<LiveDataSpecification> requestedSpecifications) {
    Map<LiveDataSpecification, Boolean> returnValue = new HashMap<LiveDataSpecification, Boolean>();
    User user = _userManager.getUser(userPrincipal.getUserName());
    if (user == null) {
      s_logger.debug("User {} does not exist - no permissions are granted", userPrincipal.getUserName());
      for (LiveDataSpecification spec : requestedSpecifications) {
        returnValue.put(spec, false);               
      }
      return returnValue;
    }
   
    Map<LiveDataSpecification, DistributionSpecification> distributionSpecs = _resolver.resolve(requestedSpecifications);
   
    for (LiveDataSpecification requestedSpec : requestedSpecifications) {
      DistributionSpecification distributionSpec = distributionSpecs.get(requestedSpec);
      if (distributionSpec != null) {
        String permission = distributionSpec.getJmsTopic().replace('.', '/');
        boolean hasPermission = user.hasPermission(permission);
        returnValue.put(requestedSpec, hasPermission);               
      } else {
        s_logger.debug("Could not resolve live data spec {} - no permissions are granted to {}", requestedSpec, userPrincipal.getUserName());
        returnValue.put(requestedSpec, false);
      }
View Full Code Here

  //-------------------------------------------------------------------------
  @Test
  public void testUserManagement() {
    // Try to get non-existent
    User user = _userManager.getUser("nonexistentuser");
    assertNull(user);
   
    // Clear DB as necessary
    user = _userManager.getUser("testuser");
    if (user != null) {
      _userManager.deleteUser(user);     
    }
   
    // Add
    user = getTestUser();
    Set<UserGroup> userGroups = new HashSet<UserGroup>();
    UserGroup userGroup = _userManager.getUserGroup("testusergroup");
    if (userGroup == null) {
      userGroup = new UserGroup(null, "testusergroup");
      userGroup.getAuthorities().add(new Authority("testauthority"));
    }
    userGroup.getUsers().add(user);
    user.setUserGroups(userGroups);
    _userManager.addUser(user);
   
    // Update
    user.setPassword("modifiedtestpw");
    _userManager.updateUser(user);
    user = _userManager.getUser("testuser");
    assertNotNull(user);
    assertTrue(user.checkPassword("modifiedtestpw"));
   
    // Delete
    _userManager.deleteUser(user);
    user = _userManager.getUser("testuser");
    assertNull(user);
View Full Code Here

    user = _userManager.getUser("testuser");
    assertNull(user);
  }

  private User getTestUser() {
    return new User(null, "testuser", "testpw", new HashSet<UserGroup>(), new Date());
  }
View Full Code Here

      authority = new Authority("testauthority");
      _userManager.addAuthority(authority);
    }
    userGroup.getAuthorities().add(authority);
   
    User user = _userManager.getUser("testuser");
    if (user == null) {
      user = getTestUser();
      _userManager.addUser(user);
    }
   
View Full Code Here

TOP

Related Classes of com.opengamma.security.user.User

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.