Example #1
0
  @Test
  public void testCreateUser() throws BiobankCheckException, Exception {
    String name = "createUser" + r.nextInt();
    String password = "******";
    UserWrapper user = UserHelper.addUser(name, password, true);

    // check biobank user
    User dbUser = ModelUtils.getObjectWithId(appService, User.class, user.getId());
    Assert.assertNotNull(dbUser);
    Assert.assertEquals(name, dbUser.getLogin());
    Assert.assertNotNull(dbUser.getCsmUserId());

    // check csm user
    UserProvisioningManager upm =
        SecurityServiceProvider.getUserProvisioningManager(
            BiobankCSMSecurityUtil.APPLICATION_CONTEXT_NAME);

    gov.nih.nci.security.authorization.domainobjects.User csmUser = upm.getUser(name);
    Assert.assertNotNull(csmUser);
    Assert.assertNotNull(csmUser.getPassword());
    Assert.assertFalse(csmUser.getPassword().isEmpty());

    // check user can connect
    BiobankApplicationService newUserAppService = AllTestsSuite.connect(name, password);
    // check user can access a biobank object using the new appService
    try {
      newUserAppService.search(Site.class, new Site());
    } catch (AccessDeniedException ade) {
      Assert.fail("User should be able to access any object");
    }
  }
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
      BiobankApplicationService service = SessionManager.getAppService();
      ManagerContext context =
          service.doAction(new ManagerContextGetAction(new ManagerContextGetInput())).getContext();

      new UserManagementDialog(
              PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), context)
          .open();
    } catch (ApplicationException e) {
      BgcPlugin.openAsyncError("Unable to Load User Management Data", e.getMessage());
    }

    return null;
  }