我想使用 gwt 开发一个插件。它必须使用 java.security.* 在客户端生成密钥。我已经提出了所有要求,但它显示以下错误。
加载模块
coreservlets.GwtApp1
Loading inherited module 'coreservlets.GwtApp1' Loading inherited module 'java.security.KeyPair' [ERROR] Unable to find 'java/security/KeyPair.gwt.xml' on your classpath; >could be a typo, or maybe you forgot to include a classpath entry for source? [ERROR] Line 15: Unexpected exception while processing element 'inherits'
我在我的 gwtapp1.gwt.xml 文件中继承了所有相关的类,如“java.security.KeyPair”
我也将 jar 包含在类路径本身中。但错误仍然没有消失。我应该怎么做.plz建议这里是我的java代码
package coreservlets.client;
import java.io.UnsupportedEncodingException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
public class Keygen {
private PrivateKey privKey;
private PublicKey pubKey;
private static Keygen keygen = null;
private Keygen() {
}
public static Keygen getInstance() {
if (keygen == null) {
keygen = new Keygen();
}
return keygen;
}
public void KeyGenerator(String ALGORITHAM) {
KeyPairGenerator keyGen = null;
SecureRandom random = null;
try {
keyGen = KeyPairGenerator.getInstance(ALGORITHAM);
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
try {
random = SecureRandom.getInstance("SHA1PRNG", "SUN");
//random = SecureRandom.getInstance("SHA1PRNG");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchProviderException ex) {
ex.printStackTrace();
}
//keyGen.initialize(1024, random);
keyGen.initialize(1024);
KeyPair key = keyGen.generateKeyPair();
privKey = key.getPrivate();
pubKey = key.getPublic();
}
public String getPubKeyasString() {
//return Base64.encodeBase64String(pubKey.getEncoded());
try {
return new String(pubKey.getEncoded(),"ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public String getPriKeyasString() {
//return Base64.encodeBase64String(privKey.getEncoded());
try {
return new String(privKey.getEncoded(),"ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}