java.net.SocketPermission Class in Java Last Updated : 19 Aug, 2021 Comments Improve Suggest changes Like Article Like Report The java.net.SocketPermisson 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 SerializableConstructor: ConstructorDescriptionManagementPermission(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. Methods: MethodDescriptionequals(object obj)It checks whether the two SocketPermission objects are equal or not.getActions()It returns the actions of this SocketPermission object in String formathashcode()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. Example: Java // Java Program to show the usage of // java.net.SocketPermission Class import java.io.IOException; import java.net.SocketPermission; import java.security.Permission; import java.security.PermissionCollection; public class Socket { public static void main(String args[]) { try { // getting permission object Permission p = getPermission(); // print actions of permission p System.out.println(p.getActions()); // printing hashcode value of permission p System.out.println(p.hashCode()); // creating a permissionCollection object and // printing it PermissionCollection p1 = p.newPermissionCollection(); System.out.print(p1); } 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, "Connect,resolve"); } } Outputconnect,resolve -1204607085 java.net.SocketPermissionCollection@30dae81 ( ) Comment More infoAdvertise with us Next Article java.net.SocketPermission Class in Java S sahilkumar101 Follow Improve Article Tags : Java Java-net-package Practice Tags : Java Similar Reads java.net.NetPermission Class in Java NetPermission class is used to allow network permissions. NetPermission class extends BasicPermission class. It is a ânamedâ permission i.e it contains a name but no action. Permission nameWhat permission allowsRisks associated with this permissionallowHttpTraceThis permission allows using the HTTP 4 min read java.net.SocketOption Class in Java The java.net.SocketOption is a socket option that is connected with a socket, as the set of channels packages is java.nio.channels.NetworkChannel that this interface has defined the setOption as well as the getOption methods to set and query's the channels within its Socket Options. --> java.net 5 min read java.net.Socket Class in Java The java.net.Socket class allows us to create socket objects that help us in implementing all fundamental socket operations. We can perform various networking operations such as sending, reading data and closing connections. Each Socket object that has been created using with java.net.Socket class h 5 min read java.lang.reflect.ReflectPermission Class in Java ReflectPermission class extends BasicPermission class. It is a ânamedâ permission i.e it contains a name but no action. It may implement actions on top of BasicPermission, if desired. It is used to get information about the behaviour of Constructors. ConstructorsDescriptionReflectPermission(String n 2 min read Java.util.PropertyPermission class in Java This class is for property permission. It extends BasicPermission. The name is the name of the property ("java.home", "os.name", etc). The naming convention follows the hierarchical property naming convention. Also, an asterisk may appear at the end of the name, following a ".", or by itself, to sig 4 min read Like