Package java.net

Examples of java.net.SocketPermission


          String host = getCodeBase().getHost();

              if (host != null && (host.length() > 0)) {
                // add permission for downloaded jars to access host they were from
                perms.add(new SocketPermission(host, SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
              }
              else if ( "file".equals(codesource.getLocation().getProtocol()) ) {
                // if running locally add file permission
                String path = codesource.getLocation().getFile().replace('/', File.separatorChar);
                  perms.add(new FilePermission(path, SecurityConstants.FILE_READ_ACTION));
View Full Code Here


  }
  if (!host.startsWith("[") && host.indexOf(':') != -1) {
      host = "[" + host + "]";
  }
  if (port == -1) {
      checkPermission(new SocketPermission(host,
    SecurityConstants.SOCKET_RESOLVE_ACTION));
  } else {
      checkPermission(new SocketPermission(host+":"+port,
    SecurityConstants.SOCKET_CONNECT_ACTION));
  }
    }
View Full Code Here

  }
  if (!host.startsWith("[") && host.indexOf(':') != -1) {
      host = "[" + host + "]";
  }
  if (port == -1)
      checkPermission(new SocketPermission(host,
    SecurityConstants.SOCKET_RESOLVE_ACTION),
    context);
  else
      checkPermission(new SocketPermission(host+":"+port,
    SecurityConstants.SOCKET_CONNECT_ACTION),
    context);
    }
View Full Code Here

     */
    public void checkListen(int port) {
  if (port == 0) {
      checkPermission(SecurityConstants.LOCAL_LISTEN_PERMISSION);
  } else {
      checkPermission(new SocketPermission("localhost:"+port,
    SecurityConstants.SOCKET_LISTEN_ACTION));
  }
    }
View Full Code Here

      throw new NullPointerException("host can't be null");
  }
  if (!host.startsWith("[") && host.indexOf(':') != -1) {
      host = "[" + host + "]";
  }
  checkPermission(new SocketPermission(host+":"+port,
      SecurityConstants.SOCKET_ACCEPT_ACTION));
    }
View Full Code Here

    public void checkMulticast(InetAddress maddr) {
  String host = maddr.getHostAddress();
  if (!host.startsWith("[") && host.indexOf(':') != -1) {
      host = "[" + host + "]";
  }
        checkPermission(new SocketPermission(host,
      SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
    }
View Full Code Here

    public void checkMulticast(InetAddress maddr, byte ttl) {
  String host = maddr.getHostAddress();
  if (!host.startsWith("[") && host.indexOf(':') != -1) {
      host = "[" + host + "]";
  }
        checkPermission(new SocketPermission(host,
      SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
    }
View Full Code Here

    } else if (!thisHost.equals(thatHost)) {
        if (thatHost == null) {
      return false;
        }
        if (this.sp == null) {
      this.sp = new SocketPermission(thisHost, "resolve");
        }
        if (that.sp == null) {
      that.sp = new SocketPermission(thatHost, "resolve");
        }
        if (!this.sp.implies(that.sp)) {
      return false;
        }
    }
View Full Code Here

                .equals(perm));

        URL httpUrl = new URL("http://home/myfile/");
        assertTrue("Wrong http: permission", httpUrl.openConnection()
                .getPermission().equals(
                        new SocketPermission("home:80", "connect")));
        httpUrl = new URL("http://home2:8080/myfile/");
        assertTrue("Wrong http: permission", httpUrl.openConnection()
                .getPermission().equals(
                        new SocketPermission("home2:8080", "connect")));
        URL ftpUrl = new URL("ftp://home/myfile/");
        assertTrue("Wrong ftp: permission", ftpUrl.openConnection()
                .getPermission().equals(
                        new SocketPermission("home:21", "connect")));
        ftpUrl = new URL("ftp://home2:22/myfile/");
        assertTrue("Wrong ftp: permission", ftpUrl.openConnection()
                .getPermission().equals(
                        new SocketPermission("home2:22", "connect")));

        URL jarUrl = new URL("jar:file:myfile!/");
        perm = new FilePermission("myfile", "read");
        result = jarUrl.openConnection().getPermission();
        assertTrue("Wrong jar: permission:" + perm + " , " + result, result
View Full Code Here

    }

    @Override
    public Permission getPermission() throws IOException {
        return new SocketPermission(getHostName() + ":" + getHostPort(), //$NON-NLS-1$
                "connect, resolve"); //$NON-NLS-1$
    }
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.