[Serializable] |
ctor #1 | Overloaded:.ctor(PermissionState state) Initializes a new instance of the SocketPermission class that allows unrestricted access to the Socket or disallows access to the Socket. |
ctor #2 | Overloaded:.ctor(NetworkAccess access, TransportType transport, string hostName, int portNumber) Initializes a new instance of the SocketPermission class for the given transport address with the specified permission. |
AllPorts | Defines a constant representing all ports. |
AcceptList | Read-only Gets a list of EndpointPermission instances identifying the endpoints that can be accepted under this permission instance. |
ConnectList | Read-only Gets a list of EndpointPermission instances identifying the endpoints that can be connected to under this permission instance. |
AddPermission | Adds a permission to the set of permissions for a transport address. |
Assert (inherited from System.Security.CodeAccessPermission) |
See base class member description: System.Security.CodeAccessPermission.Assert Asserts that calling code can access the resource identified by the current permission through the code that calls this method, even if callers higher in the stack have not been granted permission to access the resource. |
Copy | Overridden: Creates a copy of a SocketPermission instance. |
Demand (inherited from System.Security.CodeAccessPermission) |
See base class member description: System.Security.CodeAccessPermission.Demand Forces a SecurityException at run time if all callers higher in the call stack have not been granted the permission specified by the current instance. |
Deny (inherited from System.Security.CodeAccessPermission) |
See base class member description: System.Security.CodeAccessPermission.Deny Prevents callers higher in the call stack from using the code that calls this method to access the resource specified by the current instance. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
FromXml | Overridden: Reconstructs a SocketPermission instance for an XML encoding. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
Intersect | Overridden: Returns the logical intersection between two SocketPermission instances. |
IsSubsetOf | Overridden: Determines if the current permission is a subset of the specified permission. |
IsUnrestricted | Checks the overall permission state of the object. |
PermitOnly (inherited from System.Security.CodeAccessPermission) |
See base class member description: System.Security.CodeAccessPermission.PermitOnly Prevents callers higher in the call stack from using the code that calls this method to access all resources except for the resource specified by the current instance. |
ToString (inherited from System.Security.CodeAccessPermission) |
See base class member description: System.Security.CodeAccessPermission.ToString Creates and returns a string representation of the current permission object. |
ToXml | Overridden: Creates an XML encoding of a SocketPermission instance and its current state. |
Union | Overridden: Returns the logical union between two SocketPermission instances. |
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:
public SocketPermission( |
state
public SocketPermission( |
access
transport
hostName
portNumber
The hostName can be a DNS name, an IP address, or a specified IP subnet using, such as 192.168.1.*.
The portNumber can be any valid port number defined by the transport, or SocketPermission.AllPorts.
public const int AllPorts;
|
public IEnumerator AcceptList {get;}
|
public IEnumerator ConnectList {get;}
|
public void AddPermission( |
access
transport
hostName
portNumber
public void Assert(); |
Exception Type | Condition |
---|---|
SecurityException | The calling code does not have SecurityPermissionFlag.Assertion. -or- There is already an active CodeAccessPermission.Assert for the current frame. |
The call to CodeAccessPermission.Assert is effective until the calling code returns to its caller. Only one CodeAccessPermission.Assert can be active on a frame. An attempt to call CodeAccessPermission.Assert when an active CodeAccessPermission.Assert exists on the frame results in a SecurityException. Call CodeAccessPermission.RevertAssert or CodeAccessPermission.RevertAll to remove an active CodeAccessPermission.Assert.
CodeAccessPermission.Assert is ignored for a permission not granted because a demand for that permission will not succeed. However, if code lower on the call stack calls CodeAccessPermission.Demand for that permission, a SecurityException is thrown when the stack walk reaches the code that tried to call CodeAccessPermission.Assert. This happens because the code that called CodeAccessPermission.Assert has not been granted the permission, even though it tried to CodeAccessPermission.Assert it.
Because calling CodeAccessPermission.Assert removes the requirement that all code in the call chain must be granted permission to access the specified resource, it can open up security vulnerabilities if used incorrectly or inappropriately. Therefore, it should be used with great caution.
public override IPermission Copy(); |
public void Demand(); |
Exception Type | Condition |
---|---|
SecurityException | A caller higher in the call stack does not have the permission specified by the current instance. -or- A caller higher in the call stack has called CodeAccessPermission.Deny on the current permission object. |
The permissions of the code that calls this method are not examined; the check begins from the immediate caller of that code and proceeds up the stack. The call stack is typically represented as growing down, so that methods higher in the call stack call methods lower in the call stack. CodeAccessPermission.Demand succeeds only if no SecurityException is raised.
public void Deny(); |
Exception Type | Condition |
---|---|
SecurityException | There is already an active CodeAccessPermission.Deny for the current frame. |
CodeAccessPermission.Deny can limit the liability of the programmer or prevent accidental security vulnerabilities because it prevents the method that calls CodeAccessPermission.Deny from being used to access the resource protected by the denied permission. If a method calls CodeAccessPermission.Deny on a permission, and if a CodeAccessPermission.Demand for that permission is invoked by a caller lower in the call stack, that security check will fail when it reaches the CodeAccessPermission.Deny.
The call to CodeAccessPermission.Deny is effective until the calling code returns to its caller. Only one CodeAccessPermission.Deny can be active on a frame. An attempt to call CodeAccessPermission.Deny when an active CodeAccessPermission.Deny exists on the frame results in a SecurityException. Call CodeAccessPermission.RevertDeny or CodeAccessPermission.RevertAll to remove an active CodeAccessPermission.Deny. CodeAccessPermission.Deny is ignored for a permission not granted because a demand for that permission will not succeed.
~SocketPermission(); |
public override void FromXml( |
securityElement
Exception Type | Condition |
---|---|
ArgumentNullException | The securityElement is null -or- The securityElement is not a permission element for this type. |
Use the SocketPermission.ToXml method to encode the SocketPermission instance, including state information, in XML.
public virtual int GetHashCode(); |
public Type GetType(); |
public override IPermission Intersect( |
target
Exception Type | Condition |
---|---|
ArgumentException | The target parameter is not a SocketPermission. |
SecurityException | DnsPermission is not granted to the method caller and DNS resolution is required to complete the operation. |
public override bool IsSubsetOf( |
target
Exception Type | Condition |
---|---|
ArgumentException | target is not a SocketException. |
SecurityException | DnsPermission is not granted to the method caller and DNS resolution is required to complete the operation. |
For example, a permission that represents access to 192.168.1.1:80 is a subset of a permission that represents access to 192.168.1.1:Any. If this method returns true, the current permission represents no more access to the protected resource than does the specified permission.
public bool IsUnrestricted(); |
protected object MemberwiseClone(); |
public void PermitOnly(); |
Exception Type | Condition |
---|---|
SecurityException | There is already an active CodeAccessPermission.PermitOnly for the current frame. |
Call this method to ensure that your code can be used to access only the specified resources. The call to CodeAccessPermission.PermitOnly is effective until the calling code returns to its caller. Only one CodeAccessPermission.PermitOnly can be active on a frame. An attempt to call CodeAccessPermission.PermitOnly when an active CodeAccessPermission.PermitOnly exists on the frame results in a SecurityException. Call CodeAccessPermission.RevertPermitOnly or CodeAccessPermission.RevertAll to remove an active CodeAccessPermission.PermitOnly.
CodeAccessPermission.PermitOnly is ignored for a permission not granted because a demand for that permission will not succeed. However, if code lower on the call stack later calls CodeAccessPermission.Demand for that permission, a SecurityException is thrown when the stack walk reaches the code that tried to call CodeAccessPermission.PermitOnly. This is because the code that called CodeAccessPermission.PermitOnly has not been granted the permission, even though it called CodeAccessPermission.PermitOnly for that permission. The call stack is typically represented as growing down, so that methods higher in the call stack call methods lower in the call stack.
public override string ToString(); |
public override SecurityElement ToXml(); |
Use the SocketPermission.FromXml method to restore the state information from a SecurityElement instance.
public override IPermission Union( |
target
Exception Type | Condition |
---|---|
ArgumentNullException | target is null. |
ArgumentException | target is not a SocketPermission. |