Package java.net

Examples of java.net.SocketPermission$EphemeralRange


          result.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


            if (docURL.getPort() != -1) {
                docHost += ":" + docURL.getPort();
            }

            permissions[0][0] = "SocketPermission accept " + docHost;
            permissions[0][1] = new SocketPermission(docHost, "accept");
            permissions[1][0] = "SocketPermission connect " + docHost;
            permissions[1][1] = new SocketPermission(docHost, "connect");
            permissions[2][0] = "SocketPermission resolve " + docHost;
            permissions[2][1] = new SocketPermission(docHost, "resolve");
            nGrantedTmp = 3;
        } else {
            permissions = basePermissions;
        }
View Full Code Here

            if (docURL.getPort() != -1) {
                docHost += ":" + docURL.getPort();
            }

            permissions[0][0] = "SocketPermission accept " + docHost;
            permissions[0][1] = new SocketPermission(docHost, "accept");
            permissions[1][0] = "SocketPermission connect " + docHost;
            permissions[1][1] = new SocketPermission(docHost, "connect");
            permissions[2][0] = "SocketPermission resolve " + docHost;
            permissions[2][1] = new SocketPermission(docHost, "resolve");
            nGrantedTmp = 3;
        } else {
            permissions = basePermissions;
        }
View Full Code Here

  public FirewallingSecurityManager()
  {
    parent = System.getSecurityManager();

    final SocketPermission localHost = new SocketPermission(LOCALHOST, PERMISSION_VALUE);
    final SocketPermission localHostRaw = new SocketPermission(LOCALHOST_IP, PERMISSION_VALUE);
    final SocketPermission localHostFqn = new SocketPermission(LOCALHOST_LOCALDOMAIN, PERMISSION_VALUE);
    permissionCollection = localHost.newPermissionCollection();
    permissionCollection.add(localHost);
    permissionCollection.add(localHostRaw);
    permissionCollection.add(localHostFqn);
  }
View Full Code Here

   
    for (int i = 0; i < hosts.length; i++) {
      for (int j = 0; j < ports.length; j++) {
  Test test = new Test(hosts[i], ports[j]);
 
  SocketPermission px = new SocketPermission(test.x, "connect");
  SocketPermission py = new SocketPermission(test.y, "connect");

  try {
    harness.check(px.implies(py) == test.expect, test.x + " should"
      + (test.expect ? "" : " not") + " imply " + test.y);
  }
  catch (Exception e) {
    harness.check(false, test.x + " implies " + test.y + " failed");
    harness.debug(e);
  }
      }
    }

    harness.checkPoint("actions checking");
    for (int i = 1; i < 1 << actions.length; i++) {
      for (int j = 1; j < 1 << actions.length; j++) {
  SocketPermission pi = new SocketPermission("localhost", makeAction(i));
  SocketPermission pj = new SocketPermission("localhost", makeAction(j));

  harness.check(pi.implies(pj) == ((maybeAddResolve(i) & j) == j));
      }
    }
  }
View Full Code Here

      byte[] recvbuf = new byte[sendbuf.length];
      DatagramPacket recvpack = new DatagramPacket(recvbuf, recvbuf.length);
   
      Permission[] checkResolve = new Permission[] {
  new SocketPermission(hostaddr, "resolve")};
     
      Permission[] checkListen80 = new Permission[] {
   new SocketPermission("localhost:80", "listen")};

      Permission[] checkListen1024plus = new Permission[] {
   new SocketPermission("localhost:1024-", "listen")};

      Permission[] checkConnect1 = new Permission[] {
  new SocketPermission(
    hostaddr + ":" + socket1.getLocalPort(), "connect")};

      Permission[] checkAccept1 = new Permission[] {
  new SocketPermission(
    hostaddr + ":" + socket1.getLocalPort(), "accept")};
     
      Permission[] checkConnect2 = new Permission[] {
  new SocketPermission(
    hostaddr + ":" + socket2.getLocalPort(), "connect")};
     
      Permission[] checkAccept2 = new Permission[] {
  new SocketPermission(
    hostaddr + ":" + socket2.getLocalPort(), "accept")};
     
      Permission[] checkConnect3 = new Permission[] {
  new SocketPermission(
    hostaddr + ":" + socket3.getLocalPort(), "connect")};
     
      Permission[] checkAccept4 = new Permission[] {
  new SocketPermission(
    hostaddr + ":" + socket4.getLocalPort(), "accept")};
     
      Permission[] checkSetFactory = new Permission[] {
   new RuntimePermission("setFactory")};
View Full Code Here

      ServerSocket socket = new ServerSocket(0, 50, inetaddr);
      int hostport = socket.getLocalPort();

      Permission[] checkConnect = new Permission[] {
  new SocketPermission(hostaddr + ":" + hostport, "connect")};

      Permission[] checkResolveConnect = new Permission[] {
  new SocketPermission(hostname, "resolve"),
  new SocketPermission(hostaddr + ":" + hostport, "connect")};

      Permission[] checkSelectorProvider = new Permission[] {
  new RuntimePermission("selectorProvider")};

      Permission[] checkSetFactory = new Permission[] {
View Full Code Here

    harness.checkPoint("serialization checking");
   
    for (int i = 0; i < hosts.length; i++) {
      for (int j = 0; j < ports.length; j++) {
  for (int k = 1; k < 1 << actions.length; k++) {
    SocketPermission p1 = new SocketPermission(
      hosts[i] + ports[j], makeActions(k));
    SocketPermission p2 = null;
    try {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      ObjectOutput out = new ObjectOutputStream(buffer);
      out.writeObject(p1);
      out.close();
View Full Code Here

      int sport = ssocket.getLocalPort();
      Socket csocket = new Socket(inetaddr, sport, inetaddr, 0);
      int cport = csocket.getLocalPort();
     
      Permission[] checkListen80 = new Permission[] {
   new SocketPermission("localhost:80", "listen")};

      Permission[] checkListen1024plus = new Permission[] {
   new SocketPermission("localhost:1024-", "listen")};

      Permission[] checkAccept = new Permission[] {
   new SocketPermission(hostaddr + ":" + cport, "accept")};

      Permission[] checkSelectorProvider = new Permission[] {
  new RuntimePermission("selectorProvider")};

      Permission[] checkSetFactory = new Permission[] {
View Full Code Here

      for (int j = 0; j < ports.length; j++) {
  Test test = new Test(hosts[i], ports[j]);
  boolean success;

  try {
    new SocketPermission(test.hostport, "connect");
    success = true;
  }
  catch (IllegalArgumentException e) {
    success = false;
  }
View Full Code Here

TOP

Related Classes of java.net.SocketPermission$EphemeralRange

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.