Пример #1
0
        public override void postProcessEngineBuild(ProcessEngine processEngine)
        {
            if (!authorizationEnabled)
            {
                return;
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.AuthorizationService authorizationService = processEngine.getAuthorizationService();
            AuthorizationService authorizationService = processEngine.AuthorizationService;

            if (!string.ReferenceEquals(administratorGroupName, null) && administratorGroupName.Length > 0)
            {
                // create ADMIN authorizations on all built-in resources for configured group
                foreach (Resource resource in Resources.values())
                {
                    if (authorizationService.createAuthorizationQuery().groupIdIn(administratorGroupName).resourceType(resource).resourceId(ANY).count() == 0)
                    {
                        AuthorizationEntity adminGroupAuth = new AuthorizationEntity(AUTH_TYPE_GRANT);
                        adminGroupAuth.GroupId = administratorGroupName;
                        adminGroupAuth.setResource(resource);
                        adminGroupAuth.ResourceId = ANY;
                        adminGroupAuth.addPermission(ALL);
                        authorizationService.saveAuthorization(adminGroupAuth);
                        LOG.grantGroupPermissions(administratorGroupName, resource.resourceName());
                    }
                }
            }

            if (!string.ReferenceEquals(administratorUserName, null) && administratorUserName.Length > 0)
            {
                // create ADMIN authorizations on all built-in resources for configured user
                foreach (Resource resource in Resources.values())
                {
                    if (authorizationService.createAuthorizationQuery().userIdIn(administratorUserName).resourceType(resource).resourceId(ANY).count() == 0)
                    {
                        AuthorizationEntity adminUserAuth = new AuthorizationEntity(AUTH_TYPE_GRANT);
                        adminUserAuth.UserId = administratorUserName;
                        adminUserAuth.setResource(resource);
                        adminUserAuth.ResourceId = ANY;
                        adminUserAuth.addPermission(ALL);
                        authorizationService.saveAuthorization(adminUserAuth);
                        LOG.grantUserPermissions(administratorUserName, resource.resourceName());
                    }
                }
            }
        }
Пример #2
0
        protected internal static Authorization createAuthorization(AuthorizationService authorizationService, Permission permission, Resources resource, string userId)
        {
            Authorization auth = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);

            auth.addPermission(permission);
            auth.Resource   = resource;
            auth.ResourceId = org.camunda.bpm.engine.authorization.Authorization_Fields.ANY;
            auth.UserId     = userId;
            return(auth);
        }