aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRob Smart2009-09-11 12:28:48 +0100
committerDiva Canto2009-09-11 06:50:24 -0700
commiteaec7cf39ce134b4da0622f67ee6037843f6eb29 (patch)
tree82d261a37ec91787a835e974c3075bdd0d770aeb /OpenSim
parentChanged the interface of IAuthorizationService to get less data. (diff)
downloadopensim-SC_OLD-eaec7cf39ce134b4da0622f67ee6037843f6eb29.zip
opensim-SC_OLD-eaec7cf39ce134b4da0622f67ee6037843f6eb29.tar.gz
opensim-SC_OLD-eaec7cf39ce134b4da0622f67ee6037843f6eb29.tar.bz2
opensim-SC_OLD-eaec7cf39ce134b4da0622f67ee6037843f6eb29.tar.xz
Changed RemoteAuthorizationServiceConnector so that it implements the IAuthorization interface method isAuthorizedForRegion looks up user and region data and delegates the remote authorization check to the AuthorizationServiceConnector
This keeps the IAuthorization as clean as possible and moves the dependency of using a UserProfileData object out to the connector from the scene.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/AuthorizationRequest.cs36
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs49
-rw-r--r--OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs7
3 files changed, 83 insertions, 9 deletions
diff --git a/OpenSim/Framework/AuthorizationRequest.cs b/OpenSim/Framework/AuthorizationRequest.cs
index 3280c65..ef99d3a 100644
--- a/OpenSim/Framework/AuthorizationRequest.cs
+++ b/OpenSim/Framework/AuthorizationRequest.cs
@@ -46,12 +46,46 @@ namespace OpenSim.Framework
46 m_regionID = RegionID; 46 m_regionID = RegionID;
47 } 47 }
48 48
49 public AuthorizationRequest(string ID,string FirstName, string SurName, string Email, string RegionName, string RegionID)
50 {
51 m_userID = ID;
52 m_firstname = FirstName;
53 m_surname = SurName;
54 m_email = Email;
55 m_regionName = RegionName;
56 m_regionID = RegionID;
57 }
58
49 public string ID 59 public string ID
50 { 60 {
51 get { return m_userID; } 61 get { return m_userID; }
52 set { m_userID = value; } 62 set { m_userID = value; }
53 } 63 }
54 64
65 public string FirstName
66 {
67 get { return m_firstname; }
68 set { m_firstname = value; }
69 }
70
71 public string SurName
72 {
73 get { return m_surname; }
74 set { m_surname = value; }
75 }
76
77 public string Email
78 {
79 get { return m_email; }
80 set { m_email = value; }
81 }
82
83 public string RegionName
84 {
85 get { return m_regionName; }
86 set { m_regionName = value; }
87 }
88
55 public string RegionID 89 public string RegionID
56 { 90 {
57 get { return m_regionID; } 91 get { return m_regionID; }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
index b0d8baa..88e6ee2 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
@@ -35,6 +35,7 @@ using OpenSim.Services.Connectors;
35using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using OpenMetaverse;
38 39
39namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization 40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
40{ 41{
@@ -46,6 +47,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
46 MethodBase.GetCurrentMethod().DeclaringType); 47 MethodBase.GetCurrentMethod().DeclaringType);
47 48
48 private bool m_Enabled = false; 49 private bool m_Enabled = false;
50 private List<Scene> m_scenes = new List<Scene>();
49 51
50 public Type ReplaceableInterface 52 public Type ReplaceableInterface
51 { 53 {
@@ -68,7 +70,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
68 IConfig authorizationConfig = source.Configs["AuthorizationService"]; 70 IConfig authorizationConfig = source.Configs["AuthorizationService"];
69 if (authorizationConfig == null) 71 if (authorizationConfig == null)
70 { 72 {
71 m_log.Error("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini"); 73 m_log.Error("[REMOTE AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
72 return; 74 return;
73 } 75 }
74 76
@@ -76,7 +78,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
76 78
77 base.Initialise(source); 79 base.Initialise(source);
78 80
79 m_log.Info("[AUTHORIZATION CONNECTOR]: Remote authorization enabled"); 81 m_log.Info("[REMOTE AUTHORIZATION CONNECTOR]: Remote authorization enabled");
80 } 82 }
81 } 83 }
82 } 84 }
@@ -94,7 +96,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
94 if (!m_Enabled) 96 if (!m_Enabled)
95 return; 97 return;
96 98
97 scene.RegisterModuleInterface<IAuthorizationService>(this); 99 if (!m_scenes.Contains(scene))
100 {
101 m_scenes.Add(scene);
102 scene.RegisterModuleInterface<IAuthorizationService>(this);
103 }
104
98 } 105 }
99 106
100 public void RemoveRegion(Scene scene) 107 public void RemoveRegion(Scene scene)
@@ -106,8 +113,42 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
106 if (!m_Enabled) 113 if (!m_Enabled)
107 return; 114 return;
108 115
109 m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: Enabled remote authorization for region {0}", scene.RegionInfo.RegionName); 116 m_log.InfoFormat("[REMOTE AUTHORIZATION CONNECTOR]: Enabled remote authorization for region {0}", scene.RegionInfo.RegionName);
110 117
111 } 118 }
119
120 public bool IsAuthorizedForRegion(string userID, string regionID)
121 {
122 m_log.InfoFormat("[REMOTE AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} for region {1}", userID, regionID);
123
124 bool isAuthorized = true;
125
126 // get the scene this call is being made for
127 Scene scene = null;
128 lock (m_scenes)
129 {
130 foreach (Scene nextScene in m_scenes)
131 {
132 if (nextScene.RegionInfo.RegionID.ToString() == regionID)
133 {
134 scene = nextScene;
135 }
136 }
137 }
138
139 if(scene!=null)
140 {
141 UserProfileData profile = scene.CommsManager.UserService.GetUserProfile(new UUID(userID));
142 isAuthorized = IsAuthorizedForRegion(userID, profile.FirstName, profile.SurName,profile.Email,scene.RegionInfo.RegionName,regionID);
143 }
144 else
145 {
146 m_log.ErrorFormat("[REMOTE AUTHORIZATION CONNECTOR] IsAuthorizedForRegion, can't find scene to match region id of {0} ",regionID);
147 }
148
149
150 return isAuthorized;
151
152 }
112 } 153 }
113} 154}
diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
index d50a6ed..bc4daad 100644
--- a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
@@ -39,7 +39,7 @@ using OpenMetaverse;
39 39
40namespace OpenSim.Services.Connectors 40namespace OpenSim.Services.Connectors
41{ 41{
42 public class AuthorizationServicesConnector : IAuthorizationService 42 public class AuthorizationServicesConnector
43 { 43 {
44 private static readonly ILog m_log = 44 private static readonly ILog m_log =
45 LogManager.GetLogger( 45 LogManager.GetLogger(
@@ -88,14 +88,14 @@ namespace OpenSim.Services.Connectors
88 m_ResponseOnFailure = responseOnFailure; 88 m_ResponseOnFailure = responseOnFailure;
89 } 89 }
90 90
91 public bool IsAuthorizedForRegion(string userID, string regionID) 91 public bool IsAuthorizedForRegion(string userID,string firstname, string surname, string email, string regionName, string regionID)
92 { 92 {
93 // do a remote call to the authorization server specified in the AuthorizationServerURI 93 // do a remote call to the authorization server specified in the AuthorizationServerURI
94 m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} at remote server {1}", userID, m_ServerURI); 94 m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} at remote server {1}", userID, m_ServerURI);
95 95
96 string uri = m_ServerURI; 96 string uri = m_ServerURI;
97 97
98 AuthorizationRequest req = new AuthorizationRequest(userID, regionID); 98 AuthorizationRequest req = new AuthorizationRequest(userID, firstname, surname, email, regionName, regionID);
99 99
100 AuthorizationResponse response; 100 AuthorizationResponse response;
101 try 101 try
@@ -105,7 +105,6 @@ namespace OpenSim.Services.Connectors
105 catch (Exception e) 105 catch (Exception e)
106 { 106 {
107 m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} for region {1} error thrown during comms with remote server. Reason: {2}", userID, regionID, e.Message); 107 m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} for region {1} error thrown during comms with remote server. Reason: {2}", userID, regionID, e.Message);
108 m_log.WarnFormat("Inner Exception is {0}",e.InnerException);
109 return m_ResponseOnFailure; 108 return m_ResponseOnFailure;
110 } 109 }
111 110