[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Creating a new permission

Harkos

9/5/2003 5:40:00 PM

Hi everyone,

I'm currently trying to create a SecurityPermission schema where I can use
the following attribute:

[assembly:ActivationPermission ("some key", true)]

where the first parameter is some ID key, unique to the application, that I
can use to check if this copy is licensed; and the second parameter
identifies if the software must be registered in order to run. This last one
is to be used with some freeware applications where some features are locked
until registration.

Then, I want to use another atrribute within my code (mostly constructors
and methods):

[ActivationPermission (true)]

Different from the previous usage, this time I use the bool parameter to
tell if I only want to check if the application assembly containt the
attribute (false) or if the application is fully activated (true). So far
I've read enough to create the following constructors (deriving from
CodeAccessSecurityAttribute):

// This is for the assembly version
// The key is used to check the application licensing
public ActivationPermissionAttribute(stirng key, bool required) :
base(required ? SecurityAction.RequestMinimum :
SecurityAction.RequestOptional) {
this.key = key;
}

// This is for the constructor/method version
// Required means that we require the application to be activated;
otherwise
// check only if the assembly (the calling assembly, perhaps) has an
attribute
// with a valid key.
public ActivationPermissionAttribute(bool required) :
base(SecurityAction.Demand) {
this.required = required;
}

I don't know how to go any further on developing the security permissions.
The .NET Documentation is very hard to understand, and I'm not even sure if
I can do this with security permissions. Actualy no care is required over
how the licensing check is performed, only on how can I include it on my
code. Should I divide these into two permissions? Please, can someone help
me?

[]'s,
Harkos