use of java.net.SocketPermission in project wildfly by wildfly.
the class PasswordMaskingInContainerTestCase method deploy.
@Deployment
public static WebArchive deploy() {
WebArchive war = ShrinkWrap.create(WebArchive.class, "passwordMasking" + ".war");
war.addClass(PasswordMaskingTestServlet.class);
war.setWebXML(PasswordMaskingInContainerTestCase.class.getPackage(), "web.xml");
war.addAsManifestResource(createPermissionsXmlAsset(new SocketPermission("*:9092", "connect,resolve")), "permissions.xml");
return war;
}
use of java.net.SocketPermission in project jdk8u_jdk by JetBrains.
the class MailToURLConnection method getPermission.
@Override
public Permission getPermission() throws IOException {
if (permission == null) {
connect();
String host = client.getMailHost() + ":" + 25;
permission = new SocketPermission(host, "connect");
}
return permission;
}
use of java.net.SocketPermission in project jdk8u_jdk by JetBrains.
the class MyBasicPermission method trySockPC.
static void trySockPC() throws Exception {
try {
SocketPermission p0 = new SocketPermission("example.com", "connect");
PermissionCollection pc = p0.newPermissionCollection();
// this should lock out future adds
pc.setReadOnly();
//
SocketPermission p1 = new SocketPermission("example.net", "connect");
pc.add(p1);
throw new Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");
} catch (SecurityException se) {
System.out.println("SocketPermissionCollection passed");
}
}
use of java.net.SocketPermission in project jdk8u_jdk by JetBrains.
the class EmptyInputStream method followRedirect.
/* Tells us whether to follow a redirect. If so, it
* closes the connection (break any keep-alive) and
* resets the url, re-connects, and resets the request
* property.
*/
private boolean followRedirect() throws IOException {
if (!getInstanceFollowRedirects()) {
return false;
}
final int stat = getResponseCode();
if (stat < 300 || stat > 307 || stat == 306 || stat == HTTP_NOT_MODIFIED) {
return false;
}
final String loc = getHeaderField("Location");
if (loc == null) {
/* this should be present - if not, we have no choice
* but to go forward w/ the response we got
*/
return false;
}
URL locUrl;
try {
locUrl = new URL(loc);
if (!url.getProtocol().equalsIgnoreCase(locUrl.getProtocol())) {
return false;
}
} catch (MalformedURLException mue) {
// treat loc as a relative URI to conform to popular browsers
locUrl = new URL(url, loc);
}
final URL locUrl0 = locUrl;
// force recalculation
socketPermission = null;
SocketPermission p = URLtoSocketPermission(locUrl);
if (p != null) {
try {
return AccessController.doPrivilegedWithCombiner(new PrivilegedExceptionAction<Boolean>() {
public Boolean run() throws IOException {
return followRedirect0(loc, stat, locUrl0);
}
}, null, p);
} catch (PrivilegedActionException e) {
throw (IOException) e.getException();
}
} else {
// run without additional permission
return followRedirect0(loc, stat, locUrl);
}
}
use of java.net.SocketPermission in project jdk8u_jdk by JetBrains.
the class FtpURLConnection method getPermission.
/**
* Gets the <code>Permission</code> associated with the host & port.
*
* @return The <code>Permission</code> object.
*/
@Override
public Permission getPermission() {
if (permission == null) {
int urlport = url.getPort();
urlport = urlport < 0 ? FtpClient.defaultPort() : urlport;
String urlhost = this.host + ":" + urlport;
permission = new SocketPermission(urlhost, "connect");
}
return permission;
}
Aggregations