Namespace: System.Security

Provides types that form the basis of the .NET Framework security model.

The System.Security namespace is a foundational part of the .NET Framework, offering essential types for managing identity, permissions, and cryptography. It allows developers to implement robust security measures within their applications, ensuring secure access to resources and protecting sensitive data.

Key Concepts

  • Identity: Represents the security identity of a code or user.
  • Permissions: Defines the rights that code has to perform specific security-sensitive operations.
  • Cryptography: Provides access to cryptographic services, including hashing, encryption, and digital signatures.
  • Principal: Represents the security principal (user or application) that is performing an action.

Classes

Principal Class

Represents the security principal (user or application) that is performing an action.

public abstract class Principal : MarshalByRefObject, System.Security.Principal.IPrincipal

Classes that implement IPrincipal represent the security context of the current thread.

Members:
  • Identity property: Gets the identity of the current principal.
  • IsInRole(string role) method: Determines whether the current principal is in the specified role.

See Full Documentation

Identity Class

Represents the security identity of a code or user.

public abstract class Identity : MarshalByRefObject, System.Security.Principal.IIdentity

The Identity class is the base class for all identity objects in the .NET Framework security system.

Properties:
  • Name property: Gets the name of the current identity.
  • AuthenticationType property: Gets the type of authentication used to determine the name.
  • IsAuthenticated property: Gets a value indicating whether the user has been authenticated.

See Full Documentation

SecurityIdentifier Class

Represents a security identifier (SID).

public sealed class SecurityIdentifier : System.Security.Principal.IdentityReference

A Security Identifier (SID) is a unique, immutable value used to identify a security principal or security group.

Constructors:
  • SecurityIdentifier(string sid)
  • SecurityIdentifier(WellKnownSidType sidType, SecurityIdentifier domainSid)
Methods:
  • Translate(Type targetType) method: Translates the SID to a different representation.
  • IsAccountSid() method: Determines whether the SID represents an account.

See Full Documentation

Claims Namespace

Contains types related to managing and processing claims, which are assertions of information about a subject.

The System.Security.Claims namespace provides a flexible and standardized way to represent and manage claims, which are key-value pairs that describe a characteristic of a subject, such as a name, role, or group membership.

Key Types:
  • Claim class: Represents a single claim.
  • ClaimsIdentity class: Represents an identity that is defined by a set of claims.
  • ClaimsPrincipal class: Represents a principal that is defined by a set of ClaimsIdentity objects.

See Full Documentation

Cryptography Namespace

Contains cryptographic services, including encryption, decryption, and digital signatures.

The System.Security.Cryptography namespace provides algorithms that can be used to encrypt and decrypt data, sign data to ensure its integrity and authenticity, and hash data to create a secure representation.

Key Classes:
  • SymmetricAlgorithm class: Abstract base class for symmetric encryption algorithms.
  • AsymmetricAlgorithm class: Abstract base class for asymmetric encryption algorithms.
  • HashAlgorithm class: Abstract base class for hashing algorithms.
  • RSACryptoServiceProvider class: Implements the RSA algorithm.
  • SHA256Managed class: Implements the SHA256 hashing algorithm.

See Full Documentation