diff options
author | Rob Smart | 2009-09-10 16:13:18 +0100 |
---|---|---|
committer | Diva Canto | 2009-09-10 17:52:42 -0700 |
commit | 953ef780c5858b70b3b2da551640c93105feb12c (patch) | |
tree | c875871ac861e7948a8f08266118c00817d64762 /OpenSim/Services/Connectors/Authorization | |
parent | The stubs for an authorization service, at the moment the service will always... (diff) | |
download | opensim-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
Diffstat (limited to 'OpenSim/Services/Connectors/Authorization')
-rw-r--r-- | OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs | 36 |
1 files changed, 32 insertions, 4 deletions
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+"®ion="+region.RegionName+"®ionid="+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 | } |