aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/HypergridService/HGAssetService.cs63
1 files changed, 5 insertions, 58 deletions
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs
index d6541c4..f1275a0 100644
--- a/OpenSim/Services/HypergridService/HGAssetService.cs
+++ b/OpenSim/Services/HypergridService/HGAssetService.cs
@@ -58,8 +58,7 @@ namespace OpenSim.Services.HypergridService
58 58
59 private UserAccountCache m_Cache; 59 private UserAccountCache m_Cache;
60 60
61 private bool[] m_DisallowGET, m_DisallowPOST; 61 private AssetPermissions m_AssetPerms;
62 private string[] m_AssetTypeNames;
63 62
64 public HGAssetService(IConfigSource config, string configName) : base(config, configName) 63 public HGAssetService(IConfigSource config, string configName) : base(config, configName)
65 { 64 {
@@ -85,31 +84,7 @@ namespace OpenSim.Services.HypergridService
85 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); 84 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
86 85
87 // Permissions 86 // Permissions
88 Type enumType = typeof(AssetType); 87 m_AssetPerms = new AssetPermissions(assetConfig);
89 m_AssetTypeNames = Enum.GetNames(enumType);
90 for (int i = 0; i < m_AssetTypeNames.Length; i++)
91 m_AssetTypeNames[i] = m_AssetTypeNames[i].ToLower();
92 int n = Enum.GetValues(enumType).Length;
93 m_DisallowGET = new bool[n];
94 m_DisallowPOST = new bool[n];
95
96 LoadPermsFromConfig(assetConfig, "DisallowGET", m_DisallowGET);
97 LoadPermsFromConfig(assetConfig, "DisallowPOST", m_DisallowPOST);
98
99 }
100
101 private void LoadPermsFromConfig(IConfig assetConfig, string variable, bool[] bitArray)
102 {
103 string perms = assetConfig.GetString(variable, String.Empty);
104 string[] parts = perms.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries);
105 foreach (string s in parts)
106 {
107 int index = Array.IndexOf(m_AssetTypeNames, s.Trim().ToLower());
108 if (index >= 0)
109 bitArray[index] = true;
110 else
111 m_log.WarnFormat("[HGAsset Service]: Invalid AssetType {0}", s);
112 }
113 88
114 } 89 }
115 90
@@ -121,7 +96,7 @@ namespace OpenSim.Services.HypergridService
121 if (asset == null) 96 if (asset == null)
122 return null; 97 return null;
123 98
124 if (!AllowedGet(asset.Type)) 99 if (!m_AssetPerms.AllowedExport(asset.Type))
125 return null; 100 return null;
126 101
127 if (asset.Metadata.Type == (sbyte)AssetType.Object) 102 if (asset.Metadata.Type == (sbyte)AssetType.Object)
@@ -151,7 +126,7 @@ namespace OpenSim.Services.HypergridService
151 if (asset == null) 126 if (asset == null)
152 return null; 127 return null;
153 128
154 if (!AllowedGet(asset.Type)) 129 if (!m_AssetPerms.AllowedExport(asset.Type))
155 return null; 130 return null;
156 131
157 return asset.Data; 132 return asset.Data;
@@ -161,7 +136,7 @@ namespace OpenSim.Services.HypergridService
161 136
162 public override string Store(AssetBase asset) 137 public override string Store(AssetBase asset)
163 { 138 {
164 if (!AllowedPost(asset.Type)) 139 if (!m_AssetPerms.AllowedImport(asset.Type))
165 return UUID.Zero.ToString(); 140 return UUID.Zero.ToString();
166 141
167 return base.Store(asset); 142 return base.Store(asset);
@@ -175,34 +150,6 @@ namespace OpenSim.Services.HypergridService
175 150
176 #endregion 151 #endregion
177 152
178 protected bool AllowedGet(sbyte type)
179 {
180 string assetTypeName = ((AssetType)type).ToString();
181
182 int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower());
183 if (index >= 0 && m_DisallowGET[index])
184 {
185 m_log.DebugFormat("[HGAsset Service]: GET denied: service does not allow export of AssetType {0}", assetTypeName);
186 return false;
187 }
188
189 return true;
190 }
191
192 protected bool AllowedPost(sbyte type)
193 {
194 string assetTypeName = ((AssetType)type).ToString();
195
196 int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower());
197 if (index >= 0 && m_DisallowPOST[index])
198 {
199 m_log.DebugFormat("[HGAsset Service]: POST denied: service does not allow import of AssetType {0}", assetTypeName);
200 return false;
201 }
202
203 return true;
204 }
205
206 protected void AdjustIdentifiers(AssetMetadata meta) 153 protected void AdjustIdentifiers(AssetMetadata meta)
207 { 154 {
208 if (meta == null || m_Cache == null) 155 if (meta == null || m_Cache == null)