Re: cutome Code Access Permission Attribute Problem
From: Dominick Baier [DevelopMentor] (dbaier_at_pleasepleasenospamdevelop.com)
Date: 10/21/05
- Previous message: Claus Konrad: "Re: Logon with Digital Siganture (PKI/OCES - or what else they're called)"
- Maybe in reply to: Sanjaya: "cutome Code Access Permission Attribute Problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 20 Oct 2005 23:12:39 -0700
Hello Sanjaya,
you are not really building a code access permission, because you implemented
demand yourself - you are not doing a stack walk here - what you are trying
to build is something like PrincipalPermission.
grab a copy of reflector (www.aisto.com/roeder) and have a look at System.Security.Permissions.PrincipalPermission
and see how MS does it.
e.g. you only have to derive from IPermission, ISecurityEncodable
my From/To Xml looks like this:
public void FromXml(SecurityElement e)
{
string oid = e.Attribute("OperationID");
this._operationId = Convert.ToInt32(oid, CultureInfo.InvariantCulture);
}
public SecurityElement ToXml()
{
SecurityElement element = new SecurityElement("IPermission");
Type type = this.GetType();
StringBuilder AssemblyName = new StringBuilder(type.Assembly.ToString());
AssemblyName.Replace('\"', '\'');
element.AddAttribute("class", type.FullName + ", " + AssemblyName);
element.AddAttribute("version", "1");
element.AddAttribute("OperationID", _operationId.ToString(CultureInfo.InvariantCulture));
return element;
}
---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com
> Hi Dominick,
>
> Yes it is 1.1 and i have added it to the "policy assembly" as
> well.
>
> I'm not sure if it is something to do with the de/serialization in
> FromXml/ToXml. attached here is my code. pls see if you can find wny
> errors.
>
> Best Regards
> Sanjaya
> "Dominick Baier [DevelopMentor]"
> <dbaier@pleasepleasenospamdevelop.com> wrote in message
> news:42565460115b5f8c7a37ad0e31550@news.microsoft.com...
>
>> Hello Sanjaya,
>>
>> is this 1.1 ?
>>
>> if yes- the assembly containig the perm and attr must be in the
>> "policy
>>
> assembly"
>
>> list in mscorfg.msc.
>>
>> Your error sounds like a problem with de/serialization in
>> FromXml/ToXml.
>>
>> ---------------------------------------
>> Dominick Baier - DevelopMentor
>> http://www.leastprivilege.com
>>> Hi
>>>
>>> I have implemented a custom code access permission class and a
>>> corresponding attribute class. I have inherited my permission class
>>> from CodeAccessPermission and the attribute class from
>>> CodeAccessSecurityAttribute class.
>>>
>>> I have assign a strong name to the assembly and deploy it to GAC.
>>>
>>> when I try to use my custom permission class for imperative
>>> check, it happens successfully. but when I try to use the attribute
>>> class(MyPermissionAttribute) for declarative check, the application
>>> give following compilation error.
>>> "C:\MyTestApp\Form1.cs(197): Error emitting
>>> 'MySecurity.MyPermissionAttribute' attribute -- 'Unexpected
>>> exception processing attribute -- System.ArgumentNullException:
>>> Value cannot be null. Parameter name: child.'
>>>
>>> can anyone pls help me to with this?
>>>
- Previous message: Claus Konrad: "Re: Logon with Digital Siganture (PKI/OCES - or what else they're called)"
- Maybe in reply to: Sanjaya: "cutome Code Access Permission Attribute Problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]