public virtual Authorization execute(CommandContext commandContext) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.impl.persistence.entity.AuthorizationManager authorizationManager = commandContext.getAuthorizationManager(); AuthorizationManager authorizationManager = commandContext.AuthorizationManager; authorizationManager.validateResourceCompatibility(authorization); string operationType = null; AuthorizationEntity previousValues = null; if (string.ReferenceEquals(authorization.Id, null)) { authorizationManager.insert(authorization); operationType = org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE; } else { previousValues = commandContext.DbEntityManager.selectById(typeof(AuthorizationEntity), authorization.Id); authorizationManager.update(authorization); operationType = org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_UPDATE; } commandContext.OperationLogManager.logAuthorizationOperation(operationType, authorization, previousValues); return(authorization); }
public virtual Void execute(CommandContext commandContext) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.impl.persistence.entity.AuthorizationManager authorizationManager = commandContext.getAuthorizationManager(); AuthorizationManager authorizationManager = commandContext.AuthorizationManager; AuthorizationEntity authorization = (AuthorizationEntity)(new AuthorizationQueryImpl()).authorizationId(authorizationId).singleResult(); ensureNotNull("Authorization for Id '" + authorizationId + "' does not exist", "authorization", authorization); authorizationManager.delete(authorization); commandContext.OperationLogManager.logAuthorizationOperation(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_DELETE, authorization, null); return(null); }
public virtual void testCreateAuthorization() { // add base permission which allows nobody to create authorizations Authorization basePerms = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL); basePerms.Resource = AUTHORIZATION; basePerms.ResourceId = ANY; basePerms.addPermission(ALL); // add all then remove 'create' basePerms.removePermission(CREATE); authorizationService.saveAuthorization(basePerms); // now enable authorizations: processEngineConfiguration.AuthorizationEnabled = true; identityService.AuthenticatedUserId = jonny2; try { // we cannot create another authorization authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL); fail("exception expected"); } catch (AuthorizationException e) { assertEquals(1, e.MissingAuthorizations.Count); MissingAuthorization info = e.MissingAuthorizations[0]; assertEquals(jonny2, e.UserId); assertExceptionInfo(CREATE.Name, AUTHORIZATION.resourceName(), null, info); } // circumvent auth check to get new transient object Authorization authorization = new AuthorizationEntity(AUTH_TYPE_REVOKE); authorization.UserId = "someUserId"; authorization.Resource = Resources.APPLICATION; try { authorizationService.saveAuthorization(authorization); fail("exception expected"); } catch (AuthorizationException e) { assertEquals(1, e.MissingAuthorizations.Count); MissingAuthorization info = e.MissingAuthorizations[0]; assertEquals(jonny2, e.UserId); assertExceptionInfo(CREATE.Name, AUTHORIZATION.resourceName(), null, info); } }
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()); } } } }
public SaveAuthorizationCmd(Authorization authorization) { this.authorization = (AuthorizationEntity)authorization; validate(); }