コード例 #1
0
ファイル: Bundler.cs プロジェクト: DM-TOR/nhin-d
        /// <summary>
        /// Create a signed trust bundle.
        /// </summary>
        /// <param name="bundleResources">Provide a <see cref="IResourceProvider"/> to load anchors and storage destination.</param>
        /// <param name="signProvider">Provide a <see cref="ISignProvider"/> to sign the trust bundle</param>
        public byte[] Create(IResourceProvider bundleResources, ISignProvider signProvider)
        {
            byte[] p7Bdata = Create(bundleResources);
            byte[] p7MData = signProvider.Sign(p7Bdata);

            return p7MData;
        }
コード例 #2
0
ファイル: Bundler.cs プロジェクト: blinds52/nhind
        /// <summary>
        /// Create a signed trust bundle.
        /// </summary>
        /// <param name="bundleResources">Provide a <see cref="IResourceProvider"/> to load anchors and storage destination.</param>
        /// <param name="signProvider">Provide a <see cref="ISignProvider"/> to sign the trust bundle</param>
        public byte[] Create(IResourceProvider bundleResources, ISignProvider signProvider)
        {
            byte[] p7Bdata = Create(bundleResources);
            byte[] p7MData = signProvider.Sign(p7Bdata);

            return(p7MData);
        }
        private Mock <Func <string, ISignProvider> > CreateMockSignProviderFactory(ISignProvider signProvider)
        {
            var providerFactory = new Mock <Func <string, ISignProvider> >();

            providerFactory.Setup(x => x(It.IsAny <string>())).Returns(signProvider);

            return(providerFactory);
        }
コード例 #4
0
        private static void SetSignProvider(OAuthRequestContext context)
        {
            ISignProvider signingProvider = SignProviders.GetProvider(context.Parameters.SignatureMethod);

            if (signingProvider == null)
            {
                // There is no signing provider for this signature method
                throw new OAuthRequestException(null, OAuthProblemTypes.SignatureMethodRejected);
            }

            // Double check the signing provider declares that it can handle the signature method
            if (!signingProvider.SignatureMethod.Equals(context.Parameters.SignatureMethod))
            {
                throw new OAuthRequestException(null, OAuthProblemTypes.SignatureMethodRejected);
            }

            context.SignProvider = signingProvider;
        }
コード例 #5
0
        private void SignParameters(Uri requestUri, string httpMethod, OAuthParameters authParameters, IToken token)
        {
            // Check there is a signing provider for the signature method
            ISignProvider signingProvider = context.GetSignProvider(Service.SignatureMethod);

            if (signingProvider == null)
            {
                // There is no signing provider for this signature method
                throw new OAuthRequestException(null, OAuthProblemTypes.SignatureMethodRejected);
            }

            // Double check the signing provider declares that it can handle the signature method
            if (!signingProvider.SignatureMethod.Equals(Service.SignatureMethod))
            {
                throw new OAuthRequestException(null, OAuthProblemTypes.SignatureMethodRejected);
            }

            // Compute the signature
            authParameters.Sign(requestUri, httpMethod, Service.Consumer, token, signingProvider);
        }
コード例 #6
0
ファイル: Url.cs プロジェクト: ejlevin1/CloudinaryDotNet
 public Url(string cloudName, ISignProvider signProvider)
     : this(cloudName)
 {
     m_signProvider = signProvider;
 }
コード例 #7
0
ファイル: Url.cs プロジェクト: saiber/CloudinarySolution
 public Url(string cloudName, ISignProvider signProvider)
     : this(cloudName)
 {
     m_signProvider = signProvider;
 }
コード例 #8
0
ファイル: Bundler.cs プロジェクト: blinds52/nhind
 /// <summary>
 /// Create a signed trust bundle.
 /// </summary>
 /// <param name="p7Bdata">Cms data structure</param>
 /// <param name="signProvider">Provide a <see cref="ISignProvider"/> to sign the trust bundle</param>
 public byte[] Sign(byte[] p7Bdata, ISignProvider signProvider)
 {
     byte[] p7MData = signProvider.Sign(p7Bdata);
     return(p7MData);
 }
コード例 #9
0
        public void Sign(Uri requestUri, string httpMethod, IConsumer consumer, IToken token, ISignProvider signingProvider)
        {
            if (token != null)
            {
                Token = token.Token;
            }

            OAuthParameters signingParameters = Clone();
            var             signingUri        = new UriBuilder(requestUri);

            // Normalize the request uri for signing
            if (!string.IsNullOrEmpty(requestUri.Query))
            {
                // TODO: Will the parameters necessarily be Rfc3698 encoded here? If not, then Rfc3968.SplitAndDecode will throw FormatException
                signingParameters.AdditionalParameters.Add(Rfc3986.SplitAndDecode(requestUri.Query.Substring(1)));
                signingUri.Query = null;
            }

            if (signingProvider == null)
            {
                // There is no signing provider for this signature method
                throw new OAuthRequestException(null, OAuthProblemTypes.SignatureMethodRejected);
            }

            // Compute the signature
            Signature = signingProvider.ComputeSignature(
                Security.Signature.Create(httpMethod, signingUri.Uri, signingParameters), consumer.Secret,
                (token != null && token.Secret != null) ? token.Secret : null);
        }
コード例 #10
0
ファイル: Bundler.cs プロジェクト: DM-TOR/nhin-d
 /// <summary>
 /// Create a signed trust bundle.
 /// </summary>
 /// <param name="p7Bdata">Cms data structure</param>
 /// <param name="signProvider">Provide a <see cref="ISignProvider"/> to sign the trust bundle</param>
 public byte[] Sign(byte[] p7Bdata, ISignProvider signProvider)
 {
     byte[] p7MData = signProvider.Sign(p7Bdata);
     return p7MData;
 }
コード例 #11
0
        public void Sign(Uri requestUri, string httpMethod, IConsumer consumer, IToken token, ISignProvider signingProvider)
        {
            if (token != null)
                Token = token.Token;

            OAuthParameters signingParameters = Clone();
            var signingUri = new UriBuilder(requestUri);

            // Normalize the request uri for signing
            if (!string.IsNullOrEmpty(requestUri.Query)) {
                // TODO: Will the parameters necessarily be Rfc3698 encoded here? If not, then Rfc3968.SplitAndDecode will throw FormatException
                signingParameters.AdditionalParameters.Add(Rfc3986.SplitAndDecode(requestUri.Query.Substring(1)));
                signingUri.Query = null;
            }

            if (signingProvider == null)
                // There is no signing provider for this signature method
                throw new OAuthRequestException(null, OAuthProblemTypes.SignatureMethodRejected);

            // Compute the signature
            Signature = signingProvider.ComputeSignature(
                Security.Signature.Create(httpMethod, signingUri.Uri, signingParameters), consumer.Secret,
                (token != null && token.Secret != null) ? token.Secret : null);
        }