diff options
author | Jason Alexander <jason.alexander@gmail.com> | 2007-02-25 06:15:30 +0000 |
---|---|---|
committer | Jason <jason.alexander@gmail.com> | 2007-02-25 06:15:30 +0000 |
commit | 6bd863d70e3e24ff246c5ee2c0bf96e6719161bf (patch) | |
tree | 216b29ddab564d0fa5135a0a69fb2b4dfb87ef08 | |
parent | 39974724c4f7a57054edabeec817b7c5edd5ed98 (diff) | |
download | DotNetOpenAuth-6bd863d70e3e24ff246c5ee2c0bf96e6719161bf.zip DotNetOpenAuth-6bd863d70e3e24ff246c5ee2c0bf96e6719161bf.tar.gz DotNetOpenAuth-6bd863d70e3e24ff246c5ee2c0bf96e6719161bf.tar.bz2 |
git-svn-id: https://dotnetopenid.googlecode.com/svn/trunk@13 01efa1a6-402a-0410-b0ae-47b76eba00f0
-rw-r--r-- | source/Janrain.OpenId/Server/CheckIdRequest.cs | 78 | ||||
-rw-r--r-- | source/Janrain.OpenId/Server/ProtocolException.cs | 14 | ||||
-rw-r--r-- | source/Janrain.OpenId/Server/Request.cs | 2 | ||||
-rw-r--r-- | source/Janrain.OpenId/Server/Response.cs | 1 | ||||
-rw-r--r-- | source/Janrain.OpenId/Server/TrustRoot.cs | 78 | ||||
-rw-r--r-- | source/Janrain.OpenId/bin/Debug/Janrain.OpenId.dll | bin | 86016 -> 86016 bytes | |||
-rw-r--r-- | source/Janrain.OpenId/bin/Debug/Janrain.OpenId.pdb | bin | 204288 -> 206336 bytes | |||
-rw-r--r-- | source/Janrain.OpenId/obj/Debug/Janrain.OpenId.dll | bin | 86016 -> 86016 bytes | |||
-rw-r--r-- | source/Janrain.OpenId/obj/Debug/Janrain.OpenId.pdb | bin | 204288 -> 206336 bytes |
9 files changed, 131 insertions, 42 deletions
diff --git a/source/Janrain.OpenId/Server/CheckIdRequest.cs b/source/Janrain.OpenId/Server/CheckIdRequest.cs index 914f294..b5984f9 100644 --- a/source/Janrain.OpenId/Server/CheckIdRequest.cs +++ b/source/Janrain.OpenId/Server/CheckIdRequest.cs @@ -5,46 +5,83 @@ using System.Text; namespace Janrain.OpenId.Server
{
+
+ // TODO Move this out to it's own file
public class UntrustedReturnUrl : ProtocolException
{
+
+ #region Private Members
+
private Uri _return_to;
private string _trust_root;
+ #endregion
+
+ #region Constructor(s)
+
public UntrustedReturnUrl(NameValueCollection query, Uri return_to, string trust_root)
: base(query, "return_to " + return_to.AbsoluteUri + " not under trust_root " + trust_root)
{
_return_to = return_to;
_trust_root = trust_root;
}
+
+ #endregion
+
}
+ // TODO Move this out to it's own file
public class MalformedReturnUrl : ProtocolException
{
+
+ #region Private Members
+
private string _return_to;
+ #endregion
+
+ #region Constructor(s)
+
public MalformedReturnUrl(NameValueCollection query, string return_to)
: base(query, "")
{
_return_to = return_to;
}
+
+ #endregion
+
}
+ // TODO Move this out to it's own file
public class MalformedTrustRoot : ProtocolException
{
+
+ #region Constructor(s)
+
public MalformedTrustRoot(NameValueCollection query, string text)
: base(query, text)
{
}
+
+ #endregion
+
}
public class CheckIdRequest : AssociatedRequest
{
+
+ #region Private Members
+
private bool _immediate;
private string _trust_root;
private Uri _identity;
private string _mode;
private Uri _return_to;
+ #endregion
+
+ #region Constructor(s)
+
public CheckIdRequest(Uri identity, Uri return_to, string trust_root, bool immediate, string assoc_handle)
{
this.AssocHandle = assoc_handle;
@@ -133,6 +170,24 @@ namespace Janrain.OpenId.Server }
+ #endregion
+
+ #region Private Methods
+
+ private string GetField(NameValueCollection query, string field)
+ {
+ string value = query.Get("openid." + field);
+
+ if (value == null)
+ throw new ProtocolException(query, "Missing required field " + field);
+
+ return value;
+ }
+
+ #endregion
+
+ #region Public Methods
+
public Response Answer(bool allow, Uri server_url)
{
string mode;
@@ -208,16 +263,6 @@ namespace Janrain.OpenId.Server return new Uri(builder.ToString());
}
- private string GetField(NameValueCollection query, string field)
- {
- string value = query.Get("openid." + field);
-
- if (value == null)
- throw new ProtocolException(query, "Missing required field " + field);
-
- return value;
- }
-
public bool TrustRootValid
{
get
@@ -234,6 +279,10 @@ namespace Janrain.OpenId.Server }
}
+ #endregion
+
+ #region Properties
+
public bool Immediate
{
get { return _immediate; }
@@ -254,9 +303,16 @@ namespace Janrain.OpenId.Server get { return _return_to; }
}
+ #endregion
+
+ #region Inherited Properties
+
public override string Mode
{
- get { throw new Exception("The method or operation is not implemented."); }
+ get { return _mode; }
}
+
+ #endregion
+
}
}
diff --git a/source/Janrain.OpenId/Server/ProtocolException.cs b/source/Janrain.OpenId/Server/ProtocolException.cs index 65c74a9..79f1097 100644 --- a/source/Janrain.OpenId/Server/ProtocolException.cs +++ b/source/Janrain.OpenId/Server/ProtocolException.cs @@ -7,14 +7,25 @@ namespace Janrain.OpenId.Server {
public class ProtocolException : ApplicationException, IEncodable
{
+
+ #region Private Members
+
private NameValueCollection _query = new NameValueCollection();
+ #endregion
+
+ #region Constructor(s)
+
public ProtocolException(NameValueCollection query, string text)
: base(text)
{
_query = query;
}
+ #endregion
+
+ #region Properties
+
public bool HasReturnTo
{
get
@@ -23,6 +34,8 @@ namespace Janrain.OpenId.Server }
}
+ #endregion
+
#region IEncodable Members
public EncodingType WhichEncoding
@@ -82,5 +95,6 @@ namespace Janrain.OpenId.Server }
#endregion
+
}
}
diff --git a/source/Janrain.OpenId/Server/Request.cs b/source/Janrain.OpenId/Server/Request.cs index 69c5b99..c704639 100644 --- a/source/Janrain.OpenId/Server/Request.cs +++ b/source/Janrain.OpenId/Server/Request.cs @@ -12,7 +12,7 @@ namespace Janrain.OpenId.Server }
- // Move this ABC out to it's own file
+ // TODO Move this ABC out to it's own file
public abstract class AssociatedRequest : Request
{
diff --git a/source/Janrain.OpenId/Server/Response.cs b/source/Janrain.OpenId/Server/Response.cs index 262ca9a..f747fd3 100644 --- a/source/Janrain.OpenId/Server/Response.cs +++ b/source/Janrain.OpenId/Server/Response.cs @@ -154,5 +154,6 @@ namespace Janrain.OpenId.Server }
#endregion
+
}
}
diff --git a/source/Janrain.OpenId/Server/TrustRoot.cs b/source/Janrain.OpenId/Server/TrustRoot.cs index 6e96c09..15e1ca2 100644 --- a/source/Janrain.OpenId/Server/TrustRoot.cs +++ b/source/Janrain.OpenId/Server/TrustRoot.cs @@ -6,6 +6,9 @@ namespace Janrain.OpenId.Server {
public class TrustRoot
{
+
+ #region Private Members
+
private static Regex _tr_regex = new Regex("^(?<scheme>https?)://((?<wildcard>\\*)|(?<wildcard>\\*\\.)?(?<host>[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*)\\.?)(:(?<port>[0-9]+))?(?<path>(/.*|$))");
private static string[] _top_level_domains = {"com", "edu", "gov", "int", "mil", "net", "org", "biz", "info", "name", "museum", "coop", "aero", "ac", "ad", "ae", "" +
"af", "ag", "ai", "al", "am", "an", "ao", "aq", "ar", "as", "at", "au", "aw", "az", "ba", "bb", "bd", "be", "bf", "bg", "bh", "bi", "bj", "" +
@@ -26,6 +29,10 @@ namespace Janrain.OpenId.Server private int _port;
private string _path;
+ #endregion
+
+ #region Constructor(s)
+
public TrustRoot(string unparsed)
{
Match mo = _tr_regex.Match(unparsed);
@@ -55,6 +62,46 @@ namespace Janrain.OpenId.Server }
}
+ #endregion
+
+ #region Properties
+
+ public bool IsSane
+ {
+ get
+ {
+ if (_host == "localhost")
+ return true;
+
+ string[] host_parts = _host.Split('.');
+
+ string tld = host_parts[host_parts.Length - 1];
+
+ if (!Util.InArray(_top_level_domains, tld))
+ return false;
+
+ if (tld.Length == 2)
+ {
+ if (host_parts.Length == 1)
+ return false;
+
+ if (host_parts[host_parts.Length - 2].Length <= 3)
+ return host_parts.Length > 2;
+
+ }
+ else
+ {
+ return host_parts.Length > 1;
+ }
+
+ return false;
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
public bool ValidateUrl(Uri url)
{
if (url.Scheme != _scheme)
@@ -102,36 +149,7 @@ namespace Janrain.OpenId.Server return (allowed.IndexOf(_path[_path.Length - 1]) >= 0 || allowed.IndexOf(url.PathAndQuery[path_len]) >= 0);
}
- public bool IsSane
- {
- get
- {
- if (_host == "localhost")
- return true;
-
- string[] host_parts = _host.Split('.');
-
- string tld = host_parts[host_parts.Length - 1];
-
- if (!Util.InArray(_top_level_domains, tld))
- return false;
+ #endregion
- if (tld.Length == 2)
- {
- if (host_parts.Length == 1)
- return false;
-
- if (host_parts[host_parts.Length - 2].Length <= 3)
- return host_parts.Length > 2;
-
- }
- else
- {
- return host_parts.Length > 1;
- }
-
- return false;
- }
- }
}
}
diff --git a/source/Janrain.OpenId/bin/Debug/Janrain.OpenId.dll b/source/Janrain.OpenId/bin/Debug/Janrain.OpenId.dll Binary files differindex a75c451..ebc08f6 100644 --- a/source/Janrain.OpenId/bin/Debug/Janrain.OpenId.dll +++ b/source/Janrain.OpenId/bin/Debug/Janrain.OpenId.dll diff --git a/source/Janrain.OpenId/bin/Debug/Janrain.OpenId.pdb b/source/Janrain.OpenId/bin/Debug/Janrain.OpenId.pdb Binary files differindex d223a19..f942698 100644 --- a/source/Janrain.OpenId/bin/Debug/Janrain.OpenId.pdb +++ b/source/Janrain.OpenId/bin/Debug/Janrain.OpenId.pdb diff --git a/source/Janrain.OpenId/obj/Debug/Janrain.OpenId.dll b/source/Janrain.OpenId/obj/Debug/Janrain.OpenId.dll Binary files differindex a75c451..ebc08f6 100644 --- a/source/Janrain.OpenId/obj/Debug/Janrain.OpenId.dll +++ b/source/Janrain.OpenId/obj/Debug/Janrain.OpenId.dll diff --git a/source/Janrain.OpenId/obj/Debug/Janrain.OpenId.pdb b/source/Janrain.OpenId/obj/Debug/Janrain.OpenId.pdb Binary files differindex d223a19..f942698 100644 --- a/source/Janrain.OpenId/obj/Debug/Janrain.OpenId.pdb +++ b/source/Janrain.OpenId/obj/Debug/Janrain.OpenId.pdb |