diff options
author | Rob Smart | 2009-09-11 12:28:48 +0100 |
---|---|---|
committer | Diva Canto | 2009-09-11 06:50:24 -0700 |
commit | eaec7cf39ce134b4da0622f67ee6037843f6eb29 (patch) | |
tree | 82d261a37ec91787a835e974c3075bdd0d770aeb /OpenSim/Region | |
parent | Changed the interface of IAuthorizationService to get less data. (diff) | |
download | opensim-SC-eaec7cf39ce134b4da0622f67ee6037843f6eb29.zip opensim-SC-eaec7cf39ce134b4da0622f67ee6037843f6eb29.tar.gz opensim-SC-eaec7cf39ce134b4da0622f67ee6037843f6eb29.tar.bz2 opensim-SC-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/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs | 49 |
1 files changed, 45 insertions, 4 deletions
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; | |||
35 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using OpenMetaverse; | ||
38 | 39 | ||
39 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | 40 | namespace 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 | } |