adding in working functionality for the remote connector

remotes/origin/0.6.7-post-fixes
Rob Smart 2009-09-10 16:13:18 +01:00 committed by Diva Canto
parent 16940097be
commit 953ef780c5
4 changed files with 65 additions and 11 deletions

View File

@ -76,7 +76,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
base.Initialise(source); base.Initialise(source);
m_log.Info("[AUTHORIZATION CONNECTOR]: Remote assets enabled"); m_log.Info("[AUTHORIZATION CONNECTOR]: Remote authorization enabled");
} }
} }
} }

View File

@ -55,16 +55,41 @@ namespace OpenSim.Server.Handlers.Authorization
public override byte[] Handle(string path, Stream request, public override byte[] Handle(string path, Stream request,
OSHttpRequest httpRequest, OSHttpResponse httpResponse) OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{ {
byte[] result = new byte[0]; // always return success for now, this is just stub functionality
return SuccessResult();
}
string[] p = SplitParams(path); private byte[] SuccessResult()
{
XmlDocument doc = new XmlDocument();
if (p.Length == 0) XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
return result; "", "");
// Process web request doc.AppendChild(xmlnode);
return result; XmlElement rootElement = doc.CreateElement("", "Authorization",
"");
doc.AppendChild(rootElement);
XmlElement result = doc.CreateElement("", "Result", "");
result.AppendChild(doc.CreateTextNode("success"));
rootElement.AppendChild(result);
return DocToBytes(doc);
}
private byte[] DocToBytes(XmlDocument doc)
{
MemoryStream ms = new MemoryStream();
XmlTextWriter xw = new XmlTextWriter(ms, null);
xw.Formatting = Formatting.Indented;
doc.WriteTo(xw);
xw.Flush();
return ms.GetBuffer();
} }
} }
} }

View File

@ -46,6 +46,7 @@ namespace OpenSim.Services.Connectors
MethodBase.GetCurrentMethod().DeclaringType); MethodBase.GetCurrentMethod().DeclaringType);
private string m_ServerURI = String.Empty; private string m_ServerURI = String.Empty;
private bool m_ResponseOnFailure = true;
public AuthorizationServicesConnector() public AuthorizationServicesConnector()
{ {
@ -66,7 +67,7 @@ namespace OpenSim.Services.Connectors
IConfig authorizationConfig = source.Configs["AuthorizationService"]; IConfig authorizationConfig = source.Configs["AuthorizationService"];
if (authorizationConfig == null) if (authorizationConfig == null)
{ {
m_log.Error("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpanSim.ini"); m_log.Error("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
throw new Exception("Authorization connector init error"); throw new Exception("Authorization connector init error");
} }
@ -75,16 +76,43 @@ namespace OpenSim.Services.Connectors
if (serviceURI == String.Empty) if (serviceURI == String.Empty)
{ {
m_log.Error("[AUTHORIZATION CONNECTOR]: No Server URI named in section AssetService"); m_log.Error("[AUTHORIZATION CONNECTOR]: No Server URI named in section AuthorizationService");
throw new Exception("Authorization connector init error"); throw new Exception("Authorization connector init error");
} }
m_ServerURI = serviceURI; m_ServerURI = serviceURI;
// this dictates what happens if the remote service fails, if the service fails and the value is true
// the user is authorized for the region.
bool responseOnFailure = authorizationConfig.GetBoolean("ResponseOnFailure",true);
m_ResponseOnFailure = responseOnFailure;
} }
public bool isAuthorizedForRegion(UserProfileData user, RegionInfo region) public bool isAuthorizedForRegion(UserProfileData user, RegionInfo region)
{ {
// call remote service // this should be a remote call to the authorization server specified in the AuthorizationServerURI
m_log.Info("[AUTHORIZATION CONNECTOR]: isAuthorizedForRegion is not yet implemented. Returning true, the user is authorized ");
string uri = m_ServerURI + "?uuid="+user.ID + "&firstname="+user.FirstName+"&lastname="+user.SurName+"&region="+region.RegionName+"&regionid="+region.RegionID+"&email="+user.Email;
string result = string.Empty;
try
{
result = SynchronousRestObjectRequester.
MakeRequest<UserProfileData, string>("POST", uri, user);
}
catch (Exception e)
{
m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} {1} for region {2} error thrown during comms with remote server. Reason: {3}", user.FirstName,user.SurName,region.RegionName, e.Message);
return m_ResponseOnFailure;
}
m_log.DebugFormat("[AUTHORIZATION CONNECTOR] response from remote service was {0}",result);
if(result.Contains("success"))
return true; return true;
else
return false;
} }
} }

View File

@ -10,6 +10,7 @@
[Modules] [Modules]
AssetServices = "RemoteAssetServicesConnector" AssetServices = "RemoteAssetServicesConnector"
InventoryServices = "RemoteInventoryServicesConnector" InventoryServices = "RemoteInventoryServicesConnector"
AuthorizationServices = "RemoteAuthorizationServicesConnector"
NeighbourServices = "RemoteNeighbourServicesConnector" NeighbourServices = "RemoteNeighbourServicesConnector"
NeighbourServiceInConnector = true NeighbourServiceInConnector = true
LandServiceInConnector = true LandServiceInConnector = true