Example #1
0
        private void CreateLDAPEnabledOfflinePreRoutingSet()
        {
            Append(new NxComment("Pre-routing offline enabled"));

            NxObjectLookup isLdapEnabled = new NxObjectLookup(Guid.NewGuid().ToString(), "LDAPAnalyzer", "IsLdapEnabled");

            NxLogic nxLogic = new NxLogic();
            NxIf nxIf = new NxIf();
            NxAnd nxAnd = new NxAnd();
            NxIsTrue nxIsTrue = new NxIsTrue(isLdapEnabled.Identifier);
            NxDo nxDo = new NxDo();

            nxAnd.Append(nxIsTrue);
            nxIf.Append(nxAnd);
            nxDo.Append(new NxComment("Online routing"));
            nxDo.Append(new NxEvaluate("RuleFired", BuildRuleFiredParameters()));
            nxIf.Append(nxDo);
            nxLogic.Append(nxIf);

            NxElse nxElse = new NxElse();
            nxElse.Append(new NxComment("Offline routing"));
            nxElse.Append(new NxEvaluate("RuleFired", BuildOfflineRuleFiredParameters()));
            nxLogic.Append(nxElse);
            
            Append(isLdapEnabled);
            AppendLogic(nxLogic);
        }
Example #2
0
        private SortedList<int, NxElement> CreatePartiallyTrustedRoutingPath_UntrustedRecipients()
        {
            SortedList<int, NxElement> partiallyTrusted = new SortedList<int, NxElement>();
            IRoutingTable routing = m_policyChannel.Routing;
            if (null == routing)
                return partiallyTrusted;

            foreach (IRoutingItemCollection source in routing.Sources)
            {
                if ("true" == source["DefaultGroup"].Value.ToLower(CultureInfo.InvariantCulture))
                    continue;

                if (!routing.HasDefaultDestinations)
                    continue;

                Guid sourceId = source.Identifier;
                Guid destinationId = routing.DefaultDestination.Identifier;

                IRoutingMatrixCell routingMatrixCell = routing[sourceId, destinationId];

                if (m_policyChannel.Actions == null)
                    continue; // No actions

                IActionMatrixCell actionMatrixCell = m_policyChannel.Actions[sourceId, destinationId];

                if (routingMatrixCell == null)
                    continue; // No routing for routingItem/destination

                NxControl elseIf = CreateConditionalStatement(routingMatrixCell.Precedence);

                string objectId = GetRoutingItemCollectionObjectId(source);

                string senderIsInGroupId = CreateIsThingMemberOfGroupLookupIfNecessary(objectId, m_currentUserId, sourceId.ToString());
                string isEnabledId = CreateIsRouterEnabledIfNecessary(objectId);

                NxIsTrue senderIsInGroup = new NxIsTrue(senderIsInGroupId);
                NxIsTrue isEnabled = new NxIsTrue(isEnabledId);

                NxAnd and = new NxAnd();
                and.Append(isEnabled);
                and.Append(senderIsInGroup);

                if (routing.HasDefaultSources)
                {

                    elseIf.Append(and);

                    NxDo routingDo = new NxDo();
                    AddActionSetsForRoutingMatrixCell(routingDo, routingMatrixCell, actionMatrixCell);

                    elseIf.Append(routingDo);
                }

                partiallyTrusted.Add(routingMatrixCell.Precedence, elseIf);
            }
            return partiallyTrusted;
        }
Example #3
0
        private void AddNonDefaultPrecedences(SortedList<int, NxElement> precedences, IRoutingTable routing)
        {
            foreach (IRoutingItemCollection source in routing.Sources)
            {
                if ("true" == source["DefaultGroup"].Value.ToLower(CultureInfo.InvariantCulture))
                    continue;

                foreach (IRoutingItemCollection destination in routing.Destinations)
                {
                    if ("true" == destination["DefaultGroup"].Value.ToLower(CultureInfo.InvariantCulture))
                        continue;

                    string destinationObjectId = GetRoutingItemCollectionObjectId(destination);
                    string sourceObjectId = GetRoutingItemCollectionObjectId(source);

                    string trustedSourceLookup = CreateIsThingMemberOfGroupLookupIfNecessary(sourceObjectId, m_currentUserId, source.Identifier.ToString());
                    string trustedDestinationLookup = CreateIsThingMemberOfGroupLookupIfNecessary(destinationObjectId, m_destinationListId, destination.Identifier.ToString());
                    string isSourceEnabledLookup = CreateIsRouterEnabledIfNecessary(sourceObjectId);
                    string isDestinationEnabledLookup = CreateIsRouterEnabledIfNecessary(destinationObjectId);

                    string sourceId = source.Identifier.ToString();
                    string destinationId = destination.Identifier.ToString();

                    if (m_policyChannel.Routing == null)
                        continue; // No routing

                    IRoutingMatrixCell routingMatrixCell = routing[sourceId, destinationId];

                    if (m_policyChannel.Actions == null)
                        continue; // No actions

                    IActionMatrixCell actionMatrixCell = m_policyChannel.Actions[sourceId, destinationId];

                    if (routingMatrixCell == null)
                        continue; // No routing for source/destination

                    NxIsTrue isTrueTrustedSource = new NxIsTrue(trustedSourceLookup);
                    NxIsTrue isTrueTrustedDestination = new NxIsTrue(trustedDestinationLookup);
                    NxIsTrue isTrueSourceEnabled = new NxIsTrue(isSourceEnabledLookup);
                    NxIsTrue isTrueDestinationEnabled = new NxIsTrue(isDestinationEnabledLookup);

                    NxAnd and = new NxAnd();
                    and.Append(isTrueSourceEnabled);
                    if (isDestinationEnabledLookup != isSourceEnabledLookup)
                    {
                        and.Append(isTrueDestinationEnabled);
                    }
                    and.Append(isTrueTrustedSource);
                    and.Append(isTrueTrustedDestination);

                    NxControl condStatement = CreateConditionalStatement(routingMatrixCell.Precedence);
                    condStatement.Append(and);

                    NxDo routingDo = new NxDo();
                    AddActionSetsForRoutingMatrixCell(routingDo, routingMatrixCell, actionMatrixCell);

                    condStatement.Append(routingDo);
                    precedences.Add(routingMatrixCell.Precedence, condStatement);
                }
            }
        }
Example #4
0
        private void AppendNonDefaultRoutingItems(NxAnd and, string lookupId, IRoutingItemCollections routingItems)
        {
            foreach (IRoutingItemCollection routingItem in routingItems)
            {
                if ("true" == routingItem["DefaultGroup"].Value.ToLower(CultureInfo.InvariantCulture))
                    continue;

                string objectId = GetRoutingItemCollectionObjectId(routingItem);

                string isNotMemberOfGroupId = CreateIsThingNotMemberOfGroupLookupIfNecessary(objectId, lookupId, routingItem.Identifier.ToString());
                string isRouterEnabledId = CreateIsRouterEnabledIfNecessary(objectId);

                NxIsTrue isTrueRoutingItemNotMember = new NxIsTrue(isNotMemberOfGroupId);
                NxIsTrue isRouterEnabled = new NxIsTrue(isRouterEnabledId);
                and.Append(isTrueRoutingItemNotMember);
                and.Append(isRouterEnabled);
            }
        }