AppliesToBehaviorDecisionTable.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / AppliesToBehaviorDecisionTable.cs / 1 / AppliesToBehaviorDecisionTable.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------
//
// Presharp uses the c# pragma mechanism to supress its warnings. 
// These are not recognised by the base compiler so we need to explictly
// disable the following warnings. See http://winweb/cse/Tools/PREsharp/userguide/default.asp 
// for details. 
//
 

namespace Microsoft.InfoCards
{
    using System; 
    using System.Collections;
 
    internal enum AppliesToBehaviorDecision :byte 
    {
        DoNotSend = 0, 
        SendRPAppliesTo = 1,
        SendCustomAppliesTo = 2,
        FailMatch = 3
    }; 

    // 
    // This class is used to store the decision table that decides if an AppliesTo element 
    // is being sent in an RST to the IPSTS
    // 
    internal static class AppliesToBehaviorDecisionTable
    {

 
        static AppliesToBehaviorDecision[ , ] appliesToDecisionTable = new AppliesToBehaviorDecision[ 2, 3 ];
 
 

        static AppliesToBehaviorDecisionTable() 
        {
            // The table is populated as follows
            //
            //   Case AppliesTo RequireAppliesTo Result                     Scenario 
            //       in Policy in crd
            //  1    Yes       Required          RP AppliesTo sent to IP   Auditing STS 
            //  2    No        Required          Cardspace manufactured    Auditing STS 
            //                                   AppliesTo set to IP
            //  3    Yes       Not present       Fail ( done during card   - 
            //                                   matching )
            //  4    No        Not present       No AppliesTo sent to IP   Non-auditing IP/STS OR dedicated IP/STS
            //  5    Yes       Optional          RP AppliesTo sent to IP   Using Driver´┐Żs License managed card on DOL site
            //  6    No        Optional          No AppliesTo sent to IP   Scenario: Shopping at www.wine.com and need DOL IP/STS to prove age > 21 

            appliesToDecisionTable[ 0, (int)RequireAppliesToStatus.NotPresent ] = AppliesToBehaviorDecision.DoNotSend; 
            appliesToDecisionTable[ 1, (int)RequireAppliesToStatus.NotPresent ] = AppliesToBehaviorDecision.FailMatch; 
            appliesToDecisionTable[ 0, (int)RequireAppliesToStatus.Optional ] = AppliesToBehaviorDecision.DoNotSend;
            appliesToDecisionTable[ 1, (int)RequireAppliesToStatus.Optional ] = AppliesToBehaviorDecision.SendRPAppliesTo; 
            appliesToDecisionTable[ 0, (int)RequireAppliesToStatus.Required ] = AppliesToBehaviorDecision.SendCustomAppliesTo;
            appliesToDecisionTable[ 1, (int)RequireAppliesToStatus.Required ] = AppliesToBehaviorDecision.SendRPAppliesTo;
        }
 
        //
        // Summary: 
        // Finds out if AppliesTo will be sent in the RST and in what format 
        //
        // Parameters: 
        // policy - Pointer to the incoming policy.
        // requireAppliesTo - The requireAppliesTo value on the card
        // considerUnrecognizedElements - Specifies whether to treat the existence of unrecognized elements in policy
        // as the same as having an AppliesTo element specified.  This is done for privacy purposes. 
        //
        // Returns the expected behavior of AppliesTo in the RST 
        // 
        private static AppliesToBehaviorDecision GetAppliesToBehaviorDecision( InfoCardPolicy policy, RequireAppliesToStatus requireAppliesTo, bool considerUnrecognizedElements )
        { 
            int policyHasAppliesTo = null == policy.PolicyAppliesTo ? 0 : 1;

            if( considerUnrecognizedElements )
            { 
                //
                // having unknown elements is equivalent to having applies to in policy. 
                // See "CSD Dev Framework' bug 9248. 
                //
                /* SSS_WARNINGS_OFF */ policyHasAppliesTo = policy.NonWhiteListElementsFound ? 1 : policyHasAppliesTo; /* SSS_WARNINGS_ON */ 
            }

            return appliesToDecisionTable[ policyHasAppliesTo, (int)requireAppliesTo ];
        } 

        // 
        // Summary: 
        // Finds out if AppliesTo will be sent in the RST and in what format
        // 
        // Parameters:
        // policy - Pointer to the incoming policy.
        // requireAppliesTo - The requireAppliesTo value on the card
        // 
        // Returns the expected behavior of AppliesTo in the RST
        // 
        public static AppliesToBehaviorDecision GetAppliesToBehaviorDecisionForRst( InfoCardPolicy policy, RequireAppliesToStatus requireAppliesTo ) 
        {
            return GetAppliesToBehaviorDecision( policy, requireAppliesTo, false ); 
        }

        //
        // Summary: 
        // Finds out if AppliesTo will be sent in the RST and in what format
        // 
        // Parameters: 
        // policy - Pointer to the incoming policy.
        // requireAppliesTo - The requireAppliesTo value on the card 
        //
        // Returns the expected behavior of AppliesTo in the RST
        //
        public static AppliesToBehaviorDecision GetAppliesToBehaviorDecisionForPolicyMatch( InfoCardPolicy policy, RequireAppliesToStatus requireAppliesTo ) 
        {
            return GetAppliesToBehaviorDecision( policy, requireAppliesTo, true ); 
        } 

 

    }

} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK