diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Util.cs | 25 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 45 |
2 files changed, 47 insertions, 23 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 4e75a5c..875f4ad 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -2744,7 +2744,9 @@ namespace OpenSim.Framework | |||
2744 | #endregion | 2744 | #endregion |
2745 | 2745 | ||
2746 | #region Universal User Identifiers | 2746 | #region Universal User Identifiers |
2747 | /// <summary> | 2747 | |
2748 | /// <summary> | ||
2749 | /// Attempts to parse a UUI into its components: UUID, name and URL. | ||
2748 | /// </summary> | 2750 | /// </summary> |
2749 | /// <param name="value">uuid[;endpoint[;first last[;secret]]]</param> | 2751 | /// <param name="value">uuid[;endpoint[;first last[;secret]]]</param> |
2750 | /// <param name="uuid">the uuid part</param> | 2752 | /// <param name="uuid">the uuid part</param> |
@@ -2780,6 +2782,27 @@ namespace OpenSim.Framework | |||
2780 | } | 2782 | } |
2781 | 2783 | ||
2782 | /// <summary> | 2784 | /// <summary> |
2785 | /// For foreign avatars, extracts their original name and Server URL from their First Name and Last Name. | ||
2786 | /// </summary> | ||
2787 | public static bool ParseForeignAvatarName(string firstname, string lastname, | ||
2788 | out string realFirstName, out string realLastName, out string serverURI) | ||
2789 | { | ||
2790 | realFirstName = realLastName = serverURI = string.Empty; | ||
2791 | |||
2792 | if (!lastname.Contains("@")) | ||
2793 | return false; | ||
2794 | |||
2795 | if (!firstname.Contains(".")) | ||
2796 | return false; | ||
2797 | |||
2798 | realFirstName = firstname.Split('.')[0]; | ||
2799 | realLastName = firstname.Split('.')[1]; | ||
2800 | serverURI = new Uri("http://" + lastname.Replace("@", "")).ToString(); | ||
2801 | |||
2802 | return true; | ||
2803 | } | ||
2804 | |||
2805 | /// <summary> | ||
2783 | /// Produces a universal (HG) system-facing identifier given the information | 2806 | /// Produces a universal (HG) system-facing identifier given the information |
2784 | /// </summary> | 2807 | /// </summary> |
2785 | /// <param name="acircuit"></param> | 2808 | /// <param name="acircuit"></param> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 1c404bb..123f8ca 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2053,47 +2053,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2053 | CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); | 2053 | CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); |
2054 | m_host.AddScriptLPS(1); | 2054 | m_host.AddScriptLPS(1); |
2055 | 2055 | ||
2056 | if (lastname.Contains("@")) | 2056 | IUserManagement userManager = World.RequestModuleInterface<IUserManagement>(); |
2057 | if (userManager == null) | ||
2057 | { | 2058 | { |
2058 | String realFirstName; String realLastName; String serverURI; | 2059 | OSSLShoutError("osAvatarName2Key: UserManagement module not available"); |
2060 | return string.Empty; | ||
2061 | } | ||
2062 | |||
2063 | // Check if the user is already cached | ||
2064 | |||
2065 | UUID userID = userManager.GetUserIdByName(firstname, lastname); | ||
2066 | if (userID != UUID.Zero) | ||
2067 | return userID.ToString(); | ||
2059 | 2068 | ||
2060 | realFirstName = firstname.Split('.')[0]; | 2069 | // Query for the user |
2061 | realLastName = firstname.Split('.')[1]; | ||
2062 | serverURI = new Uri("http://" + lastname.Replace("@", "")).ToString(); | ||
2063 | 2070 | ||
2071 | String realFirstName; String realLastName; String serverURI; | ||
2072 | if (Util.ParseForeignAvatarName(firstname, lastname, out realFirstName, out realLastName, out serverURI)) | ||
2073 | { | ||
2064 | try | 2074 | try |
2065 | { | 2075 | { |
2066 | UserAgentServiceConnector userConnection = new UserAgentServiceConnector(serverURI, true); | 2076 | UserAgentServiceConnector userConnection = new UserAgentServiceConnector(serverURI, true); |
2067 | 2077 | ||
2068 | if (userConnection != null) | 2078 | if (userConnection != null) |
2069 | { | 2079 | { |
2070 | UUID ruserid = userConnection.GetUUID(realFirstName, realLastName); | 2080 | userID = userConnection.GetUUID(realFirstName, realLastName); |
2071 | 2081 | if (userID != UUID.Zero) | |
2072 | if (ruserid != null) | ||
2073 | { | 2082 | { |
2074 | IUserManagement userManager = m_ScriptEngine.World.RequestModuleInterface<IUserManagement>(); | 2083 | userManager.AddUser(userID, realFirstName, realLastName, serverURI); |
2075 | 2084 | return userID.ToString(); | |
2076 | if (userManager != null) | ||
2077 | { | ||
2078 | //Use the HomeURI from the script to get user infos and then ask the remote gridserver for the real HomeURI. | ||
2079 | userManager.AddUser(ruserid, realFirstName, realLastName, serverURI); | ||
2080 | serverURI = userManager.GetUserServerURL(ruserid, "HomeURI"); | ||
2081 | userManager.AddUser(ruserid, realFirstName, realLastName, serverURI); | ||
2082 | |||
2083 | return ruserid.ToString(); | ||
2084 | } | ||
2085 | } | 2085 | } |
2086 | } | 2086 | } |
2087 | } | 2087 | } |
2088 | catch (Exception osAvatarException) | 2088 | catch (Exception /*e*/) |
2089 | { | 2089 | { |
2090 | //m_log.Warn("[osAvatarName2Key] UserAgentServiceConnector - Unable to connect to destination grid\n" + osAvatarException.Message); | 2090 | // m_log.Warn("[osAvatarName2Key] UserAgentServiceConnector - Unable to connect to destination grid ", e); |
2091 | } | 2091 | } |
2092 | } | 2092 | } |
2093 | else | 2093 | else |
2094 | { | 2094 | { |
2095 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname); | 2095 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname); |
2096 | if (account != null) return account.PrincipalID.ToString(); | 2096 | if (account != null) |
2097 | return account.PrincipalID.ToString(); | ||
2097 | } | 2098 | } |
2098 | 2099 | ||
2099 | return UUID.Zero.ToString(); | 2100 | return UUID.Zero.ToString(); |