hostaddr + ":" + socket4.getLocalPort(), "accept")};
Permission[] checkSetFactory = new Permission[] {
new RuntimePermission("setFactory")};
TestSecurityManager sm = new TestSecurityManager(harness);
try {
sm.install();
// throwpoint: java.net.DatagramSocket-DatagramSocket()
harness.checkPoint("DatagramSocket()");
try {
sm.prepareChecks(checkListen1024plus);
new DatagramSocket().close();
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
// throwpoint: java.net.DatagramSocket-DatagramSocket(SocketAddress)
harness.checkPoint("DatagramSocket(SocketAddress)");
try {
sm.prepareChecks(checkListen80);
try {
new DatagramSocket(new InetSocketAddress(inetaddr, 80)).close();
}
catch (BindException e) {
}
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
try {
sm.prepareChecks(checkListen1024plus);
new DatagramSocket(new InetSocketAddress(inetaddr, 0)).close();
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
// throwpoint: java.net.DatagramSocket-DatagramSocket(int)
harness.checkPoint("DatagramSocket(int)");
try {
sm.prepareChecks(checkListen80);
try {
new DatagramSocket(80).close();
}
catch (BindException e) {
}
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
try {
sm.prepareChecks(checkListen1024plus);
new DatagramSocket(0).close();
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
// throwpoint: java.net.DatagramSocket-DatagramSocket(int, InetAddress)
harness.checkPoint("DatagramSocket(int, InetAddress)");
try {
sm.prepareChecks(checkListen80);
try {
new DatagramSocket(80, inetaddr).close();
}
catch (BindException e) {
}
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
try {
sm.prepareChecks(checkListen1024plus);
new DatagramSocket(0, inetaddr).close();
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
// throwpoint: java.net.DatagramSocket-connect
harness.checkPoint("connect");
try {
sm.prepareChecks(checkConnect1, checkAccept1);
socket2.connect(sock1addr);
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
try {
sm.prepareChecks(checkConnect2, checkAccept2);
socket1.connect(sock2addr, socket2.getLocalPort());
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
// throwpoint: java.net.DatagramSocket-send
harness.checkPoint("send");
try {
sm.prepareChecks(checkConnect3);
socket4.send(sendpack);
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
// throwpoint: java.net.DatagramSocket-receive
harness.checkPoint("receive");
try {
sm.prepareChecks(checkAccept4);
socket3.receive(recvpack);
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
// throwpoint: java.net.DatagramSocket-getLocalAddress
harness.checkPoint("getLocalAddress");
try {
sm.prepareChecks(checkResolve);
socket1.getLocalAddress();
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
// throwpoint: java.net.DatagramSocket-getLocalSocketAddress
harness.checkPoint("getLocalSocketAddress");
try {
sm.prepareChecks(checkResolve);
socket1.getLocalSocketAddress();
sm.checkAllChecked();
}
catch (SecurityException e) {
harness.debug(e);
harness.check(false, "unexpected check");
}
// throwpoint: java.net.Socket-setDatagramSocketImplFactory
harness.checkPoint("setDatagramSocketImplFactory");
try {
sm.prepareHaltingChecks(checkSetFactory);
DatagramSocket.setDatagramSocketImplFactory(null);
harness.check(false);
}
catch (TestSecurityManager.SuccessException ex) {
harness.check(true);
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
}
finally {
sm.uninstall();
}
}
catch (Exception e) {
harness.debug(e);
harness.check(false, "Unexpected exception");