Skip to content

Commit

Permalink
move parts of token to metadata project
Browse files Browse the repository at this point in the history
  • Loading branch information
rpmansion committed Apr 11, 2020
1 parent 67a3c0d commit a9ba25f
Show file tree
Hide file tree
Showing 57 changed files with 365 additions and 359 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using Sustainsys.Saml2.Tokens;
using Microsoft.IdentityModel.Xml;

namespace Sustainsys.Saml2.Metadata
namespace Sustainsys.Saml2.Metadata.Descriptors
{
public class KeyDescriptor
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Sustainsys.Saml2.Internal
namespace Sustainsys.Saml2.Metadata.Helpers
{
static class CompareHelper
{
Expand Down
151 changes: 151 additions & 0 deletions Sustainsys.Saml2.Metadata/KeyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
using Sustainsys.Saml2.Metadata.Tokens;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Xml;

namespace Sustainsys.Saml2.Metadata
{
public abstract class KeyData
{
}

public class X509Digest
{
public Uri Algorithm { get; set; }
public byte[] Value { get; set; }
}

public class X509IssuerSerial
{
public string Name { get; private set; }
public string Serial { get; private set; }

public X509IssuerSerial(string name, string serial)
{
Name = name;
Serial = serial;
}
}

public class X509Data : KeyData
{
public X509IssuerSerial IssuerSerial { get; set; }
public byte[] SKI { get; set; }
public string SubjectName { get; set; }

public ICollection<X509Certificate2> Certificates { get; set; } =
new Collection<X509Certificate2>();

public byte[] CRL { get; set; }
public X509Digest Digest { get; set; }
}

public class RetrievalMethod
{
public Uri Uri { get; set; }
public Uri Type { get; set; }

public ICollection<XmlElement> Transforms { get; private set; } =
new Collection<XmlElement>();
}

public abstract class KeyValue
{
}

public class DsaKeyValue : KeyValue
{
public DSAParameters Parameters { get; set; }

public DsaKeyValue(DSAParameters parameters)
{
Parameters = parameters;
}
}

public class RsaKeyValue : KeyValue
{
public RSAParameters Parameters { get; set; }

public RsaKeyValue(RSAParameters parameters)
{
Parameters = parameters;
}
}

#if !NET461

public class EcKeyValue : KeyValue
{
public ECParameters Parameters { get; set; }

public EcKeyValue(ECParameters parameters)
{
Parameters = parameters;
}
}

#endif

public class DSigKeyInfo
{
public string Id { get; set; }

public ICollection<string> KeyNames { get; private set; } =
new Collection<string>();

public ICollection<KeyValue> KeyValues { get; private set; } =
new Collection<KeyValue>();

public ICollection<RetrievalMethod> RetrievalMethods { get; private set; } =
new Collection<RetrievalMethod>();

public ICollection<KeyData> Data { get; private set; } =
new Collection<KeyData>();

public SecurityKeyIdentifier MakeSecurityKeyIdentifier()
{
var ski = new SecurityKeyIdentifier();
foreach (var keyValue in KeyValues)
{
if (keyValue is RsaKeyValue rsaKeyValue)
{
ski.Add(new RsaKeyIdentifierClause(rsaKeyValue.Parameters));
}
else if (keyValue is DsaKeyValue dsaKeyValue)
{
ski.Add(new DsaKeyIdentifierClause(dsaKeyValue.Parameters));
}
#if !NET461
else if (keyValue is EcKeyValue ecKeyValue)
{
ski.Add(new EcKeyIdentifierClause(ecKeyValue.Parameters));
}
#endif
}
foreach (string keyName in KeyNames)
{
ski.Add(new KeyNameIdentifierClause(keyName));
}
foreach (var keyData in Data)
{
if (keyData is X509Data x509Data)
{
foreach (var cert in x509Data.Certificates)
{
ski.Add(new X509RawDataKeyIdentifierClause(cert));
}
if (x509Data.IssuerSerial != null)
{
ski.Add(new X509IssuerSerialKeyIdentifierClause(
x509Data.IssuerSerial.Name, x509Data.IssuerSerial.Serial));
}
}
}
return ski;
}
}
}
9 changes: 9 additions & 0 deletions Sustainsys.Saml2.Metadata/KeyType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Sustainsys.Saml2.Metadata
{
public enum KeyType
{
Unspecified = 0,
Signing = 1,
Encryption = 2
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Sustainsys.Saml2.Metadata.Services
{
public class ApplicationService : Endpoint
public class ApplicationServiceEndpoint : Endpoint
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Sustainsys.Saml2.Metadata.Services
{
public class PassiveRequestorEndpoint : Endpoint
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Sustainsys.Saml2.Metadata.Services
{
public class SingleSignOutNotificationEndpoint : Endpoint
{
}
}
4 changes: 0 additions & 4 deletions Sustainsys.Saml2.Metadata/Sustainsys.Saml2.Metadata.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,4 @@
<PackageReference Include="System.Security.Cryptography.Xml" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<Folder Include="Descriptors\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Security.Cryptography;

namespace Sustainsys.Saml2.Tokens
namespace Sustainsys.Saml2.Metadata.Tokens
{
public abstract class AsymmetricSecurityKey : SecurityKey
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.IdentityModel.Tokens;
using System;
using System;
using Microsoft.IdentityModel.Tokens;

namespace Sustainsys.Saml2.Tokens
namespace Sustainsys.Saml2.Metadata.Tokens
{
public abstract class BinaryKeyIdentifierClause : SecurityKeyIdentifierClause
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Sustainsys.Saml2.Internal;
using System;
using System.Linq;
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using Sustainsys.Saml2.Metadata.Helpers;

namespace Sustainsys.Saml2.Tokens
namespace Sustainsys.Saml2.Metadata.Tokens
{
public class DsaSecurityKey : AsymmetricSecurityKey
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Security.Cryptography;
using Sustainsys.Saml2.Internal;
using Sustainsys.Saml2.Metadata.Helpers;

#if !NET461

namespace Sustainsys.Saml2.Tokens
namespace Sustainsys.Saml2.Metadata.Tokens
{
static class EcUtils
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Sustainsys.Saml2.Tokens
namespace Sustainsys.Saml2.Metadata.Tokens
{
public class KeyNameIdentifierClause : SecurityKeyIdentifierClause
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using Sustainsys.Saml2.Internal;
using System;
using System.Linq;
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using System.Xml;
using Sustainsys.Saml2.Metadata.Helpers;

namespace Sustainsys.Saml2.Tokens
namespace Sustainsys.Saml2.Metadata.Tokens
{
public class RsaSecurityKey : AsymmetricSecurityKey
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Sustainsys.Saml2.Tokens
namespace Sustainsys.Saml2.Metadata.Tokens
{
public static class SecurityAlgorithms
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Sustainsys.Saml2.Tokens
namespace Sustainsys.Saml2.Metadata.Tokens
{
public abstract class SecurityKey
{
Expand Down
Loading

0 comments on commit a9ba25f

Please sign in to comment.