30 using System.Collections.Generic;
32 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Framework.ServiceAuth;
36 using OpenSim.Services.Interfaces;
37 using OpenSim.Server.Base;
40 namespace OpenSim.Services.Connectors
44 private static readonly ILog m_log =
46 MethodBase.GetCurrentMethod().DeclaringType);
48 private string m_ServerURI = String.Empty;
56 m_ServerURI = serverURI.TrimEnd(
'/');
60 : base(source,
"AuthenticationService")
67 IConfig assetConfig = source.Configs[
"AuthenticationService"];
68 if (assetConfig == null)
70 m_log.Error(
"[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini");
71 throw new Exception(
"Authentication connector init error");
74 string serviceURI = assetConfig.GetString(
"AuthenticationServerURI",
77 if (serviceURI == String.Empty)
79 m_log.Error(
"[AUTH CONNECTOR]: No Server URI named in section AuthenticationService");
80 throw new Exception(
"Authentication connector init error");
82 m_ServerURI = serviceURI;
84 base.Initialise(source,
"AuthenticationService");
87 public string Authenticate(UUID principalID,
string password,
int lifetime, out UUID realID)
94 public string Authenticate(UUID principalID,
string password,
int lifetime)
96 Dictionary<string, object> sendData =
new Dictionary<string, object>();
97 sendData[
"LIFETIME"] = lifetime.ToString();
98 sendData[
"PRINCIPAL"] = principalID.ToString();
99 sendData[
"PASSWORD"] = password;
101 sendData[
"METHOD"] =
"authenticate";
103 string reply = SynchronousRestFormsRequester.MakeRequest(
"POST",
104 m_ServerURI +
"/auth/plain",
105 ServerUtils.BuildQueryString(sendData), m_Auth);
107 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
110 if (replyData[
"Result"].ToString() !=
"Success")
113 return replyData[
"Token"].ToString();
116 public bool Verify(UUID principalID,
string token,
int lifetime)
119 Dictionary<string, object> sendData =
new Dictionary<string, object>();
120 sendData[
"LIFETIME"] = lifetime.ToString();
121 sendData[
"PRINCIPAL"] = principalID.ToString();
122 sendData[
"TOKEN"] = token;
124 sendData[
"METHOD"] =
"verify";
126 string reply = SynchronousRestFormsRequester.MakeRequest(
"POST",
127 m_ServerURI +
"/auth/plain",
128 ServerUtils.BuildQueryString(sendData), m_Auth);
130 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
133 if (replyData[
"Result"].ToString() !=
"Success")
139 public bool Release(UUID principalID,
string token)
141 Dictionary<string, object> sendData =
new Dictionary<string, object>();
142 sendData[
"PRINCIPAL"] = principalID.ToString();
143 sendData[
"TOKEN"] = token;
145 sendData[
"METHOD"] =
"release";
147 string reply = SynchronousRestFormsRequester.MakeRequest(
"POST",
148 m_ServerURI +
"/auth/plain",
149 ServerUtils.BuildQueryString(sendData), m_Auth);
151 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
154 if (replyData[
"Result"].ToString() !=
"Success")
AuthInfo GetAuthInfo(UUID principalID)
AuthenticationServicesConnector(IConfigSource source)
bool SetPassword(UUID principalID, string passwd)
bool Release(UUID principalID, string token)
AuthenticationServicesConnector()
AuthenticationServicesConnector(string serverURI)
string Authenticate(UUID principalID, string password, int lifetime)
bool Verify(UUID principalID, string token, int lifetime)
virtual void Initialise(IConfigSource source)
string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
bool SetAuthInfo(AuthInfo info)