public static OpenBankingClientRegistrationClaims CreateRegistrationClaims( string issuerUrl, SoftwareStatementProfile sProfile, bool concatScopes) { sProfile.ArgNotNull(nameof(sProfile)); OpenBankingClientRegistrationClaims registrationClaims = new OpenBankingClientRegistrationClaims { Iss = sProfile.SoftwareStatementPayload.SoftwareId, Aud = issuerUrl, RedirectUris = sProfile.SoftwareStatementPayload.SoftwareRedirectUris, SoftwareId = sProfile.SoftwareStatementPayload.SoftwareId, Scope = sProfile.SoftwareStatementPayload.Scope, /* Scope = concatScopes * ? new[] { sProfile.SoftwareStatementPayload.Scope } * : sProfile.SoftwareStatementPayload.Scope.Split(' ', StringSplitOptions.RemoveEmptyEntries), */ SoftwareStatement = sProfile.SoftwareStatement, TlsClientAuthSubjectDn = $"CN={sProfile.SoftwareStatementPayload.SoftwareId},OU={sProfile.SoftwareStatementPayload.OrgId},O=OpenBanking,C=GB" }; return(registrationClaims); }
public static SoftwareStatementProfileContext Data( this SoftwareStatementProfileContext context, SoftwareStatementProfile value) { context.ArgNotNull(nameof(context)); value.ArgNotNull(nameof(value)); context.Data = value; return(context); }
public void SetSoftwareStatementProfile(SoftwareStatementProfile profile) { profile.ArgNotNull(nameof(profile)); Models.Persistent.SoftwareStatementProfile value = _mapper.Map <Models.Persistent.SoftwareStatementProfile>(profile); value.State = "ok"; string[] softwareStatementComponentsBase64 = profile.SoftwareStatement.Split(new[] { '.' }); if (softwareStatementComponentsBase64.Length != 3) { throw new ArgumentException("softwareStatementComponentsBase64 needs 3 components."); } value.SoftwareStatementHeaderBase64 = softwareStatementComponentsBase64[0]; value.SoftwareStatementPayloadBase64 = softwareStatementComponentsBase64[1]; value.SoftwareStatementPayload = value.SoftwareStatementPayloadFromBase64(softwareStatementComponentsBase64[1]); value.SoftwwareStatementSignatureBase64 = softwareStatementComponentsBase64[2]; _defaultSoftwareStatementProfile = value; }
public string CreateJwt <TClaims>( SoftwareStatementProfile profile, TClaims claims, bool useOpenBankingJwtHeaders) where TClaims : class { profile.ArgNotNull(nameof(profile)); claims.ArgNotNull(nameof(claims)); Dictionary <string, object> headers = useOpenBankingJwtHeaders ? CreateOpenBankingJwtHeaders( signingId: profile.SigningKeyId, orgId: profile.SoftwareStatementPayload.OrgId, softwareId: profile.SoftwareStatementPayload.SoftwareId) : CreateJwtHeaders(profile.SigningKeyId); string payloadJson = JsonConvert.SerializeObject( value: claims, settings: new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); X509Certificate2 privateKey = CertificateFactories.GetCertificate2FromPem( privateKey: profile.SigningKey, pem: profile.SigningCertificate); RSA privateKeyRsa = privateKey.GetRSAPrivateKey(); string result = JWT.Encode( payload: payloadJson, key: privateKeyRsa, algorithm: JwsAlgorithm.PS256, extraHeaders: headers); return(result); }