Skip to content

Commit

Permalink
added setting to skip setting validUntil attribute in metadata genera…
Browse files Browse the repository at this point in the history
…tion (hard coded to be 7 days) as it will create alot of confusion for new users
  • Loading branch information
stevenao committed Mar 3, 2016
1 parent 7ebc3cf commit eba7f23
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
9 changes: 6 additions & 3 deletions src/SAML2.Core/Config/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace SAML2.Config
/// </summary>
public class Metadata
{


/// <summary>
/// Gets or sets a value indicating whether to exclude artifact endpoints in metadata generation.
/// </summary>
Expand All @@ -36,7 +34,12 @@ public class Metadata
/// Gets or sets the requested attributes.
/// </summary>
/// <value>The requested attributes.</value>
public IList<Attribute> RequestedAttributes { get; set; }
public IList<Attribute> RequestedAttributes { get; set; }

/// <summary>
/// Set Metadata validUntil attribute to be the days from now. The default is to ignore the validUntil attribute so the metadata will not expire.
/// </summary>
public int? ValidForDays { get; set; }

public Metadata()
{
Expand Down
39 changes: 22 additions & 17 deletions src/SAML2.Core/Saml20MetadataDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,16 @@ private static XmlDocument LoadFileAsXmlDocument(string filename, IEnumerable<En
var reader = new StreamReader(filename, e);
d.Load(reader);
});
}

/// <summary>
/// Loads a file into an XmlDocument. If the loading or the signature check fails, the method will retry using another encoding.
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns>The XML document.</returns>
private static XmlDocument LoadAsXmlDocument(IEnumerable<Encoding> encodings, Action<XmlDocument> docLoad, Action<XmlDocument, Encoding> quirksModeDocLoad)
}

/// <summary>
/// Loads a file into an XmlDocument. If the loading or the signature check fails, the method will retry using another encoding.
/// </summary>
/// <param name="encodings"></param>
/// <param name="docLoad"></param>
/// <param name="quirksModeDocLoad"></param>
/// <returns>The XML document.</returns>
private static XmlDocument LoadAsXmlDocument(IEnumerable<Encoding> encodings, Action<XmlDocument> docLoad, Action<XmlDocument, Encoding> quirksModeDocLoad)
{
var doc = new XmlDocument { PreserveWhitespace = true };

Expand Down Expand Up @@ -515,13 +517,14 @@ private static EntityDescriptor GetDefaultEntityInstance()
};

return result;
}

/// <summary>
/// Signs the document.
/// </summary>
/// <param name="doc">The doc.</param>
private static void SignDocument(XmlDocument doc, X509Certificate2 certificate)
}

/// <summary>
/// Signs the document.
/// </summary>
/// <param name="doc">The doc.</param>
/// <param name="certificate"></param>
private static void SignDocument(XmlDocument doc, X509Certificate2 certificate)
{
if (!certificate.HasPrivateKey)
{
Expand Down Expand Up @@ -560,8 +563,10 @@ private static void SignDocument(XmlDocument doc, X509Certificate2 certificate)
private void ConvertToMetadata(Saml2Configuration config, KeyInfo keyInfo)
{
var entity = CreateDefaultEntity();
entity.EntityID = config.ServiceProvider.Id;
entity.ValidUntil = DateTime.Now.AddDays(7);
entity.EntityID = config.ServiceProvider.Id;

if( config.Metadata.ValidForDays.HasValue )
entity.ValidUntil = DateTime.Now.AddDays(config.Metadata.ValidForDays.Value);

var serviceProviderDescriptor = new SpSsoDescriptor
{
Expand Down

0 comments on commit eba7f23

Please sign in to comment.