Skip to content

Commit

Permalink
* Moved class
Browse files Browse the repository at this point in the history
* Refactor: narrative
  • Loading branch information
ben-biddington committed Aug 24, 2010
1 parent 7bcc615 commit ed52fb8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Brick/Xml/Signing/IXmlSigner.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Xml;

namespace Brick {
namespace Brick.Xml.Signing {
public interface IXmlSigner {
XmlDocument Sign(XmlDocument message);
}
Expand Down
15 changes: 8 additions & 7 deletions src/Brick/XmlSigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Xml;
using Brick.DateAndTime;
using Brick.Hashing;
using Brick.Xml.Signing;

namespace Brick {
public class XmlSigner : IXmlSigner {
Expand All @@ -13,16 +14,12 @@ public XmlSigner(String password) {

public XmlDocument Sign(XmlDocument message) {
return Sign(message, NewNonce(), DefaultExpiresAt);
}

private String NewNonce() {
return Convert.ToBase64String(Guid.NewGuid().ToByteArray());
}
}

public XmlDocument Sign(
XmlDocument message,
String nonce,
DateTime expirationTime
DateTime expiresAt
) {
if (message.DocumentElement == null)
throw new ArgumentException("No root node in xdoc.");
Expand All @@ -32,7 +29,7 @@ DateTime expirationTime
SignMessage(
copy.DocumentElement,
Convert.FromBase64String(nonce),
expirationTime,
expiresAt,
new SharedSecret().From(_password)
);

Expand Down Expand Up @@ -74,6 +71,10 @@ byte[] secret
message.AppendChild(child);
}

private String NewNonce() {
return Convert.ToBase64String(Guid.NewGuid().ToByteArray());
}

private static DateTime DefaultExpiresAt {
get { return DateTime.Now.AddMinutes(15); }
}
Expand Down

0 comments on commit ed52fb8

Please sign in to comment.