当前位置: 首页>>代码示例>>Java>>正文


Java IdentityService.newUser方法代码示例

本文整理汇总了Java中org.camunda.bpm.engine.IdentityService.newUser方法的典型用法代码示例。如果您正苦于以下问题:Java IdentityService.newUser方法的具体用法?Java IdentityService.newUser怎么用?Java IdentityService.newUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.camunda.bpm.engine.IdentityService的用法示例。


在下文中一共展示了IdentityService.newUser方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createUser

import org.camunda.bpm.engine.IdentityService; //导入方法依赖的package包/类
private void createUser(User user, Map<String, String> userPass, ProcessEngine processEngine) {
    IdentityService identityService = processEngine.getIdentityService();
    if (!userExist(user.getEmail(), identityService)) {

        String[] fio = user.getName().split(" ");

        org.camunda.bpm.engine.identity.User newUser = identityService.newUser(user.getEmail());

        newUser.setEmail(user.getEmail());
        newUser.setFirstName(fio[1]);
        newUser.setLastName(fio[0]);
        String password = userPass.get(user.getEmail());
        newUser.setPassword(isNotEmpty(password) ? password : UUID.randomUUID().toString());
        identityService.saveUser(newUser);

        identityService.createMembership(user.getEmail(), ALL_USERS);
        createViewFilter(processEngine, user.getEmail());
    }
}
 
开发者ID:IntegrityVision,项目名称:Purchase-order-process-template,代码行数:20,代码来源:ResourcesAuthorization.java

示例2: createAuthenticationData

import org.camunda.bpm.engine.IdentityService; //导入方法依赖的package包/类
private void createAuthenticationData() {
  IdentityService identityService = engineRule.getIdentityService();
  Group group = identityService.newGroup("group");
  identityService.saveGroup(group);
  User user = identityService.newUser("user");
  User user2 = identityService.newUser("user2");
  identityService.saveUser(user);
  identityService.saveUser(user2);
  Tenant tenant = identityService.newTenant("tenant");
  identityService.saveTenant(tenant);
  Tenant tenant2 = identityService.newTenant("tenant2");
  identityService.saveTenant(tenant2);
  identityService.createMembership("user", "group");
  identityService.createTenantUserMembership("tenant", "user");
  identityService.createTenantUserMembership("tenant2", "user2");


  TestResource resource1 = new TestResource("resource1", 100);
  // create global authorization which grants all permissions to all users (on resource1):
  AuthorizationService authorizationService = engineRule.getAuthorizationService();
  Authorization globalAuth = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
  globalAuth.setResource(resource1);
  globalAuth.setResourceId(ANY);
  globalAuth.addPermission(ALL);
  authorizationService.saveAuthorization(globalAuth);

  //grant user read auth on resource2
  TestResource resource2 = new TestResource("resource2", 200);
  Authorization userGrant = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
  userGrant.setUserId("user");
  userGrant.setResource(resource2);
  userGrant.setResourceId(ANY);
  userGrant.addPermission(READ);
  authorizationService.saveAuthorization(userGrant);

  identityService.setAuthenticatedUserId("user");
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:38,代码来源:PurgeDatabaseTest.java

示例3: createUser

import org.camunda.bpm.engine.IdentityService; //导入方法依赖的package包/类
public void createUser(UserDto userDto) {
  final IdentityService identityService = getIdentityService();

  if(identityService.isReadOnly()) {
    throw new InvalidRequestException(Status.FORBIDDEN, "Identity service implementation is read-only.");
  }

  UserProfileDto profile = userDto.getProfile();
  if(profile == null || profile.getId() == null) {
    throw new InvalidRequestException(Status.BAD_REQUEST, "request object must provide profile information with valid id.");
  }

  User newUser = identityService.newUser(profile.getId());
  profile.update(newUser);

  if(userDto.getCredentials() != null) {
    newUser.setPassword(userDto.getCredentials().getPassword());
  }

  identityService.saveUser(newUser);

}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:23,代码来源:UserRestServiceImpl.java

示例4: startProcessInstance

import org.camunda.bpm.engine.IdentityService; //导入方法依赖的package包/类
@DescribesScenario("startProcessInstance")
public static ScenarioSetup startProcessInstance() {
  return new ScenarioSetup() {
    public void execute(ProcessEngine engine, String scenarioName) {
      IdentityService identityService = engine.getIdentityService();

      // create an user
      String userId = "test";
      User user = identityService.newUser(userId);
      identityService.saveUser(user);

      // create group
      String groupId = "accounting";
      Group group = identityService.newGroup(groupId);
      identityService.saveGroup(group);

      // create membership
      identityService.createMembership("test", "accounting");

      // start a process instance
      engine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess", scenarioName);
    }
  };
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:25,代码来源:AuthorizationScenario.java

示例5: initUser

import org.camunda.bpm.engine.IdentityService; //导入方法依赖的package包/类
@DescribesScenario("initUser")
@Times(1)
public static ScenarioSetup initUser() {
  return new ScenarioSetup() {
    public void execute(ProcessEngine engine, String scenarioName) {
      // given
      IdentityService identityService = engine.getIdentityService();
      User user = identityService.newUser(USER_NAME);
      user.setPassword(USER_PWD);

      // when
      identityService.saveUser(user);

    }
  };
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:DeployUserWithoutSaltForPasswordHashingScenario.java

示例6: createUserIfNotExists

import org.camunda.bpm.engine.IdentityService; //导入方法依赖的package包/类
private void createUserIfNotExists(IdentityService identityService,
                                   String userId,
                                   String firstName,
                                   String lastName,
                                   String imagePath,
                                   String[] groups) {
  /*
   * Check if needed user exists and create it otherwise
   */
  User user = identityService.createUserQuery().userId(userId).singleResult();
  if (user == null) {
    log.info("User '" + userId + "' does not exist.");
    user = identityService.newUser(userId);
    user.setFirstName(firstName);
    user.setLastName(lastName);
    identityService.saveUser(user);
    identityService.setUserPicture(userId, pictureForUser(imagePath));
    log.info("New user '" + userId + "' created.");

    /*
     * Add user to groups
     */
    for (String groupId: groups) {
      identityService.createMembership(userId, groupId);
    }
  }
}
 
开发者ID:plexiti,项目名称:the-job-announcement,代码行数:28,代码来源:UserBean.java

示例7: afterPropertiesSet

import org.camunda.bpm.engine.IdentityService; //导入方法依赖的package包/类
public void afterPropertiesSet() throws Exception {

    System.out.println("Generating demo data");

    scheduleInstanceStart();

    // ensure admin user exists
    IdentityService identityService = processEngine.getIdentityService();
    User user = identityService.createUserQuery().userId("demo").singleResult();
    if(user == null) {
      User newUser = identityService.newUser("demo");
      newUser.setPassword("demo");
      identityService.saveUser(newUser);
      System.out.println("Created used 'demo', password 'demo'");
      AuthorizationService authorizationService = processEngine.getAuthorizationService();

      // create group
      if(identityService.createGroupQuery().groupId(Groups.CAMUNDA_ADMIN).count() == 0) {
        Group camundaAdminGroup = identityService.newGroup(Groups.CAMUNDA_ADMIN);
        camundaAdminGroup.setName("camunda BPM Administrators");
        camundaAdminGroup.setType(Groups.GROUP_TYPE_SYSTEM);
        identityService.saveGroup(camundaAdminGroup);
      }

      // create ADMIN authorizations on all built-in resources
      for (Resource resource : Resources.values()) {
        if(authorizationService.createAuthorizationQuery().groupIdIn(Groups.CAMUNDA_ADMIN).resourceType(resource).resourceId(ANY).count() == 0) {
          AuthorizationEntity userAdminAuth = new AuthorizationEntity(AUTH_TYPE_GRANT);
          userAdminAuth.setGroupId(Groups.CAMUNDA_ADMIN);
          userAdminAuth.setResource(resource);
          userAdminAuth.setResourceId(ANY);
          userAdminAuth.addPermission(ALL);
          authorizationService.saveAuthorization(userAdminAuth);
        }
      }

      processEngine.getIdentityService()
      .createMembership("demo", Groups.CAMUNDA_ADMIN);
    }
  }
 
开发者ID:camunda,项目名称:camunda-bpm-elasticsearch,代码行数:41,代码来源:DemoDataGenerator.java

示例8: startProcessInstance

import org.camunda.bpm.engine.IdentityService; //导入方法依赖的package包/类
@DescribesScenario("startProcessInstance")
@Times(1)
public static ScenarioSetup startProcessInstance() {
  return new ScenarioSetup() {
    public void execute(ProcessEngine engine, String scenarioName) {
      IdentityService identityService = engine.getIdentityService();

      String userId = USER_ID + scenarioName;
      String groupid = GROUP_ID + scenarioName;
      // create an user
      User user = identityService.newUser(userId);
      identityService.saveUser(user);

      // create group
      Group group = identityService.newGroup(groupid);
      identityService.saveGroup(group);

      // create membership
      identityService.createMembership(userId, groupid);

      //create full authorization
      AuthorizationService authorizationService = engine.getAuthorizationService();

      //authorization for process definition
      Authorization authProcDef = createAuthorization(authorizationService, Permissions.ALL, Resources.PROCESS_DEFINITION, userId);
      engine.getAuthorizationService().saveAuthorization(authProcDef);

      //authorization for deployment
      Authorization authDeployment = createAuthorization(authorizationService, Permissions.ALL, Resources.DEPLOYMENT, userId);
      engine.getAuthorizationService().saveAuthorization(authDeployment);

      //authorization for process instance create
      Authorization authProcessInstance = createAuthorization(authorizationService, Permissions.CREATE, Resources.PROCESS_INSTANCE, userId);
      engine.getAuthorizationService().saveAuthorization(authProcessInstance);

      // start a process instance
      engine.getRuntimeService().startProcessInstanceByKey(PROCESS_DEF_KEY, scenarioName);
    }
  };
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:41,代码来源:AuthorizationScenario.java

示例9: createUser

import org.camunda.bpm.engine.IdentityService; //导入方法依赖的package包/类
static User createUser(final IdentityService identityService, final User adminUser) {
  User newUser = identityService.newUser(adminUser.getId());
  BeanUtils.copyProperties(adminUser, newUser);
  identityService.saveUser(newUser);
  return newUser;
}
 
开发者ID:camunda,项目名称:camunda-bpm-spring-boot-starter,代码行数:7,代码来源:CreateAdminUserConfiguration.java

示例10: createUser

import org.camunda.bpm.engine.IdentityService; //导入方法依赖的package包/类
protected User createUser(IdentityService identityService, String userId) {
  User user = identityService.newUser(userId);
  identityService.saveUser(user);
  return user;
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:6,代码来源:AuthorizationScenario.java


注:本文中的org.camunda.bpm.engine.IdentityService.newUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。