<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to DenyPermissionsForExecutableJar</title><link>https://sourceforge.net/p/pro-grade/wiki/DenyPermissionsForExecutableJar/</link><description>Recent changes to DenyPermissionsForExecutableJar</description><atom:link href="https://sourceforge.net/p/pro-grade/wiki/DenyPermissionsForExecutableJar/feed" rel="self"/><language>en</language><lastBuildDate>Tue, 08 Nov 2016 21:26:27 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/pro-grade/wiki/DenyPermissionsForExecutableJar/feed" rel="self" type="application/rss+xml"/><item><title>DenyPermissionsForExecutableJar modified by Josef Cacek</title><link>https://sourceforge.net/p/pro-grade/wiki/DenyPermissionsForExecutableJar/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v5
+++ v6
@@ -1,10 +1,8 @@
-# Use policy with deny rule for an executable JAR file
+# Use policy with deny rules for an executable JAR file

 This tutorial shows how to use pro-grade policy with **deny rules**.

-We will start a Jetty web server and use policy file with deny rule to restrict access to the application. The access over the loopback interface (`localhost`) will not be possible, other interfaces should stay working.
-
-*Configuration is described for Linux/Unix systems. Use similar way for Windows.*
+We will start a [Jetty web server](http://www.eclipse.org/jetty/) and use [pro-grade](http://pro-grade.sourceforge.net/pro-grade.html) policy file with deny rules to restrict access to the application. The access from the `localhost` (i.e. loopback) will not be possible. Access for remote clients comming through other network interfaces should stay working.

 ## Prepare

@@ -17,7 +15,7 @@

     java -jar jetty-runner-9.3.14.v20161028.jar .

-If you open now http://localhost:8080/ in your brower, you should see directory listing of the current directory.
+If you open http://localhost:8080/ in your brower, you should see directory listing of the current directory.

 ## Create policy file

@@ -33,10 +31,11 @@
         permission java.net.SocketPermission "", "accept";
     }

+First rule allows everything to anyone. The second rule removes the `SocketPermission` (for localhost target and `accept` action) from the granted set.

 ## Run jetty with the new policy

-If you want to use pro-grade, you can't use `-jar` parameter as you did in previous step because you need to use classpath parameter which doesn't work together with `-jar`. You could use an uber-jar, but let's keep it simple and do it in a standard way.
+If you want to use pro-grade security manager, you can't use `-jar` parameter as you did in previous step because you need to use classpath parameter which doesn't work together with `-jar`. You could use an uber-jar, but let's keep it simple and do it in a standard way.

 The steps to do are:

@@ -54,7 +53,7 @@

 If you open/reload http://localhost:8080/ URL again, you should not be able to connect to the jetty server. Exception should appear in the jetty console window.

-You use your public address instead of loopback (localhost), then you should be able to connect to jetty without problem. (e.g. if your public IP is 192.168.1.1, then try to open http://192.168.1.1:8080/)
+Use your public address instead of loopback (localhost) and you should be able to connect to jetty without problem. (e.g. if your public IP is 192.168.1.1, then try to open http://192.168.1.1:8080/)

 ### Jasper issue

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Josef Cacek</dc:creator><pubDate>Tue, 08 Nov 2016 21:26:27 -0000</pubDate><guid>https://sourceforge.netfd6eb9be4500a79dd97e5f16ec38aefade74ca54</guid></item><item><title>DenyPermissionsForExecutableJar modified by Josef Cacek</title><link>https://sourceforge.net/p/pro-grade/wiki/DenyPermissionsForExecutableJar/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v4
+++ v5
@@ -67,29 +67,4 @@
         at org.apache.jasper.compiler.JspRuntimeContext.&amp;lt;init&amp;gt;(JspRuntimeContext.java:115)
         at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:118)
         at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:640)
-        at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:419)
-        at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892)
-        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349)
-        at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1404)
-        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1366)
-        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
-        at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
-        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:520)
-        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
-        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
-        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
-        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
-        at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:161)
-        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
-        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
-        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
-        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
-        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
-        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
-        at org.eclipse.jetty.server.Server.start(Server.java:422)
-        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
-        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
-        at org.eclipse.jetty.server.Server.doStart(Server.java:389)
-        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
-        at org.eclipse.jetty.runner.Runner.run(Runner.java:495)
-        at org.eclipse.jetty.runner.Runner.main(Runner.java:536)
+        ...
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Josef Cacek</dc:creator><pubDate>Tue, 08 Nov 2016 21:01:40 -0000</pubDate><guid>https://sourceforge.neta61eb7e54676d46557eb14f6ae2c7ede733bcdfa</guid></item><item><title>DenyPermissionsForExecutableJar modified by Josef Cacek</title><link>https://sourceforge.net/p/pro-grade/wiki/DenyPermissionsForExecutableJar/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -2,9 +2,9 @@

 This tutorial shows how to use pro-grade policy with **deny rules**.

-We will start a Jetty web server and using policy file with deny rule, we will restrict access to the application.
+We will start a Jetty web server and use policy file with deny rule to restrict access to the application. The access over the loopback interface (`localhost`) will not be possible, other interfaces should stay working.

-*Configuration is described for Linux/Unix systems. Use similar way for Windows - just edit batch files instead of bash scripts.*
+*Configuration is described for Linux/Unix systems. Use similar way for Windows.*

 ## Prepare

@@ -48,7 +48,7 @@
 Now the command looks like:

     java -Djava.security.manager=net.sourceforge.prograde.sm.ProGradeJSM \
-        -Djava.security.policy==/tmp/deny-localhost.policy \
+        -Djava.security.policy==deny-localhost.policy \
         -cp jetty-runner-9.3.14.v20161028.jar:pro-grade-1.1.1.jar \
         org.eclipse.jetty.runner.Runner .

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Josef Cacek</dc:creator><pubDate>Tue, 08 Nov 2016 21:00:00 -0000</pubDate><guid>https://sourceforge.netd4c0acd9ad68abe8741f4abf028d5e05b9924e22</guid></item><item><title>DenyPermissionsForExecutableJar modified by Josef Cacek</title><link>https://sourceforge.net/p/pro-grade/wiki/DenyPermissionsForExecutableJar/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -9,6 +9,7 @@
 ## Prepare

 Download jetty and pro-grade to a test folder:
+
 * https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-runner/9.3.14.v20161028/jetty-runner-9.3.14.v20161028.jar
 * https://repo1.maven.org/maven2/net/sourceforge/pro-grade/pro-grade/1.1.1/pro-grade-1.1.1.jar

@@ -38,6 +39,7 @@
 If you want to use pro-grade, you can't use `-jar` parameter as you did in previous step because you need to use classpath parameter which doesn't work together with `-jar`. You could use an uber-jar, but let's keep it simple and do it in a standard way.

 The steps to do are:
+
 * provide the main class (the value defined in the JAR in `META-INF/MANIFEST.MF`) on the command line - without `-jar` we don't have it automatically
 * add the original jar to classpath
 * add pro-grade JAR to classpath
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Josef Cacek</dc:creator><pubDate>Tue, 08 Nov 2016 20:54:31 -0000</pubDate><guid>https://sourceforge.net8c095bfbab840ab8767768a55eee02db7cb7299a</guid></item><item><title>DenyPermissionsForExecutableJar modified by Josef Cacek</title><link>https://sourceforge.net/p/pro-grade/wiki/DenyPermissionsForExecutableJar/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -9,8 +9,8 @@
 ## Prepare

 Download jetty and pro-grade to a test folder:
- * https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-runner/9.3.14.v20161028/jetty-runner-9.3.14.v20161028.jar
- * https://repo1.maven.org/maven2/net/sourceforge/pro-grade/pro-grade/1.1.1/pro-grade-1.1.1.jar
+* https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-runner/9.3.14.v20161028/jetty-runner-9.3.14.v20161028.jar
+* https://repo1.maven.org/maven2/net/sourceforge/pro-grade/pro-grade/1.1.1/pro-grade-1.1.1.jar

 Verify the jetty works by running:

@@ -35,11 +35,15 @@

 ## Run jetty with the new policy

-Now you can't use `-jar` parameter. The steps to do are:
- * provide the main class (the value defined in the JAR in `META-INF/MANIFEST.MF`) on the command line
- * add the original jar to classpath
- * add pro-grade JAR to classpath
- * use pro-grade security manager and the newly created policy
+If you want to use pro-grade, you can't use `-jar` parameter as you did in previous step because you need to use classpath parameter which doesn't work together with `-jar`. You could use an uber-jar, but let's keep it simple and do it in a standard way.
+
+The steps to do are:
+* provide the main class (the value defined in the JAR in `META-INF/MANIFEST.MF`) on the command line - without `-jar` we don't have it automatically
+* add the original jar to classpath
+* add pro-grade JAR to classpath
+* use pro-grade security manager and the newly created policy
+
+Now the command looks like:

     java -Djava.security.manager=net.sourceforge.prograde.sm.ProGradeJSM \
         -Djava.security.policy==/tmp/deny-localhost.policy \
@@ -48,7 +52,7 @@

 If you open/reload http://localhost:8080/ URL again, you should not be able to connect to the jetty server. Exception should appear in the jetty console window.

-If you use your public address instead of loopback (localhost), then you should be able to connect to jetty without problem. (e.g. if your public IP is 192.168.1.1, then try to open http://192.168.1.1:8080/)
+You use your public address instead of loopback (localhost), then you should be able to connect to jetty without problem. (e.g. if your public IP is 192.168.1.1, then try to open http://192.168.1.1:8080/)

 ### Jasper issue

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Josef Cacek</dc:creator><pubDate>Tue, 08 Nov 2016 20:51:50 -0000</pubDate><guid>https://sourceforge.net31598d279d0adbdeaa5ce1978d3f8be7fd223d59</guid></item><item><title>DenyPermissionsForExecutableJar modified by Josef Cacek</title><link>https://sourceforge.net/p/pro-grade/wiki/DenyPermissionsForExecutableJar/</link><description>&lt;div class="markdown_content"&gt;&lt;h1 id="use-policy-with-deny-rule-for-an-executable-jar-file"&gt;Use policy with deny rule for an executable JAR file&lt;/h1&gt;
&lt;p&gt;This tutorial shows how to use pro-grade policy with &lt;strong&gt;deny rules&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;We will start a Jetty web server and using policy file with deny rule, we will restrict access to the application.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Configuration is described for Linux/Unix systems. Use similar way for Windows - just edit batch files instead of bash scripts.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="prepare"&gt;Prepare&lt;/h2&gt;
&lt;p&gt;Download jetty and pro-grade to a test folder:&lt;br/&gt;
 * &lt;a href="https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-runner/9.3.14.v20161028/jetty-runner-9.3.14.v20161028.jar" rel="nofollow"&gt;https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-runner/9.3.14.v20161028/jetty-runner-9.3.14.v20161028.jar&lt;/a&gt;&lt;br/&gt;
 * &lt;a href="https://repo1.maven.org/maven2/net/sourceforge/pro-grade/pro-grade/1.1.1/pro-grade-1.1.1.jar" rel="nofollow"&gt;https://repo1.maven.org/maven2/net/sourceforge/pro-grade/pro-grade/1.1.1/pro-grade-1.1.1.jar&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Verify the jetty works by running:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;java -jar jetty-runner-9.3.14.v20161028.jar .
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If you open now &lt;a href="http://localhost:8080/" rel="nofollow"&gt;http://localhost:8080/&lt;/a&gt; in your brower, you should see directory listing of the current directory.&lt;/p&gt;
&lt;h2 id="create-policy-file"&gt;Create policy file&lt;/h2&gt;
&lt;p&gt;Create a text file named &lt;code&gt;deny-localhost.policy&lt;/code&gt; with content:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;// Grant all to everyone
grant {
    permission java.security.AllPermission;
};

// Deny access to from localhost
deny {
    permission java.net.SocketPermission "", "accept";
}
&lt;/pre&gt;&lt;/div&gt;


&lt;h2 id="run-jetty-with-the-new-policy"&gt;Run jetty with the new policy&lt;/h2&gt;
&lt;p&gt;Now you can't use &lt;code&gt;-jar&lt;/code&gt; parameter. The steps to do are:&lt;br/&gt;
 * provide the main class (the value defined in the JAR in &lt;code&gt;META-INF/MANIFEST.MF&lt;/code&gt;) on the command line&lt;br/&gt;
 * add the original jar to classpath&lt;br/&gt;
 * add pro-grade JAR to classpath&lt;br/&gt;
 * use pro-grade security manager and the newly created policy&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;java -Djava.security.manager=net.sourceforge.prograde.sm.ProGradeJSM \
    -Djava.security.policy==/tmp/deny-localhost.policy \
    -cp jetty-runner-9.3.14.v20161028.jar:pro-grade-1.1.1.jar \
    org.eclipse.jetty.runner.Runner .
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If you open/reload &lt;a href="http://localhost:8080/" rel="nofollow"&gt;http://localhost:8080/&lt;/a&gt; URL again, you should not be able to connect to the jetty server. Exception should appear in the jetty console window.&lt;/p&gt;
&lt;p&gt;If you use your public address instead of loopback (localhost), then you should be able to connect to jetty without problem. (e.g. if your public IP is 192.168.1.1, then try to open &lt;a href="http://192.168.1.1:8080/" rel="nofollow"&gt;http://192.168.1.1:8080/&lt;/a&gt;)&lt;/p&gt;
&lt;h3 id="jasper-issue"&gt;Jasper issue&lt;/h3&gt;
&lt;p&gt;If you see an exception similar to following one in the jetty output, don't worry. It's just a Jasper (JSP compiler) issue with handling custom security policies.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="x"&gt;java.lang.SecurityException: attempt to add a Permission to a readonly Permissions object&lt;/span&gt;
&lt;span class="x"&gt;    at java.security.Permissions.add(Permissions.java:126)&lt;/span&gt;
&lt;span class="x"&gt;    at java.security.Policy&lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="nv"&gt;UnsupportedEmptyCollection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;Policy.java:&lt;/span&gt;&lt;span class="m"&gt;827&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;    at org.apache.jasper.compiler.JspRuntimeContext.initSecurity(JspRuntimeContext.java:477)&lt;/span&gt;
&lt;span class="x"&gt;    at org.apache.jasper.compiler.JspRuntimeContext.&amp;lt;init&amp;gt;(JspRuntimeContext.java:115)&lt;/span&gt;
&lt;span class="x"&gt;    at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:118)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:640)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:419)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1404)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1366)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:520)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:161)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.server.Server.start(Server.java:422)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.server.Server.doStart(Server.java:389)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.runner.Runner.run(Runner.java:495)&lt;/span&gt;
&lt;span class="x"&gt;    at org.eclipse.jetty.runner.Runner.main(Runner.java:536)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Josef Cacek</dc:creator><pubDate>Tue, 08 Nov 2016 20:40:14 -0000</pubDate><guid>https://sourceforge.net85910ca690b6fbf9ada1318ef5be80837d91c646</guid></item></channel></rss>