/// <summary>
 /// Initializes a new instance of the <see cref="OAuthAccessTokenSettings"/> class.
 /// </summary>
 /// <param name="url">The URL of the Jira instance to request to.</param>
 /// <param name="consumerKey">The consumer key provided by the Jira application link.</param>
 /// <param name="consumerSecret">The consumer private key in XML format.</param>
 /// <param name="oAuthRequestToken">The OAuth request token generated by Jira.</param>
 /// <param name="oAuthTokenSecret">The OAuth token secret generated by Jira.</param>
 /// <param name="signatureMethod">The signature method used to sign the request.</param>
 /// <param name="accessTokenUrl">The relative URL to request the access token to Jira.</param>
 public OAuthAccessTokenSettings(
     string url,
     string consumerKey,
     string consumerSecret,
     string oAuthRequestToken,
     string oAuthTokenSecret,
     JiraOAuthSignatureMethod signatureMethod = JiraOAuthSignatureMethod.RsaSha1,
     string accessTokenUrl = DefaultAccessTokenUrl)
 {
     Url               = url;
     ConsumerKey       = consumerKey;
     ConsumerSecret    = consumerSecret;
     OAuthRequestToken = oAuthRequestToken;
     OAuthTokenSecret  = oAuthTokenSecret;
     SignatureMethod   = signatureMethod;
     AccessTokenUrl    = accessTokenUrl;
 }
Example #2
0
 /// <summary>
 /// Creates a Request token settings to generate a request token.
 /// </summary>
 /// <param name="url">The URL of the Jira instance to request to.</param>
 /// <param name="consumerKey">The consumer key provided by the Jira application link.</param>
 /// <param name="consumerSecret">The consumer private key in XML format.</param>
 /// <param name="callbackUrl">The callback url for the request token.</param>
 /// <param name="signatureMethod">The signature method used to sign the request.</param>
 /// <param name="requestTokenUrl">The relative URL to request the token.</param>
 /// <param name="authorizeUrl">The relative URL to authorize the token.</param>
 public OAuthRequestTokenSettings(
     string url,
     string consumerKey,
     string consumerSecret,
     string callbackUrl = null,
     JiraOAuthSignatureMethod signatureMethod = JiraOAuthSignatureMethod.RsaSha1,
     string requestTokenUrl = DefaultRequestTokenUrl,
     string authorizeUrl    = DefaultAuthorizeUrl)
 {
     Url             = url;
     ConsumerKey     = consumerKey;
     ConsumerSecret  = consumerSecret;
     CallbackUrl     = callbackUrl;
     SignatureMethod = signatureMethod;
     RequestTokenUrl = requestTokenUrl;
     AuthorizeUrl    = authorizeUrl;
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JiraOAuthRestClient"/> class.
 /// </summary>
 /// <param name="url">The url of the Jira instance to request to.</param>
 /// <param name="consumerKey">The consumer key provided by the Jira application link.</param>
 /// <param name="consumerSecret">The consumer private key in XML format.</param>
 /// <param name="oAuthAccessToken">The OAuth access token obtained from Jira.</param>
 /// <param name="oAuthTokenSecret">The OAuth token secret generated by Jira.</param>
 /// <param name="oAuthSignatureMethod">The signature method used to sign the request.</param>
 /// <param name="settings">The settings used to configure the rest client.</param>
 public JiraOAuthRestClient(
     string url,
     string consumerKey,
     string consumerSecret,
     string oAuthAccessToken,
     string oAuthTokenSecret,
     JiraOAuthSignatureMethod oAuthSignatureMethod = JiraOAuthSignatureMethod.RsaSha1,
     JiraRestClientSettings settings = null)
     : base(
         url,
         OAuth1Authenticator.ForProtectedResource(
             consumerKey,
             consumerSecret,
             oAuthAccessToken,
             oAuthTokenSecret,
             oAuthSignatureMethod.ToOAuthSignatureMethod()),
         settings)
 {
 }
        /// <summary>
        /// Converts to <see cref="OAuthSignatureMethod"/>.
        /// </summary>
        /// <param name="signatureMethod">The signature method.</param>
        /// <returns>The RestSharp signature method.</returns>
        public static OAuthSignatureMethod ToOAuthSignatureMethod(this JiraOAuthSignatureMethod signatureMethod)
        {
            switch (signatureMethod)
            {
            case JiraOAuthSignatureMethod.HmacSha1:
                return(OAuthSignatureMethod.HmacSha1);

            case JiraOAuthSignatureMethod.HmacSha256:
                return(OAuthSignatureMethod.HmacSha256);

            case JiraOAuthSignatureMethod.PlainText:
                return(OAuthSignatureMethod.PlainText);

            case JiraOAuthSignatureMethod.RsaSha1:
                return(OAuthSignatureMethod.RsaSha1);

            default:
                return(OAuthSignatureMethod.RsaSha1);
            }
        }
Example #5
0
        /// <summary>
        /// Creates a JIRA rest client using OAuth authentication protocol.
        /// </summary>
        /// <param name="url">Url to the JIRA server.</param>
        /// <param name="consumerKey">The consumer key provided by the Jira application link.</param>
        /// <param name="consumerSecret">The consumer public key in XML format.</param>
        /// <param name="oAuthAccessToken">The access token provided by Jira after the request token has been authorize.</param>
        /// <param name="oAuthTokenSecret">The token secret provided by Jira when asking for a request token.</param>
        /// <param name="oAuthSignatureMethod">The signature method used to generate the request token.</param>
        /// <param name="settings">Settings to configure the rest client.</param>
        /// <returns>Jira object configured to use REST API.</returns>
        public static Jira CreateOAuthRestClient(
            string url,
            string consumerKey,
            string consumerSecret,
            string oAuthAccessToken,
            string oAuthTokenSecret,
            JiraOAuthSignatureMethod oAuthSignatureMethod = JiraOAuthSignatureMethod.RsaSha1,
            JiraRestClientSettings settings = null)
        {
            settings = settings ?? new JiraRestClientSettings();
            var restClient = new JiraOAuthRestClient(
                url,
                consumerKey,
                consumerSecret,
                oAuthAccessToken,
                oAuthTokenSecret,
                oAuthSignatureMethod,
                settings);

            return(CreateRestClient(restClient));
        }