Package java.net

Examples of java.net.SocketPermission


   
    /**
     * @tests serialization/deserialization.
     */
    public void testSerializationSelf() throws Exception {
        SocketPermission permission = new SocketPermission("harmony.apache.org", "connect");;

        SerializationTest.verifySelf(permission);
    }
View Full Code Here


String name, String actions) {
// XXX shorten list to most popular ones?
if (claz.equals(FilePermission.class)) {
return new FilePermission(name, actions);
} else if (claz.equals(SocketPermission.class)) {
return new SocketPermission(name, actions);
} else if (claz.equals(RuntimePermission.class)) {
return new RuntimePermission(name, actions);
} else if (claz.equals(PropertyPermission.class)) {
return new PropertyPermission(name, actions);
} else if (claz.equals(NetPermission.class)) {
View Full Code Here

    public synchronized void enablePermissionCache(PermissionCache c) {
  if (c != null) {
      cache = c;
      connectPerm = new CachedPermissionImpl
    (cache, new SocketPermission("*","connect"));
      cacheEnabled = true;
  }
    }
View Full Code Here

      addPermission(new MBeanServerPermission("newMBeanServer"));

      JMXServiceURL url = createJMXConnectorServerAddress();
      JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, createServerEnvironment(), newMBeanServer());

      addPermission(new SocketPermission("localhost:" + url.getPort(), "listen"));
      try
      {
         cntorServer.start();
      }
      finally
View Full Code Here

      JMXServiceURL url = createJMXConnectorServerAddress();
      JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, createServerEnvironment(), newMBeanServer());

      // Required by the server
      addPermission(new SocketPermission("localhost:" + url.getPort(), "listen"));

      JMXConnector cntor = null;
      try
      {
         cntorServer.start();

         RemoteModifiablePolicy policy = (RemoteModifiablePolicy)Policy.getPolicy();
         policy.setSeparateClientServerPermissions(true);

         try
         {
            JMXConnectorFactory.connect(cntorServer.getAddress());
            fail();
         }
         catch (SecurityException x)
         {
         }

         // Allow any client to connect to the server
         addPermission(new SocketPermission("*:1024-" + url.getPort(), "accept"));
         // Allow this client to open a socket to connect to the server
         policy.addClientPermission(new SocketPermission("localhost:" + url.getPort(), "connect"));
         cntor = JMXConnectorFactory.connect(cntorServer.getAddress());
      }
      finally
      {
         if (cntor != null) cntor.close();
View Full Code Here

      try
      {
         cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, serverEnv, newMBeanServer());

         // Required by the server
         addPermission(new SocketPermission("localhost:" + url.getPort(), "listen"));
         cntorServer.start();

         RemoteModifiablePolicy policy = (RemoteModifiablePolicy)Policy.getPolicy();
         policy.setSeparateClientServerPermissions(true);

         Map clientEnv = createClientEnvironment();
         clientEnv.put(JMXConnector.CREDENTIALS, new String[]{"test", "test"});
         // Allow this client to open a socket to connect to the server
         policy.addClientPermission(new SocketPermission("localhost:" + url.getPort(), "connect"));
         // Allow the authenticated subject to listen and accept a connection
         policy.addServerPermission(new JMXPrincipal("test"), new SocketPermission("localhost:" + url.getPort(), "listen"));
         policy.addServerPermission(new JMXPrincipal("test"), new SocketPermission("*:1024-" + url.getPort(), "accept"));

         // No credentials
         try
         {
            JMXConnectorFactory.connect(cntorServer.getAddress());
View Full Code Here

      try
      {
         cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, serverEnv, newMBeanServer());

         // Required by the server
         addPermission(new SocketPermission("localhost:" + url.getPort(), "listen"));
         cntorServer.start();

         policy.setSeparateClientServerPermissions(true);

         Map clientEnv = createClientEnvironment();
         clientEnv.put(JMXConnector.CREDENTIALS, new String[]{"test", "test"});
         policy.addClientPermission(new SocketPermission("localhost:" + url.getPort(), "connect"));
         policy.addServerPermission(new JMXPrincipal("test"), new AuthPermission("doAsPrivileged"));
         policy.addServerPermission(new JMXPrincipal("test"), new SocketPermission("localhost:" + url.getPort(), "listen"));
         policy.addServerPermission(new JMXPrincipal("test"), new SocketPermission("*:1024-" + url.getPort(), "accept"));
         cntor = JMXConnectorFactory.connect(cntorServer.getAddress(), clientEnv);

         addPermission(new MBeanTrustPermission("*"));
         policy.addServerPermission(new JMXPrincipal("test"), new MBeanPermission("*", "instantiate, registerMBean, getAttribute"));
         MBeanServerConnection cntion = cntor.getMBeanServerConnection();
View Full Code Here

      JMXConnector cntor = null;
      try
      {
         cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, createServerEnvironment(), newMBeanServer());
         // Required by the server
         addPermission(new SocketPermission("localhost:" + url.getPort(), "listen"));
         cntorServer.start();

         policy.setSeparateClientServerPermissions(true);

         policy.addClientPermission(new SocketPermission("localhost:" + url.getPort(), "connect"));
         addPermission(new SocketPermission("localhost:" + url.getPort(), "listen"));
         addPermission(new SocketPermission("*:1024-" + url.getPort(), "accept"));
         cntor = JMXConnectorFactory.connect(cntorServer.getAddress(), createClientEnvironment());

         MBeanServerConnection cntion = cntor.getMBeanServerConnection();

         testAddRemoveNotificationListener(cntion);
View Full Code Here

      JMXConnector cntor = null;
      try
      {
         cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, createServerEnvironment(), newMBeanServer());
         // Required by the server
         addPermission(new SocketPermission("localhost:" + url.getPort(), "listen"));
         cntorServer.start();

         policy.setSeparateClientServerPermissions(true);

         policy.addClientPermission(new SocketPermission("localhost:" + url.getPort(), "connect"));
         addPermission(new SocketPermission("localhost:" + url.getPort(), "listen"));
         addPermission(new SocketPermission("*:1024-" + url.getPort(), "accept"));
         cntor = JMXConnectorFactory.connect(cntorServer.getAddress(), createClientEnvironment());

         MBeanServerConnection cntion = cntor.getMBeanServerConnection();

         testCreateMBean4Params(cntion);
View Full Code Here

      JMXConnector cntor = null;
      try
      {
         cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, createServerEnvironment(), newMBeanServer());
         // Required by the server
         addPermission(new SocketPermission("localhost:" + url.getPort(), "listen"));
         cntorServer.start();

         policy.setSeparateClientServerPermissions(true);

         policy.addClientPermission(new SocketPermission("localhost:" + url.getPort(), "connect"));
         addPermission(new SocketPermission("localhost:" + url.getPort(), "listen"));
         addPermission(new SocketPermission("*:1024-" + url.getPort(), "accept"));
         cntor = JMXConnectorFactory.connect(cntorServer.getAddress(), createClientEnvironment());

         MBeanServerConnection cntion = cntor.getMBeanServerConnection();

         testCreateMBean5Params(cntion);
View Full Code Here

TOP

Related Classes of java.net.SocketPermission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.