diff options
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/TrustedApplet.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/TrustedApplet.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/TrustedApplet.java b/Master/Reference Architectures and Patterns/hjp5/examples/TrustedApplet.java new file mode 100644 index 0000000..30f56a3 --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/TrustedApplet.java @@ -0,0 +1,64 @@ +/* TrustedApplet.java */
+
+import java.awt.*;
+import java.applet.*;
+import java.util.*;
+import java.io.*;
+
+public class TrustedApplet
+extends Applet
+{
+ static final String ALLOWED_DIR = "c:\\tmp\\applets\\";
+ static final String FNAME = "TrustedApplet.log";
+ static final String LOGMSG = "Erzeugt von Applet: ";
+ String msg;
+
+ public void init()
+ {
+ msg = "Uninitialisiert";
+ FileWriter out = null;
+ try {
+ //Ausgabedatei erzeugen
+ out = new FileWriter(ALLOWED_DIR + FNAME);
+ //Logmessage schreiben
+ out.write(LOGMSG);
+ //Zeitstempel schreiben
+ GregorianCalendar cal = new GregorianCalendar();
+ out.write(cal.get(Calendar.DATE) + ".");
+ out.write((cal.get(Calendar.MONTH) + 1) + ".");
+ out.write(cal.get(Calendar.YEAR) + " ");
+ out.write(cal.get(Calendar.HOUR_OF_DAY) + ":");
+ out.write(cal.get(Calendar.MINUTE) + ":");
+ out.write(cal.get(Calendar.SECOND) + "");
+ out.write(System.getProperty("line.separator"));
+ //System-Properties lesen und in Datei schreiben
+ out.write(getProp("user.name"));
+ out.write(getProp("user.home"));
+ out.write(getProp("user.dir"));
+ //Datei schließen
+ msg = "Alle Sicherheitshuerden ueberwunden!";
+ } catch (Exception e) {
+ msg = e.toString();
+ } finally {
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException e) {
+ //silently ignore
+ }
+ }
+ }
+ }
+
+ public void paint(Graphics g)
+ {
+ g.drawString(msg, 20, 20);
+ }
+
+ private String getProp(String prop)
+ {
+ return prop + "=" +
+ System.getProperty(prop) +
+ System.getProperty("line.separator");
+ }
+}
\ No newline at end of file |
