Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCheckDbForCfgValue_auto()
        public virtual void shouldCheckDbForCfgValue_auto()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.db.ListQueryParameterObject query = new org.camunda.bpm.engine.impl.db.ListQueryParameterObject();
            ListQueryParameterObject query = new ListQueryParameterObject();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.db.AuthorizationCheck authCheck = query.getAuthCheck();
            AuthorizationCheck authCheck = query.AuthCheck;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.HashMap<String, Object> expectedQueryParams = new java.util.HashMap<String, Object>();
            Dictionary <string, object> expectedQueryParams = new Dictionary <string, object>();

            expectedQueryParams["userId"]       = AUTHENTICATED_USER_ID;
            expectedQueryParams["authGroupIds"] = AUTHENTICATED_GROUPS;

            // given
            when(mockedConfiguration.AuthorizationCheckRevokes).thenReturn(ProcessEngineConfiguration.AUTHORIZATION_CHECK_REVOKE_AUTO);
            when(mockedEntityManager.selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams))).thenReturn(true);

            // if
            authorizationManager.configureQuery(query);

            // then
            assertEquals(true, authCheck.RevokeAuthorizationCheckEnabled);
            verify(mockedEntityManager, times(1)).selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams));
        }
Example #2
0
        protected internal virtual bool isRevokeAuthCheckEnabled(string userId, IList <string> groupIds)
        {
            bool?isRevokeAuthCheckEnabled = this.isRevokeAuthCheckUsed;

            if (isRevokeAuthCheckEnabled == null)
            {
                string configuredMode = Context.ProcessEngineConfiguration.AuthorizationCheckRevokes;
                if (!string.ReferenceEquals(configuredMode, null))
                {
                    configuredMode = configuredMode.ToLower();
                }
                if (ProcessEngineConfiguration.AUTHORIZATION_CHECK_REVOKE_ALWAYS.Equals(configuredMode))
                {
                    isRevokeAuthCheckEnabled = true;
                }
                else if (ProcessEngineConfiguration.AUTHORIZATION_CHECK_REVOKE_NEVER.Equals(configuredMode))
                {
                    isRevokeAuthCheckEnabled = false;
                }
                else
                {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.Map<String, Object> params = new java.util.HashMap<String, Object>();
                    IDictionary <string, object> @params = new Dictionary <string, object>();
                    @params["userId"]        = userId;
                    @params["authGroupIds"]  = filterAuthenticatedGroupIds(groupIds);
                    isRevokeAuthCheckEnabled = DbEntityManager.selectBoolean("selectRevokeAuthorization", @params);
                }
                this.isRevokeAuthCheckUsed = isRevokeAuthCheckEnabled;
            }

            return(isRevokeAuthCheckEnabled.Value);
        }
Example #3
0
        public virtual bool isAuthorized(string userId, IList <string> groupIds, CompositePermissionCheck compositePermissionCheck)
        {
            foreach (PermissionCheck permissionCheck in compositePermissionCheck.AllPermissionChecks)
            {
                if (!isResourceValidForPermission(permissionCheck))
                {
                    throw LOG.invalidResourceForPermission(permissionCheck.Resource.resourceName(), permissionCheck.Permission.Name);
                }
            }
            IList <string> filteredGroupIds = filterAuthenticatedGroupIds(groupIds);

            bool isRevokeAuthorizationCheckEnabled = isRevokeAuthCheckEnabled(userId, groupIds);
            AuthorizationCheck authCheck           = new AuthorizationCheck(userId, filteredGroupIds, compositePermissionCheck, isRevokeAuthorizationCheckEnabled);

            return(DbEntityManager.selectBoolean("isUserAuthorizedForResource", authCheck));
        }