diff options
author | Diva Canto | 2010-01-16 21:42:44 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-16 21:42:44 -0800 |
commit | 04e29c1bacbc1e2df980ae15896a847ce7535da2 (patch) | |
tree | e799d2837af1a41bc2c3b2d571201e9a8a6d7ae7 /OpenSim/Services/HypergridService/GatekeeperService.cs | |
parent | Finished moving object crossings into EntityTransferModule (diff) | |
download | opensim-SC-04e29c1bacbc1e2df980ae15896a847ce7535da2.zip opensim-SC-04e29c1bacbc1e2df980ae15896a847ce7535da2.tar.gz opensim-SC-04e29c1bacbc1e2df980ae15896a847ce7535da2.tar.bz2 opensim-SC-04e29c1bacbc1e2df980ae15896a847ce7535da2.tar.xz |
Beginning of rewriting HG. Compiles, and runs, but HG functions not restored yet.
Diffstat (limited to 'OpenSim/Services/HypergridService/GatekeeperService.cs')
-rw-r--r-- | OpenSim/Services/HypergridService/GatekeeperService.cs | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs new file mode 100644 index 0000000..174174c --- /dev/null +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs | |||
@@ -0,0 +1,167 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Reflection; | ||
4 | |||
5 | using OpenSim.Framework; | ||
6 | using OpenSim.Services.Interfaces; | ||
7 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
8 | using OpenSim.Server.Base; | ||
9 | |||
10 | using OpenMetaverse; | ||
11 | |||
12 | using Nini.Config; | ||
13 | using log4net; | ||
14 | |||
15 | namespace OpenSim.Services.HypergridService | ||
16 | { | ||
17 | public class GatekeeperService : IGatekeeperService | ||
18 | { | ||
19 | private static readonly ILog m_log = | ||
20 | LogManager.GetLogger( | ||
21 | MethodBase.GetCurrentMethod().DeclaringType); | ||
22 | |||
23 | IGridService m_GridService; | ||
24 | IPresenceService m_PresenceService; | ||
25 | IAuthenticationService m_AuthenticationService; | ||
26 | IUserAccountService m_UserAccountService; | ||
27 | ISimulationService m_SimulationService; | ||
28 | |||
29 | string m_AuthDll; | ||
30 | |||
31 | UUID m_ScopeID; | ||
32 | bool m_AllowTeleportsToAnyRegion; | ||
33 | GridRegion m_DefaultGatewayRegion; | ||
34 | |||
35 | public GatekeeperService(IConfigSource config, ISimulationService simService) | ||
36 | { | ||
37 | IConfig serverConfig = config.Configs["GatekeeperService"]; | ||
38 | if (serverConfig == null) | ||
39 | throw new Exception(String.Format("No section GatekeeperService in config file")); | ||
40 | |||
41 | string accountService = serverConfig.GetString("UserAccountService", String.Empty); | ||
42 | string gridService = serverConfig.GetString("GridService", String.Empty); | ||
43 | string presenceService = serverConfig.GetString("PresenceService", String.Empty); | ||
44 | string simulationService = serverConfig.GetString("SimulationService", String.Empty); | ||
45 | |||
46 | m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty); | ||
47 | |||
48 | if (accountService == string.Empty || gridService == string.Empty || | ||
49 | presenceService == string.Empty || m_AuthDll == string.Empty) | ||
50 | throw new Exception("Incomplete specifications, Gatekeeper Service cannot function."); | ||
51 | |||
52 | string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString()); | ||
53 | UUID.TryParse(scope, out m_ScopeID); | ||
54 | //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); | ||
55 | m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true); | ||
56 | |||
57 | Object[] args = new Object[] { config }; | ||
58 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); | ||
59 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); | ||
60 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); | ||
61 | if (simService != null) | ||
62 | m_SimulationService = simService; | ||
63 | else if (simulationService != string.Empty) | ||
64 | m_SimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args); | ||
65 | |||
66 | if (m_UserAccountService == null || m_GridService == null || | ||
67 | m_PresenceService == null || m_SimulationService == null) | ||
68 | throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); | ||
69 | |||
70 | m_log.Debug("[GATEKEEPER SERVICE]: Starting..."); | ||
71 | } | ||
72 | |||
73 | public GatekeeperService(IConfigSource config) | ||
74 | : this(config, null) | ||
75 | { | ||
76 | } | ||
77 | |||
78 | public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason) | ||
79 | { | ||
80 | regionID = m_DefaultGatewayRegion.RegionID; | ||
81 | regionHandle = m_DefaultGatewayRegion.RegionHandle; | ||
82 | imageURL = string.Empty; | ||
83 | reason = string.Empty; | ||
84 | |||
85 | if (!m_AllowTeleportsToAnyRegion) | ||
86 | { | ||
87 | regionID = m_DefaultGatewayRegion.RegionID; | ||
88 | regionHandle = m_DefaultGatewayRegion.RegionHandle; | ||
89 | if (regionName != string.Empty) | ||
90 | { | ||
91 | reason = "Direct links to regions not allowed"; | ||
92 | return false; | ||
93 | } | ||
94 | |||
95 | return true; | ||
96 | } | ||
97 | |||
98 | GridRegion region = m_GridService.GetRegionByName(m_ScopeID, regionName); | ||
99 | if (region == null) | ||
100 | { | ||
101 | reason = "Region not found"; | ||
102 | return false; | ||
103 | } | ||
104 | |||
105 | regionID = region.RegionID; | ||
106 | regionHandle = region.RegionHandle; | ||
107 | string regionimage = "regionImage" + region.RegionID.ToString(); | ||
108 | regionimage = regionimage.Replace("-", ""); | ||
109 | |||
110 | imageURL = "http://" + region.ExternalHostName + ":" + region.HttpPort + "/index.php?method=" + regionimage; | ||
111 | |||
112 | return true; | ||
113 | } | ||
114 | |||
115 | public GridRegion GetHyperlinkRegion(UUID regionID) | ||
116 | { | ||
117 | if (!m_AllowTeleportsToAnyRegion) | ||
118 | // Don't even check the given regionID | ||
119 | return m_DefaultGatewayRegion; | ||
120 | |||
121 | GridRegion region = m_GridService.GetRegionByUUID(m_ScopeID, regionID); | ||
122 | return region; | ||
123 | } | ||
124 | |||
125 | public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination) | ||
126 | { | ||
127 | if (!Authenticate(aCircuit)) | ||
128 | return false; | ||
129 | |||
130 | // Check to see if we have a local user with that UUID | ||
131 | UserAccount account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID); | ||
132 | if (account != null) | ||
133 | // No, sorry; go away | ||
134 | return false; | ||
135 | |||
136 | // May want to authorize | ||
137 | |||
138 | // Login the presence | ||
139 | if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID)) | ||
140 | return false; | ||
141 | |||
142 | // Finally launch the agent at the destination | ||
143 | string reason = string.Empty; | ||
144 | return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason); | ||
145 | } | ||
146 | |||
147 | public bool LoginAttachments(ISceneObject sog, GridRegion destination) | ||
148 | { | ||
149 | // May want to filter attachments | ||
150 | return m_SimulationService.CreateObject(destination, sog, false); | ||
151 | } | ||
152 | |||
153 | protected bool Authenticate(AgentCircuitData aCircuit) | ||
154 | { | ||
155 | string authURL = string.Empty; // GetAuthURL(aCircuit); | ||
156 | if (authURL == string.Empty) | ||
157 | return false; | ||
158 | |||
159 | Object[] args = new Object[] { authURL }; | ||
160 | IAuthenticationService authService = ServerUtils.LoadPlugin<IAuthenticationService>(m_AuthDll, args); | ||
161 | if (authService != null) | ||
162 | return authService.Verify(aCircuit.AgentID, aCircuit.SecureSessionID.ToString(), 30); | ||
163 | |||
164 | return false; | ||
165 | } | ||
166 | } | ||
167 | } | ||