1
0

IAuthorizationService.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using OpenSim.Framework;
  29. namespace OpenSim.Services.Interfaces
  30. {
  31. // Generic Authorization service used for authorizing principals in a particular region
  32. public interface IAuthorizationService
  33. {
  34. /// <summary>
  35. /// Check whether the user should be given access to the region.
  36. /// </summary>
  37. /// <remarks>
  38. /// We also supply user first name and last name for situations where the user does not have an account
  39. /// on the region (e.g. they're a visitor via Hypergrid).
  40. /// </remarks>
  41. /// <param name="userID"></param>
  42. /// <param name="firstName">/param>
  43. /// <param name="lastName"></param>
  44. /// <param name="regionID"></param>
  45. /// <param name="message"></param>
  46. /// <returns></returns>
  47. bool IsAuthorizedForRegion(
  48. string userID, string firstName, string lastName, string regionID, out string message);
  49. }
  50. public class AuthorizationRequest
  51. {
  52. private string m_userID;
  53. private string m_firstname;
  54. private string m_surname;
  55. private string m_email;
  56. private string m_regionName;
  57. private string m_regionID;
  58. public AuthorizationRequest()
  59. {
  60. }
  61. public AuthorizationRequest(string ID, string RegionID)
  62. {
  63. m_userID = ID;
  64. m_regionID = RegionID;
  65. }
  66. public AuthorizationRequest(
  67. string ID, string FirstName, string SurName, string Email, string RegionName, string RegionID)
  68. {
  69. m_userID = ID;
  70. m_firstname = FirstName;
  71. m_surname = SurName;
  72. m_email = Email;
  73. m_regionName = RegionName;
  74. m_regionID = RegionID;
  75. }
  76. public string ID
  77. {
  78. get { return m_userID; }
  79. set { m_userID = value; }
  80. }
  81. public string FirstName
  82. {
  83. get { return m_firstname; }
  84. set { m_firstname = value; }
  85. }
  86. public string SurName
  87. {
  88. get { return m_surname; }
  89. set { m_surname = value; }
  90. }
  91. public string Email
  92. {
  93. get { return m_email; }
  94. set { m_email = value; }
  95. }
  96. public string RegionName
  97. {
  98. get { return m_regionName; }
  99. set { m_regionName = value; }
  100. }
  101. public string RegionID
  102. {
  103. get { return m_regionID; }
  104. set { m_regionID = value; }
  105. }
  106. }
  107. public class AuthorizationResponse
  108. {
  109. private bool m_isAuthorized;
  110. private string m_message;
  111. public AuthorizationResponse()
  112. {
  113. }
  114. public AuthorizationResponse(bool isAuthorized, string message)
  115. {
  116. m_isAuthorized = isAuthorized;
  117. m_message = message;
  118. }
  119. public bool IsAuthorized
  120. {
  121. get { return m_isAuthorized; }
  122. set { m_isAuthorized = value; }
  123. }
  124. public string Message
  125. {
  126. get { return m_message; }
  127. set { m_message = value; }
  128. }
  129. }
  130. }