MessagePartProtectionMode.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.Security
  5. {
  6. enum MessagePartProtectionMode
  7. {
  8. None,
  9. Sign,
  10. Encrypt,
  11. SignThenEncrypt,
  12. EncryptThenSign,
  13. }
  14. static class MessagePartProtectionModeHelper
  15. {
  16. public static MessagePartProtectionMode GetProtectionMode(bool sign, bool encrypt, bool signThenEncrypt)
  17. {
  18. if (sign)
  19. {
  20. if (encrypt)
  21. {
  22. if (signThenEncrypt)
  23. {
  24. return MessagePartProtectionMode.SignThenEncrypt;
  25. }
  26. else
  27. {
  28. return MessagePartProtectionMode.EncryptThenSign;
  29. }
  30. }
  31. else
  32. {
  33. return MessagePartProtectionMode.Sign;
  34. }
  35. }
  36. else if (encrypt)
  37. {
  38. return MessagePartProtectionMode.Encrypt;
  39. }
  40. else
  41. {
  42. return MessagePartProtectionMode.None;
  43. }
  44. }
  45. }
  46. }