* [MRM] Implements permission checks on IObject implementations in SOPObject.cs. Does not implement security on IObjectInventory yet.
parent
8b6d79aa3c
commit
975c49a399
|
@ -3,5 +3,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
public interface ISecurityCredential
|
||||
{
|
||||
ISocialEntity owner { get; }
|
||||
bool CanEditObject(IObject target);
|
||||
bool CanEditTerrain(int x, int y);
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using OpenSim.Framework;
|
||||
|
@ -68,6 +69,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
return m_rootScene.GetSceneObjectPart(m_localID);
|
||||
}
|
||||
|
||||
private bool CanEdit()
|
||||
{
|
||||
if(!m_security.CanEditObject(this))
|
||||
{
|
||||
throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#region OnTouch
|
||||
|
||||
private event OnTouchDelegate _OnTouch;
|
||||
|
@ -139,13 +149,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
public string Name
|
||||
{
|
||||
get { return GetSOP().Name; }
|
||||
set { GetSOP().Name = value; }
|
||||
set
|
||||
{
|
||||
if (CanEdit())
|
||||
GetSOP().Name = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get { return GetSOP().Description; }
|
||||
set { GetSOP().Description = value; }
|
||||
set
|
||||
{
|
||||
if (CanEdit())
|
||||
GetSOP().Description = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IObject[] Children
|
||||
|
@ -169,7 +187,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
|
||||
public IObject Root
|
||||
{
|
||||
get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); }
|
||||
get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId, m_security); }
|
||||
}
|
||||
|
||||
public IObjectMaterial[] Materials
|
||||
|
@ -191,7 +209,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
public Vector3 Scale
|
||||
{
|
||||
get { return GetSOP().Scale; }
|
||||
set { GetSOP().Scale = value; }
|
||||
set
|
||||
{
|
||||
if (CanEdit())
|
||||
GetSOP().Scale = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Quaternion WorldRotation
|
||||
|
@ -211,15 +233,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
get { return GetSOP().AbsolutePosition; }
|
||||
set
|
||||
{
|
||||
SceneObjectPart pos = GetSOP();
|
||||
pos.UpdateOffSet(value - pos.AbsolutePosition);
|
||||
if (CanEdit())
|
||||
{
|
||||
SceneObjectPart pos = GetSOP();
|
||||
pos.UpdateOffSet(value - pos.AbsolutePosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 OffsetPosition
|
||||
{
|
||||
get { return GetSOP().OffsetPosition; }
|
||||
set { GetSOP().OffsetPosition = value; }
|
||||
set
|
||||
{
|
||||
if (CanEdit())
|
||||
{
|
||||
GetSOP().OffsetPosition = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 SitTarget
|
||||
|
@ -319,8 +350,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
|
||||
public void Say(string msg)
|
||||
{
|
||||
SceneObjectPart sop = GetSOP();
|
||||
if (!CanEdit())
|
||||
return;
|
||||
|
||||
SceneObjectPart sop = GetSOP();
|
||||
m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false);
|
||||
}
|
||||
|
||||
|
@ -512,6 +545,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
}
|
||||
set
|
||||
{
|
||||
if (!CanEdit())
|
||||
return;
|
||||
|
||||
GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z);
|
||||
}
|
||||
}
|
||||
|
@ -525,6 +561,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
}
|
||||
set
|
||||
{
|
||||
if (!CanEdit())
|
||||
return;
|
||||
|
||||
GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z);
|
||||
}
|
||||
}
|
||||
|
@ -538,6 +577,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
}
|
||||
set
|
||||
{
|
||||
if (!CanEdit())
|
||||
return;
|
||||
|
||||
GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z);
|
||||
}
|
||||
}
|
||||
|
@ -560,27 +602,44 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
}
|
||||
set
|
||||
{
|
||||
if (!CanEdit())
|
||||
return;
|
||||
|
||||
GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z);
|
||||
}
|
||||
}
|
||||
|
||||
public bool FloatOnWater
|
||||
{
|
||||
set { GetSOP().PhysActor.FloatOnWater = value; }
|
||||
set
|
||||
{
|
||||
if (!CanEdit())
|
||||
return;
|
||||
GetSOP().PhysActor.FloatOnWater = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddForce(Vector3 force, bool pushforce)
|
||||
{
|
||||
if (!CanEdit())
|
||||
return;
|
||||
|
||||
GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce);
|
||||
}
|
||||
|
||||
public void AddAngularForce(Vector3 force, bool pushforce)
|
||||
{
|
||||
if (!CanEdit())
|
||||
return;
|
||||
|
||||
GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce);
|
||||
}
|
||||
|
||||
public void SetMomentum(Vector3 momentum)
|
||||
{
|
||||
if (!CanEdit())
|
||||
return;
|
||||
|
||||
GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z));
|
||||
}
|
||||
|
||||
|
@ -595,6 +654,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
get { return m_sculptMap; }
|
||||
set
|
||||
{
|
||||
if (!CanEdit())
|
||||
return;
|
||||
|
||||
m_sculptMap = value;
|
||||
SetPrimitiveSculpted(SculptMap, (byte) SculptType);
|
||||
}
|
||||
|
@ -607,6 +669,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
get { return m_sculptType; }
|
||||
set
|
||||
{
|
||||
if(!CanEdit())
|
||||
return;
|
||||
|
||||
m_sculptType = value;
|
||||
SetPrimitiveSculpted(SculptMap, (byte) SculptType);
|
||||
}
|
||||
|
@ -663,6 +728,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
|
||||
public void Play(UUID asset, double volume)
|
||||
{
|
||||
if (!CanEdit())
|
||||
return;
|
||||
|
||||
GetSOP().SendSound(asset.ToString(), volume, true, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||
{
|
||||
class SecurityCredential : ISecurityCredential
|
||||
{
|
||||
private readonly ISocialEntity m_owner;
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public SecurityCredential(ISocialEntity m_owner)
|
||||
{
|
||||
|
@ -17,5 +20,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
{
|
||||
get { return m_owner; }
|
||||
}
|
||||
|
||||
public bool CanEditObject(IObject target)
|
||||
{
|
||||
return m_scene.Permissions.CanEditObject(target.GlobalID, m_owner.GlobalID);
|
||||
}
|
||||
|
||||
public bool CanEditTerrain(int x, int y)
|
||||
{
|
||||
return m_scene.Permissions.CanTerraformLand(m_owner.GlobalID, new Vector3(x, y, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue