<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FSecurity%2FPolicy</id>
		<title>Java/Security/Policy - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FSecurity%2FPolicy"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Security/Policy&amp;action=history"/>
		<updated>2026-04-21T19:14:24Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Security/Policy&amp;diff=7655&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Security/Policy&amp;diff=7655&amp;oldid=prev"/>
				<updated>2010-06-01T06:49:25Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:49, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Security/Policy&amp;diff=7654&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Security/Policy&amp;diff=7654&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:45Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Authorized File Writer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.io.FileWriter;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
public class AuthorizedFileWriter {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    System.setSecurityManager(new SecurityManager());&lt;br /&gt;
    String file = &amp;quot;authorized.txt&amp;quot;;&lt;br /&gt;
    String fileBody = &amp;quot;test&amp;quot;;&lt;br /&gt;
    try {&lt;br /&gt;
      FileWriter fileWriter = new FileWriter(file);&lt;br /&gt;
      fileWriter.write(fileBody);&lt;br /&gt;
      fileWriter.close();&lt;br /&gt;
      System.exit(0);&lt;br /&gt;
    } catch (IOException ioException) {&lt;br /&gt;
      ioException.printStackTrace();&lt;br /&gt;
      System.exit(1);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
// authorized.policy&lt;br /&gt;
// Policy file that grants file write permission &lt;br /&gt;
// only to file &amp;quot;authorized.txt&amp;quot;&lt;br /&gt;
grant {&lt;br /&gt;
   permission java.io.FilePermission&lt;br /&gt;
     &amp;quot;authorized.txt&amp;quot;, &amp;quot;write&amp;quot;;&lt;br /&gt;
};&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
// codebase_authorized.policy&lt;br /&gt;
// Policy file that grants write permission to &lt;br /&gt;
// file &amp;quot;codebase_authorized.txt&amp;quot; for codebase &amp;quot;C:/myclasses&amp;quot;&lt;br /&gt;
grant codebase &amp;quot;file:/C:/myclasses&amp;quot; {&lt;br /&gt;
   permission java.io.FilePermission&lt;br /&gt;
     &amp;quot;codebase_authorized.txt&amp;quot;, &amp;quot;write&amp;quot;;&lt;br /&gt;
};&lt;br /&gt;
*/&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Managing Policy Files: By default, the JDK uses the policy files located in ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
    file:${java.home}/lib/security/java.policy&lt;br /&gt;
    file:${user.home}/.java.policy&lt;br /&gt;
These policy files are specified in the default security file:&lt;br /&gt;
    ${java.home}/lib/security/java.security&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Policy Demo ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/* From http://java.sun.ru/docs/books/tutorial/index.html */&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 *&lt;br /&gt;
 * -Redistribution of source code must retain the above copyright notice, this&lt;br /&gt;
 *  list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 * -Redistribution in binary form must reproduce the above copyright notice,&lt;br /&gt;
 *  this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 *  and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * Neither the name of Sun Microsystems, Inc. or the names of contributors may&lt;br /&gt;
 * be used to endorse or promote products derived from this software without&lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL&lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING&lt;br /&gt;
 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. (&amp;quot;SUN&amp;quot;)&lt;br /&gt;
 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE&lt;br /&gt;
 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS&lt;br /&gt;
 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST&lt;br /&gt;
 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,&lt;br /&gt;
 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY&lt;br /&gt;
 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,&lt;br /&gt;
 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 *&lt;br /&gt;
 * You acknowledge that this software is not designed, licensed or intended&lt;br /&gt;
 * for use in the design, construction, operation or maintenance of any&lt;br /&gt;
 * nuclear facility.&lt;br /&gt;
 */&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== System properties and security policy  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/* From http://java.sun.ru/docs/books/tutorial/index.html */&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 *&lt;br /&gt;
 * -Redistribution of source code must retain the above copyright notice, this&lt;br /&gt;
 *  list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 * -Redistribution in binary form must reproduce the above copyright notice,&lt;br /&gt;
 *  this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 *  and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * Neither the name of Sun Microsystems, Inc. or the names of contributors may&lt;br /&gt;
 * be used to endorse or promote products derived from this software without&lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL&lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING&lt;br /&gt;
 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. (&amp;quot;SUN&amp;quot;)&lt;br /&gt;
 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE&lt;br /&gt;
 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS&lt;br /&gt;
 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST&lt;br /&gt;
 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,&lt;br /&gt;
 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY&lt;br /&gt;
 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,&lt;br /&gt;
 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 *&lt;br /&gt;
 * You acknowledge that this software is not designed, licensed or intended&lt;br /&gt;
 * for use in the design, construction, operation or maintenance of any&lt;br /&gt;
 * nuclear facility.&lt;br /&gt;
 */&lt;br /&gt;
public class GetProps {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    /* Test reading properties w &amp;amp; w/out security manager */&lt;br /&gt;
    String s;&lt;br /&gt;
    try {&lt;br /&gt;
      System.out.println(&amp;quot;About to get os.name property value&amp;quot;);&lt;br /&gt;
      s = System.getProperty(&amp;quot;os.name&amp;quot;, &amp;quot;not specified&amp;quot;);&lt;br /&gt;
      System.out.println(&amp;quot;  The name of your operating system is: &amp;quot; + s);&lt;br /&gt;
      System.out.println(&amp;quot;About to get java.version property value&amp;quot;);&lt;br /&gt;
      s = System.getProperty(&amp;quot;java.version&amp;quot;, &amp;quot;not specified&amp;quot;);&lt;br /&gt;
      System.out.println(&amp;quot;  The version of the JVM you are running is: &amp;quot;&lt;br /&gt;
          + s);&lt;br /&gt;
      System.out.println(&amp;quot;About to get user.home property value&amp;quot;);&lt;br /&gt;
      s = System.getProperty(&amp;quot;user.home&amp;quot;, &amp;quot;not specified&amp;quot;);&lt;br /&gt;
      System.out.println(&amp;quot;  Your user home directory is: &amp;quot; + s);&lt;br /&gt;
      System.out.println(&amp;quot;About to get java.home property value&amp;quot;);&lt;br /&gt;
      s = System.getProperty(&amp;quot;java.home&amp;quot;, &amp;quot;not specified&amp;quot;);&lt;br /&gt;
      System.out.println(&amp;quot;  Your JRE installation directory is: &amp;quot; + s);&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      System.err.println(&amp;quot;Caught exception &amp;quot; + e.toString());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//File: java.policy&lt;br /&gt;
/*&lt;br /&gt;
&lt;br /&gt;
// Standard extensions get all permissions by default&lt;br /&gt;
grant codeBase &amp;quot;file:${java.home}/lib/ext/&amp;quot; {&lt;br /&gt;
  permission java.security.AllPermission;&lt;br /&gt;
};&lt;br /&gt;
// default permissions granted to all domains&lt;br /&gt;
grant { &lt;br /&gt;
  // allows anyone to listen on un-privileged ports&lt;br /&gt;
  permission java.net.SocketPermission &amp;quot;localhost:1024-&amp;quot;, &amp;quot;listen&amp;quot;;&lt;br /&gt;
  // &amp;quot;standard&amp;quot; properies that can be read by anyone&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.version&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.vendor&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.vendor.url&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.class.version&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;os.name&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;os.version&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;os.arch&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;file.separator&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;path.separator&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;line.separator&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.specification.version&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.specification.vendor&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.specification.name&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.vm.specification.version&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.vm.specification.vendor&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.vm.specification.name&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.vm.version&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.vm.vendor&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
  permission java.util.PropertyPermission &amp;quot;java.vm.name&amp;quot;, &amp;quot;read&amp;quot;;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== To ignore the policies in the java.security file, and use the specified policy, use &amp;quot;==&amp;quot; instead of &amp;quot;=&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
java -Djava.security.manager -Djava.security.policy==someURL MyApp&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== To specify an additional policy file, set the java.security.policy system property at the command line: ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
c:\java -Djava.security.manager -Djava.security.policy=someURL MyApp&lt;br /&gt;
c:\appletviewer -J-Djava.security.policy=someURL HTMLfile&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>