Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JCE 1.2.1: java.lang.SecurityException!

0 views
Skip to first unread message

Shicheng

unread,
Sep 11, 2000, 6:33:34 PM9/11/00
to
Hello there,
I have installed Java 2 and JCE 1.2.1 on my PC running Win2000;
when trying to test an applet using appletviewer, I got the
following error:

java.lang.ExceptionInInitializerError: java.lang.SecurityException:
Cannot set up certs for trusted CAs
at javax.crypto.b.<clinit>([DashoPro-V1.2-120198])
at javax.crypto.Cipher.getInstance([DashoPro-V1.2-120198])
at Enigma.init(Enigma.java:44)
at sun.applet.AppletPanel.run(AppletPanel.java:344)
at java.lang.Thread.run(Thread.java:484)

Any advice on how to solve the problem would be helpful.

Thanks,

Shicheng


======================here is the code===============================

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.security.*;
import javax.crypto.*;

public class Enigma extends Applet
{
static final String ALGORITHM = "DES";
static final String TRANSFORMATION = ALGORITHM +
"/ECB/PKCS5Padding";

TextArea theInputText = new TextArea(10, 64);
TextArea theOutputText = new TextArea(10, 64);
Button theEncodeButton = new Button("Encode");
Button theDecodeButton = new Button("Decode");

SecretKey theKey;
Cipher theCipher;

public void init()
{
setLayout(new BorderLayout());
Panel p1 = new Panel();
Panel p2 = new Panel();
p1.setLayout(new GridLayout(0, 1));
p2.setLayout(new GridLayout(1, 0));
add(p1, BorderLayout.CENTER);
add(p2, BorderLayout.SOUTH);
p1.add(new Label("Input:"));
p1.add(theInputText);
p1.add(new Label("Output:"));
p1.add(theOutputText);
p2.add(theEncodeButton);
p2.add(theDecodeButton);
Font f = new Font("Monospaced", Font.PLAIN, 12);
theInputText.setFont(f);
theOutputText.setFont(f);
theOutputText.setEditable(false);
theEncodeButton.addActionListener(new Encoder());
theDecodeButton.addActionListener(new Decoder());

try
{
theCipher = Cipher.getInstance(TRANSFORMATION);
KeyGenerator generator =
KeyGenerator.getInstance(ALGORITHM);
theKey = generator.generateKey();
}
catch (Exception ex) { fatalError(ex); }
}

public void fatalError(Exception ex)
{
System.err.println("Fatal error:\n" + ex.toString());
theOutputText.setText("Fatal error:\n" + ex.toString());
ex.printStackTrace();
}

class Encoder implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
try
{
theCipher.init(Cipher.ENCRYPT_MODE, theKey);
byte [] text = theInputText.getText().getBytes();
byte [] codedtext = theCipher.doFinal(text);

theOutputText.setText(Hex.byteArrayToHexString(codedtext));
}
catch (Exception ex) { fatalError(ex); }
}
}

class Decoder implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
try
{
theCipher.init(Cipher.DECRYPT_MODE, theKey);
String chars = theInputText.getText();
byte [] text = Hex.hexStringToByteArray(chars);
byte [] codedtext = theCipher.doFinal(text);
theOutputText.setText(new String(codedtext));
}
catch (Exception ex) { fatalError(ex); }
}
}
}


Sent via Deja.com http://www.deja.com/
Before you buy.

0 new messages