Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim

remotes/origin/0.6.7-post-fixes
Justin Clark-Casey (justincc) 2009-09-16 18:21:46 +01:00
commit a4c093469a
8 changed files with 76 additions and 9 deletions

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using OpenMetaverse;
using OpenSim.Framework;
namespace OpenSim.Data
{
public class RegionData
{
public UUID RegionID;
public UUID ScopeID;
public string RegionName;
public int posX;
public int posY;
public Dictionary<string, object> Data;
}
/// <summary>
/// An interface for connecting to the authentication datastore
/// </summary>
public interface IRegionData
{
RegionData Get(UUID regionID, UUID ScopeID);
RegionData Get(string regionName, UUID ScopeID);
RegionData Get(int x, int y, UUID ScopeID);
List<RegionData> Get(int xStart, int yStart, int xEnd, int yEnd, UUID ScopeID);
bool Store(RegionData data);
bool SetDataItem(UUID principalID, string item, string value);
bool Delete(UUID regionID);
}
}

View File

@ -132,9 +132,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
} }
public bool IsAuthorizedForRegion(string userID, string regionID) public bool IsAuthorizedForRegion(string userID, string regionID, out string message)
{ {
return m_AuthorizationService.IsAuthorizedForRegion(userID, regionID); return m_AuthorizationService.IsAuthorizedForRegion(userID, regionID, out message);
} }
} }

View File

@ -117,11 +117,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
} }
public bool IsAuthorizedForRegion(string userID, string regionID) public bool IsAuthorizedForRegion(string userID, string regionID, out string message)
{ {
m_log.InfoFormat("[REMOTE AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} for region {1}", userID, regionID); m_log.InfoFormat("[REMOTE AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} for region {1}", userID, regionID);
bool isAuthorized = true; bool isAuthorized = true;
message = String.Empty;
// get the scene this call is being made for // get the scene this call is being made for
Scene scene = null; Scene scene = null;
@ -140,7 +141,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
{ {
UserProfileData profile = scene.CommsManager.UserService.GetUserProfile(new UUID(userID)); UserProfileData profile = scene.CommsManager.UserService.GetUserProfile(new UUID(userID));
isAuthorized = IsAuthorizedForRegion(userID, profile.FirstName, profile.SurName, isAuthorized = IsAuthorizedForRegion(userID, profile.FirstName, profile.SurName,
profile.Email, scene.RegionInfo.RegionName, regionID); profile.Email, scene.RegionInfo.RegionName, regionID, out message);
} }
else else
{ {

View File

@ -3250,10 +3250,11 @@ namespace OpenSim.Region.Framework.Scenes
if (AuthorizationService != null) if (AuthorizationService != null)
{ {
if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString())) if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason))
{ {
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
//reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName);
return false; return false;
} }
} }

View File

@ -60,7 +60,8 @@ namespace OpenSim.Server.Handlers.Authorization
XmlSerializer xs = new XmlSerializer(typeof (AuthorizationRequest)); XmlSerializer xs = new XmlSerializer(typeof (AuthorizationRequest));
AuthorizationRequest Authorization = (AuthorizationRequest) xs.Deserialize(request); AuthorizationRequest Authorization = (AuthorizationRequest) xs.Deserialize(request);
bool authorized = m_AuthorizationService.IsAuthorizedForRegion(Authorization.ID, Authorization.RegionID); string message = String.Empty;
bool authorized = m_AuthorizationService.IsAuthorizedForRegion(Authorization.ID, Authorization.RegionID,out message);
AuthorizationResponse result = new AuthorizationResponse(authorized, Authorization.ID + " has been authorized"); AuthorizationResponse result = new AuthorizationResponse(authorized, Authorization.ID + " has been authorized");

View File

@ -48,8 +48,9 @@ namespace OpenSim.Services.AuthorizationService
m_log.Info("[AUTHORIZATION CONNECTOR]: Local Authorization service enabled"); m_log.Info("[AUTHORIZATION CONNECTOR]: Local Authorization service enabled");
} }
public bool IsAuthorizedForRegion(string userID, string regionID) public bool IsAuthorizedForRegion(string userID, string regionID, out string message)
{ {
message = "Authorized";
return true; return true;
} }
} }

View File

@ -88,7 +88,7 @@ namespace OpenSim.Services.Connectors
m_ResponseOnFailure = responseOnFailure; m_ResponseOnFailure = responseOnFailure;
} }
public bool IsAuthorizedForRegion(string userID, string firstname, string surname, string email, string regionName, string regionID) public bool IsAuthorizedForRegion(string userID, string firstname, string surname, string email, string regionName, string regionID, out string message)
{ {
// do a remote call to the authorization server specified in the AuthorizationServerURI // do a remote call to the authorization server specified in the AuthorizationServerURI
m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} at remote server {1}", userID, m_ServerURI); m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} at remote server {1}", userID, m_ServerURI);
@ -105,10 +105,12 @@ namespace OpenSim.Services.Connectors
catch (Exception e) catch (Exception e)
{ {
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); 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);
message="";
return m_ResponseOnFailure; return m_ResponseOnFailure;
} }
m_log.DebugFormat("[AUTHORIZATION CONNECTOR] response from remote service was {0}", response.Message); m_log.DebugFormat("[AUTHORIZATION CONNECTOR] response from remote service was {0}", response.Message);
message = response.Message;
return response.IsAuthorized; return response.IsAuthorized;
} }

View File

@ -40,7 +40,7 @@ namespace OpenSim.Services.Interfaces
// This method returns a simple true false indicating // This method returns a simple true false indicating
// whether or not a user has access to the region // whether or not a user has access to the region
// //
bool IsAuthorizedForRegion(string userID, string regionID); bool IsAuthorizedForRegion(string userID, string regionID, out string message);
} }