diff options
author | Dr Scofield | 2009-04-27 11:51:25 +0000 |
---|---|---|
committer | Dr Scofield | 2009-04-27 11:51:25 +0000 |
commit | 515e62dc2f4614b140da222c082d3cd69c5960d4 (patch) | |
tree | eda95f708aad85c1fbbe14459111beb3790b8526 /OpenSim/ApplicationPlugins | |
parent | Add copyright headers. Formatting cleanup. (diff) | |
download | opensim-SC_OLD-515e62dc2f4614b140da222c082d3cd69c5960d4.zip opensim-SC_OLD-515e62dc2f4614b140da222c082d3cd69c5960d4.tar.gz opensim-SC_OLD-515e62dc2f4614b140da222c082d3cd69c5960d4.tar.bz2 opensim-SC_OLD-515e62dc2f4614b140da222c082d3cd69c5960d4.tar.xz |
From: Alan M Webb <alan_webb@us.ibm.com>
Added support for access control lists.
Scene: Added test to AddNewClient for an entry in the access
list when connecting to a region with limited access.
EstateSettings: Added an HasAccess(UUID) property to test for
an entry in the estate's access list.
RemoteAdmin: Add RPC calls for admin_acl_list, clear, add,
and remove.
Diffstat (limited to 'OpenSim/ApplicationPlugins')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 288 |
1 files changed, 287 insertions, 1 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index a7290b9..f6bfb33 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -102,19 +102,26 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
102 | Dictionary<string, XmlRpcMethod> availableMethods = new Dictionary<string, XmlRpcMethod>(); | 102 | Dictionary<string, XmlRpcMethod> availableMethods = new Dictionary<string, XmlRpcMethod>(); |
103 | availableMethods["admin_create_region"] = XmlRpcCreateRegionMethod; | 103 | availableMethods["admin_create_region"] = XmlRpcCreateRegionMethod; |
104 | availableMethods["admin_delete_region"] = XmlRpcDeleteRegionMethod; | 104 | availableMethods["admin_delete_region"] = XmlRpcDeleteRegionMethod; |
105 | availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod; | ||
105 | availableMethods["admin_shutdown"] = XmlRpcShutdownMethod; | 106 | availableMethods["admin_shutdown"] = XmlRpcShutdownMethod; |
106 | availableMethods["admin_broadcast"] = XmlRpcAlertMethod; | 107 | availableMethods["admin_broadcast"] = XmlRpcAlertMethod; |
107 | availableMethods["admin_restart"] = XmlRpcRestartMethod; | 108 | availableMethods["admin_restart"] = XmlRpcRestartMethod; |
108 | availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; | 109 | availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; |
110 | // User management | ||
109 | availableMethods["admin_create_user"] = XmlRpcCreateUserMethod; | 111 | availableMethods["admin_create_user"] = XmlRpcCreateUserMethod; |
110 | availableMethods["admin_create_user_email"] = XmlRpcCreateUserMethod; | 112 | availableMethods["admin_create_user_email"] = XmlRpcCreateUserMethod; |
111 | availableMethods["admin_exists_user"] = XmlRpcUserExistsMethod; | 113 | availableMethods["admin_exists_user"] = XmlRpcUserExistsMethod; |
112 | availableMethods["admin_update_user"] = XmlRpcUpdateUserAccountMethod; | 114 | availableMethods["admin_update_user"] = XmlRpcUpdateUserAccountMethod; |
115 | // Region state management | ||
113 | availableMethods["admin_load_xml"] = XmlRpcLoadXMLMethod; | 116 | availableMethods["admin_load_xml"] = XmlRpcLoadXMLMethod; |
114 | availableMethods["admin_save_xml"] = XmlRpcSaveXMLMethod; | 117 | availableMethods["admin_save_xml"] = XmlRpcSaveXMLMethod; |
115 | availableMethods["admin_load_oar"] = XmlRpcLoadOARMethod; | 118 | availableMethods["admin_load_oar"] = XmlRpcLoadOARMethod; |
116 | availableMethods["admin_save_oar"] = XmlRpcSaveOARMethod; | 119 | availableMethods["admin_save_oar"] = XmlRpcSaveOARMethod; |
117 | availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod; | 120 | // Estate access list management |
121 | availableMethods["admin_acl_clear"] = XmlRpcAccessListClear; | ||
122 | availableMethods["admin_acl_add"] = XmlRpcAccessListAdd; | ||
123 | availableMethods["admin_acl_remove"] = XmlRpcAccessListRemove; | ||
124 | availableMethods["admin_acl_list"] = XmlRpcAccessListList; | ||
118 | 125 | ||
119 | // Either enable full remote functionality or just selected features | 126 | // Either enable full remote functionality or just selected features |
120 | string enabledMethods = m_config.GetString("enabled_methods", "all"); | 127 | string enabledMethods = m_config.GetString("enabled_methods", "all"); |
@@ -1496,8 +1503,287 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1496 | return response; | 1503 | return response; |
1497 | } | 1504 | } |
1498 | 1505 | ||
1506 | public XmlRpcResponse XmlRpcAccessListClear(XmlRpcRequest request) | ||
1507 | { | ||
1508 | |||
1509 | m_log.Info("[RADMIN]: Received Access List Clear Request"); | ||
1510 | XmlRpcResponse response = new XmlRpcResponse(); | ||
1511 | Hashtable responseData = new Hashtable(); | ||
1512 | |||
1513 | try | ||
1514 | { | ||
1515 | responseData["success"] = "true"; | ||
1516 | |||
1517 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
1518 | |||
1519 | if (!requestData.Contains("password")) | ||
1520 | throw new Exception(String.Format("missing required parameter")); | ||
1521 | if (!String.IsNullOrEmpty(requiredPassword) && | ||
1522 | (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); | ||
1523 | |||
1524 | if (requestData.Contains("region_uuid")) | ||
1525 | { | ||
1526 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1527 | if (!m_app.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1528 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1529 | m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString()); | ||
1530 | } | ||
1531 | else if (requestData.Contains("region_name")) | ||
1532 | { | ||
1533 | string region_name = (string) requestData["region_name"]; | ||
1534 | if (!m_app.SceneManager.TrySetCurrentScene(region_name)) | ||
1535 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1536 | m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name); | ||
1537 | } | ||
1538 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1539 | |||
1540 | Scene s = m_app.SceneManager.CurrentScene; | ||
1541 | s.RegionInfo.EstateSettings.EstateAccess = new UUID[]{}; | ||
1542 | |||
1543 | } | ||
1544 | catch (Exception e) | ||
1545 | { | ||
1546 | m_log.InfoFormat("[RADMIN] Access List Clear Request: {0}", e.Message); | ||
1547 | |||
1548 | responseData["success"] = "false"; | ||
1549 | responseData["error"] = e.Message; | ||
1550 | |||
1551 | } | ||
1552 | finally | ||
1553 | { | ||
1554 | response.Value = responseData; | ||
1555 | } | ||
1556 | |||
1557 | m_log.Info("[RADMIN]: Access List Clear Request complete"); | ||
1558 | return response; | ||
1559 | } | ||
1560 | |||
1561 | public XmlRpcResponse XmlRpcAccessListAdd(XmlRpcRequest request) | ||
1562 | { | ||
1563 | |||
1564 | m_log.Info("[RADMIN]: Received Access List Add Request"); | ||
1565 | XmlRpcResponse response = new XmlRpcResponse(); | ||
1566 | Hashtable responseData = new Hashtable(); | ||
1567 | |||
1568 | try | ||
1569 | { | ||
1570 | responseData["success"] = "true"; | ||
1571 | |||
1572 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
1573 | |||
1574 | if (!requestData.Contains("password")) | ||
1575 | throw new Exception(String.Format("missing required parameter")); | ||
1576 | if (!String.IsNullOrEmpty(requiredPassword) && | ||
1577 | (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); | ||
1578 | |||
1579 | if (requestData.Contains("region_uuid")) | ||
1580 | { | ||
1581 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1582 | if (!m_app.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1583 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1584 | m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString()); | ||
1585 | } | ||
1586 | else if (requestData.Contains("region_name")) | ||
1587 | { | ||
1588 | string region_name = (string) requestData["region_name"]; | ||
1589 | if (!m_app.SceneManager.TrySetCurrentScene(region_name)) | ||
1590 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1591 | m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name); | ||
1592 | } | ||
1593 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1594 | |||
1595 | int addk = 0; | ||
1596 | |||
1597 | if(requestData.Contains("users")) | ||
1598 | { | ||
1599 | UserProfileCacheService ups = m_app.CommunicationsManager.UserProfileCacheService; | ||
1600 | Scene s = m_app.SceneManager.CurrentScene; | ||
1601 | Hashtable users = (Hashtable) requestData["users"]; | ||
1602 | List<UUID> uuids = new List<UUID>(); | ||
1603 | foreach(string name in users.Values) | ||
1604 | { | ||
1605 | string[] parts = name.Split(); | ||
1606 | uuids.Add(ups.GetUserDetails(parts[0],parts[1]).UserProfile.ID); | ||
1607 | } | ||
1608 | List<UUID> acl = new List<UUID>(s.RegionInfo.EstateSettings.EstateAccess); | ||
1609 | foreach(UUID uuid in uuids) | ||
1610 | { | ||
1611 | if(!acl.Contains(uuid)) | ||
1612 | { | ||
1613 | acl.Add(uuid); | ||
1614 | addk++; | ||
1615 | } | ||
1616 | } | ||
1617 | s.RegionInfo.EstateSettings.EstateAccess = acl.ToArray(); | ||
1618 | } | ||
1619 | |||
1620 | responseData["added"] = addk; | ||
1621 | |||
1622 | } | ||
1623 | catch (Exception e) | ||
1624 | { | ||
1625 | m_log.InfoFormat("[RADMIN] Access List Add Request: {0}", e.Message); | ||
1626 | |||
1627 | responseData["success"] = "false"; | ||
1628 | responseData["error"] = e.Message; | ||
1629 | |||
1630 | } | ||
1631 | finally | ||
1632 | { | ||
1633 | response.Value = responseData; | ||
1634 | } | ||
1635 | |||
1636 | m_log.Info("[RADMIN]: Access List Add Request complete"); | ||
1637 | return response; | ||
1638 | } | ||
1639 | |||
1640 | public XmlRpcResponse XmlRpcAccessListRemove(XmlRpcRequest request) | ||
1641 | { | ||
1642 | |||
1643 | m_log.Info("[RADMIN]: Received Access List Remove Request"); | ||
1644 | XmlRpcResponse response = new XmlRpcResponse(); | ||
1645 | Hashtable responseData = new Hashtable(); | ||
1646 | |||
1647 | try | ||
1648 | { | ||
1649 | responseData["success"] = "true"; | ||
1650 | |||
1651 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
1652 | |||
1653 | if (!requestData.Contains("password")) | ||
1654 | throw new Exception(String.Format("missing required parameter")); | ||
1655 | if (!String.IsNullOrEmpty(requiredPassword) && | ||
1656 | (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); | ||
1657 | |||
1658 | if (requestData.Contains("region_uuid")) | ||
1659 | { | ||
1660 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1661 | if (!m_app.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1662 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1663 | m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString()); | ||
1664 | } | ||
1665 | else if (requestData.Contains("region_name")) | ||
1666 | { | ||
1667 | string region_name = (string) requestData["region_name"]; | ||
1668 | if (!m_app.SceneManager.TrySetCurrentScene(region_name)) | ||
1669 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1670 | m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name); | ||
1671 | } | ||
1672 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1673 | |||
1674 | int remk = 0; | ||
1675 | |||
1676 | if(requestData.Contains("users")) | ||
1677 | { | ||
1678 | UserProfileCacheService ups = m_app.CommunicationsManager.UserProfileCacheService; | ||
1679 | Scene s = m_app.SceneManager.CurrentScene; | ||
1680 | Hashtable users = (Hashtable) requestData["users"]; | ||
1681 | List<UUID> uuids = new List<UUID>(); | ||
1682 | foreach(string name in users.Values) | ||
1683 | { | ||
1684 | string[] parts = name.Split(); | ||
1685 | uuids.Add(ups.GetUserDetails(parts[0],parts[1]).UserProfile.ID); | ||
1686 | } | ||
1687 | List<UUID> acl = new List<UUID>(s.RegionInfo.EstateSettings.EstateAccess); | ||
1688 | foreach(UUID uuid in uuids) | ||
1689 | { | ||
1690 | if(acl.Contains(uuid)) | ||
1691 | { | ||
1692 | acl.Remove(uuid); | ||
1693 | remk++; | ||
1694 | } | ||
1695 | } | ||
1696 | s.RegionInfo.EstateSettings.EstateAccess = acl.ToArray(); | ||
1697 | } | ||
1698 | |||
1699 | responseData["added"] = remk; | ||
1700 | |||
1701 | |||
1702 | } | ||
1703 | catch (Exception e) | ||
1704 | { | ||
1705 | m_log.InfoFormat("[RADMIN] Access List Remove Request: {0}", e.Message); | ||
1706 | |||
1707 | responseData["success"] = "false"; | ||
1708 | responseData["error"] = e.Message; | ||
1709 | |||
1710 | } | ||
1711 | finally | ||
1712 | { | ||
1713 | response.Value = responseData; | ||
1714 | } | ||
1715 | |||
1716 | m_log.Info("[RADMIN]: Access List Remove Request complete"); | ||
1717 | return response; | ||
1718 | } | ||
1719 | |||
1720 | public XmlRpcResponse XmlRpcAccessListList(XmlRpcRequest request) | ||
1721 | { | ||
1722 | |||
1723 | m_log.Info("[RADMIN]: Received Access List List Request"); | ||
1724 | XmlRpcResponse response = new XmlRpcResponse(); | ||
1725 | Hashtable responseData = new Hashtable(); | ||
1726 | |||
1727 | try | ||
1728 | { | ||
1729 | responseData["success"] = "true"; | ||
1730 | |||
1731 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
1732 | |||
1733 | if (!requestData.Contains("password")) | ||
1734 | throw new Exception(String.Format("missing required parameter")); | ||
1735 | if (!String.IsNullOrEmpty(requiredPassword) && | ||
1736 | (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); | ||
1737 | |||
1738 | if (requestData.Contains("region_uuid")) | ||
1739 | { | ||
1740 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1741 | if (!m_app.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1742 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1743 | m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString()); | ||
1744 | } | ||
1745 | else if (requestData.Contains("region_name")) | ||
1746 | { | ||
1747 | string region_name = (string) requestData["region_name"]; | ||
1748 | if (!m_app.SceneManager.TrySetCurrentScene(region_name)) | ||
1749 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1750 | m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name); | ||
1751 | } | ||
1752 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1753 | |||
1754 | Scene s = m_app.SceneManager.CurrentScene; | ||
1755 | UUID[] acl = s.RegionInfo.EstateSettings.EstateAccess; | ||
1756 | Hashtable users = new Hashtable(); | ||
1757 | |||
1758 | foreach(UUID user in acl) | ||
1759 | { | ||
1760 | users[user.ToString()] = | ||
1761 | m_app.CommunicationsManager.UserProfileCacheService.GetUserDetails(user).UserProfile.Name; | ||
1762 | } | ||
1763 | |||
1764 | responseData["users"] = users; | ||
1765 | |||
1766 | } | ||
1767 | catch (Exception e) | ||
1768 | { | ||
1769 | m_log.InfoFormat("[RADMIN] Acces List List: {0}", e.Message); | ||
1770 | |||
1771 | responseData["success"] = "false"; | ||
1772 | responseData["error"] = e.Message; | ||
1773 | |||
1774 | } | ||
1775 | finally | ||
1776 | { | ||
1777 | response.Value = responseData; | ||
1778 | } | ||
1779 | |||
1780 | m_log.Info("[RADMIN]: Access List List Request complete"); | ||
1781 | return response; | ||
1782 | } | ||
1783 | |||
1499 | public void Dispose() | 1784 | public void Dispose() |
1500 | { | 1785 | { |
1501 | } | 1786 | } |
1502 | } | 1787 | } |
1788 | |||
1503 | } | 1789 | } |