image.png

资源与权限码说明

image.png

资源

image.png
image.png
资源定义在org.camunda.bpm.engine.authorization.Resources 类中

  1. public enum Resources implements Resource {
  2. APPLICATION(EntityTypes.APPLICATION, 0),
  3. USER(EntityTypes.USER, 1),
  4. GROUP(EntityTypes.GROUP, 2),
  5. GROUP_MEMBERSHIP(EntityTypes.GROUP_MEMBERSHIP, 3),
  6. AUTHORIZATION(EntityTypes.AUTHORIZATION, 4),
  7. FILTER(EntityTypes.FILTER, 5),
  8. PROCESS_DEFINITION(EntityTypes.PROCESS_DEFINITION, 6),
  9. TASK(EntityTypes.TASK, 7),
  10. PROCESS_INSTANCE(EntityTypes.PROCESS_INSTANCE, 8),
  11. DEPLOYMENT(EntityTypes.DEPLOYMENT, 9),
  12. DECISION_DEFINITION(EntityTypes.DECISION_DEFINITION, 10),
  13. TENANT(EntityTypes.TENANT, 11),
  14. TENANT_MEMBERSHIP(EntityTypes.TENANT_MEMBERSHIP, 12),
  15. BATCH(EntityTypes.BATCH, 13),
  16. DECISION_REQUIREMENTS_DEFINITION(EntityTypes.DECISION_REQUIREMENTS_DEFINITION, 14),
  17. REPORT(EntityTypes.REPORT, 15),
  18. DASHBOARD(EntityTypes.DASHBOARD, 16);
  19. String name;
  20. int id;
  21. Resources(String name, int id) {
  22. this.name = name;
  23. this.id = id;
  24. }
  25. public String resourceName() {
  26. return name;
  27. }
  28. public int resourceType() {
  29. return id;
  30. }
  31. }

授权系列

查询用户权限

image.png

给用户权限

image.png

授权登陆

  1. Authorization authorization = authorizationService.createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
  2. authorization.setGroupId(null);
  3. authorization.setResourceId("*");
  4. authorization.setUserId("gjf1");
  5. authorization.setResource(Resources.APPLICATION);
  6. authorization.setPermissions(new Permission[]{Permissions.ACCESS});
  7. authorizationService.saveAuthorization(authorization);

授权操作组,租户,权限等资源

authorization.setResource(“修改此处资源即可”);

授权用户操作cockpit项目


超级管理员使用

image.png

DatabasePrefixHandler 的使用

  1. public class DatabasePrefixHandler {
  2. protected Pattern pattern = Pattern.compile("^\\{(.*?)\\}");
  3. //添加大括号
  4. public String generatePrefix(String algorithmName){
  5. return "{" + algorithmName + "}";
  6. }
  7. //
  8. public String retrieveAlgorithmName(String encryptedPasswordWithPrefix) {
  9. Matcher matcher = pattern.matcher(encryptedPasswordWithPrefix);
  10. if(matcher.find()){
  11. return matcher.group(1);
  12. }
  13. return null;
  14. }
  15. public String removePrefix(String encryptedPasswordWithPrefix) {
  16. int index = encryptedPasswordWithPrefix.indexOf("}");
  17. if(!encryptedPasswordWithPrefix.startsWith("{") || index < 0){
  18. return null;
  19. }
  20. return encryptedPasswordWithPrefix.substring(index+1);
  21. }
  22. }