Exemplo n.º 1
0
 protected String buildJavaScriptProvisionableUser(PscUser user) {
   try {
     return String.format(
         "new psc.admin.ProvisionableUser(%s, %s, %s)",
         buildJavaScriptString(user.getCsmUser().getLoginName()),
         buildProvisionableUserRoleJSON(user).toString(JSON_INDENT_DEPTH),
         "PROVISIONABLE_ROLES");
   } catch (JSONException e) {
     throw new StudyCalendarSystemException("Building JSON for provisionable user failed", e);
   }
 }
Exemplo n.º 2
0
  @SuppressWarnings({"unchecked"})
  public static AdministerUserCommand create(
      PscUser existingUser,
      ProvisioningSessionFactory psFactory,
      AuthorizationManager authorizationManager,
      AuthenticationSystem authenticationSystem,
      ApplicationSecurityManager applicationSecurityManager,
      PscUserService pscUserService,
      CsmUserCache csmUserCache,
      PscUser provisioner) {
    AdministerUserCommand command =
        new AdministerUserCommand(
            existingUser,
            psFactory,
            authorizationManager,
            authenticationSystem,
            applicationSecurityManager,
            csmUserCache);
    if (provisioner == null) return command;

    VisibleAuthorizationInformation visAuthInfo =
        pscUserService.getVisibleAuthorizationInformationFor(provisioner);
    command.setProvisionableSites(visAuthInfo.getSites());
    command.setProvisionableRoles(
        visAuthInfo.getRoles().toArray(new SuiteRole[visAuthInfo.getRoles().size()]));
    command.setProvisionableRoleGroups(
        visAuthInfo.getRoles().toArray(new SuiteRole[visAuthInfo.getRoles().size()]));
    command.setProvisionableManagedStudies(visAuthInfo.getStudiesForTemplateManagement());
    command.setProvisionableParticipatingStudies(visAuthInfo.getStudiesForSiteParticipation());

    if (provisioner.getMembership(PscRole.USER_ADMINISTRATOR) != null) {
      SuiteRoleMembership ua = provisioner.getMembership(PscRole.USER_ADMINISTRATOR);
      command.setCanProvisionAllSites(ua.isAllSites());
      command.setCanProvisionManagingAllStudies(true);
      command.setCanProvisionParticipateInAllStudies(true);
    } else if (provisioner.getMembership(PscRole.SYSTEM_ADMINISTRATOR) != null) {
      command.setCanProvisionAllSites(true);
    }

    return command;
  }