-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from ITfoxtec/development
Development
- Loading branch information
Showing
14 changed files
with
230 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/ITfoxtec.Identity.Saml2/Schemas/Metadata/LocalizedNameType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.Collections.Generic; | ||
using System.Xml.Linq; | ||
|
||
namespace ITfoxtec.Identity.Saml2.Schemas.Metadata | ||
{ | ||
/// <summary> | ||
/// The LocalizedName element specifies a language specific name. | ||
/// </summary> | ||
public class LocalizedNameType | ||
{ | ||
/// <param name="name">The name.</param> | ||
public LocalizedNameType(string name) | ||
{ | ||
Name = name; | ||
} | ||
|
||
/// <param name="name">The name.</param> | ||
/// <param name="lang">The language.</param> | ||
public LocalizedNameType(string name, string lang) : this(name) | ||
{ | ||
Lang = lang; | ||
} | ||
|
||
/// <summary> | ||
/// The language. | ||
/// </summary> | ||
public string Lang { get; protected set; } | ||
|
||
/// <summary> | ||
/// The Name. | ||
/// </summary> | ||
public string Name { get; protected set; } | ||
|
||
public XElement ToXElement(XName elementName) | ||
{ | ||
var envelope = new XElement(elementName); | ||
|
||
envelope.Add(GetXContent()); | ||
|
||
return envelope; | ||
} | ||
|
||
protected IEnumerable<XObject> GetXContent() | ||
{ | ||
if (Lang != null) | ||
{ | ||
yield return new XAttribute(XNamespace.Xml + Saml2MetadataConstants.Message.Lang, Lang); | ||
} | ||
|
||
yield return new XText(Name); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/ITfoxtec.Identity.Saml2/Schemas/Metadata/LocalizedUriType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Xml.Linq; | ||
|
||
namespace ITfoxtec.Identity.Saml2.Schemas.Metadata | ||
{ | ||
/// <summary> | ||
/// The LocalizedUri element specifies a language specific URI. | ||
/// </summary> | ||
public class LocalizedUriType | ||
{ | ||
/// <param name="uri">The URI.</param> | ||
public LocalizedUriType(Uri uri) | ||
{ | ||
Uri = uri; | ||
} | ||
|
||
/// <param name="uri">The URI.</param> | ||
/// <param name="lang">The language.</param> | ||
public LocalizedUriType(Uri uri, string lang) : this(uri) | ||
{ | ||
Lang = lang; | ||
} | ||
|
||
/// <summary> | ||
/// The language. | ||
/// </summary> | ||
public string Lang { get; protected set; } | ||
|
||
/// <summary> | ||
/// The URI. | ||
/// </summary> | ||
public Uri Uri { get; protected set; } | ||
|
||
public XElement ToXElement(XName elementName) | ||
{ | ||
var envelope = new XElement(elementName); | ||
|
||
envelope.Add(GetXContent()); | ||
|
||
return envelope; | ||
} | ||
|
||
protected IEnumerable<XObject> GetXContent() | ||
{ | ||
if (Lang != null) | ||
{ | ||
yield return new XAttribute(XNamespace.Xml + Saml2MetadataConstants.Message.Lang, Lang); | ||
} | ||
|
||
yield return new XText(Uri.OriginalString); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
src/ITfoxtec.Identity.Saml2/Schemas/Metadata/ServiceName.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System; | ||
using System.Security.Cryptography.X509Certificates; | ||
|
||
namespace TestWebApp.Controllers | ||
{ | ||
|
@@ -27,32 +26,38 @@ public IActionResult Index() | |
entityDescriptor.IdPSsoDescriptor = new IdPSsoDescriptor | ||
{ | ||
WantAuthnRequestsSigned = config.SignAuthnRequest, | ||
SigningCertificates = new X509Certificate2[] | ||
{ | ||
SigningCertificates = | ||
[ | ||
config.SigningCertificate | ||
}, | ||
], | ||
//EncryptionCertificates = config.DecryptionCertificates, | ||
SingleSignOnServices = new SingleSignOnService[] | ||
{ | ||
SingleSignOnServices = | ||
[ | ||
new SingleSignOnService { Binding = ProtocolBindings.HttpRedirect, Location = config.SingleSignOnDestination } | ||
}, | ||
SingleLogoutServices = new SingleLogoutService[] | ||
{ | ||
], | ||
SingleLogoutServices = | ||
[ | ||
new SingleLogoutService { Binding = ProtocolBindings.HttpPost, Location = config.SingleLogoutDestination } | ||
}, | ||
ArtifactResolutionServices = new ArtifactResolutionService[] | ||
{ | ||
], | ||
ArtifactResolutionServices = | ||
[ | ||
new ArtifactResolutionService { Binding = ProtocolBindings.ArtifactSoap, Index = config.ArtifactResolutionService.Index, Location = config.ArtifactResolutionService.Location } | ||
}, | ||
NameIDFormats = new Uri[] { NameIdentifierFormats.X509SubjectName }, | ||
Attributes = new SamlAttribute[] | ||
{ | ||
], | ||
NameIDFormats = [NameIdentifierFormats.X509SubjectName], | ||
Attributes = | ||
[ | ||
new SamlAttribute("urn:oid:1.3.6.1.4.1.5923.1.1.1.6", friendlyName: "eduPersonPrincipalName"), | ||
new SamlAttribute("urn:oid:1.3.6.1.4.1.5923.1.1.1.1", new string[] { "member", "student", "employee" }) | ||
} | ||
] | ||
}; | ||
entityDescriptor.Organization = new Organization("Some Organization", "Some Organization Display Name", "http://some-organization.com"); | ||
entityDescriptor.ContactPersons = new[] { | ||
var organization = new Organization( | ||
[new LocalizedNameType("Some Organization", "en")], | ||
[new LocalizedNameType("Some Organization Display Name", "en")], | ||
[new LocalizedUriType(new Uri("http://some-organization.com"), "en")]); | ||
|
||
entityDescriptor.Organization = organization; | ||
entityDescriptor.ContactPersons = | ||
[ | ||
new ContactPerson(ContactTypes.Administrative) | ||
{ | ||
Company = "Some Company", | ||
|
@@ -69,7 +74,7 @@ public IActionResult Index() | |
EmailAddress = "[email protected]", | ||
TelephoneNumber = "22222222", | ||
} | ||
}; | ||
]; | ||
return new Saml2Metadata(entityDescriptor).CreateMetadata().ToActionResult(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.