Skip to content

Commit 2bd3b7d

Browse files
authored
Merge pull request #17 from claboran/feature/Net60
Feature/net60
2 parents c355751 + 5667848 commit 2bd3b7d

32 files changed

+801
-695
lines changed

.idea/.idea.ForceDotNetJwtCompanion/.idea/indexLayout.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.ForceDotNetJwtCompanion/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.

.vs/ForceDotNetJwtCompanion/FileContentIndex/read.lock

Whitespace-only changes.
63.5 KB
Binary file not shown.
Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
<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">
2-
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=b06ee029_002D60e0_002D49ea_002D8edd_002Dc60a53227d03/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="Authenticate_WithUnencryptedKey_Success" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
3-
&lt;TestAncestor&gt;
4-
&lt;TestId&gt;xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.Tests.AuthenticationClientTests.Authenticate_WithUnencryptedKey_Success&lt;/TestId&gt;
5-
&lt;/TestAncestor&gt;
6-
&lt;/SessionState&gt;</s:String>
7-
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=b0ef948d_002Db53c_002D45dd_002Da72c_002Dde125cf79071/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="ReadKeyFile" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
8-
&lt;Or&gt;
9-
&lt;TestAncestor&gt;
10-
&lt;TestId&gt;xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.KeyHelperTests&lt;/TestId&gt;
11-
&lt;TestId&gt;xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.JwtTests.JwtPayloadTest&lt;/TestId&gt;
12-
&lt;TestId&gt;xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.JwtTests.CreateExpTimeAsStringTest&lt;/TestId&gt;
13-
&lt;TestId&gt;xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.JwtTests.JwtPayloadToBase64Test&lt;/TestId&gt;
14-
&lt;TestId&gt;xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.JwtTests&lt;/TestId&gt;
15-
&lt;TestId&gt;xUnit::2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96::net5.0::ForceDotNetJwtCompanionTest.Tests.ValidatorsTests&lt;/TestId&gt;
16-
&lt;/TestAncestor&gt;
17-
&lt;ProjectFolder&gt;2CADC6E3-1FCE-4BF7-A27B-7CE49CFE0F96/d:Tests&lt;/ProjectFolder&gt;
18-
&lt;/Or&gt;
2+
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=e39ae419_002D0ef4_002D4086_002D8fda_002Debf0bcde3426/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
3+
&lt;Solution /&gt;&#xD;
194
&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary>
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
using System;
22
using System.Net;
33

4-
namespace ForceDotNetJwtCompanion
4+
namespace ForceDotNetJwtCompanion;
5+
6+
public class ForceAuthenticationException : Exception
57
{
6-
public class ForceAuthenticationException : Exception
7-
{
8-
public HttpStatusCode HttpStatusCode { get; }
8+
public HttpStatusCode HttpStatusCode { get; }
99

10-
public ForceAuthenticationException(HttpStatusCode statusCode, string description) : base(description)
11-
{
12-
HttpStatusCode = statusCode;
13-
}
10+
public ForceAuthenticationException(HttpStatusCode statusCode, string description) : base(description)
11+
{
12+
HttpStatusCode = statusCode;
1413
}
1514
}

ForceDotNetJwtCompanion/ForceDotNetJwtCompanion.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.1</TargetFramework>
55
<Title>.Net Authorization of an Salesforce Org with OAuth 2.0 JWT Bearer Flow</Title>
6-
<Authors>Christian Laboranowitsch</Authors>
6+
<Authors>Christian Laboranowitsch, Stefan van Raaij</Authors>
77
<PackageProjectUrl>https://github.com/claboran/ForceDotNetJwtCompanion</PackageProjectUrl>
88
<PackageLicenseUrl>https://github.com/claboran/ForceDotNetJwtCompanion/blob/master/LICENSE</PackageLicenseUrl>
99
<RepositoryUrl>https://github.com/claboran/ForceDotNetJwtCompanion.git</RepositoryUrl>
1010
<RepositoryType>git</RepositoryType>
1111
<PackageTags>jwt salesforce .Net</PackageTags>
12-
<PackageVersion>1.0.1</PackageVersion>
12+
<PackageVersion>1.0.3</PackageVersion>
1313
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
14+
<Description>Authenticate a Salesforce Connected App with OAuth2 JWT Bearer Flow</Description>
15+
<LangVersion>10</LangVersion>
16+
<Nullable>enable</Nullable>
17+
<PackageReleaseNotes>update solution januari 2023</PackageReleaseNotes>
1418
</PropertyGroup>
1519

1620
<ItemGroup>
17-
<PackageReference Include="BouncyCastle.NetCore" Version="1.8.8" />
18-
<PackageReference Include="Newtonsoft.Json" Version="[11.0.1,)" />
21+
<PackageReference Include="BouncyCastle.NetCore" Version="1.9.0" />
22+
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
1923
</ItemGroup>
2024

2125
</Project>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
4+
namespace ForceDotNetJwtCompanion;
5+
6+
/// <summary>
7+
/// IJwtAuthenticationClient
8+
///
9+
/// HTTP handling and orchestration of JWT OAuth Flow with Salesforce.
10+
///
11+
/// </summary>
12+
public interface IJwtAuthenticationClient : IDisposable
13+
{
14+
string InstanceUrl { get; set; }
15+
string AccessToken { get; set; }
16+
string Id { get; set; }
17+
string ApiVersion { get; set; }
18+
19+
/// <summary>
20+
/// JwtUnencryptedPrivateKeyAsync
21+
///
22+
/// Obtain access token with unencrypted private key (not recommended)
23+
/// Token Endpoint: https://login.salesforce.com/services/oauth2/token (production)
24+
/// </summary>
25+
/// <param name="clientId">ClientId of the Connected App aka Consumer Key</param>
26+
/// <param name="key">Private key as string, it is not required to remove header and footer</param>
27+
/// <param name="username">Salesforce username</param>
28+
Task JwtUnencryptedPrivateKeyAsync(string clientId, string key, string username);
29+
30+
/// <summary>
31+
/// JwtPrivateKeyAsync
32+
///
33+
/// Obtain access token with encrypted private key
34+
/// Token Endpoint: https://login.salesforce.com/services/oauth2/token (production)
35+
/// </summary>
36+
/// <param name="clientId">ClientId of the Connected App aka Consumer Key</param>
37+
/// <param name="key">Private key as string, it is not required to remove header and footer</param>
38+
/// <param name="passphrase">Passphrase of the private key</param>
39+
/// <param name="username">Salesforce username</param>
40+
Task JwtPrivateKeyAsync(string clientId, string key, string passphrase, string username);
41+
42+
/// <summary>
43+
/// JwtUnencryptedPrivateKeyAsync
44+
///
45+
/// Obtain access token with unencrypted private key (not recommended)
46+
/// with token endpoint
47+
/// </summary>
48+
/// <param name="clientId">ClientId of the Connected App aka Consumer Key</param>
49+
/// <param name="key">Private key as string, it is not required to remove header and footer</param>
50+
/// <param name="username">Salesforce username</param>
51+
/// <param name="tokenEndpoint">TokenEndpointUrl e.g. https://test.salesforce.com/services/oauth2/token</param>
52+
Task JwtUnencryptedPrivateKeyAsync(string clientId, string key, string username, string tokenEndpoint);
53+
54+
/// <summary>
55+
/// JwtPrivateKeyAsync
56+
///
57+
/// Obtain access token with encrypted private key
58+
/// with token endpoint
59+
/// </summary>
60+
/// <param name="clientId">ClientId of the Connected App aka Consumer Key</param>
61+
/// <param name="key">Private key as string, it is not required to remove header and footer</param>
62+
/// <param name="passphrase">Passphrase of the private key</param>
63+
/// <param name="username">Salesforce username</param>
64+
/// <param name="tokenEndpoint">TokenEndpointUrl e.g. https://test.salesforce.com/services/oauth2/token</param>
65+
Task JwtPrivateKeyAsync(string clientId, string key, string passphrase, string username, string tokenEndpoint);
66+
}

0 commit comments

Comments
 (0)