2 using System.Collections.Generic;
3 using System.Reflection;
10 namespace OpenSim.Framework
14 private static readonly ILog m_log =
16 MethodBase.GetCurrentMethod().DeclaringType);
18 private bool[] m_DisallowExport, m_DisallowImport;
19 private string[] m_AssetTypeNames;
23 Type enumType = typeof(AssetType);
24 m_AssetTypeNames = Enum.GetNames(enumType);
25 for (
int i = 0; i < m_AssetTypeNames.Length; i++)
26 m_AssetTypeNames[i] = m_AssetTypeNames[i].ToLower();
27 int n = Enum.GetValues(enumType).Length;
28 m_DisallowExport =
new bool[n];
29 m_DisallowImport =
new bool[n];
31 LoadPermsFromConfig(config,
"DisallowExport", m_DisallowExport);
32 LoadPermsFromConfig(config,
"DisallowImport", m_DisallowImport);
36 private void LoadPermsFromConfig(IConfig assetConfig,
string variable,
bool[] bitArray)
38 if (assetConfig == null)
41 string perms = assetConfig.GetString(variable, String.Empty);
42 string[] parts = perms.Split(
new char[] {
',' }, StringSplitOptions.RemoveEmptyEntries);
43 foreach (
string s
in parts)
45 int index = Array.IndexOf(m_AssetTypeNames, s.Trim().ToLower());
47 bitArray[index] =
true;
49 m_log.WarnFormat(
"[Asset Permissions]: Invalid AssetType {0}", s);
56 string assetTypeName = ((AssetType)type).ToString();
58 int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower());
59 if (index >= 0 && m_DisallowExport[index])
61 m_log.DebugFormat(
"[Asset Permissions]: Export denied: configuration does not allow export of AssetType {0}", assetTypeName);
70 string assetTypeName = ((AssetType)type).ToString();
72 int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower());
73 if (index >= 0 && m_DisallowImport[index])
75 m_log.DebugFormat(
"[Asset Permissions]: Import denied: configuration does not allow import of AssetType {0}", assetTypeName);
bool AllowedExport(sbyte type)
bool AllowedImport(sbyte type)
AssetPermissions(IConfig config)