Skip to content
Related Articles

Related Articles

Improve Article Class in Java
  • Difficulty Level : Basic
  • Last Updated : 17 Mar, 2021

The class represents whether you have permission to access a network via sockets. A SocketPermission consists of a host and a set of actions.

Class Declaration:

public final class SocketPermission
extends Permission
implements Serializable


ManagementPermission(String name)This constructs a ManagementPermission with the specified name.
ManagementPermission(String name, String actions)This constructs a new ManagementPermission object.

public SocketPermission(String host, String action): 

Used for creating a new object of SocketPermission class with specified actions.


equals(object obj)It checks whether the two SocketPermission objects are equal or not.
getActions()It returns the actions of this SocketPermission object in String format
hashcode()It returns the hash code value for this object.
implies(Permission p)It checks whether this SocketPermssion object implies this permission or not.
newPermissonCollection()It returns a new PermissionCollection object.



// Java Program to show the usage of 
// Class
public class Socket {
    public static void main(String args[])
        try {
            // getting permission object
            Permission p = getPermission();
            // print actions of permission p
            // printing hashcode vlaue of permission p
            // creating a permissionCollection object and
            // printing it
            PermissionCollection p1 = p.newPermissionCollection();
        catch (Exception e) {
            System.err.print("Permission denied");
    public static Permission getPermission()
        throws IOException
        int port = 3000;
        String host = "localhost";
        return new SocketPermission(host + ":" + port,
-1204607085 (

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :