[Mono-devel-list] Questions on security attributes

Sebastien Pouliot spouliot at videotron.ca
Thu Sep 16 07:14:07 EDT 2004


Hello Alexis,

>1) Anyone know how SetCustomAttributes responds to SecurityAttributes
>on MS.NET? Will it treat them as plain custom attributes, or will it
>tell the difference and parse them as security? I need to know to see
>where I should make Mono do the same.

Good question as SecurityAttribute derives from Attribute. The best* way to
know this is to try it on the MS runtime (if you don't have MS runtime
accessible then I can help you on IRC).

* Actually the real best way is to write this as a unit test so it can be
reused afterward to ensure that the feature won't get broken in future
versions of Mono.

>2) I get a CustomAttributeBuilder object and wish to actually create
>the SecurityAttribute object (so as to  CreatePermission ().toXML ()
>). I couldn't find a method that does this from a
>CustomAttributeBuilder, but I could define an internal call in the
>runtime and build it myself (this could be useful for other purposes
>too). Should I do this? It's not hard but I feel like I'm missing
>something.

I'm not sure where you are exactly when doing this.

Producer:
When generating assemblies adding permissions is done by calling
AddDeclarativeSecurity. The security attributes are executed by the
compilers (like mcs) to generate the XML (which is then stored in the
compiled assembly metadata).

Consumer:
The security attributes are encoded as permission sets in the metadata as
XML. PermissionSet.FromXml will be able to recreate the permissions (once
you have the XML).

Sebastien Pouliot
home: spouliot at videotron.ca
blog: http://pages.infinit.net/ctech/poupou.html




More information about the Mono-devel-list mailing list