Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public AdvancedIdentityShareController(ILogger<AdvancedIdentityShareController>
_clientSdkId = Environment.GetEnvironmentVariable("YOTI_CLIENT_SDK_ID");
_logger.LogInformation(string.Format("Yoti Client SDK ID='{0}'", _clientSdkId));
}

// GET: /advanced-identity-share
[Route("advanced-identity-share")]
public IActionResult DigitalIdentity()
Expand All @@ -36,7 +36,7 @@ public IActionResult DigitalIdentity()
StreamReader privateKeyStream = System.IO.File.OpenText(yotiKeyFilePath);

var yotiClient = new DigitalIdentityClient(_clientSdkId, privateKeyStream);

string advancedIdentityProfileJson = @"
{
""profiles"": [
Expand All @@ -60,9 +60,9 @@ public IActionResult DigitalIdentity()
]

}";

var advancedIdentityProfile = JsonConvert.DeserializeObject<AdvancedIdentityProfile>(advancedIdentityProfileJson);

var policy = new PolicyBuilder()
.WithAdvancedIdentityProfileRequirements(advancedIdentityProfile)
.Build();
Expand All @@ -85,10 +85,10 @@ public IActionResult DigitalIdentity()
exception: e,
message: e.Message);

TempData["Error"] = e.Message;
TempData["Error"] = e.Message;
TempData["InnerException"] = e.InnerException?.Message;
return RedirectToAction("Error", "Success");
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public HomeController(ILogger<HomeController> logger)
_clientSdkId = Environment.GetEnvironmentVariable("YOTI_CLIENT_SDK_ID");
_logger.LogInformation(string.Format("Yoti Client SDK ID='{0}'", _clientSdkId));
}

// GET: /generate-share
[Route("generate-share")]
public IActionResult DigitalIdentity()
Expand All @@ -40,13 +40,13 @@ public IActionResult DigitalIdentity()
.WithName("given_names")
.WithOptional(false)
.Build();

var notification = new NotificationBuilder()
.WithUrl("https://example.com/webhook")
.WithMethod("POST")
.WithVerifyTls(true)
.Build();

var policy = new PolicyBuilder()
.WithWantedAttribute(givenNamesWantedAttribute)
.WithFullName()
Expand All @@ -57,7 +57,7 @@ public IActionResult DigitalIdentity()
.WithNationality()
.WithGender()
.WithDocumentDetails()
.WithDocumentImages()
.WithDocumentImages()
.Build();

var sessionReq = new ShareSessionRequestBuilder().WithPolicy(policy)
Expand All @@ -81,10 +81,10 @@ public IActionResult DigitalIdentity()
exception: e,
message: e.Message);

TempData["Error"] = e.Message;
TempData["Error"] = e.Message;
TempData["InnerException"] = e.InnerException?.Message;
return RedirectToAction("Error", "Success");
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public IActionResult ReceiptInfo(string ReceiptID)
StreamReader privateKeyStream = System.IO.File.OpenText(yotiKeyFilePath);

var yotiClient = new DigitalIdentityClient(_clientSdkId, privateKeyStream);

var ReceiptResult = yotiClient.GetShareReceipt(ReceiptID);

DisplayAttributes displayAttributes = CreateDisplayAttributes(ReceiptResult.UserContent.UserProfile.AttributeCollection);
if (ReceiptResult.UserContent.UserProfile.FullName != null)
{
Expand All @@ -58,7 +58,7 @@ public IActionResult ReceiptInfo(string ReceiptID)
displayAttributes.Base64Selfie = selfie.GetValue().GetBase64URI();
}
ViewBag.YotiClientSdkId = _clientSdkId;

return View("SuccessResult", displayAttributes);
}
catch (Exception e)
Expand All @@ -72,7 +72,7 @@ public IActionResult ReceiptInfo(string ReceiptID)
return RedirectToAction("Error", "Success");
}
}

private static DisplayAttributes CreateDisplayAttributes(ReadOnlyCollection<BaseAttribute> attributes)
{
var displayAttributes = new DisplayAttributes();
Expand Down Expand Up @@ -159,5 +159,5 @@ private static void AddDisplayAttribute<T>(string name, string icon, BaseAttribu
if (baseAttribute is YotiAttribute<T> yotiAttribute)
displayAttributes.Add(name, icon, yotiAttribute.GetAnchors(), yotiAttribute.GetValue());
}
}
}
}
2 changes: 1 addition & 1 deletion src/Examples/DigitalIdentity/DigitalIdentity/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void ConfigureServices(IServiceCollection services)
options.Cookie.IsEssential = true;
});
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using Yoti.Auth.DocScan.Session.Create.Filter;
using Yoti.Auth.DocScan.Session.Create.Objectives;
using Yoti.Auth.DocScan.Session.Create.Task;

namespace DocScanExample.Controllers
{
public class DbsController : Controller
Expand All @@ -26,7 +26,7 @@ public class DbsController : Controller
public DbsController(IHttpContextAccessor httpContextAccessor)
{
var request = httpContextAccessor.HttpContext.Request;

_baseUrl = $"{request.Scheme}://{request.Host}"; ;
_apiUrl = GetApiUrl();
_client = GetDocScanClient(_apiUrl);
Expand Down Expand Up @@ -92,12 +92,12 @@ public IActionResult Index()
.WithSubject(new
{
subject_id = "some_subject_id_string"
})
})
.Build();

CreateSessionResult createSessionResult = _client.CreateSession(sessionSpec);
string sessionId = createSessionResult.SessionId;

string path = $"web/index.html?sessionID={sessionId}&sessionToken={createSessionResult.ClientSessionToken}";
Uri uri = new Uri(_apiUrl, path);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using Yoti.Auth.DocScan.Session.Create.Filter;
using Yoti.Auth.DocScan.Session.Create.Objectives;
using Yoti.Auth.DocScan.Session.Create.Task;

namespace DocScanExample.Controllers
{
public class HomeController : Controller
Expand All @@ -26,7 +26,7 @@ public class HomeController : Controller
public HomeController(IHttpContextAccessor httpContextAccessor)
{
var request = httpContextAccessor.HttpContext.Request;

_baseUrl = $"{request.Scheme}://{request.Host}"; ;
_apiUrl = GetApiUrl();
_client = GetDocScanClient(_apiUrl);
Expand Down Expand Up @@ -126,16 +126,16 @@ public IActionResult Index()
.Build()
)
.WithRequiredDocument(
new RequiredSupplementaryDocumentBuilder()
new RequiredSupplementaryDocumentBuilder()
.WithObjective(
new ProofOfAddressObjectiveBuilder().Build())
.Build()
)
)
.Build();

CreateSessionResult createSessionResult = _client.CreateSession(sessionSpec);
string sessionId = createSessionResult.SessionId;

string path = $"web/index.html?sessionID={sessionId}&sessionToken={createSessionResult.ClientSessionToken}";
Uri uri = new Uri(_apiUrl, path);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using Yoti.Auth.DocScan.Session.Create.Filter;
using Yoti.Auth.DocScan.Session.Create.Objectives;
using Yoti.Auth.DocScan.Session.Create.Task;

namespace DocScanExample.Controllers
{
public class IdentityProfileController : Controller
Expand Down Expand Up @@ -98,7 +98,7 @@ public IActionResult Index()

CreateSessionResult createSessionResult = _client.CreateSession(sessionSpec);
string sessionId = createSessionResult.SessionId;

string path = $"web/index.html?sessionID={sessionId}&sessionToken={createSessionResult.ClientSessionToken}";
Uri uri = new Uri(_apiUrl, path);

Expand Down
48 changes: 24 additions & 24 deletions src/Examples/DocScan/DocScanExample/Models/DisplayHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@

namespace DocScanExample.Models
{
public static class DisplayHelper
public static class DisplayHelper
{
public static string GetSummaryResponseKindText(ReportResponseWithSummary advancedReport)
{
var searchConfigType = advancedReport.WatchlistSummary.SearchConfig.GetType();
if (searchConfigType == typeof(WatchlistAdvancedCaSearchConfigResponseYotiAccount))
{
return "Yoti Account";
}
if (searchConfigType == typeof(WatchlistAdvancedCaSearchConfigResponseCustomAccount))
{
return "Custom Account";
}
if (searchConfigType == typeof(WatchlistScreeningConfig))
{
return "Watchlist Screening";
}
return "N/A";
}
public static string GetPrettifiedWatchlistSearchConfig(ReportResponseWithSummary advancedReport)
{
var json = JsonConvert.SerializeObject(advancedReport.WatchlistSummary.SearchConfig);
return JValue.Parse(json).ToString(Formatting.Indented);
}
}
public static string GetSummaryResponseKindText(ReportResponseWithSummary advancedReport)
{
var searchConfigType = advancedReport.WatchlistSummary.SearchConfig.GetType();
if (searchConfigType == typeof(WatchlistAdvancedCaSearchConfigResponseYotiAccount))
{
return "Yoti Account";
}
if (searchConfigType == typeof(WatchlistAdvancedCaSearchConfigResponseCustomAccount))
{
return "Custom Account";
}
if (searchConfigType == typeof(WatchlistScreeningConfig))
{
return "Watchlist Screening";
}
return "N/A";
}
public static string GetPrettifiedWatchlistSearchConfig(ReportResponseWithSummary advancedReport)
{
var json = JsonConvert.SerializeObject(advancedReport.WatchlistSummary.SearchConfig);
return JValue.Parse(json).ToString(Formatting.Indented);
}
}
}
16 changes: 8 additions & 8 deletions src/Examples/Profile/CoreExample/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ public IActionResult DBSStandard()

DynamicPolicy dynamicPolicy = new DynamicPolicyBuilder()
.WithIdentityProfileRequirements(new
{
trust_framework = "UK_TFIDA",
scheme = new
{
type = "DBS",
objective = "BASIC"
}
})
{
trust_framework = "UK_TFIDA",
scheme = new
{
type = "DBS",
objective = "BASIC"
}
})
.Build();

var dynamicScenario = new DynamicScenarioBuilder()
Expand Down
14 changes: 7 additions & 7 deletions src/Yoti.Auth/CryptoEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ internal static byte[] DecipherAes(byte[] key, byte[] iv, byte[] cipherBytes)

var result = new byte[numOutputBytes];
Array.Copy(outputBuffer, result, numOutputBytes);

return result;
}

internal static byte[] DecryptRsa(byte[] cipherBytes, AsymmetricCipherKeyPair keypair)
{
// decrypt using rsa with private key and PKCS 1 v1.5 padding
Expand Down Expand Up @@ -133,14 +133,14 @@ internal static string GetAuthKey(AsymmetricCipherKeyPair keyPair)

return Conversion.BytesToBase64(publicKey);
}

public static byte[] DecryptAesGcm(byte[] cipherText, byte[] iv, byte[] secret)
{
try
{
GcmBlockCipher cipher = new GcmBlockCipher(new Org.BouncyCastle.Crypto.Engines.AesEngine());
ParametersWithIV parameters = new ParametersWithIV(new KeyParameter(secret), iv);

cipher.Init(false, parameters);

byte[] plainText = new byte[cipher.GetOutputSize(cipherText.Length)];
Expand All @@ -154,7 +154,7 @@ public static byte[] DecryptAesGcm(byte[] cipherText, byte[] iv, byte[] secret)
throw new Exception($"Failed to decrypt receipt key: {ex.Message}", ex);
}
}

public static byte[] UnwrapReceiptKey(byte[] wrappedReceiptKey, byte[] encryptedItemKey, byte[] itemKeyIv, AsymmetricCipherKeyPair key)
{
try
Expand All @@ -170,7 +170,7 @@ public static byte[] UnwrapReceiptKey(byte[] wrappedReceiptKey, byte[] encrypted
throw new Exception($"Failed to unwrap receipt key: {ex.Message}", ex);
}
}

public static byte[] DecryptReceiptContent(byte[] content, byte[] receiptContentKey)
{
try
Expand All @@ -185,7 +185,7 @@ public static byte[] DecryptReceiptContent(byte[] content, byte[] receiptContent

return DecipherAes(receiptContentKey, decodedData.Iv.ToByteArray(), decodedData.CipherText.ToByteArray());
}
catch(Exception ex)
catch (Exception ex)
{
throw new Exception($"Failed to decrypt receipt content: {ex.Message}", ex);
}
Expand Down
Loading