IEEE.org     |     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

Commit 3dd1e1cc authored by Douglas Williams's avatar Douglas Williams
Browse files

Commit for Phase 1 completion

parents
root = true
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = false
indent_style = space
indent_size = 4
max_line_length = 100
[{*.json,.*.yml}]
indent_style = space
indent_size = 2
[Makefile]
indent_style = tab
\ No newline at end of file
# Auto detect text files and perform LF normalization
* text=auto
IdentityServer.db
identityserver4_log.txt
tempkey.rsa
ClrConsumer.db
ClrEditor.db
ClrWallet.db
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio
.vs/
.vscode/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
/ClrProvider/src/keys.rsa
*.db-shm
*.db-wal
*.db
ClrBuilder/src/Packages.json
*.DotSettings
<Project>
<PropertyGroup>
<Configurations>Debug;Dev;Qa;Release</Configurations>
<LangVersion>8.0</LangVersion>
<Authors>IMS Global; Andy Miller; RANDA Development Team; Keith Williams</Authors>
<Version>0.0.1</Version>
</PropertyGroup>
</Project>
\ No newline at end of file
Copyright © 2019 IMS Global Learning Consortium, Inc. All Rights Reserved.
Trademark Information -- http://www.imsglobal.org/copyright.html
This license consists of the Apache 2.0 license, modified to address the type of products that can utilize the software. IMS makes available the Comprehensive Learner Record (CLR) Reference Implementation to IMS Members for the sole purpose of developing end-user products implementing the CLR 1.0 standard with an Apache2 license. The license prohibits re-licensing any of the software as a Comprehensive Learner Record development environment to 3rd parties.
Use of the Reference Implementation and/or code libraries does not signify achievement of IMS conformance certification. The official list of conformance certifications is available at http://www.imscert.org.
Trademarks. This license does not grant you any right in the trademarks, service marks, brand names or logos of IMS Global Learning Consortium, Inc..
DISCLAIMER. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OR CONDITION, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
LICENSORS HEREBY DISCLAIM ALL LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenCredentialPublisher.ClrLibrary.Attributes
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class JsonTypeAttribute: Attribute
{
public string Name { get; set; }
public JsonTypeAttribute(string name)
{
Name = name;
}
}
}
using OpenCredentialPublisher.ClrLibrary.Models;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenCredentialPublisher.ClrLibrary.Binders
{
public class VerifiableCredentialsBinder : ISerializationBinder
{
public IList<Type> KnownTypes { get; set; }
public void BindToName(Type serializedType, out string assemblyName, out string typeName)
{
if (KnownTypes.All(t => t != serializedType))
{
assemblyName = null;
typeName = null;
return;
}
assemblyName = null;
typeName = serializedType.Name;
}
public Type BindToType(string assemblyName, string typeName)
{
if (KnownTypes.All(t => t.Name != typeName))
{
return typeof(object);
}
return KnownTypes.SingleOrDefault(t => t.Name == typeName);
}
public static VerifiableCredentialsBinder GetBinder()
{
var binder = new VerifiableCredentialsBinder
{
KnownTypes = new List<Type>
{
typeof(ICredentialSubject),
typeof(ClrSubject),
typeof(ClrSetSubject)
}
};
return binder;
}
}
}
// ReSharper disable UnusedMember.Global
namespace OpenCredentialPublisher.ClrLibrary
{
public static class ClrConstants
{
public static class JsonLd
{
public static string Context = "https://purl.imsglobal.org/spec/clr/v1p0/context/clr_v1p0.jsonld";
}
public static class MediaTypes
{
public static string JsonMediaType = "application/json";
public static string JsonLdMediaType = "application/ld+json";
}
public static class Scopes
{
public static string Delete = "https://purl.imsglobal.org/spec/clr/v1p0/scope/delete";
public static string Readonly = "https://purl.imsglobal.org/spec/clr/v1p0/scope/readonly";
public static string Replace = "https://purl.imsglobal.org/spec/clr/v1p0/scope/replace";
public static string[] AllScopes =
{
Delete,
Readonly,
Replace
};
}
}
}
using System;
using System.Globalization;
using System.Text.Json;
namespace OpenCredentialPublisher.ClrLibrary.Converters.Json
{
public class DateConverter : System.Text.Json.Serialization.JsonConverter<DateTime>
{
private const string Format = "o";
public override DateTime Read(
ref Utf8JsonReader reader,
Type typeToConvert,
JsonSerializerOptions options) =>
DateTime.Parse(reader.GetString(),
CultureInfo.InvariantCulture);
public override void Write(
Utf8JsonWriter writer,
DateTime dateTimeValue,
JsonSerializerOptions options) =>
writer.WriteStringValue(dateTimeValue.Kind == DateTimeKind.Utc ? dateTimeValue.ToString(Format) : dateTimeValue.ToUniversalTime().ToString(Format));
}
}
using OpenCredentialPublisher.ClrLibrary.Attributes;
using OpenCredentialPublisher.ClrLibrary.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace OpenCredentialPublisher.ClrLibrary.Converters.Json
{
public class PolymorphicConverter<TItem, TList> : JsonConverter<TList>
where TItem : notnull
where TList : IList<TItem>, new()
{
public PolymorphicConverter()
{
var itemType = typeof(TItem);
if (itemType.IsInterface)
{
var implementedTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()).Where(y => itemType.IsAssignableFrom(y) && !y.IsInterface);
foreach(var implementedType in implementedTypes)
{
var jsonTypeAttribute = (JsonTypeAttribute)Attribute.GetCustomAttribute(implementedType, typeof(JsonTypeAttribute));
KeyTypeLookup.Add(jsonTypeAttribute?.Name ?? implementedType.Name, implementedType);
}
}
}
public ReversibleLookup<string, Type> KeyTypeLookup = new ReversibleLookup<string, Type>();
public override bool CanConvert(Type typeToConvert)
=> typeof(TList).IsAssignableFrom(typeToConvert);
public override TList Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
// Helper function for validating where you are in the JSON
void validateToken(Utf8JsonReader reader, JsonTokenType tokenType)
{
if (reader.TokenType != tokenType)
throw new JsonException($"Invalid token: Was expecting a '{tokenType}' token but received a '{reader.TokenType}' token");
}
var isArray = reader.TokenType == JsonTokenType.StartArray;
if (isArray)
{
reader.Read();
}
// Advance to the first object after the StartArray token. This should be either a StartObject token, or the EndArray token. Anything else is invalid.
var results = new TList();
while (reader.TokenType == JsonTokenType.StartObject)
{ // Start of 'wrapper' object
using var jsonDoc = JsonDocument.ParseValue(ref reader);
var typeName = jsonDoc.RootElement.GetProperty("type").GetString();
if (KeyTypeLookup.TryGetValue(typeName, out var concreteItemType))
{
var item = (TItem)JsonSerializer.Deserialize(jsonDoc.RootElement.GetRawText(), concreteItemType, options);
results.Add(item);
}
else
{
throw new JsonException($"Unknown type key '{typeName}' found");
}
//reader.Read(); // Move past end of item object
//reader.Read(); // Move past end of 'wrapper' object
}
if (isArray)
validateToken(reader, JsonTokenType.EndArray);
return results;
}
public override void Write(Utf8JsonWriter writer, TList items, JsonSerializerOptions options)
{
if (items.Count > 1)
writer.WriteStartArray();
foreach (var item in items)
{
var itemType = item.GetType();
if (KeyTypeLookup.ReverseLookup.TryGetValue(itemType, out var typeKey))
{
JsonSerializer.Serialize(writer, item, itemType, options);
}
else
{
throw new JsonException($"Unknown type '{itemType.FullName}' found");
}
}
if (items.Count > 1)
writer.WriteEndArray();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;