<?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%2FService</id>
		<title>Java/Security/Service - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FSecurity%2FService"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Security/Service&amp;action=history"/>
		<updated>2026-04-21T19:06:39Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Security/Service&amp;diff=7667&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Security/Service&amp;diff=7667&amp;oldid=prev"/>
				<updated>2010-06-01T06:49:30Z</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/Service&amp;diff=7666&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/Service&amp;diff=7666&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;== Secure Service ==&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;
/*&lt;br /&gt;
 * Copyright (c) 2000 David Flanagan.  All rights reserved.&lt;br /&gt;
 * This code is from the book Java Examples in a Nutshell, 2nd Edition.&lt;br /&gt;
 * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.&lt;br /&gt;
 * You may study, use, and modify it for any non-commercial purpose.&lt;br /&gt;
 * You may distribute it non-commercially as long as you retain this notice.&lt;br /&gt;
 * For a commercial use license, or to purchase the book (recommended),&lt;br /&gt;
 * visit http://www.davidflanagan.ru/javaexamples2.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.io.OutputStream;&lt;br /&gt;
import java.io.PrintWriter;&lt;br /&gt;
import com.sun.corba.se.spi.activation.Server;&lt;br /&gt;
/**&lt;br /&gt;
 * This is a demonstration service. It attempts to do things that may or may not&lt;br /&gt;
 * be allowed by the security policy and reports the results of its attempts to&lt;br /&gt;
 * the client.&lt;br /&gt;
 */&lt;br /&gt;
public class SecureService implements Server.Service {&lt;br /&gt;
  public void serve(InputStream i, OutputStream o) throws IOException {&lt;br /&gt;
    PrintWriter out = new PrintWriter(o);&lt;br /&gt;
    // Try to install our own security manager. If we can do this,&lt;br /&gt;
    // we can defeat any access control.&lt;br /&gt;
    out.println(&amp;quot;Trying to create and install a security manager...&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      System.setSecurityManager(new SecurityManager());&lt;br /&gt;
      out.println(&amp;quot;Success!&amp;quot;);&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      out.println(&amp;quot;Failed: &amp;quot; + e);&lt;br /&gt;
    }&lt;br /&gt;
    // Try to make the Server and the Java VM exit.&lt;br /&gt;
    // This is a denial of service attack, and it should not succeed!&lt;br /&gt;
    out.println();&lt;br /&gt;
    out.println(&amp;quot;Trying to exit...&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      System.exit(-1);&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      out.println(&amp;quot;Failed: &amp;quot; + e);&lt;br /&gt;
    }&lt;br /&gt;
    // The default system policy allows this property to be read&lt;br /&gt;
    out.println();&lt;br /&gt;
    out.println(&amp;quot;Attempting to find java version...&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      out.println(System.getProperty(&amp;quot;java.version&amp;quot;));&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      out.println(&amp;quot;Failed: &amp;quot; + e);&lt;br /&gt;
    }&lt;br /&gt;
    // The default system policy does not allow this property to be read&lt;br /&gt;
    out.println();&lt;br /&gt;
    out.println(&amp;quot;Attempting to find home directory...&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      out.println(System.getProperty(&amp;quot;user.home&amp;quot;));&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      out.println(&amp;quot;Failed: &amp;quot; + e);&lt;br /&gt;
    }&lt;br /&gt;
    // Our custom policy explicitly allows this property to be read&lt;br /&gt;
    out.println();&lt;br /&gt;
    out.println(&amp;quot;Attempting to read service.tmp property...&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      String tmpdir = System.getProperty(&amp;quot;service.tmp&amp;quot;);&lt;br /&gt;
      out.println(tmpdir);&lt;br /&gt;
      File dir = new File(tmpdir);&lt;br /&gt;
      File f = new File(dir, &amp;quot;testfile&amp;quot;);&lt;br /&gt;
      // Check whether we&amp;quot;ve been given permission to write files to&lt;br /&gt;
      // the tmpdir directory&lt;br /&gt;
      out.println();&lt;br /&gt;
      out.println(&amp;quot;Attempting to write a file in &amp;quot; + tmpdir + &amp;quot;...&amp;quot;);&lt;br /&gt;
      try {&lt;br /&gt;
        new FileOutputStream(f);&lt;br /&gt;
        out.println(&amp;quot;Opened file for writing: &amp;quot; + f);&lt;br /&gt;
      } catch (Exception e) {&lt;br /&gt;
        out.println(&amp;quot;Failed: &amp;quot; + e);&lt;br /&gt;
      }&lt;br /&gt;
      // Check whether we&amp;quot;ve been given permission to read files from&lt;br /&gt;
      // the tmpdir directory&lt;br /&gt;
      out.println();&lt;br /&gt;
      out.println(&amp;quot;Attempting to read from &amp;quot; + tmpdir + &amp;quot;...&amp;quot;);&lt;br /&gt;
      try {&lt;br /&gt;
        FileReader in = new FileReader(f);&lt;br /&gt;
        out.println(&amp;quot;Opened file for reading: &amp;quot; + f);&lt;br /&gt;
      } catch (Exception e) {&lt;br /&gt;
        out.println(&amp;quot;Failed: &amp;quot; + e);&lt;br /&gt;
      }&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      out.println(&amp;quot;Failed: &amp;quot; + e);&lt;br /&gt;
    }&lt;br /&gt;
    // Close the Service sockets&lt;br /&gt;
    out.close();&lt;br /&gt;
    i.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
//Server.policy&lt;br /&gt;
//These lines grant permissions to any code loaded from the directory shown.&lt;br /&gt;
//Edit the directory to match the installation on your system.&lt;br /&gt;
//On Windows systems, change the forward slashes to double backslashes: &amp;quot;\\&amp;quot;.&lt;br /&gt;
grant codeBase &amp;quot;file:/home/david/Books/JavaExamples2/Examples&amp;quot; {&lt;br /&gt;
   // Allow the server to listen for and accept network connections&lt;br /&gt;
   // from any host on any port &amp;gt; 1024&lt;br /&gt;
   permission java.net.SocketPermission &amp;quot;*:1024-&amp;quot;, &amp;quot;listen,accept&amp;quot;;&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;/div&gt;</summary>
			</entry>

	</feed>