• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.camunda.bpm.engine.identity.User的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



User类属于org.camunda.bpm.engine.identity包,在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
public User init() {
  requireNonNull(getId(), "missing field: camunda.bpm.admin-user.id");
  requireNonNull(getPassword(), "missing field: camunda.bpm.admin-user.password");

  if (StringUtils.isBlank(getFirstName())) {
    setFirstName(capitalize(id));
  }
  if (StringUtils.isBlank(getLastName())) {
    setLastName(capitalize(id));
  }
  if (StringUtils.isBlank(getEmail())) {
    setEmail(id + "@localhost");
  }

  return this;
}
 
开发者ID:camunda,项目名称:camunda-bpm-spring-boot-starter,代码行数:17,代码来源:AdminUserProperty.java


示例2: createMockIdentityQueries

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
private void createMockIdentityQueries() {
  UserQuery sampleUserQuery = mock(UserQuery.class);

  List<User> mockUsers = new ArrayList<User>();

  mockUser = MockProvider.createMockUser();
  mockUsers.add(mockUser);

  when(sampleUserQuery.list()).thenReturn(mockUsers);
  when(sampleUserQuery.memberOfGroup(anyString())).thenReturn(sampleUserQuery);
  when(sampleUserQuery.count()).thenReturn((long) mockUsers.size());

  GroupQuery sampleGroupQuery = mock(GroupQuery.class);

  List<Group> mockGroups = MockProvider.createMockGroups();
  when(sampleGroupQuery.list()).thenReturn(mockGroups);
  when(sampleGroupQuery.groupMember(anyString())).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.orderByGroupName()).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.orderByGroupId()).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.orderByGroupType()).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.asc()).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.desc()).thenReturn(sampleGroupQuery);

  when(processEngine.getIdentityService().createGroupQuery()).thenReturn(sampleGroupQuery);
  when(processEngine.getIdentityService().createUserQuery()).thenReturn(sampleUserQuery);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:27,代码来源:IdentityRestServiceQueryTest.java


示例3: testOrderByUserFirstName

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
public void testOrderByUserFirstName() {
  List<User> orderedUsers = identityService.createUserQuery().orderByUserLastName().asc().list();
  List<User> userList = identityService.createUserQuery().list();

  Collections.sort(userList, new Comparator<User>() {
    @Override
    public int compare(User o1, User o2) {
      return o1.getLastName().compareToIgnoreCase(o2.getLastName());
    }
  });

  int len = orderedUsers.size();
  for (int i = 0; i < len; i++) {
    assertEquals("Index: " + i, orderedUsers.get(i).getLastName(), userList.get(i).getLastName());
  }
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:LdapEnableSortControlSupportTest.java


示例4: updateCredentials

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
public void updateCredentials(UserCredentialsDto account) {
  ensureNotReadOnly();

  Authentication currentAuthentication = identityService.getCurrentAuthentication();
  if(currentAuthentication != null && currentAuthentication.getUserId() != null) {
    if(!identityService.checkPassword(currentAuthentication.getUserId(), account.getAuthenticatedUserPassword())) {
      throw new InvalidRequestException(Status.BAD_REQUEST, "The given authenticated user password is not valid.");
    }
  }

  User dbUser = findUserObject();
  if(dbUser == null) {
    throw new InvalidRequestException(Status.NOT_FOUND, "User with id " + resourceId + " does not exist");
  }

  dbUser.setPassword(account.getPassword());

  identityService.saveUser(dbUser);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:20,代码来源:UserResourceImpl.java


示例5: testUserPaging

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
public static void testUserPaging(IdentityService identityService) {
  Set<String> userNames = new HashSet<String>();
  List<User> users = identityService.createUserQuery().listPage(0, 2);
  assertEquals(2, users.size());
  checkPagingResults(userNames, users.get(0).getId(), users.get(1).getId());

  users = identityService.createUserQuery().listPage(2, 2);
  assertEquals(2, users.size());
  checkPagingResults(userNames, users.get(0).getId(), users.get(1).getId());

  users = identityService.createUserQuery().listPage(4, 2);
  assertEquals(2, users.size());
  checkPagingResults(userNames, users.get(0).getId(), users.get(1).getId());

  users = identityService.createUserQuery().listPage(6, 2);
  assertEquals(2, users.size());
  checkPagingResults(userNames, users.get(0).getId(), users.get(1).getId());

  users = identityService.createUserQuery().listPage(12, 2);
  assertEquals(0, users.size());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:22,代码来源:LdapTestUtilities.java


示例6: setUp

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
@Before
public void setUp() {
  identityService = engineRule.getIdentityService();

  createTenant(TENANT_ONE, "Tenant_1");
  createTenant(TENANT_TWO, "Tenant_2");

  User user = identityService.newUser(USER);
  identityService.saveUser(user);

  Group group = identityService.newGroup(GROUP);
  identityService.saveGroup(group);

  identityService.createMembership(USER, GROUP);

  identityService.createTenantUserMembership(TENANT_ONE, USER);
  identityService.createTenantGroupMembership(TENANT_TWO, GROUP);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:19,代码来源:TenantQueryTest.java


示例7: testReadOnlyPutUserCredentialsFails

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
@Test
public void testReadOnlyPutUserCredentialsFails() {
  User userUdpdate = MockProvider.createMockUser();
  when(identityServiceMock.isReadOnly()).thenReturn(true);

  given()
      .pathParam("id", MockProvider.EXAMPLE_USER_ID)
      .body(UserCredentialsDto.fromUser(userUdpdate)).contentType(ContentType.JSON)
  .then().expect()
      .statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON)
      .body("type", equalTo(InvalidRequestException.class.getSimpleName()))
      .body("message", equalTo("Identity service implementation is read-only."))
  .when().put(USER_CREDENTIALS_URL);

  verify(identityServiceMock, never()).saveUser(userUdpdate);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:UserRestServiceInteractionTest.java


示例8: getGroupInfo

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
@Override
public GroupInfoDto getGroupInfo(String userId) {
  if (userId == null) {
    throw new InvalidRequestException(Status.BAD_REQUEST, "No user id was supplied");
  }

  IdentityService identityService = getProcessEngine().getIdentityService();

  GroupQuery query = identityService.createGroupQuery();
  List<Group> userGroups = query.groupMember(userId).orderByGroupName().asc().list();

  Set<UserDto> allGroupUsers = new HashSet<UserDto>();
  List<GroupDto> allGroups = new ArrayList<GroupDto>();

  for (Group group : userGroups) {
    List<User> groupUsers = identityService.createUserQuery().memberOfGroup(group.getId()).list();
    for (User user: groupUsers) {
      if (!user.getId().equals(userId)) {
        allGroupUsers.add(new UserDto(user.getId(), user.getFirstName(), user.getLastName()));
      }
    }
    allGroups.add(new GroupDto(group.getId(), group.getName()));
  }

  return new GroupInfoDto(allGroups, allGroupUsers);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:27,代码来源:IdentityRestServiceImpl.java


示例9: testPutCredentialsNonExistingUserFails

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
@Test
public void testPutCredentialsNonExistingUserFails() {
  UserQuery sampleUserQuery = mock(UserQuery.class);
  when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery);
  when(sampleUserQuery.userId("aNonExistingUser")).thenReturn(sampleUserQuery);
  when(sampleUserQuery.singleResult()).thenReturn(null);

  UserCredentialsDto dto = new UserCredentialsDto();
  dto.setPassword("new-password");

  given()
      .pathParam("id", "aNonExistingUser")
      .body(dto).contentType(ContentType.JSON)
  .then()
      .then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON)
      .body("type", equalTo(InvalidRequestException.class.getSimpleName()))
      .body("message", equalTo("User with id aNonExistingUser does not exist"))
  .when()
      .put(USER_CREDENTIALS_URL);

  // user was not updated
  verify(identityServiceMock, never()).saveUser(any(User.class));
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:24,代码来源:UserRestServiceInteractionTest.java


示例10: startProcessInstance

import org.camunda.bpm.engine.identity.User; //导入依赖的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


示例11: testPutProfileThrowsAuthorizationException

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
@Test
public void testPutProfileThrowsAuthorizationException() {
  User initialUser = MockProvider.createMockUser();
  User userUpdate = MockProvider.createMockUserUpdate();

  UserQuery sampleUserQuery = mock(UserQuery.class);
  when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery);
  when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery);
  when(sampleUserQuery.singleResult()).thenReturn(initialUser);

  String message = "exception expected";
  doThrow(new AuthorizationException(message)).when(identityServiceMock).saveUser(any(User.class));

  UserProfileDto updateDto = UserProfileDto.fromUser(userUpdate);

  given()
      .pathParam("id", MockProvider.EXAMPLE_USER_ID)
      .body(updateDto).contentType(ContentType.JSON)
  .then()
      .statusCode(Status.FORBIDDEN.getStatusCode())
      .contentType(ContentType.JSON)
      .body("type", equalTo(AuthorizationException.class.getSimpleName()))
      .body("message", equalTo(message))
  .when()
      .put(USER_PROFILE_URL);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:27,代码来源:UserRestServiceInteractionTest.java


示例12: testPutCredentialsThrowsAuthorizationException

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
@Test
public void testPutCredentialsThrowsAuthorizationException() {
  User initialUser = MockProvider.createMockUser();
  UserQuery sampleUserQuery = mock(UserQuery.class);
  when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery);
  when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery);
  when(sampleUserQuery.singleResult()).thenReturn(initialUser);

  String message = "exception expected";
  doThrow(new AuthorizationException(message)).when(identityServiceMock).saveUser(any(User.class));

  UserCredentialsDto dto = new UserCredentialsDto();
  dto.setPassword("new-password");

  given()
      .pathParam("id", MockProvider.EXAMPLE_USER_ID)
      .body(dto).contentType(ContentType.JSON)
  .then()
    .statusCode(Status.FORBIDDEN.getStatusCode())
    .contentType(ContentType.JSON)
    .body("type", equalTo(AuthorizationException.class.getSimpleName()))
    .body("message", equalTo(message))
  .when()
      .put(USER_CREDENTIALS_URL);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:26,代码来源:UserRestServiceInteractionTest.java


示例13: testPutCredentials

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
@Test
public void testPutCredentials() {
  User initialUser = MockProvider.createMockUser();
  UserQuery sampleUserQuery = mock(UserQuery.class);
  when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery);
  when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery);
  when(sampleUserQuery.singleResult()).thenReturn(initialUser);

  UserCredentialsDto dto = new UserCredentialsDto();
  dto.setPassword("new-password");

  given()
      .pathParam("id", MockProvider.EXAMPLE_USER_ID)
      .body(dto).contentType(ContentType.JSON)
  .then()
      .statusCode(Status.NO_CONTENT.getStatusCode())
  .when()
      .put(USER_CREDENTIALS_URL);

  // password was updated
  verify(initialUser).setPassword(dto.getPassword());

  // and then saved
  verify(identityServiceMock).saveUser(initialUser);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:26,代码来源:UserRestServiceInteractionTest.java


示例14: saveUser

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
public User saveUser(User user) {
  UserEntity userEntity = (UserEntity) user;

  // encrypt password
  userEntity.encryptPassword();

  if(userEntity.getRevision() == 0) {
    checkAuthorization(Permissions.CREATE, Resources.USER, null);
    getDbEntityManager().insert(userEntity);
    createDefaultAuthorizations(userEntity);
  } else {
    checkAuthorization(Permissions.UPDATE, Resources.USER, user.getId());
    getDbEntityManager().merge(userEntity);
  }

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


示例15: createUser

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
protected User createUser(String userId) {
  User user = identityService.newUser(userId);
  identityService.saveUser(user);

  // give user all permission to manipulate authorizations
  Authorization authorization = createGrantAuthorization(AUTHORIZATION, ANY);
  authorization.setUserId(userId);
  authorization.addPermission(ALL);
  saveAuthorization(authorization);

  // give user all permission to manipulate users
  authorization = createGrantAuthorization(USER, ANY);
  authorization.setUserId(userId);
  authorization.addPermission(Permissions.ALL);
  saveAuthorization(authorization);

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


示例16: testUserCreateExistingFails

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
@Test
public void testUserCreateExistingFails() {
  User newUser = MockProvider.createMockUser();
  when(identityServiceMock.newUser(MockProvider.EXAMPLE_USER_ID)).thenReturn(newUser);
  doThrow(new ProcessEngineException("")).when(identityServiceMock).saveUser(newUser);

  UserDto userDto = UserDto.fromUser(newUser, true);

  given()
    .body(userDto).contentType(ContentType.JSON)
  .then()
    .statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON)
    .body("type", equalTo(ProcessEngineException.class.getSimpleName()))
  .when()
    .post(USER_CREATE_URL);

  verify(identityServiceMock).newUser(MockProvider.EXAMPLE_USER_ID);
  verify(identityServiceMock).saveUser(newUser);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:20,代码来源:UserRestServiceInteractionTest.java


示例17: shouldFetchTaskCountWithAuthorization

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
@Test
public void shouldFetchTaskCountWithAuthorization() {
  // given
  User user = identityService.newUser(userId);
  identityService.saveUser(user);

  Authorization authorization = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
  authorization.addPermission(READ);
  authorization.setResource(TASK);
  authorization.setResourceId(ANY);
  authorization.setUserId(userId);
  authorizationService.saveAuthorization(authorization);

  processEngineConfiguration.setAuthorizationEnabled(true);
  authenticate();

  // when
  List<TaskCountByCandidateGroupResult> results = taskService.createTaskReport().taskCountByCandidateGroup();
  processEngineConfiguration.setAuthorizationEnabled(false);
  authorizationService.deleteAuthorization(authorization.getId());
  identityService.deleteUser(userId);

  assertEquals(0, results.size());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:25,代码来源:TaskCountByCandidateGroupAuthorizationTest.java


示例18: testClaimAlreadyClaimedTaskBySameUser

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
@Test
public void testClaimAlreadyClaimedTaskBySameUser() {
  Task task = taskService.newTask();
  taskService.saveTask(task);
  User user = identityService.newUser("user");
  identityService.saveUser(user);

  // Claim task the first time
  taskService.claim(task.getId(), user.getId());
  task = taskService.createTaskQuery().taskId(task.getId()).singleResult();

  // Claim the task again with the same user. No exception should be thrown
  taskService.claim(task.getId(), user.getId());

  taskService.deleteTask(task.getId(), true);
  identityService.deleteUser(user.getId());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:18,代码来源:TaskServiceTest.java


示例19: testUnClaimTask

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
@Test
public void testUnClaimTask() {
  Task task = taskService.newTask();
  taskService.saveTask(task);
  User user = identityService.newUser("user");
  identityService.saveUser(user);

  // Claim task the first time
  taskService.claim(task.getId(), user.getId());
  task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
  assertEquals(user.getId(), task.getAssignee());

  // Unclaim the task
  taskService.claim(task.getId(), null);

  task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
  assertNull(task.getAssignee());

  taskService.deleteTask(task.getId(), true);
  identityService.deleteUser(user.getId());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:22,代码来源:TaskServiceTest.java


示例20: testSetAssignee

import org.camunda.bpm.engine.identity.User; //导入依赖的package包/类
@Test
public void testSetAssignee() {
  User user = identityService.newUser("user");
  identityService.saveUser(user);

  Task task = taskService.newTask();
  assertNull(task.getAssignee());
  taskService.saveTask(task);

  // Set assignee
  taskService.setAssignee(task.getId(), user.getId());

  // Fetch task again
  task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
  assertEquals(user.getId(), task.getAssignee());

  identityService.deleteUser(user.getId());
  taskService.deleteTask(task.getId(), true);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:20,代码来源:TaskServiceTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java APIException类代码示例发布时间:2022-05-22
下一篇:
Java User类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap