ServiceSignature.cs 1018 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (C) Alibaba Cloud Computing
  3. * All rights reserved.
  4. *
  5. * 版权所有 (C)阿里云计算有限公司
  6. */
  7. using System;
  8. using Aliyun.OSS.Properties;
  9. namespace Aliyun.OSS.Common.Authentication
  10. {
  11. internal abstract class ServiceSignature
  12. {
  13. public abstract string SignatureMethod { get; }
  14. public abstract string SignatureVersion { get; }
  15. public string ComputeSignature(String key, String data)
  16. {
  17. if (string.IsNullOrEmpty(key))
  18. throw new ArgumentException(Resources.ExceptionIfArgumentStringIsNullOrEmpty, "key");
  19. if (string.IsNullOrEmpty(data))
  20. throw new ArgumentException(Resources.ExceptionIfArgumentStringIsNullOrEmpty, "data");
  21. return ComputeSignatureCore(key, data);
  22. }
  23. protected abstract string ComputeSignatureCore(string key, string data);
  24. public static ServiceSignature Create()
  25. {
  26. return new HmacSha1Signature();
  27. }
  28. }
  29. }