aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs154
1 files changed, 150 insertions, 4 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index f3490fb..5453420 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Globalization;
31using System.IO; 32using System.IO;
32using System.Xml; 33using System.Xml;
33using System.Net; 34using System.Net;
@@ -51,6 +52,7 @@ using OpenSim.Services.Interfaces;
51using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; 52using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
52using GridRegion = OpenSim.Services.Interfaces.GridRegion; 53using GridRegion = OpenSim.Services.Interfaces.GridRegion;
53using PermissionMask = OpenSim.Framework.PermissionMask; 54using PermissionMask = OpenSim.Framework.PermissionMask;
55using RegionInfo = OpenSim.Framework.RegionInfo;
54 56
55namespace OpenSim.ApplicationPlugins.RemoteController 57namespace OpenSim.ApplicationPlugins.RemoteController
56{ 58{
@@ -149,6 +151,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
149 availableMethods["admin_create_user_email"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod); 151 availableMethods["admin_create_user_email"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod);
150 availableMethods["admin_exists_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUserExistsMethod); 152 availableMethods["admin_exists_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUserExistsMethod);
151 availableMethods["admin_update_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUpdateUserAccountMethod); 153 availableMethods["admin_update_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUpdateUserAccountMethod);
154 availableMethods["admin_authenticate_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAuthenticateUserMethod);
152 155
153 // Region state management 156 // Region state management
154 availableMethods["admin_load_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadXMLMethod); 157 availableMethods["admin_load_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadXMLMethod);
@@ -1412,6 +1415,139 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1412 } 1415 }
1413 1416
1414 /// <summary> 1417 /// <summary>
1418 /// Authenticate an user.
1419 /// <summary>
1420 /// <param name="request">incoming XML RPC request</param>
1421 /// <remarks>
1422 /// XmlRpcAuthenticateUserMethod takes the following XMLRPC
1423 /// parameters
1424 /// <list type="table">
1425 /// <listheader><term>parameter name</term><description>description</description></listheader>
1426 /// <item><term>password</term>
1427 /// <description>admin password as set in OpenSim.ini</description></item>
1428 /// <item><term>user_firstname</term>
1429 /// <description>avatar's first name</description></item>
1430 /// <item><term>user_lastname</term>
1431 /// <description>avatar's last name</description></item>
1432 /// <item><term>user_password</term>
1433 /// <description>MD5 hash of avatar's password</description></item>
1434 /// <item><term>token_lifetime</term>
1435 /// <description>the lifetime of the returned token (upper bounded to 30s)</description></item>
1436 /// </list>
1437 ///
1438 /// XmlRpcAuthenticateUserMethod returns
1439 /// <list type="table">
1440 /// <listheader><term>name</term><description>description</description></listheader>
1441 /// <item><term>success</term>
1442 /// <description>true or false</description></item>
1443 /// <item><term>token</term>
1444 /// <description>the authentication token sent by OpenSim</description></item>
1445 /// <item><term>error</term>
1446 /// <description>error message if success is false</description></item>
1447 /// </list>
1448 /// </remarks>
1449 private void XmlRpcAuthenticateUserMethod(XmlRpcRequest request, XmlRpcResponse response,
1450 IPEndPoint remoteClient)
1451 {
1452 m_log.Info("[RADMIN]: AuthenticateUser: new request");
1453
1454 var responseData = (Hashtable)response.Value;
1455 var requestData = (Hashtable)request.Params[0];
1456
1457 lock (m_requestLock)
1458 {
1459 try
1460 {
1461 CheckStringParameters(requestData, responseData, new[]
1462 {
1463 "user_firstname",
1464 "user_lastname",
1465 "user_password",
1466 "token_lifetime"
1467 });
1468
1469 var firstName = (string)requestData["user_firstname"];
1470 var lastName = (string)requestData["user_lastname"];
1471 var password = (string)requestData["user_password"];
1472
1473 var scene = m_application.SceneManager.CurrentOrFirstScene;
1474
1475 if (scene.Equals(null))
1476 {
1477 m_log.Debug("scene does not exist");
1478 throw new Exception("Scene does not exist.");
1479 }
1480
1481 var scopeID = scene.RegionInfo.ScopeID;
1482 var account = scene.UserAccountService.GetUserAccount(scopeID, firstName, lastName);
1483
1484 if (account.Equals(null) || account.PrincipalID.Equals(UUID.Zero))
1485 {
1486 m_log.DebugFormat("avatar {0} {1} does not exist", firstName, lastName);
1487 throw new Exception(String.Format("avatar {0} {1} does not exist", firstName, lastName));
1488 }
1489
1490 if (String.IsNullOrEmpty(password))
1491 {
1492 m_log.DebugFormat("[RADMIN]: AuthenticateUser: no password provided for {0} {1}", firstName,
1493 lastName);
1494 throw new Exception(String.Format("no password provided for {0} {1}", firstName,
1495 lastName));
1496 }
1497
1498 int lifetime;
1499 if (int.TryParse((string)requestData["token_lifetime"], NumberStyles.Integer, CultureInfo.InvariantCulture, out lifetime) == false)
1500 {
1501 m_log.DebugFormat("[RADMIN]: AuthenticateUser: no token lifetime provided for {0} {1}", firstName,
1502 lastName);
1503 throw new Exception(String.Format("no token lifetime provided for {0} {1}", firstName,
1504 lastName));
1505 }
1506
1507 // Upper bound on lifetime set to 30s.
1508 if (lifetime > 30)
1509 {
1510 m_log.DebugFormat("[RADMIN]: AuthenticateUser: token lifetime longer than 30s for {0} {1}", firstName,
1511 lastName);
1512 throw new Exception(String.Format("token lifetime longer than 30s for {0} {1}", firstName,
1513 lastName));
1514 }
1515
1516 var authModule = scene.RequestModuleInterface<IAuthenticationService>();
1517 if (authModule == null)
1518 {
1519 m_log.Debug("[RADMIN]: AuthenticateUser: no authentication module loded");
1520 throw new Exception("no authentication module loaded");
1521 }
1522
1523 var token = authModule.Authenticate(account.PrincipalID, password, lifetime);
1524 if (String.IsNullOrEmpty(token))
1525 {
1526 m_log.DebugFormat("[RADMIN]: AuthenticateUser: authentication failed for {0} {1}", firstName,
1527 lastName);
1528 throw new Exception(String.Format("authentication failed for {0} {1}", firstName,
1529 lastName));
1530 }
1531
1532 m_log.DebugFormat("[RADMIN]: AuthenticateUser: account for user {0} {1} identified with token {2}",
1533 firstName, lastName, token);
1534
1535 responseData["token"] = token;
1536 responseData["success"] = true;
1537
1538 }
1539 catch (Exception e)
1540 {
1541 responseData["success"] = false;
1542 responseData["error"] = e.Message;
1543 throw e;
1544 }
1545
1546 m_log.Info("[RADMIN]: AuthenticateUser: request complete");
1547 }
1548 }
1549
1550 /// <summary>
1415 /// Load an OAR file into a region.. 1551 /// Load an OAR file into a region..
1416 /// <summary> 1552 /// <summary>
1417 /// <param name="request">incoming XML RPC request</param> 1553 /// <param name="request">incoming XML RPC request</param>
@@ -1539,7 +1675,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1539 /// </remarks> 1675 /// </remarks>
1540 private void XmlRpcSaveOARMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 1676 private void XmlRpcSaveOARMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
1541 { 1677 {
1542 m_log.Info("[RADMIN]: Received Save OAR Administrator Request"); 1678 m_log.Info("[RADMIN]: Received Save OAR Request");
1543 1679
1544 Hashtable responseData = (Hashtable)response.Value; 1680 Hashtable responseData = (Hashtable)response.Value;
1545 Hashtable requestData = (Hashtable)request.Params[0]; 1681 Hashtable requestData = (Hashtable)request.Params[0];
@@ -1585,8 +1721,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1585 1721
1586 if (archiver != null) 1722 if (archiver != null)
1587 { 1723 {
1724 Guid requestId = Guid.NewGuid();
1588 scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted; 1725 scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted;
1589 archiver.ArchiveRegion(filename, options); 1726
1727 m_log.InfoFormat(
1728 "[RADMIN]: Submitting save OAR request for {0} to file {1}, request ID {2}",
1729 scene.Name, filename, requestId);
1730
1731 archiver.ArchiveRegion(filename, requestId, options);
1590 1732
1591 lock (m_saveOarLock) 1733 lock (m_saveOarLock)
1592 Monitor.Wait(m_saveOarLock,5000); 1734 Monitor.Wait(m_saveOarLock,5000);
@@ -1607,12 +1749,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1607 throw e; 1749 throw e;
1608 } 1750 }
1609 1751
1610 m_log.Info("[RADMIN]: Save OAR Administrator Request complete"); 1752 m_log.Info("[RADMIN]: Save OAR Request complete");
1611 } 1753 }
1612 1754
1613 private void RemoteAdminOarSaveCompleted(Guid uuid, string name) 1755 private void RemoteAdminOarSaveCompleted(Guid uuid, string name)
1614 { 1756 {
1615 m_log.DebugFormat("[RADMIN]: File processing complete for {0}", name); 1757 if (name != "")
1758 m_log.ErrorFormat("[RADMIN]: Saving of OAR file with request ID {0} failed with message {1}", uuid, name);
1759 else
1760 m_log.DebugFormat("[RADMIN]: Saved OAR file for request {0}", uuid);
1761
1616 lock (m_saveOarLock) 1762 lock (m_saveOarLock)
1617 Monitor.Pulse(m_saveOarLock); 1763 Monitor.Pulse(m_saveOarLock);
1618 } 1764 }