本文整理汇总了Java中org.camunda.bpm.engine.IdentityService类的典型用法代码示例。如果您正苦于以下问题:Java IdentityService类的具体用法?Java IdentityService怎么用?Java IdentityService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IdentityService类属于org.camunda.bpm.engine包,在下文中一共展示了IdentityService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
}
示例2: getTenantIdOfCurrentAuthentication
import org.camunda.bpm.engine.IdentityService; //导入依赖的package包/类
protected String getTenantIdOfCurrentAuthentication() {
IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService();
Authentication currentAuthentication = identityService.getCurrentAuthentication();
if (currentAuthentication != null) {
List<String> tenantIds = currentAuthentication.getTenantIds();
if (tenantIds.size() == 1) {
return tenantIds.get(0);
} else if (tenantIds.isEmpty()) {
return null;
} else {
throw new IllegalStateException("more than one authenticated tenant");
}
} else {
return null;
}
}
示例3: testGroupPaging
import org.camunda.bpm.engine.IdentityService; //导入依赖的package包/类
public static void testGroupPaging(IdentityService identityService) {
Set<String> groupNames = new HashSet<String>();
List<Group> groups = identityService.createGroupQuery().listPage(0, 2);
assertEquals(2, groups.size());
checkPagingResults(groupNames, groups.get(0).getId(), groups.get(1).getId());
groups = identityService.createGroupQuery().listPage(2, 2);
assertEquals(2, groups.size());
checkPagingResults(groupNames, groups.get(0).getId(), groups.get(1).getId());
groups = identityService.createGroupQuery().listPage(4, 2);
assertEquals(2, groups.size());
assertFalse(groupNames.contains(groups.get(0).getId()));
groupNames.add(groups.get(0).getId());
groups = identityService.createGroupQuery().listPage(6, 2);
assertEquals(0, groups.size());
}
示例4: testUserPaging
import org.camunda.bpm.engine.IdentityService; //导入依赖的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());
}
示例5: testUserPagingWithMemberOfGroup
import org.camunda.bpm.engine.IdentityService; //导入依赖的package包/类
public static void testUserPagingWithMemberOfGroup(IdentityService identityService) {
Set<String> userNames = new HashSet<String>();
List<User> users = identityService.createUserQuery().memberOfGroup("all").listPage(0, 2);
assertEquals(2, users.size());
checkPagingResults(userNames, users.get(0).getId(), users.get(1).getId());
users = identityService.createUserQuery().memberOfGroup("all").listPage(2, 2);
assertEquals(2, users.size());
checkPagingResults(userNames, users.get(0).getId(), users.get(1).getId());
users = identityService.createUserQuery().memberOfGroup("all").listPage(4, 2);
assertEquals(2, users.size());
checkPagingResults(userNames, users.get(0).getId(), users.get(1).getId());
users = identityService.createUserQuery().memberOfGroup("all").listPage(11, 2);
assertEquals(1, users.size());
assertFalse(userNames.contains(users.get(0).getId()));
users = identityService.createUserQuery().memberOfGroup("all").listPage(12, 2);
assertEquals(0, users.size());
}
示例6: 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");
}
示例7: resolveNotCachedLinks
import org.camunda.bpm.engine.IdentityService; //导入依赖的package包/类
protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) {
IdentityService identityService = processEngine.getIdentityService();
List<User> users = identityService.createUserQuery()
.userIdIn(linkedIds)
.listPage(0, linkedIds.length);
List<HalResource<?>> resolvedUsers = new ArrayList<HalResource<?>>();
for (User user : users) {
resolvedUsers.add(HalUser.fromUser(user));
}
return resolvedUsers;
}
示例8: resolveNotCachedLinks
import org.camunda.bpm.engine.IdentityService; //导入依赖的package包/类
@Override
protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) {
IdentityService identityService = processEngine.getIdentityService();
List<Tenant> tenants = identityService
.createTenantQuery()
.tenantIdIn(linkedIds)
.list();
List<HalResource<?>> resolvedTenants = new ArrayList<HalResource<?>>();
for (Tenant tenant : tenants) {
resolvedTenants.add(HalTenant.fromTenant(tenant));
}
return resolvedTenants;
}
示例9: getApplicationPathForDeployment
import org.camunda.bpm.engine.IdentityService; //导入依赖的package包/类
public static String getApplicationPathForDeployment(ProcessEngine engine, String deploymentId) {
// get the name of the process application that made the deployment
String processApplicationName = null;
IdentityService identityService = engine.getIdentityService();
Authentication currentAuthentication = identityService.getCurrentAuthentication();
try {
identityService.clearAuthentication();
processApplicationName = engine.getManagementService().getProcessApplicationForDeployment(deploymentId);
} finally {
identityService.setAuthentication(currentAuthentication);
}
if (processApplicationName == null) {
// no a process application deployment
return null;
} else {
ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(processApplicationName);
return processApplicationInfo.getProperties().get(ProcessApplicationInfo.PROP_SERVLET_CONTEXT_PATH);
}
}
示例10: getGroupInfo
import org.camunda.bpm.engine.IdentityService; //导入依赖的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);
}
示例11: availableOperations
import org.camunda.bpm.engine.IdentityService; //导入依赖的package包/类
public ResourceOptionsDto availableOperations(UriInfo context) {
final IdentityService identityService = getIdentityService();
UriBuilder baseUriBuilder = context.getBaseUriBuilder()
.path(relativeRootResourcePath)
.path(GroupRestService.PATH);
ResourceOptionsDto resourceOptionsDto = new ResourceOptionsDto();
// GET /
URI baseUri = baseUriBuilder.build();
resourceOptionsDto.addReflexiveLink(baseUri, HttpMethod.GET, "list");
// GET /count
URI countUri = baseUriBuilder.clone().path("/count").build();
resourceOptionsDto.addReflexiveLink(countUri, HttpMethod.GET, "count");
// POST /create
if(!identityService.isReadOnly() && isAuthorized(CREATE)) {
URI createUri = baseUriBuilder.clone().path("/create").build();
resourceOptionsDto.addReflexiveLink(createUri, HttpMethod.POST, "create");
}
return resourceOptionsDto;
}
示例12: isAuthorized
import org.camunda.bpm.engine.IdentityService; //导入依赖的package包/类
protected boolean isAuthorized(Permission permission, Resource resource, String resourceId) {
if (!processEngine.getProcessEngineConfiguration().isAuthorizationEnabled()) {
// if authorization is disabled everyone is authorized
return true;
}
final IdentityService identityService = processEngine.getIdentityService();
final AuthorizationService authorizationService = processEngine.getAuthorizationService();
Authentication authentication = identityService.getCurrentAuthentication();
if(authentication == null) {
return true;
} else {
return authorizationService
.isUserAuthorized(authentication.getUserId(), authentication.getGroupIds(), permission, resource, resourceId);
}
}
示例13: 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);
}
示例14: availableOperations
import org.camunda.bpm.engine.IdentityService; //导入依赖的package包/类
public ResourceOptionsDto availableOperations(UriInfo context) {
final IdentityService identityService = getIdentityService();
UriBuilder baseUriBuilder = context.getBaseUriBuilder()
.path(relativeRootResourcePath)
.path(UserRestService.PATH);
ResourceOptionsDto resourceOptionsDto = new ResourceOptionsDto();
// GET /
URI baseUri = baseUriBuilder.build();
resourceOptionsDto.addReflexiveLink(baseUri, HttpMethod.GET, "list");
// GET /count
URI countUri = baseUriBuilder.clone().path("/count").build();
resourceOptionsDto.addReflexiveLink(countUri, HttpMethod.GET, "count");
// POST /create
if(!identityService.isReadOnly() && isAuthorized(CREATE)) {
URI createUri = baseUriBuilder.clone().path("/create").build();
resourceOptionsDto.addReflexiveLink(createUri, HttpMethod.POST, "create");
}
return resourceOptionsDto;
}
示例15: setupUserData
import org.camunda.bpm.engine.IdentityService; //导入依赖的package包/类
@Before
public void setupUserData() {
identityServiceMock = mock(IdentityService.class);
authorizationServiceMock = mock(AuthorizationService.class);
processEngineConfigurationMock = mock(ProcessEngineConfiguration.class);
// mock identity service
when(processEngine.getIdentityService()).thenReturn(identityServiceMock);
// authorization service
when(processEngine.getAuthorizationService()).thenReturn(authorizationServiceMock);
// process engine configuration
when(processEngine.getProcessEngineConfiguration()).thenReturn(processEngineConfigurationMock);
}