aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService/GridService.cs
diff options
context:
space:
mode:
authorDiva Canto2010-01-15 15:13:11 -0800
committerDiva Canto2010-01-15 15:13:11 -0800
commit8d5a5d6a4dd3aa33fc7ba7555c86b34ac5f6db8f (patch)
tree2711c442fff9214cc6c8b9488e06781ec241b908 /OpenSim/Services/GridService/GridService.cs
parent* General cleanup of Teleports, Crossings and Child agents. They are now in t... (diff)
parentImplement region registration with authentication (diff)
downloadopensim-SC_OLD-8d5a5d6a4dd3aa33fc7ba7555c86b34ac5f6db8f.zip
opensim-SC_OLD-8d5a5d6a4dd3aa33fc7ba7555c86b34ac5f6db8f.tar.gz
opensim-SC_OLD-8d5a5d6a4dd3aa33fc7ba7555c86b34ac5f6db8f.tar.bz2
opensim-SC_OLD-8d5a5d6a4dd3aa33fc7ba7555c86b34ac5f6db8f.tar.xz
Merge branch 'presence-refactor' of ssh://diva@opensimulator.org/var/git/opensim into presence-refactor
Diffstat (limited to 'OpenSim/Services/GridService/GridService.cs')
-rw-r--r--OpenSim/Services/GridService/GridService.cs61
1 files changed, 59 insertions, 2 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 4f93ce5..5c55c0b 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -34,6 +34,7 @@ using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Data; 36using OpenSim.Data;
37using OpenSim.Server.Base;
37using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenMetaverse; 40using OpenMetaverse;
@@ -50,6 +51,8 @@ namespace OpenSim.Services.GridService
50 private static GridService m_RootInstance = null; 51 private static GridService m_RootInstance = null;
51 protected IConfigSource m_config; 52 protected IConfigSource m_config;
52 53
54 protected IAuthenticationService m_AuthenticationService = null;
55
53 public GridService(IConfigSource config) 56 public GridService(IConfigSource config)
54 : base(config) 57 : base(config)
55 { 58 {
@@ -60,6 +63,14 @@ namespace OpenSim.Services.GridService
60 if (gridConfig != null) 63 if (gridConfig != null)
61 { 64 {
62 m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); 65 m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);
66
67 string authService = gridConfig.GetString("AuthenticationService", String.Empty);
68
69 if (authService != String.Empty)
70 {
71 Object[] args = new Object[] { config };
72 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args);
73 }
63 } 74 }
64 75
65 if (m_RootInstance == null) 76 if (m_RootInstance == null)
@@ -90,6 +101,46 @@ namespace OpenSim.Services.GridService
90 // This needs better sanity testing. What if regionInfo is registering in 101 // This needs better sanity testing. What if regionInfo is registering in
91 // overlapping coords? 102 // overlapping coords?
92 RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); 103 RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
104 if (region != null)
105 {
106 // There is a preexisting record
107 //
108 // Get it's flags
109 //
110 OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(region.Data["Flags"]);
111
112 // Is this a reservation?
113 //
114 if ((rflags & OpenSim.Data.RegionFlags.Reservation) != 0)
115 {
116 // Regions reserved for the null key cannot be taken.
117 //
118 if (region.Data["PrincipalID"] == UUID.Zero.ToString())
119 return false;
120
121 // Treat it as an auth request
122 //
123 // NOTE: Fudging the flags value here, so these flags
124 // should not be used elsewhere. Don't optimize
125 // this with the later retrieval of the same flags!
126 //
127 rflags |= OpenSim.Data.RegionFlags.Authenticate;
128 }
129
130 if ((rflags & OpenSim.Data.RegionFlags.Authenticate) != 0)
131 {
132 // Can we authenticate at all?
133 //
134 if (m_AuthenticationService == null)
135 return false;
136
137 if (!m_AuthenticationService.Verify(new UUID(region.Data["PrincipalID"].ToString()), regionInfos.Token, 30))
138 return false;
139
140 return false;
141 }
142 }
143
93 if ((region != null) && (region.RegionID != regionInfos.RegionID)) 144 if ((region != null) && (region.RegionID != regionInfos.RegionID))
94 { 145 {
95 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", 146 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.",
@@ -99,6 +150,9 @@ namespace OpenSim.Services.GridService
99 if ((region != null) && (region.RegionID == regionInfos.RegionID) && 150 if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
100 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) 151 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
101 { 152 {
153 if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0)
154 return false;
155
102 // Region reregistering in other coordinates. Delete the old entry 156 // Region reregistering in other coordinates. Delete the old entry
103 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", 157 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.",
104 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); 158 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY);
@@ -119,10 +173,13 @@ namespace OpenSim.Services.GridService
119 173
120 if (region != null) 174 if (region != null)
121 { 175 {
122 if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) 176 int oldFlags = Convert.ToInt32(region.Data["flags"]);
177 if ((oldFlags & (int)OpenSim.Data.RegionFlags.LockedOut) != 0)
123 return false; 178 return false;
124 179
125 rdata.Data["flags"] = region.Data["flags"]; // Preserve fields 180 oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation;
181
182 rdata.Data["flags"] = oldFlags.ToString(); // Preserve flags
126 } 183 }
127 else 184 else
128 { 185 {