28 using System.Reflection;
32 using OpenSim.Framework;
33 using OpenSim.Services.Interfaces;
35 namespace OpenSim.Framework.Serialization
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 public const string OSPA_PREFIX =
"ospa:";
46 public const string OSPA_NAME_KEY =
"n";
47 public const string OSPA_NAME_VALUE_SEPARATOR =
" ";
48 public const string OSPA_TUPLE_SEPARATOR =
"|";
49 public static readonly
char[] OSPA_TUPLE_SEPARATOR_ARRAY = OSPA_TUPLE_SEPARATOR.ToCharArray();
50 public const string OSPA_PAIR_SEPARATOR =
"=";
60 if (userService == null)
62 m_log.Warn(
"[OSP RESOLVER]: UserService is null");
63 return userId.ToString();
66 UserAccount account = userService.GetUserAccount(UUID.Zero, userId);
85 public static string MakeOspa(
string firstName,
string lastName)
88 = OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName;
111 if (!ospa.StartsWith(OSPA_PREFIX))
119 string ospaMeat = ospa.Substring(OSPA_PREFIX.Length);
120 string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY);
122 foreach (
string tuple
in ospaTuples)
124 int tupleSeparatorIndex = tuple.IndexOf(OSPA_PAIR_SEPARATOR);
126 if (tupleSeparatorIndex < 0)
128 m_log.WarnFormat(
"[OSP RESOLVER]: Ignoring non-tuple component {0} in OSPA {1}", tuple, ospa);
132 string key = tuple.Remove(tupleSeparatorIndex).Trim();
133 string value = tuple.Substring(tupleSeparatorIndex + 1).Trim();
135 if (OSPA_NAME_KEY == key)
136 return ResolveOspaName(value, userService);
149 return new UUID(
Utils.MD5(Encoding.Unicode.GetBytes(name)), 0);
163 if (userService == null)
166 int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR);
168 if (nameSeparatorIndex < 0)
170 m_log.WarnFormat(
"[OSP RESOLVER]: Ignoring unseparated name {0}", name);
174 string firstName = name.Remove(nameSeparatorIndex).TrimEnd();
175 string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart();
177 UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName);
184 return account.PrincipalID;
static UUID ResolveOspa(string ospa, IUserAccountService userService)
Resolve an osp string into the most suitable internal OpenSim identifier.
static UUID HashName(string name)
Hash a profile name into a UUID
OpenSim.Server.Handlers.Simulation.Utils Utils
static string MakeOspa(UUID userId, IUserAccountService userService)
Make an OSPA given a user UUID
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString key
static string MakeOspa(string firstName, string lastName)
Make an OSPA given a user name
Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for identify...
static UUID ResolveOspaName(string name, IUserAccountService userService)
Resolve an OSPI name by querying existing persistent user profiles. If there is no persistent user pr...