Package java.net

Examples of java.net.SocketPermission


        }
        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


     * @exception  SecurityException  if the calling thread does not have
     *             permission to listen on the specified port.
     * @see        #checkPermission(java.security.Permission) checkPermission
     */
    public void checkListen(int port) {
        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

            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 void test_ConstructorLjava_lang_StringLjava_lang_String() {
        assertEquals("Incorrect name", starName, star_Resolve.getName());
        assertEquals("Incorrect actions", "resolve", star_Resolve.getActions());

        SocketPermission sp1 = new SocketPermission("", "connect");
        assertEquals("Wrong name1", "localhost", sp1.getName());
        SocketPermission sp2 = new SocketPermission(":80", "connect");
        assertEquals("Wrong name2", ":80", sp2.getName());

        // Regression for HARMONY-1462
        SocketPermission sp3 = new SocketPermission("localhost:*", "listen");
        assertEquals("Wrong name3", "localhost:*", sp3.getName());
        // For all ports
        SocketPermission spAllPorts = new SocketPermission("localhost:0-65535",
                "listen");
        assertTrue("Port range error", sp3.implies(spAllPorts));
        assertTrue("Port range error", spAllPorts.implies(sp3));
    }
View Full Code Here

                .equals(star_All));
        assertTrue("Same but returned unequal", www_All.equals(copyOfWww_All));
        assertTrue("Returned true when compared to a String", !www_All
                .equals(www_All.toString()));

        SocketPermission sp1 = new SocketPermission("TEST1.com",
                "resolve,connect");
        SocketPermission sp2 = new SocketPermission("test1.com",
                "resolve,connect");
        assertTrue("Different cases should be equal", sp1.equals(sp2));

        // Regression for HARMONY-1524
        assertFalse(sp1.equals(null));

        // Regression for HARMONY-3333
        sp1 = new SocketPermission("TEST1.com:333", "resolve");
        sp2 = new SocketPermission("test1.com:444", "resolve");
        assertTrue("Different cases should be equal", sp1.equals(sp2));

        sp1 = new SocketPermission(Support_Configuration.InetTestAddress,
                "resolve,connect");
        sp2 = new SocketPermission(Support_Configuration.InetTestIP,
                "resolve,connect");
        assertEquals("Same IP address should be equal", sp1, sp2);
    }
View Full Code Here

        assertTrue("Wild should imply normal", star_All.implies(www_All));
        assertTrue("Normal shouldn't imply wildcard", !www_All
                .implies(star_Resolve));
        assertTrue("Resolve shouldn't imply all", !star_Resolve
                .implies(star_All));
        SocketPermission p1 = new SocketPermission(wwwName + ":80-81",
                "connect");
        SocketPermission p2 = new SocketPermission(wwwName + ":80", "connect");
        assertTrue("Port 80 is implied by 80-81", p1.implies(p2));
        p1 = new SocketPermission(wwwName + ":79-80", "connect");
        assertTrue("Port 80 is implied by 79-80", p1.implies(p2));
        p1 = new SocketPermission(wwwName + ":79-81", "connect");
        assertTrue("Port 80 is implied by 79-81", p1.implies(p2));
        p2 = new SocketPermission(wwwName + ":79-80", "connect");
        assertTrue("Port 79-80 is implied by 79-81", p1.implies(p2));
        p2 = new SocketPermission(wwwName, "resolve");
        assertTrue(
                "Any identical host should imply resolve regardless of the ports",
                p1.implies(p2));

        SocketPermission sp1 = new SocketPermission("www.Ibm.com", "resolve");
        SocketPermission sp2 = new SocketPermission("www.IBM.com", "resolve");
        assertTrue("SocketPermission is case sensitive", sp1.implies(sp2));

        SocketPermission sp3 = new SocketPermission("*.ibm.com", "resolve");
        assertTrue("SocketPermission wildcard is case sensitive", sp3
                .implies(sp2));

        InetAddress host = null;
        try {
            host = InetAddress.getByName(Support_Configuration.UnresolvedIP);
        } catch (UnknownHostException e) {
        }

        SocketPermission perm1 = new SocketPermission(
                Support_Configuration.UnresolvedIP, "connect");
        SocketPermission perm2 = new SocketPermission(
                Support_Configuration.UnresolvedIP + ":80", "connect");
        assertTrue("should imply port 80", perm1.implies(perm2));
        PermissionCollection col = perm1.newPermissionCollection();
        col.add(perm1);
        assertTrue("collection should imply port 80", col.implies(perm2));
View Full Code Here

        assertTrue("Should imply resolve on " + starName, pc
                .implies(star_Resolve));
        assertTrue("Should imply all on " + wwwName, pc.implies(www_All));

        pc = star_Resolve.newPermissionCollection();
        SocketPermission p1 = new SocketPermission(wwwName + ":79-80",
                "connect");
        pc.add(p1);
        SocketPermission p2 = new SocketPermission(wwwName, "resolve");
        assertTrue(
                "Any identical host should imply resolve regardless of the ports",
                pc.implies(p2));
        assertTrue("A different host should not imply resolve", !pc
                .implies(star_Resolve));
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.