aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Util.cs63
1 files changed, 63 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index aaa2724..e5ff27a 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1694,5 +1694,68 @@ namespace OpenSim.Framework
1694 return (T)Enum.Parse(typeof(T), value); ; 1694 return (T)Enum.Parse(typeof(T), value); ;
1695 } 1695 }
1696 #endregion 1696 #endregion
1697
1698 #region Universal User Identifiers
1699 /// <summary>
1700 /// </summary>
1701 /// <param name="value">uuid[;endpoint[;name]]</param>
1702 /// <param name="uuid"></param>
1703 /// <param name="url"></param>
1704 /// <param name="firstname"></param>
1705 /// <param name="lastname"></param>
1706 public static bool ParseUniversalUserIdentifier(string value, out UUID uuid, out string url, out string firstname, out string lastname, out string secret)
1707 {
1708 uuid = UUID.Zero; url = string.Empty; firstname = "Unknown"; lastname = "User"; secret = string.Empty;
1709
1710 string[] parts = value.Split(';');
1711 if (parts.Length >= 1)
1712 if (!UUID.TryParse(parts[0], out uuid))
1713 return false;
1714
1715 if (parts.Length >= 2)
1716 url = parts[1];
1717
1718 if (parts.Length >= 3)
1719 {
1720 string[] name = parts[2].Split();
1721 if (name.Length == 2)
1722 {
1723 firstname = name[0];
1724 lastname = name[1];
1725 }
1726 }
1727 if (parts.Length >= 4)
1728 secret = parts[3];
1729
1730 return true;
1731 }
1732
1733 /// <summary>
1734 ///
1735 /// </summary>
1736 /// <param name="acircuit"></param>
1737 /// <returns>uuid[;endpoint[;name]]</returns>
1738 public static string ProduceUserUniversalIdentifier(AgentCircuitData acircuit)
1739 {
1740 if (acircuit.ServiceURLs.ContainsKey("HomeURI"))
1741 {
1742 string agentsURI = acircuit.ServiceURLs["HomeURI"].ToString();
1743 if (!agentsURI.EndsWith("/"))
1744 agentsURI += "/";
1745
1746 // This is ugly, but there's no other way, given that the name is changed
1747 // in the agent circuit data for foreigners
1748 if (acircuit.lastname.Contains("@"))
1749 {
1750 string[] parts = acircuit.firstname.Split(new char[] { '.' });
1751 if (parts.Length == 2)
1752 return acircuit.AgentID.ToString() + ";" + agentsURI + ";" + parts[0] + " " + parts[1];
1753 }
1754 return acircuit.AgentID.ToString() + ";" + agentsURI + ";" + acircuit.firstname + " " + acircuit.lastname;
1755 }
1756 else
1757 return acircuit.AgentID.ToString();
1758 }
1759 #endregion
1697 } 1760 }
1698} 1761}