本文整理汇总了Java中org.camunda.bpm.engine.AuthorizationService类的典型用法代码示例。如果您正苦于以下问题:Java AuthorizationService类的具体用法?Java AuthorizationService怎么用?Java AuthorizationService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthorizationService类属于org.camunda.bpm.engine包,在下文中一共展示了AuthorizationService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: instantiate
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
public Authorization instantiate(AuthorizationService authorizationService, Map<String, String> replacements) {
Authorization authorization = authorizationService.createNewAuthorization(type);
// TODO: group id is missing
authorization.setResource(resource);
if (replacements.containsKey(resourceId)) {
authorization.setResourceId(replacements.get(resourceId));
}
else {
authorization.setResourceId(resourceId);
}
authorization.setUserId(userId);
authorization.setPermissions(permissions);
return authorization;
}
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:18,代码来源:AuthorizationSpec.java
示例2: createAuthenticationData
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的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: isAuthorized
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的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);
}
}
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:19,代码来源:AbstractAuthorizedRestResource.java
示例4: setupUserData
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的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);
}
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:16,代码来源:UserRestServiceInteractionTest.java
示例5: setupData
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
@Before
public void setupData() {
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);
mockTenant = MockProvider.createMockTenant();
mockQuery = setUpMockQuery(mockTenant);
}
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:18,代码来源:TenantRestServiceInteractionTest.java
示例6: initDb
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
public void initDb() {
ProcessEngine processEngine = lookupProcessEngine(ENGINE_NAME);
if (processEngine != null) {
IdentityService identityService = processEngine.getIdentityService();
AuthorizationService authorizationService = processEngine.getAuthorizationService();
// the group must be created at the first start of the application
if (identityService.createGroupQuery().groupId(ALL_USERS).list().size() == 0) {
Group group = identityService.newGroup(ALL_USERS);
group.setName(ALL_USERS);
identityService.saveGroup(group);
// set Auth for new group
addAuthorizationGroup(authorizationService, Resources.APPLICATION, "tasklist", ALL_USERS, new Permission[] {Permissions.ACCESS});
addAuthorizationGroup(authorizationService, Resources.USER, Authorization.ANY, ALL_USERS, new Permission[] {Permissions.READ});
addAuthorizationGroup(authorizationService, Resources.PROCESS_DEFINITION, "TechOrder", ALL_USERS, new Permission[] {Permissions.READ,
Permissions.CREATE_INSTANCE, Permissions.READ_HISTORY});
addAuthorizationGroup(authorizationService, Resources.PROCESS_INSTANCE, Authorization.ANY, ALL_USERS, new Permission[] {Permissions.CREATE});
createDefaultFilter(processEngine);
}
// create users
Set<User> users = orgStructure.getUsers();
Map<String, String> userPass = orgStructure.getUserPass(users);
users.stream().filter(user -> !userExist(user.getEmail(), identityService)).forEach(user -> createUser(user, userPass, processEngine));
} else {
throw new RuntimeException("Unable to init db");
}
}
开发者ID:IntegrityVision,项目名称:Purchase-order-process-template,代码行数:31,代码来源:ResourcesAuthorization.java
示例7: addAuthorizationGroup
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
private void addAuthorizationGroup(AuthorizationService authorizationService,
Resource resource, String resourceId,
String groupId, Permission[] permissions) {
Authorization newAuthorization = authorizationService.createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
newAuthorization.setGroupId(groupId);
newAuthorization.setResource(resource);
newAuthorization.setResourceId(resourceId);
for (Permission permission : permissions) {
newAuthorization.addPermission(permission);
}
authorizationService.saveAuthorization(newAuthorization);
}
开发者ID:IntegrityVision,项目名称:Purchase-order-process-template,代码行数:13,代码来源:ResourcesAuthorization.java
示例8: addAuthorizationUser
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
public void addAuthorizationUser(AuthorizationService authorizationService,
Resource resource, String resourceId,
String userId, Permission[] permissions) {
Authorization newAuthorization = authorizationService.createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
newAuthorization.setUserId(userId);
newAuthorization.setResource(resource);
newAuthorization.setResourceId(resourceId);
Arrays.stream(permissions).forEach(newAuthorization::addPermission);
for (Permission permission : permissions) {
newAuthorization.addPermission(permission);
}
authorizationService.saveAuthorization(newAuthorization);
}
开发者ID:IntegrityVision,项目名称:Purchase-order-process-template,代码行数:14,代码来源:ResourcesAuthorization.java
示例9: postProcessEngineBuild
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
@Override
public void postProcessEngineBuild(final ProcessEngine processEngine) {
requireNonNull(adminUser);
final IdentityService identityService = processEngine.getIdentityService();
final AuthorizationService authorizationService = processEngine.getAuthorizationService();
if (userAlreadyExists(identityService, adminUser)) {
return;
}
createUser(identityService, adminUser);
// create group
if (identityService.createGroupQuery().groupId(CAMUNDA_ADMIN).count() == 0) {
Group camundaAdminGroup = identityService.newGroup(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(CAMUNDA_ADMIN).resourceType(resource).resourceId(ANY).count() == 0) {
AuthorizationEntity userAdminAuth = new AuthorizationEntity(AUTH_TYPE_GRANT);
userAdminAuth.setGroupId(CAMUNDA_ADMIN);
userAdminAuth.setResource(resource);
userAdminAuth.setResourceId(ANY);
userAdminAuth.addPermission(ALL);
authorizationService.saveAuthorization(userAdminAuth);
}
}
identityService.createMembership(adminUser.getId(), CAMUNDA_ADMIN);
LOG.creatingInitialAdminUser(adminUser);
}
开发者ID:camunda,项目名称:camunda-bpm-spring-boot-starter,代码行数:37,代码来源:CreateAdminUserConfiguration.java
示例10: afterPropertiesSet
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的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
示例11: tearDown
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
public void tearDown(AuthorizationService authorizationService) {
Set<String> activeAuthorizations = new HashSet<String>();
for (Authorization activeAuthorization : authorizationService.createAuthorizationQuery().list()) {
activeAuthorizations.add(activeAuthorization.getId());
}
for (Authorization createdAuthorization : createdAuthorizations) {
if (activeAuthorizations.contains(createdAuthorization.getId())) {
authorizationService.deleteAuthorization(createdAuthorization.getId());
}
}
}
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:13,代码来源:AuthorizationScenarioInstance.java
示例12: setupGroupData
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
@Before
public void setupGroupData() {
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);
}
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:15,代码来源:GroupRestServiceInteractionTest.java
示例13: grouptGrant
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
protected void grouptGrant(String groupId, Resource resource, Permission... perms) {
AuthorizationService authorizationService = engine.getAuthorizationService();
Authorization groupGrant = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
groupGrant.setResource(resource);
groupGrant.setResourceId(ANY);
for (Permission permission : perms) {
groupGrant.addPermission(permission);
}
groupGrant.setGroupId(groupId);
authorizationService.saveAuthorization(groupGrant);
}
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:13,代码来源:AuthorizationPerformanceTestCase.java
示例14: userGrant
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
protected void userGrant(String userId, Resource resource, Permission... perms) {
AuthorizationService authorizationService = engine.getAuthorizationService();
Authorization groupGrant = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
groupGrant.setResource(resource);
groupGrant.setResourceId(ANY);
for (Permission permission : perms) {
groupGrant.addPermission(permission);
}
groupGrant.setUserId(userId);
authorizationService.saveAuthorization(groupGrant);
}
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:13,代码来源:AuthorizationPerformanceTestCase.java
示例15: createAuthorizations
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
@Before
public void createAuthorizations() {
AuthorizationService authorizationService = engine.getAuthorizationService();
List<Authorization> auths = authorizationService.createAuthorizationQuery().list();
for (Authorization authorization : auths) {
authorizationService.deleteAuthorization(authorization.getId());
}
userGrant("test", resource, permissions);
for (int i = 0; i < 5; i++) {
grouptGrant("g"+i, resource, permissions);
}
engine.getProcessEngineConfiguration().setAuthorizationEnabled(true);
}
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:15,代码来源:HistoryAuthorizationQueryPerformanceTest.java
示例16: startProcessInstance
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的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
示例17: createAuthorization
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
protected static Authorization createAuthorization(AuthorizationService authorizationService, Permission permission, Resources resource, String userId) {
Authorization auth = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
auth.addPermission(permission);
auth.setResource(resource);
auth.setResourceId(Authorization.ANY);
auth.setUserId(userId);
return auth;
}
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:9,代码来源:AuthorizationScenario.java
示例18: setAutoLoginAuthentication
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
/**
* Reads the auto-login-username from the URL parameters and create an
* {@link Authentication} for it containing its groups, tenants and
* authorized apps.
*
* No password check is done here, so you can log onto every user without a
* password. Only makes sense in demo environments!
*/
protected void setAutoLoginAuthentication(final ServletRequest request, Authentications authentications) {
final HttpServletRequest req = (HttpServletRequest) request;
final ProcessEngine engine = getEngine();
// Get the username from the user in SSO
String username = retrieveUsername(req);
// if not set - no auto login
if (username == null) {
return;
}
// if already in the list of logged in users - nothing to do
Authentication authentication = authentications.getAuthenticationForProcessEngine(engine.getName());
if (authentication != null && authentication.getName() == username) {
return;
}
AuthorizationService authorizationService = engine.getAuthorizationService();
// query group information
List<String> groupIds = getGroupsOfUser(engine, username);
List<String> tenantIds = getTenantsOfUser(engine, username);
// check user's app authorizations by iterating of list of apps and ask
// if permitted
HashSet<String> authorizedApps = new HashSet<String>();
authorizedApps.add("admin");
if (engine.getProcessEngineConfiguration().isAuthorizationEnabled()) {
for (String application : APPS) {
if (authorizationService.isUserAuthorized(username, groupIds, ACCESS, APPLICATION, application)) {
authorizedApps.add(application);
}
}
} else {
Collections.addAll(authorizedApps, APPS);
}
// create new authentication object to store authentication
UserAuthentication newAuthentication = new UserAuthentication(username, engine.getName());
newAuthentication.setGroupIds(groupIds);
newAuthentication.setTenantIds(tenantIds);
newAuthentication.setAuthorizedApps(authorizedApps);
// and add the new logged in user
authentications.addAuthentication(newAuthentication);
}
开发者ID:camunda-consulting,项目名称:camunda-webapp-plugins,代码行数:56,代码来源:AutoLoginAuthenticationFilter.java
示例19: getAuthorizationService
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
public AuthorizationService getAuthorizationService() {
return processEngine.getAuthorizationService();
}
开发者ID:camunda,项目名称:camunda-bpm-assert-scenario,代码行数:4,代码来源:AbstractProcessEngineServicesDelegate.java
示例20: doLogin
import org.camunda.bpm.engine.AuthorizationService; //导入依赖的package包/类
/**
* Login a user that has already been authenticated and
* optionally provide its groups.
*
* This method is a copy of {@link UserAuthenticationResource#doLogin(String, String, String, String)}
* except that it neither checks the password nor for application permissions
* and works on a given list of authentications.
*
* The password (or any other proof of identity) MUST be checked by the
* application server before it passes the request to the application.
*
* Application permissions are checked by the applications themselves.
*
* It should be kept in sync with the latest version from Camunda,
* e.g. by doing a diff between the Java files.
* Hint: Ignore whitespace when doing the diff.
*
* @param engineName Name of the engine to login to
* @param username Id of the authenticated user
* @param authentications Current authentications from the session
* @param groupIds Groups of the authenticated user
* If groupIds is null, they will be retrieved from the {@link IdentityService}.
*/
public void doLogin(
String engineName,
String username,
Authentications authentications,
List<String> groupIds) {
final ProcessEngine processEngine = lookupProcessEngine(engineName);
if(processEngine == null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Process engine with name "+engineName+" does not exist");
}
// make sure authentication is executed without authentication :)
processEngine.getIdentityService().clearAuthentication();
if (groupIds == null)
groupIds = getGroupsOfUser(processEngine, username);
List<String> tenantIds = getTenantsOfUser(processEngine, username);
// check user's app authorizations
AuthorizationService authorizationService = processEngine.getAuthorizationService();
HashSet<String> authorizedApps = new HashSet<String>();
authorizedApps.add("welcome");
if (processEngine.getProcessEngineConfiguration().isAuthorizationEnabled()) {
for (String application: APPS) {
if (isAuthorizedForApp(authorizationService, username, groupIds, application)) {
authorizedApps.add(application);
}
}
} else {
Collections.addAll(authorizedApps, APPS);
}
// create new authentication
UserAuthentication newAuthentication = new UserAuthentication(username, engineName);
newAuthentication.setGroupIds(groupIds);
newAuthentication.setTenantIds(tenantIds);
newAuthentication.setAuthorizedApps(authorizedApps);
authentications.addAuthentication(newAuthentication);
}
开发者ID:camunda,项目名称:camunda-sso-jboss,代码行数:66,代码来源:ContainerBasedUserAuthenticationResource.java
注:本文中的org.camunda.bpm.engine.AuthorizationService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论