Import Waterfall under the directory pluggable-jvm.
git-svn-id: svn://10.0.0.236/trunk@94499 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
138
mozilla/java/pluggable-jvm/wf/tests/https/SecureApplet.java
Normal file
138
mozilla/java/pluggable-jvm/wf/tests/https/SecureApplet.java
Normal file
@@ -0,0 +1,138 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is The Waterfall Java Plugin Module
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems Inc
|
||||
* Portions created by Sun Microsystems Inc are Copyright (C) 2001
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* $Id: SecureApplet.java,v 1.1.1.1 2001-05-10 18:12:37 edburns%acm.org Exp $
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Nikolay N. Igotti <inn@sparc.spb.su>
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.applet.*;
|
||||
import java.text.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class SecureApplet extends Applet implements ActionListener
|
||||
{
|
||||
Button b1, b2, clear;
|
||||
TextArea content;
|
||||
|
||||
public void init() {
|
||||
b1 = new Button("Secure");
|
||||
b2 = new Button("Nonsecure");
|
||||
clear = new Button("Clear");
|
||||
content = new TextArea(15, 35);
|
||||
setFont(new Font("Monospaced", Font.PLAIN, 10));
|
||||
add(content);
|
||||
add(b1); add(b2); add(clear);
|
||||
b1.addActionListener(this);
|
||||
b2.addActionListener(this);
|
||||
clear.addActionListener(this);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
Button source = (Button)evt.getSource();
|
||||
if (source == b1)
|
||||
{
|
||||
doSecureConnect("lyola");
|
||||
return;
|
||||
}
|
||||
if (source == b2)
|
||||
{
|
||||
doNonsecureConnect("lyola");
|
||||
return;
|
||||
}
|
||||
if (source == clear)
|
||||
{
|
||||
content.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void paint(Graphics g) {
|
||||
|
||||
}
|
||||
|
||||
public void start() {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
}
|
||||
|
||||
public String getAppletInfo() {
|
||||
return "Title: Secure Connection test";
|
||||
}
|
||||
|
||||
void readStream(URL u, InputStream is) {
|
||||
byte[] buf = new byte[256];
|
||||
int r;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
content.setText("reading....");
|
||||
sb.append("Following read from url "+u+":\n");
|
||||
try {
|
||||
while ( (r = is.read(buf)) != -1)
|
||||
{
|
||||
sb.append(new String(buf, 0, r));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
sb.append("_________________________________________");
|
||||
content.setText(new String(sb));
|
||||
}
|
||||
|
||||
void doSecureConnect(String host) {
|
||||
InputStream is;
|
||||
URL u;
|
||||
try {
|
||||
URL u1 = getDocumentBase();
|
||||
u = new URL("https",
|
||||
u1.getHost(),
|
||||
443,
|
||||
"/applets/https/data1.dat");
|
||||
is = u.openStream();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
readStream(u, is);
|
||||
}
|
||||
|
||||
void doNonsecureConnect(String host) {
|
||||
InputStream is;
|
||||
URL u;
|
||||
try {
|
||||
URL u1 = getDocumentBase();
|
||||
u = new URL("http",
|
||||
u1.getHost(),
|
||||
80,
|
||||
"/applets/https/data2.dat");
|
||||
is = u.openStream();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
readStream(u, is);
|
||||
}
|
||||
|
||||
}
|
||||
3
mozilla/java/pluggable-jvm/wf/tests/https/data1.dat
Normal file
3
mozilla/java/pluggable-jvm/wf/tests/https/data1.dat
Normal file
@@ -0,0 +1,3 @@
|
||||
This is secured data.
|
||||
Q: What's tiny and yellow and very, very, dangerous?
|
||||
A: A canary with the super-user password.
|
||||
10
mozilla/java/pluggable-jvm/wf/tests/https/data2.dat
Normal file
10
mozilla/java/pluggable-jvm/wf/tests/https/data2.dat
Normal file
@@ -0,0 +1,10 @@
|
||||
Insecure data.
|
||||
Cite 1:
|
||||
It's not an optical illusion, it just looks like one.
|
||||
-- Phil White
|
||||
Cite 2:
|
||||
Every program has at least one bug and can be shortened by at least one
|
||||
instruction -- from which, by induction, one can deduce that every
|
||||
program can be reduced to one instruction which doesn't work.
|
||||
|
||||
Result - no samsara wheel installed on my webserver.
|
||||
14
mozilla/java/pluggable-jvm/wf/tests/https/example1.html
Normal file
14
mozilla/java/pluggable-jvm/wf/tests/https/example1.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>HTTPS test sample</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<h1>Secure/Nonsecure connection</h1>
|
||||
<hr>
|
||||
<applet codebase="." code="SecureApplet.class" width=250 height=250>
|
||||
alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason."
|
||||
Your browser is completely ignoring the <APPLET> tag!
|
||||
</applet>
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
Reference in New Issue
Block a user