aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRob Smart2009-09-10 16:13:18 +0100
committerDiva Canto2009-09-10 17:52:42 -0700
commit953ef780c5858b70b3b2da551640c93105feb12c (patch)
treec875871ac861e7948a8f08266118c00817d64762
parentThe stubs for an authorization service, at the moment the service will always... (diff)
downloadopensim-SC_OLD-953ef780c5858b70b3b2da551640c93105feb12c.zip
opensim-SC_OLD-953ef780c5858b70b3b2da551640c93105feb12c.tar.gz
opensim-SC_OLD-953ef780c5858b70b3b2da551640c93105feb12c.tar.bz2
opensim-SC_OLD-953ef780c5858b70b3b2da551640c93105feb12c.tar.xz
adding in working functionality for the remote connector
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Authorization/AuthorizationServerGetHandler.cs37
-rw-r--r--OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs36
-rw-r--r--bin/config-include/Grid.ini1
4 files changed, 65 insertions, 11 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
index 5870111..b0d8baa 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
@@ -76,7 +76,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
76 76
77 base.Initialise(source); 77 base.Initialise(source);
78 78
79 m_log.Info("[AUTHORIZATION CONNECTOR]: Remote assets enabled"); 79 m_log.Info("[AUTHORIZATION CONNECTOR]: Remote authorization enabled");
80 } 80 }
81 } 81 }
82 } 82 }
diff --git a/OpenSim/Server/Handlers/Authorization/AuthorizationServerGetHandler.cs b/OpenSim/Server/Handlers/Authorization/AuthorizationServerGetHandler.cs
index 4e4960c..9e4c00e 100644
--- a/OpenSim/Server/Handlers/Authorization/AuthorizationServerGetHandler.cs
+++ b/OpenSim/Server/Handlers/Authorization/AuthorizationServerGetHandler.cs
@@ -55,16 +55,41 @@ namespace OpenSim.Server.Handlers.Authorization
55 public override byte[] Handle(string path, Stream request, 55 public override byte[] Handle(string path, Stream request,
56 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 56 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
57 { 57 {
58 byte[] result = new byte[0]; 58 // always return success for now, this is just stub functionality
59 return SuccessResult();
60 }
61
62 private byte[] SuccessResult()
63 {
64 XmlDocument doc = new XmlDocument();
65
66 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
67 "", "");
68
69 doc.AppendChild(xmlnode);
59 70
60 string[] p = SplitParams(path); 71 XmlElement rootElement = doc.CreateElement("", "Authorization",
72 "");
61 73
62 if (p.Length == 0) 74 doc.AppendChild(rootElement);
63 return result;
64 75
65 // Process web request 76 XmlElement result = doc.CreateElement("", "Result", "");
77 result.AppendChild(doc.CreateTextNode("success"));
78
79 rootElement.AppendChild(result);
80
81 return DocToBytes(doc);
82 }
83
84 private byte[] DocToBytes(XmlDocument doc)
85 {
86 MemoryStream ms = new MemoryStream();
87 XmlTextWriter xw = new XmlTextWriter(ms, null);
88 xw.Formatting = Formatting.Indented;
89 doc.WriteTo(xw);
90 xw.Flush();
66 91
67 return result; 92 return ms.GetBuffer();
68 } 93 }
69 } 94 }
70} 95}
diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
index a0cdc30..151d96a 100644
--- a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
@@ -46,6 +46,7 @@ namespace OpenSim.Services.Connectors
46 MethodBase.GetCurrentMethod().DeclaringType); 46 MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 private string m_ServerURI = String.Empty; 48 private string m_ServerURI = String.Empty;
49 private bool m_ResponseOnFailure = true;
49 50
50 public AuthorizationServicesConnector() 51 public AuthorizationServicesConnector()
51 { 52 {
@@ -66,7 +67,7 @@ namespace OpenSim.Services.Connectors
66 IConfig authorizationConfig = source.Configs["AuthorizationService"]; 67 IConfig authorizationConfig = source.Configs["AuthorizationService"];
67 if (authorizationConfig == null) 68 if (authorizationConfig == null)
68 { 69 {
69 m_log.Error("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpanSim.ini"); 70 m_log.Error("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
70 throw new Exception("Authorization connector init error"); 71 throw new Exception("Authorization connector init error");
71 } 72 }
72 73
@@ -75,16 +76,43 @@ namespace OpenSim.Services.Connectors
75 76
76 if (serviceURI == String.Empty) 77 if (serviceURI == String.Empty)
77 { 78 {
78 m_log.Error("[AUTHORIZATION CONNECTOR]: No Server URI named in section AssetService"); 79 m_log.Error("[AUTHORIZATION CONNECTOR]: No Server URI named in section AuthorizationService");
79 throw new Exception("Authorization connector init error"); 80 throw new Exception("Authorization connector init error");
80 } 81 }
81 m_ServerURI = serviceURI; 82 m_ServerURI = serviceURI;
83
84 // this dictates what happens if the remote service fails, if the service fails and the value is true
85 // the user is authorized for the region.
86 bool responseOnFailure = authorizationConfig.GetBoolean("ResponseOnFailure",true);
87
88 m_ResponseOnFailure = responseOnFailure;
82 } 89 }
83 90
84 public bool isAuthorizedForRegion(UserProfileData user, RegionInfo region) 91 public bool isAuthorizedForRegion(UserProfileData user, RegionInfo region)
85 { 92 {
86 // call remote service 93 // this should be a remote call to the authorization server specified in the AuthorizationServerURI
87 return true; 94 m_log.Info("[AUTHORIZATION CONNECTOR]: isAuthorizedForRegion is not yet implemented. Returning true, the user is authorized ");
95
96 string uri = m_ServerURI + "?uuid="+user.ID + "&firstname="+user.FirstName+"&lastname="+user.SurName+"&region="+region.RegionName+"&regionid="+region.RegionID+"&email="+user.Email;
97
98 string result = string.Empty;
99
100 try
101 {
102 result = SynchronousRestObjectRequester.
103 MakeRequest<UserProfileData, string>("POST", uri, user);
104 }
105 catch (Exception e)
106 {
107 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);
108 return m_ResponseOnFailure;
109 }
110
111 m_log.DebugFormat("[AUTHORIZATION CONNECTOR] response from remote service was {0}",result);
112 if(result.Contains("success"))
113 return true;
114 else
115 return false;
88 } 116 }
89 117
90 } 118 }
diff --git a/bin/config-include/Grid.ini b/bin/config-include/Grid.ini
index 3b8f3a9..10f7dbd 100644
--- a/bin/config-include/Grid.ini
+++ b/bin/config-include/Grid.ini
@@ -10,6 +10,7 @@
10[Modules] 10[Modules]
11 AssetServices = "RemoteAssetServicesConnector" 11 AssetServices = "RemoteAssetServicesConnector"
12 InventoryServices = "RemoteInventoryServicesConnector" 12 InventoryServices = "RemoteInventoryServicesConnector"
13 AuthorizationServices = "RemoteAuthorizationServicesConnector"
13 NeighbourServices = "RemoteNeighbourServicesConnector" 14 NeighbourServices = "RemoteNeighbourServicesConnector"
14 NeighbourServiceInConnector = true 15 NeighbourServiceInConnector = true
15 LandServiceInConnector = true 16 LandServiceInConnector = true