-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from claboran/feature/Net60
Feature/net60
- Loading branch information
Showing
32 changed files
with
801 additions
and
695 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file added
BIN
+5.86 KB
.vs/ForceDotNetJwtCompanion/FileContentIndex/24d434d3-b16e-4230-8196-e9e853eac919.vsidx
Binary file not shown.
Binary file added
BIN
+214 KB
.vs/ForceDotNetJwtCompanion/FileContentIndex/3af0476b-5fc7-4a62-8b59-7030693c4462.vsidx
Binary file not shown.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,4 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=b06ee029_002D60e0_002D49ea_002D8edd_002Dc60a53227d03/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" Name="Authenticate_WithUnencryptedKey_Success" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> | ||
<TestAncestor> | ||
<TestId>xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.Tests.AuthenticationClientTests.Authenticate_WithUnencryptedKey_Success</TestId> | ||
</TestAncestor> | ||
</SessionState></s:String> | ||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=b0ef948d_002Db53c_002D45dd_002Da72c_002Dde125cf79071/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="ReadKeyFile" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> | ||
<Or> | ||
<TestAncestor> | ||
<TestId>xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.KeyHelperTests</TestId> | ||
<TestId>xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.JwtTests.JwtPayloadTest</TestId> | ||
<TestId>xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.JwtTests.CreateExpTimeAsStringTest</TestId> | ||
<TestId>xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.JwtTests.JwtPayloadToBase64Test</TestId> | ||
<TestId>xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.JwtTests</TestId> | ||
<TestId>xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.Tests.ValidatorsTests</TestId> | ||
</TestAncestor> | ||
<ProjectFolder>2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96/d:Tests</ProjectFolder> | ||
</Or> | ||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=e39ae419_002D0ef4_002D4086_002D8fda_002Debf0bcde3426/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
 | ||
<Solution />
 | ||
</SessionState></s:String></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
using System; | ||
using System.Net; | ||
|
||
namespace ForceDotNetJwtCompanion | ||
namespace ForceDotNetJwtCompanion; | ||
|
||
public class ForceAuthenticationException : Exception | ||
{ | ||
public class ForceAuthenticationException : Exception | ||
{ | ||
public HttpStatusCode HttpStatusCode { get; } | ||
public HttpStatusCode HttpStatusCode { get; } | ||
|
||
public ForceAuthenticationException(HttpStatusCode statusCode, string description) : base(description) | ||
{ | ||
HttpStatusCode = statusCode; | ||
} | ||
public ForceAuthenticationException(HttpStatusCode statusCode, string description) : base(description) | ||
{ | ||
HttpStatusCode = statusCode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace ForceDotNetJwtCompanion; | ||
|
||
/// <summary> | ||
/// IJwtAuthenticationClient | ||
/// | ||
/// HTTP handling and orchestration of JWT OAuth Flow with Salesforce. | ||
/// | ||
/// </summary> | ||
public interface IJwtAuthenticationClient : IDisposable | ||
{ | ||
string InstanceUrl { get; set; } | ||
string AccessToken { get; set; } | ||
string Id { get; set; } | ||
string ApiVersion { get; set; } | ||
|
||
/// <summary> | ||
/// JwtUnencryptedPrivateKeyAsync | ||
/// | ||
/// Obtain access token with unencrypted private key (not recommended) | ||
/// Token Endpoint: https://login.salesforce.com/services/oauth2/token (production) | ||
/// </summary> | ||
/// <param name="clientId">ClientId of the Connected App aka Consumer Key</param> | ||
/// <param name="key">Private key as string, it is not required to remove header and footer</param> | ||
/// <param name="username">Salesforce username</param> | ||
Task JwtUnencryptedPrivateKeyAsync(string clientId, string key, string username); | ||
|
||
/// <summary> | ||
/// JwtPrivateKeyAsync | ||
/// | ||
/// Obtain access token with encrypted private key | ||
/// Token Endpoint: https://login.salesforce.com/services/oauth2/token (production) | ||
/// </summary> | ||
/// <param name="clientId">ClientId of the Connected App aka Consumer Key</param> | ||
/// <param name="key">Private key as string, it is not required to remove header and footer</param> | ||
/// <param name="passphrase">Passphrase of the private key</param> | ||
/// <param name="username">Salesforce username</param> | ||
Task JwtPrivateKeyAsync(string clientId, string key, string passphrase, string username); | ||
|
||
/// <summary> | ||
/// JwtUnencryptedPrivateKeyAsync | ||
/// | ||
/// Obtain access token with unencrypted private key (not recommended) | ||
/// with token endpoint | ||
/// </summary> | ||
/// <param name="clientId">ClientId of the Connected App aka Consumer Key</param> | ||
/// <param name="key">Private key as string, it is not required to remove header and footer</param> | ||
/// <param name="username">Salesforce username</param> | ||
/// <param name="tokenEndpoint">TokenEndpointUrl e.g. https://test.salesforce.com/services/oauth2/token</param> | ||
Task JwtUnencryptedPrivateKeyAsync(string clientId, string key, string username, string tokenEndpoint); | ||
|
||
/// <summary> | ||
/// JwtPrivateKeyAsync | ||
/// | ||
/// Obtain access token with encrypted private key | ||
/// with token endpoint | ||
/// </summary> | ||
/// <param name="clientId">ClientId of the Connected App aka Consumer Key</param> | ||
/// <param name="key">Private key as string, it is not required to remove header and footer</param> | ||
/// <param name="passphrase">Passphrase of the private key</param> | ||
/// <param name="username">Salesforce username</param> | ||
/// <param name="tokenEndpoint">TokenEndpointUrl e.g. https://test.salesforce.com/services/oauth2/token</param> | ||
Task JwtPrivateKeyAsync(string clientId, string key, string passphrase, string username, string tokenEndpoint); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
using System; | ||
|
||
namespace ForceDotNetJwtCompanion.Jwt | ||
namespace ForceDotNetJwtCompanion.Jwt; | ||
|
||
/// <summary> | ||
/// JwtHelpers | ||
/// | ||
/// Helper functions for JWT creation | ||
/// | ||
/// </summary> | ||
public static class JwtHelpers | ||
{ | ||
/// <summary> | ||
/// JwtHelpers | ||
/// | ||
/// Helper functions for JWT creation | ||
/// CreateExpTimeAsString | ||
/// Converts timestamp with TTL = 3 minutes | ||
/// You should use UTC time | ||
/// | ||
/// <see>https://help.salesforce.com/articleView?id=remoteaccess_oauth_jwt_flow.htm&type=5</see> | ||
/// | ||
/// </summary> | ||
public static class JwtHelpers | ||
{ | ||
/// <summary> | ||
/// CreateExpTimeAsString | ||
/// Converts timestamp with TTL = 3 minutes | ||
/// You should use UTC time | ||
/// | ||
/// <see>https://help.salesforce.com/articleView?id=remoteaccess_oauth_jwt_flow.htm&type=5</see> | ||
/// | ||
/// </summary> | ||
/// <param name="now"></param> | ||
/// <returns>epoc as string (seconds since 01.01.1970)</returns> | ||
public static string CreateExpTimeAsString(DateTime now) => | ||
new DateTimeOffset(now.AddMinutes(3)) | ||
.ToUnixTimeSeconds() | ||
.ToString(); | ||
} | ||
/// <param name="now"></param> | ||
/// <returns>epoc as string (seconds since 01.01.1970)</returns> | ||
public static string CreateExpTimeAsString(DateTime now) => | ||
new DateTimeOffset(now.AddMinutes(3)) | ||
.ToUnixTimeSeconds() | ||
.ToString(); | ||
} |
Oops, something went wrong.