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