URLConnection.Permission Property

Definition

Returns a permission object representing the permission necessary to make the connection represented by this object.

public virtual Java.Security.Permission? Permission { [Android.Runtime.Register("getPermission", "()Ljava/security/Permission;", "GetGetPermissionHandler")] get; }
[<get: Android.Runtime.Register("getPermission", "()Ljava/security/Permission;", "GetGetPermissionHandler")>]
member this.Permission : Java.Security.Permission

Property Value

the permission object representing the permission necessary to make the connection represented by this URLConnection.

Attributes

Exceptions

if an I/O error occurs while creating the permission object.

Remarks

Returns a permission object representing the permission necessary to make the connection represented by this object. This method returns null if no permission is required to make the connection. By default, this method returns java.security.AllPermission. Subclasses should override this method and return the permission that best represents the permission required to make a a connection to the URL. For example, a URLConnection representing a file: URL would return a java.io.FilePermission object.

The permission returned may dependent upon the state of the connection. For example, the permission before connecting may be different from that after connecting. For example, an HTTP sever, say foo.com, may redirect the connection to a different host, say bar.com. Before connecting the permission returned by the connection will represent the permission needed to connect to foo.com, while the permission returned after connecting will be to bar.com.

Permissions are generally used for two purposes: to protect caches of objects obtained through URLConnections, and to check the right of a recipient to learn about a particular URL. In the first case, the permission should be obtained <em>after</em> the object has been obtained. For example, in an HTTP connection, this will represent the permission to connect to the host from which the data was ultimately fetched. In the second case, the permission should be obtained and tested <em>before</em> connecting.

Java documentation for java.net.URLConnection.getPermission().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to