diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs index 18a7177..c982db6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs | |||
@@ -39,13 +39,15 @@ using OpenMetaverse; | |||
39 | 39 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | 40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization |
41 | { | 41 | { |
42 | public class LocalAuthorizationServicesConnector : ISharedRegionModule, IAuthorizationService | 42 | public class LocalAuthorizationServicesConnector : INonSharedRegionModule, IAuthorizationService |
43 | { | 43 | { |
44 | private static readonly ILog m_log = | 44 | private static readonly ILog m_log = |
45 | LogManager.GetLogger( | 45 | LogManager.GetLogger( |
46 | MethodBase.GetCurrentMethod().DeclaringType); | 46 | MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | private IAuthorizationService m_AuthorizationService; | 48 | private IAuthorizationService m_AuthorizationService; |
49 | private Scene m_Scene; | ||
50 | private IConfig m_AuthorizationConfig; | ||
49 | 51 | ||
50 | private bool m_Enabled = false; | 52 | private bool m_Enabled = false; |
51 | 53 | ||
@@ -69,33 +71,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | |||
69 | string name = moduleConfig.GetString("AuthorizationServices", string.Empty); | 71 | string name = moduleConfig.GetString("AuthorizationServices", string.Empty); |
70 | if (name == Name) | 72 | if (name == Name) |
71 | { | 73 | { |
72 | IConfig authorizationConfig = source.Configs["AuthorizationService"]; | ||
73 | if (authorizationConfig == null) | ||
74 | { | ||
75 | m_log.Error("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini"); | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | string serviceDll = authorizationConfig.GetString("LocalServiceModule", | ||
80 | String.Empty); | ||
81 | |||
82 | if (serviceDll == String.Empty) | ||
83 | { | ||
84 | m_log.Error("[AUTHORIZATION CONNECTOR]: No LocalServiceModule named in section AuthorizationService"); | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | Object[] args = new Object[] { source }; | ||
89 | m_AuthorizationService = | ||
90 | ServerUtils.LoadPlugin<IAuthorizationService>(serviceDll, | ||
91 | args); | ||
92 | |||
93 | if (m_AuthorizationService == null) | ||
94 | { | ||
95 | m_log.Error("[AUTHORIZATION CONNECTOR]: Can't load authorization service"); | ||
96 | return; | ||
97 | } | ||
98 | m_Enabled = true; | 74 | m_Enabled = true; |
75 | m_AuthorizationConfig = source.Configs["AuthorizationService"]; | ||
99 | m_log.Info("[AUTHORIZATION CONNECTOR]: Local authorization connector enabled"); | 76 | m_log.Info("[AUTHORIZATION CONNECTOR]: Local authorization connector enabled"); |
100 | } | 77 | } |
101 | } | 78 | } |
@@ -115,6 +92,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | |||
115 | return; | 92 | return; |
116 | 93 | ||
117 | scene.RegisterModuleInterface<IAuthorizationService>(this); | 94 | scene.RegisterModuleInterface<IAuthorizationService>(this); |
95 | m_Scene = scene; | ||
96 | |||
97 | scene.EventManager.OnLoginsEnabled += new EventManager.LoginsEnabled(OnLoginsEnabled); | ||
118 | } | 98 | } |
119 | 99 | ||
120 | public void RemoveRegion(Scene scene) | 100 | public void RemoveRegion(Scene scene) |
@@ -131,9 +111,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | |||
131 | scene.RegionInfo.RegionName); | 111 | scene.RegionInfo.RegionName); |
132 | } | 112 | } |
133 | 113 | ||
114 | private void OnLoginsEnabled(string regionName) | ||
115 | { | ||
116 | m_AuthorizationService = new AuthorizationService(m_AuthorizationConfig, m_Scene); | ||
117 | } | ||
118 | |||
134 | public bool IsAuthorizedForRegion( | 119 | public bool IsAuthorizedForRegion( |
135 | string userID, string firstName, string lastName, string regionID, out string message) | 120 | string userID, string firstName, string lastName, string regionID, out string message) |
136 | { | 121 | { |
122 | message = ""; | ||
123 | if (!m_Enabled) | ||
124 | return true; | ||
125 | |||
137 | return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message); | 126 | return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message); |
138 | } | 127 | } |
139 | } | 128 | } |