From: "Kristian Wendel" <kribb@keyway.net>
To: <java-security@web2.javasoft.com>
Subject: Security violation
Date: Fri, 13 Feb 1998 17:46:43 -0800
This is a multi-part message in MIME format.
------=_NextPart_000_0004_01BD38A7.5919D140
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello!
I have written a Java animation applet. It works just fine on my =
computer, but when my friends try to view the webpage, the applet will =
not load, in the statusbar comes the message - security violation, what =
does this mean, and what can be done about it?
The applet doesn't perform anything strange or evil, just a basic =
animation, with the possibilites for the user to start and stop it, as =
well as changing the framerate.
I have provided you with the code
Hoping for an answer
Sincerely
Kristian Wendel
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class KW extends Applet implements Runnable, ItemListener
{=20
static int i, framerate =3D 100;
Thread animatorThread =3D null;
boolean frozen =3D false;
Image[] images;
Graphics offGraphics;
Image offImage;
Panel sp =3D new Panel();
CheckboxGroup framerategroup =3D new CheckboxGroup();
Checkbox[] selectedframerate =3D new Checkbox[3];
MediaTracker tracker;
public void init()
{
setLayout(new BorderLayout(5,5));
add("South", sp);
sp.add(selectedframerate[0] =3D new Checkbox("1",framerategroup,true));
sp.add(selectedframerate[1] =3D new Checkbox("2",framerategroup,false));
sp.add(selectedframerate[2] =3D new Checkbox("3",framerategroup,false));
selectedframerate[0].addItemListener(this);
selectedframerate[1].addItemListener(this);
selectedframerate[2].addItemListener(this);
tracker =3D new MediaTracker(this);
images =3D new Image[38];
for (i =3D 1; i <=3D 38; i++)
{
images[i-1] =3D getImage(getCodeBase(), "kw"+i+".jpg");
tracker.addImage(images[i-1], 0);
}
addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
if (frozen)
{
frozen =3D false;
start();
}=20
else
{
frozen =3D true;
animatorThread =3D null;
}
}
});
}
public void start()
{
if (frozen) {}=20
else
{
if (animatorThread =3D=3D null)
{
animatorThread =3D new Thread(this);
}
animatorThread.start();
}
}
public void stop()
{
animatorThread =3D null;
}
public void run()
{
try
{
tracker.waitForAll();
} catch (InterruptedException e) {}
long startTime =3D System.currentTimeMillis();=20
Thread currentThread =3D Thread.currentThread();=20
while (currentThread =3D=3D animatorThread)
{
for (i =3D 0; i <=3D 38; i++)
{
repaint();
try
{
startTime +=3D framerate;
Thread.sleep(Math.max(0,=20
startTime-System.currentTimeMillis()));
}
catch (InterruptedException e)
{
break;
}
}
}
}
public void paint(Graphics g)
{
update(g);
}
public final void update(Graphics g)
{
if (!tracker.checkAll())
{
g.clearRect(0,0,160,120);
g.drawString("This may take a while,", 25, 55);
g.drawString("about 15 - 60 seconds", 25, 70);
g.drawString(" Have patience ", 25, 85);
}
offImage =3D createImage(160,120);
offGraphics =3D offImage.getGraphics();=20
offGraphics.setColor(getBackground());
offGraphics.fillRect(0,0,160,120);
offGraphics.setColor(Color.black);
offGraphics.drawImage(images[i-1],0,0,this);
g.drawImage(offImage, 0, 0, this);
}
public void itemStateChanged(ItemEvent e)
{
if (framerategroup.getSelectedCheckbox()=3D=3Dselectedframerate[0])
framerate =3D 100;
else if (framerategroup.getSelectedCheckbox()=3D=3Dselectedframerate[1])
framerate =3D 150;
else if (framerategroup.getSelectedCheckbox()=3D=3Dselectedframerate[2])
framerate =3D 300;
}
}
------=_NextPart_000_0004_01BD38A7.5919D140
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
Hello!
I have written a Java animation applet. It works just fine on my = computer,=20 but when my friends try to view the webpage, the applet will not load, = in the=20 statusbar comes the message - security violation, what does this mean, = and what=20 can be done about it?
The applet doesn't perform anything strange or evil, just a basic = animation,=20 with the possibilites for the user to start and stop it, as well as = changing the=20 framerate.
I have provided you with the code
Hoping for an answer
Sincerely
Kristian Wendel
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class KW extends Applet implements Runnable, ItemListener
{
static int i, framerate =3D 100;
Thread animatorThread =3D null;
boolean frozen =3D false;
Image[] images;
Graphics offGraphics;
Image offImage;
Panel sp =3D new Panel();
CheckboxGroup framerategroup =3D new CheckboxGroup();
Checkbox[] selectedframerate =3D new Checkbox[3];
MediaTracker tracker;
public void init()
{
setLayout(new BorderLayout(5,5));
add("South", sp);
sp.add(selectedframerate[0] =3D new=20 Checkbox("1",framerategroup,true));
sp.add(selectedframerate[1] =3D new=20 Checkbox("2",framerategroup,false));
sp.add(selectedframerate[2] =3D new=20 Checkbox("3",framerategroup,false));
selectedframerate[0].addItemListener(this);
selectedframerate[1].addItemListener(this);
selectedframerate[2].addItemListener(this);
tracker =3D new MediaTracker(this);
images =3D new Image[38];
for (i =3D 1; i <=3D 38; i++)
{
images[i-1] =3D getImage(getCodeBase(), = "kw"+i+".jpg");
tracker.addImage(images[i-1], 0);
}
addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
if (frozen)
{
frozen =3D false;
start();
}
else
{
frozen =3D true;
animatorThread =3D null;
}
}
});
}
public void start()
{
if (frozen) {}
else
{
if (animatorThread =3D=3D null)
{
animatorThread =3D new Thread(this);
}
animatorThread.start();
}
}
public void stop()
{
animatorThread =3D null;
}
public void run()
{
try
{
tracker.waitForAll();
} catch (InterruptedException e) {}
long startTime =3D System.currentTimeMillis();
Thread currentThread =3D Thread.currentThread();
while (currentThread =3D=3D animatorThread)
{
for (i =3D 0; i <=3D 38; i++)
{
repaint();
try
{
startTime +=3D framerate;
Thread.sleep(Math.max(0,
startTime-System.currentTimeMillis()));
}
catch (InterruptedException e)
{
break;
}
}
}
}
public void paint(Graphics g)
{
update(g);
}
public final void update(Graphics g)
{
if (!tracker.checkAll())
{
g.clearRect(0,0,160,120);
g.drawString("This may take a while,", 25, 55);
g.drawString("about 15 - 60 seconds", 25, 70);
g.drawString(" Have patience ", 25, 85);
}
offImage =3D createImage(160,120);
offGraphics =3D offImage.getGraphics();
offGraphics.setColor(getBackground());
offGraphics.fillRect(0,0,160,120);
offGraphics.setColor(Color.black);
offGraphics.drawImage(images[i-1],0,0,this);
g.drawImage(offImage, 0, 0, this);
}
public void itemStateChanged(ItemEvent e)
{
if = (framerategroup.getSelectedCheckbox()=3D=3Dselectedframerate[0])
framerate =3D 100;
else if = (framerategroup.getSelectedCheckbox()=3D=3Dselectedframerate[1])
framerate =3D 150;
else if = (framerategroup.getSelectedCheckbox()=3D=3Dselectedframerate[2])
framerate =3D 300;
}
}