System.Security.Policy.StrongNameMembershipCondition Class

Assembly: Mscorlib.dll
Namespace: System.Security.Policy
Summary
Determines whether an assembly belongs to a code group by testing its strong name. This class cannot be inherited.
C# Syntax:
[Serializable]
public sealed class StrongNameMembershipCondition : IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
Remarks
Strong names are well suited to specifying code assemblies to which you give a rich set of powerful permissions. Since strong names are cryptographically verified, attackers cannot impersonate rightful assemblies and use their permissions.
See also:
System.Security.Policy Namespace

System.Security.Policy.StrongNameMembershipCondition Member List:

Public Constructors
ctor #1 Initializes a new instance of the StrongNameMembershipCondition class with the strong name public key blob, name, and version number that determine membership.
Public Properties
Name Read-write

Gets or sets the simple name of the StrongName for which the membership condition tests.
PublicKey Read-write

Gets or sets the StrongNamePublicKeyBlob of the StrongName for which the membership condition tests.
Version Read-write

Gets or sets the Version of the StrongName for which the membership condition tests.
Public Methods
Check Determines whether the specified evidence satisfies the membership condition.
Copy Creates an equivalent copy of the current StrongNameMembershipCondition.
Equals Overridden:
Determines whether the StrongName from the specified object is equivalent to the StrongName contained in the current StrongNameMembershipCondition.
FromXml Overloaded:
FromXml(SecurityElement e)

Reconstructs a security object with a specified state from an XML encoding.
FromXml Overloaded:
FromXml(SecurityElement e, PolicyLevel level)

Reconstructs a security object with a specified state from an XML encoding.
GetHashCode Overridden:
Returns the hash code for the current StrongNameMembershipCondition.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString Overridden:
Creates and returns a string representation of the current StrongNameMembershipCondition.
ToXml Overloaded:
ToXml()

Creates an XML encoding of the security object and its current state.
ToXml Overloaded:
ToXml(PolicyLevel level)

Creates an XML encoding of the security object and its current state with the specified PolicyLevel.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Security.Policy.StrongNameMembershipCondition Member Details

ctor #1
Summary
Initializes a new instance of the StrongNameMembershipCondition class with the strong name public key blob, name, and version number that determine membership.
C# Syntax:
public StrongNameMembershipCondition(
   StrongNamePublicKeyBlob blob,
   string name,
   Version version
);
Parameters:

blob

The strong name public key blob of the software publisher.

name

The simple name section of the strong name.

version

The version number of the strong name.

Exceptions
Exception Type Condition
ArgumentNullException The blob parameter is null.
Remarks
Strong names are well suited to specifying code assemblies to which you give a rich set of powerful permissions. Since strong names are cryptographically verified, attackers cannot impersonate rightful assemblies and use their permissions. The name and version parameters are optional. For example, you can create a StrongNameMembershipCondition that checks for StrongNameMembershipCondition.PublicKey and StrongNameMembershipCondition.Name (but not StrongNameMembershipCondition.Version) by passing null into the version parameter.

Return to top


Property: Name (read-write)
Summary
Gets or sets the simple name of the StrongName for which the membership condition tests.
C# Syntax:
public string Name {get; set;}

Return to top


Property: PublicKey (read-write)
Summary
Gets or sets the StrongNamePublicKeyBlob of the StrongName for which the membership condition tests.
C# Syntax:
public StrongNamePublicKeyBlob PublicKey {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException An attempt is made to set the StrongNameMembershipCondition.PublicKey to null.
Remarks
A blob is cryptographic information that uniquely specifies the public key of the software publisher.

Blobs differ from certificates in that the blob only has information about the public key; the certificate also includes information that associates a name of the holder with the key, as well as information to verify the certificate.

Return to top


Property: Version (read-write)
Summary
Gets or sets the Version of the StrongName for which the membership condition tests.
C# Syntax:
public Version Version {get; set;}
See also:
Version

Return to top


Method: Check(
   Evidence evidence
)
Summary
Determines whether the specified evidence satisfies the membership condition.
C# Syntax:
public bool Check(
   Evidence evidence
);
Parameters:

evidence

The Evidence against which to make the test.

Return Value:
true if the specified evidence satisfies the membership condition; otherwise, false.
Implements:
IMembershipCondition.Check
Remarks
This membership condition tests only the StrongName evidence object.

The membership condition is satisfied if the specified evidence contains a StrongName with the same StrongName (public key, name, and version) as specified by the StrongNameMembershipCondition.

Return to top


Method: Copy()
Summary
Creates an equivalent copy of the current StrongNameMembershipCondition.
C# Syntax:
public IMembershipCondition Copy();
Return Value:
A new, identical copy of the current StrongNameMembershipCondition
Implements:
IMembershipCondition.Copy

Return to top


Overridden Method: Equals(
   object o
)
Summary
Determines whether the StrongName from the specified object is equivalent to the StrongName contained in the current StrongNameMembershipCondition.
C# Syntax:
public override bool Equals(
   object o
);
Parameters:

o

The object to compare to the current StrongNameMembershipCondition.

Return Value:
true if the StrongName from the specified object is equivalent to the StrongName contained in the current StrongNameMembershipCondition; otherwise, false.
Implements:
IMembershipCondition.Equals
Remarks
For two StrongName classes to be equal, their name, version, and public key blob must match exactly.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~StrongNameMembershipCondition();

For more information on members inherited from System.Object click on the link above.

Return to top


Overloaded Method: FromXml(
   SecurityElement e
)
Summary
Reconstructs a security object with a specified state from an XML encoding.
C# Syntax:
public void FromXml(
   SecurityElement e
);
Parameters:

e

The XML encoding to use to reconstruct the security object.

Implements:
ISecurityEncodable.FromXml

Return to top


Overloaded Method: FromXml(
   SecurityElement e,
   PolicyLevel level
)
Summary
Reconstructs a security object with a specified state from an XML encoding.
C# Syntax:
public void FromXml(
   SecurityElement e,
   PolicyLevel level
);
Parameters:

e

The XML encoding to use to reconstruct the security object.

level

The PolicyLevel context, used to resolve NamedPermissionSet references.

Exceptions
Exception Type Condition
ArgumentNullException The e parameter is null.
ArgumentException The e parameter is not a valid membership condition element.
Implements:
ISecurityPolicyEncodable.FromXml

Return to top


Overridden Method: GetHashCode()
Summary
Returns the hash code for the current StrongNameMembershipCondition.
C# Syntax:
public override int GetHashCode();
Return Value:
The hash code for the current StrongNameMembershipCondition.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Overridden Method: ToString()
Summary
Creates and returns a string representation of the current StrongNameMembershipCondition.
C# Syntax:
public override string ToString();
Return Value:
A representation of the current StrongNameMembershipCondition.
Implements:
IMembershipCondition.ToString

Return to top


Overloaded Method: ToXml()
Summary
Creates an XML encoding of the security object and its current state.
C# Syntax:
public SecurityElement ToXml();
Return Value:
An XML encoding of the security object, including any state information.
Implements:
ISecurityEncodable.ToXml

Return to top


Overloaded Method: ToXml(
   PolicyLevel level
)
Summary
Creates an XML encoding of the security object and its current state with the specified PolicyLevel.
C# Syntax:
public SecurityElement ToXml(
   PolicyLevel level
);
Parameters:

level

The PolicyLevel context, which is used to resolve NamedPermissionSet references.

Return Value:
An XML encoding of the security object, including any state information.
Implements:
ISecurityPolicyEncodable.ToXml

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.