最新评论 -凯发k8网页登录

 

最新评论

共3页: 1    
david.turing 2008-12-27 09:17  
我是bea的工程师,weblogic现在是双栈运行,目前jax-ws是基于metro的,base jaxb的。
david.turing 2008-06-14 09:49  
典型的部署期泄露,这种有可能是spring的bug,它可能没有正确实现j2ee的context销毁接口。
david.turing 2008-04-24 13:05  
1.5的concurrent hashmap产生的用途就是为了hashmap同步
david.turing 2008-04-23 11:01  
邢总说对了,佩服。不过,厂家的支持会让spring更适用于商业化。未来的weblogic版本(essex),应该对spring有较大的优化,包括:

1, 基于spring的部署方式实现本地wls部署,我们可以将spring module实现weblogic.application.module接口,即可让spring模块享受weblogic的2阶段部署的特性。

2, 一些预配置的beans能够无需spring配置声明即可注入到spring应用中,applicationcontext看上去会简洁很多

3, 为beans提供scope,比如clusteringscope,以便支持集群技术

4, weblogic consle展示spring应用的runtimembeans

5, 9.2之后wldf可以用于上面的runtimembeans,可以定期抓取runtime信息了

6, spring应用默认支持openjpa作为持久层支持,当然,kodo、hibernate切换也是简单的
david.turing 2008-04-22 10:16  
说的没错,任何优秀的产品都会有bug,但除非用的场景足够多和复杂,否则某些严重的bug还是会隐藏的很深。
david.turing 2007-11-07 17:52  
我晕,没有publish到blog的文章也能google到?
david.turing 2007-11-04 09:46  
如果你使用了sha1并对散列值进行rsa签名、加密,则padding的过程无需你本人去干预。
或者你可以看看下面的代码(rsautils.java):

package org.dev2dev.security.crypto.asymmetric;

import java.io.bufferedinputstream;
import java.io.bufferedoutputstream;
import java.io.bufferedreader;
import java.io.bytearrayinputstream;
import java.io.bytearrayoutputstream;
import java.io.fileinputstream;
import java.io.filenotfoundexception;
import java.io.fileoutputstream;
import java.io.ioexception;
import java.io.inputstream;
import java.io.inputstreamreader;
import java.io.outputstream;
import java.math.biginteger;
import java.security.securerandom;

import org.bouncycastle.crypto.asymmetricblockcipher;
import org.bouncycastle.crypto.asymmetriccipherkeypair;
import org.bouncycastle.crypto.datalengthexception;
import org.bouncycastle.crypto.encodings.oaepencoding;
import org.bouncycastle.crypto.encodings.pkcs1encoding;
import org.bouncycastle.crypto.engines.desengine;
import org.bouncycastle.crypto.engines.rsaengine;
import org.bouncycastle.crypto.generators.rsakeypairgenerator;
import org.bouncycastle.crypto.params.rsakeygenerationparameters;
import org.bouncycastle.crypto.params.rsakeyparameters;
import org.bouncycastle.crypto.params.rsaprivatecrtkeyparameters;
import org.bouncycastle.util.encoders.hex;
import org.dev2dev.security.crypto.blockcipher.blockciphertool;


/**
* rsa工具类
* @author david.turing
* @凯发天生赢家一触即发官网 copyright guangzhou bea usergroup
* @version 0.7
* @modifytime 22:30:34
*/
public class rsautils {

int keylength=1024;
int certainty=20;
rsakeygenerationparameters keyparam;
asymmetricblockcipher eng = null;
rsakeypairgenerator pgen = null;
asymmetriccipherkeypair pair = null;

public rsautils()
{

}

public string getname()
{
return "rsa";
}

/**
* 设置rsa的密钥长度
* @param rsakeylength
*/
public void setkeylength(int rsakeylength)
{
if(rsakeylength==512||rsakeylength==768||rsakeylength==1024||rsakeylength==2048)
keylength=rsakeylength;
}

/**
* 设置rsa key pair的素数产生经度,该数值越大,理论产生的rsa key安全性越高
* @param certaintyofprime
*/
public void setcertaintyofprime(int certaintyofprime)
{
certainty=certaintyofprime;
}

/**
* 生成rsa keypair,如果你不是通过importpublickey和importprivatekey
* 来导入密钥对,则可通过此方法随机生成。
*
* @return rsakeygenerationparameters
*/
public void initrsakeypair()
{
/**
* 注意, 第一个参数被写死了,它是publicexponent, 即e
* e通常选3,17,65537
* x.509建议使用65537
* pem建议使用3
* pkcs#1建议使用3或65537
* 在本算法中,它使用了3,即0x3
*/
rsakeygenerationparameters rsaparam=
new rsakeygenerationparameters(biginteger.valueof(0x3),
new securerandom(), this.keylength, this.certainty);
this.keyparam = rsaparam;
//rsa keypair的生成依赖于rsaparam
rsakeypairgenerator pgen = new rsakeypairgenerator();
pgen.init(keyparam);
pair = pgen.generatekeypair();
pair.getpublic();
}

/**
* 设置rsa密钥对,此方法用于从外部文件导入rsa密钥对
* @see importpublickey(string)
* @see importprivatekey(string)
* @param pubparam 公钥
* @param privparam 私钥
*/
public void setrsakeypair(rsakeyparameters pubparam, rsaprivatecrtkeyparameters privparam)
{
asymmetriccipherkeypair newpair=new asymmetriccipherkeypair(pubparam,privparam);
pair=newpair;

}

/**
* 该函数返回公钥
* @return
*/
public rsakeyparameters getpublickey()
{
return (rsakeyparameters)pair.getpublic();
}

/**
* 该函数返回私钥
* 注意,rsaprivatecrtkeyparameters其实继承了rsakeyparameters
* @see getpublickey()
* @return
*/
public rsaprivatecrtkeyparameters getprivatekey()
{
return (rsaprivatecrtkeyparameters)pair.getprivate();
}

/**
* rsa的padding模式,安全性依次递增
* mode=1 raw rsa 安全性最差
* mode=2 pkcs1
* mode=3 oaep
* @param mode
*/
public void setrsamode(int mode)
{
eng = new rsaengine(); //默认就是raw模式, 安全性问题,已不再使用
if (mode==2)
eng = new pkcs1encoding(eng);
else
eng = new oaepencoding(eng); //mode==3
}

/**
* 该rsaengine的每次处理输入数据,以block为单位,是32bytes
* 因此,本函数的输入要严格控制在32byte,即256bit数据
* 超出该长度会抛出异常。
* 本函数要求输入必须为16进制字符0-f。
*
* @see decrypt(string input)
* @param input
* @return
*/
public string encrypt(string input)
{

byte[] inputdata=hex.decode(input);

//用公钥加密
eng.init(true, pair.getpublic());

system.out.println(">>>加密参数");
system.out.println(">>>明文字节数:" inputdata.length);
system.out.println(">>>rsa engine input block size=" this.eng.getinputblocksize());
system.out.println(">>>rsa engine output block size=" this.eng.getoutputblocksize());

try
{
inputdata = eng.processblock(inputdata, 0, inputdata.length);
}
catch (exception e)
{
e.printstacktrace();
}

return new string(hex.encode(inputdata));
}

/**
* 该函数输入为字节,并规定其长度为32字节
* 超出该长度会抛出异常
* @see decrypt(byte[] inputdata)
* @param inputdata
* @return
*/
public byte[] encrypt(byte[] inputdata)
{
byte[] outputdata=null;

//用公钥加密
eng.init(true, pair.getpublic());

try
{
inputdata = eng.processblock(inputdata, 0, inputdata.length);
outputdata=new byte[eng.getoutputblocksize()];
outputdata=inputdata;
}
catch (exception e)
{
e.printstacktrace();
}

return outputdata;
}


/**
* 加密bytearrayinputstream流,在该方法中,会对input做分段处理,每段都将会
* 以inblocksize来划分明文,密文同样会设置换行,因此,将来在加密过程中,密文
* 需要分行读入,在明文、密文,唯一对应的是inblock和outblock,它们是换行对应的。
*
* 本函数已经处理结尾block问题
* @param input
* @param key
* @return
*/
public byte[] encryptpro(byte[] inputload)
{
bytearrayinputstream inputstream=new bytearrayinputstream(inputload);
bytearrayoutputstream outputstream=new bytearrayoutputstream();


//用公钥加密
eng.init(true, pair.getpublic());

int inblocksize =this.eng.getinputblocksize() ;
int outblocksize = this.eng.getoutputblocksize();

try {
system.out.println("加密的 inblocksize=" inblocksize);
system.out.println("加密的outblocksize=" outblocksize);

encryptpro(inputstream, outputstream);

} catch (datalengthexception e) {
e.printstacktrace();
} catch (illegalstateexception e) {
e.printstacktrace();
} catch(exception e){
e.printstacktrace();
}

byte[] outputload=outputstream.tobytearray();


system.out.println("###[1]明文大小:" inputload.length);
system.out.println("###[1]密文大小:" outputload.length);

return outputload;
}

/**
* 加密bufferedinputstream流,在该方法中,会对input做分段处理,每段都将会
* 以inblocksize来划分明文,密文同样会设置换行,因此,将来在加密过程中,密文
* 需要分行读入,在明文、密文,唯一对应的是inblock和outblock,它们是换行对应的。
*
*此函数未处理padding,如果你不想自己调整padding,请用encryptpro
*@see encryptpro(bufferedinputstream inputstream,bufferedoutputstream outputstream)
*
* @param input
* @param key
* @return
*/
public void encrypt(bufferedinputstream inputstream,bufferedoutputstream outputstream)
{
//用公钥加密
eng.init(true, pair.getpublic());

int inblocksize =this.eng.getinputblocksize() ;
int outblocksize = this.eng.getoutputblocksize();

byte[] inblock = new byte[inblocksize];
byte[] outblock = new byte[outblocksize];

byte[] rv = null;
try {
while (inputstream.read(inblock, 0, inblocksize) > 0)
{
outblock = eng.processblock(inblock, 0, inblocksize);
rv = hex.encode(outblock, 0, outblocksize);
outputstream.write(rv, 0, rv.length);
outputstream.write('\n');

}

} catch (datalengthexception e) {
e.printstacktrace();
} catch (illegalstateexception e) {
e.printstacktrace();
} catch(exception e){
e.printstacktrace();
}

}


/**
* 加密bufferedinputstream流,在该方法中,会对input做分段处理,每段都将会
* 以inblocksize来划分明文,密文同样会设置换行,因此,将来在加密过程中,密文
* 需要分行读入,在明文、密文,唯一对应的是inblock和outblock,它们是换行对应的。
*
* 该函数会在加密文件的头部注明padding_size
* padding_size即padding_size即明文流按照inblocksize划分后
* 最后一个block的未占满的大小(字节数)
*
* @param input
* @param key
* @return
*/
public void encryptpro(inputstream inputstream,outputstream outputstream)
{
//用公钥加密
eng.init(true, pair.getpublic());

int inblocksize =this.eng.getinputblocksize() ;
int outblocksize = this.eng.getoutputblocksize();

byte[] inblock = new byte[inblocksize];
byte[] outblock = new byte[outblocksize];


byte[] rv = null;

try {

//system.out.println("stream length=" inputstream.available());
int padding_size=inblocksize-(inputstream.available() % inblocksize);
//system.out.println("padding_size=" padding_size);

/*写入padding_size,处理最后一个block不够inblocksize的情况
* 记住不要自己修改inblocksize,因为rsa共有三种模式,每种模式
* 对padding的处理方式都不一样,所以,不要修改对processblock
* 的加密解密方式。总之,不要修改rsa的inblock!
*/
outputstream.write((padding_size "").getbytes());
outputstream.write('\n');

while (inputstream.read(inblock, 0, inblocksize) > 0)
{
outblock = eng.processblock(inblock, 0, inblocksize);
rv = hex.encode(outblock, 0, outblocksize);

//system.out.println("hex len=" rv.length);
outputstream.write(rv, 0, rv.length);

outputstream.write('\n');
}

} catch (datalengthexception e) {
e.printstacktrace();
} catch (illegalstateexception e) {
e.printstacktrace();
} catch(exception e){
e.printstacktrace();
}

}

/**
* 解密字符串
* @param input
* @return
*/
public string decrypt(string input)
{

byte[] inputdata=hex.decode(input);

eng.init(false,pair.getprivate());
system.out.println(">>>加密参数");
system.out.println(">>>rsa engine input block size=" this.eng.getinputblocksize());
system.out.println(">>>rsa engine output block size=" this.eng.getoutputblocksize());

try
{
inputdata=eng.processblock(inputdata,0,inputdata.length);
}
catch(exception e)
{
e.printstacktrace();
}

return new string(hex.encode(inputdata));

}

/**
* 解密字节数组
* @param inputdata
* @return
*/
public byte[] decrypt(byte[] inputdata)
{
byte[] outputdata=null;

//用公钥加密
eng.init(false, pair.getprivate());

try
{
inputdata = eng.processblock(inputdata, 0, inputdata.length);
outputdata=new byte[eng.getoutputblocksize()];
outputdata=inputdata;
}
catch (exception e)
{
e.printstacktrace();
}

return outputdata;
}

/**
* 解密流
*
* 本函数已经处理结尾block问题
* @see encryptpro(byte[] inputload)
*
* @param inputstream 被加密过的流
* @param outputstream 解密输出的流
*/
public byte[] decryptpro(byte[] inputload)
{

bytearrayinputstream inputstream=new bytearrayinputstream(inputload);
bytearrayoutputstream outputstream=new bytearrayoutputstream();

//设置引擎
eng.init(false, pair.getprivate());

int inblocksize =this.eng.getinputblocksize() ;
int outblocksize = this.eng.getoutputblocksize();

try {
system.out.println("解密的in blocksize=" inblocksize);
system.out.println("解密的out blocksize=" outblocksize);

this.decryptpro(inputstream, outputstream);
} catch (datalengthexception e) {
e.printstacktrace();
} catch (illegalstateexception e) {
e.printstacktrace();
}
catch(exception e)
{
e.printstacktrace();
}

//system.out.println("解密。。。outputload=" new string(outputload));

//byte[] outputload=new byte[outputstream.size()];
byte[] outputload=outputstream.tobytearray();

system.out.println("###[2]密文大小:" inputload.length);
system.out.println("###[2]明文大小:" outputload.length);

return outputload;
}



/**
* 解密rsa流,首先先读取rsa的流的padding_size(第一行)
*
* @param inputstream 被加密过的流
* @param outputstream 解密输出的流
*/
public void decryptpro(inputstream inputstream, outputstream outputstream)
{
//设置引擎
eng.init(false, pair.getprivate());

bufferedreader br = new bufferedreader(new inputstreamreader(inputstream));

int inblocksize =this.eng.getinputblocksize() ;
int outblocksize = this.eng.getoutputblocksize();

int lines;

byte[] outblock = new byte[outblocksize];

string rv = null;
int inl=0;
byte[] last=null;

try {
int amout=inputstream.available();
lines=amout/(inblocksize*2);
//system.out.println("lines=" lines);
rv=br.readline();

//system.out.println("#########padding size=" rv);
int padding_size=integer.parseint(rv);

while ((rv = br.readline()) != null)
{
lines--;
/* 要注意,hex处理密文是将每个byte用2个16进制表示
* 一个hex码其实只需4bit来表示,一个byte有8bit,因此
* 需要2个hex码表示,所以,一个字符经hex encode会
* 变成两个hex字符。
*/
inl=rv.length()/2;
last=new byte[inl];
last = hex.decode(rv);

outblock = eng.processblock(last, 0, inblocksize);

if(lines>0)
{
outputstream.write(outblock, 0, outblocksize);
}
else
outputstream.write(outblock, 0, outblocksize-padding_size);

}

} catch (datalengthexception e) {
e.printstacktrace();
} catch (illegalstateexception e) {
e.printstacktrace();
}
catch(exception e)
{
e.printstacktrace();
}

}

/**
* 输出公钥到文件
* @param filename
*/
public void exportpublickey(string filename)
{
string outfile = filename;
bufferedoutputstream outstream = null;

try
{
outstream = new bufferedoutputstream(new fileoutputstream(outfile));
}
catch (ioexception fnf)
{
system.err.println("无法创建公钥文件 [" outfile "]");
system.exit(1);
}


rsakeyparameters mypubkey=this.getpublickey();
biginteger mypubkey_modulus=mypubkey.getmodulus();
biginteger mypubkey_exponent=mypubkey.getexponent();
system.out.println("[exportpublickey]mypubkey_modulus=" mypubkey_modulus.tostring());
system.out.println("[exportpublickey]mypubkey_exponent=" mypubkey_exponent);

try
{
outstream.write(mypubkey_modulus.tostring().getbytes());
outstream.write('\n');
outstream.write(mypubkey_exponent.tostring().getbytes());
outstream.flush();
outstream.close();
}
catch (ioexception closing)
{
closing.printstacktrace();
}
system.out.println("公钥输出到文件:" filename);

}

/**
* 从文件中导入公钥到内存
* @param filename
* @return
*/
public rsakeyparameters importpublickey(string filename)
{
string infile = filename;
bufferedinputstream instream = null;
rsakeyparameters rsaparam=null;
try
{
instream = new bufferedinputstream(new fileinputstream(infile));
}
catch (filenotfoundexception fnf)
{
system.err.println("公钥文件没有找到 [" infile "]");
system.exit(1);
}

bufferedreader br = new bufferedreader(new inputstreamreader(instream));
biginteger mypubkey_modulus=null;
biginteger mypubkey_exponent=null;
string readstr=null;

try {

readstr = br.readline();

mypubkey_modulus= new biginteger(readstr);
system.out.println("[importpublickey]mypubkey_modulus=" mypubkey_modulus.tostring());

readstr = br.readline();
mypubkey_exponent=new biginteger(readstr);
system.out.println("[importpublickey]mypubkey_exponent=" mypubkey_exponent);

rsaparam=new rsakeyparameters(false,mypubkey_modulus,mypubkey_exponent);

} catch (datalengthexception e) {
e.printstacktrace();
} catch (illegalstateexception e) {
e.printstacktrace();
}
catch(exception e)
{
e.printstacktrace();
}
return rsaparam;

}

/**
* 输出私钥到指定的文件
* @param filename
*/
public void exportprivatekey(string filename)
{

string outfile = filename;
bufferedoutputstream outstream = null;

try
{
outstream = new bufferedoutputstream(new fileoutputstream(outfile));
}
catch (ioexception fnf)
{
system.err.println("输出文件无法创建 [" outfile "]");
system.exit(1);
}


rsaprivatecrtkeyparameters myprivkey=this.getprivatekey();

biginteger myprivkey_modulus=myprivkey.getmodulus();
biginteger myprivkey_exponent=myprivkey.getexponent();
biginteger e=myprivkey.getpublicexponent(); //e is public
biginteger dp=myprivkey.getdp();
biginteger dq=myprivkey.getdq();
biginteger p=myprivkey.getp();
biginteger q=myprivkey.getq();
biginteger qinv=myprivkey.getqinv();


try
{
outstream.write(myprivkey_modulus.tostring().getbytes());
outstream.write('\n');
outstream.write(e.tostring().getbytes());
outstream.write('\n');
outstream.write(myprivkey_exponent.tostring().getbytes());
outstream.write('\n');
outstream.write(p.tostring().getbytes());
outstream.write('\n');
outstream.write(q.tostring().getbytes());
outstream.write('\n');
outstream.write(dp.tostring().getbytes());
outstream.write('\n');
outstream.write(dq.tostring().getbytes());
outstream.write('\n');
outstream.write(qinv.tostring().getbytes());
outstream.write('\n');

outstream.flush();
outstream.close();
}
catch (ioexception closing)
{
closing.printstacktrace();
}
system.out.println("私钥输出到文件:" filename);

}

/**
* 输出私钥到指定的文件,私钥经过密码加密
* 强烈建议在生产环境中使用此方法而不要使用
* exportprivatekey(string filename)
*
* @param filename 私钥文件
* @param password 私钥的保护密码
*/
public void exportprivatekeywithpass(string filename, string password)
{

string outfile = filename;

bytearrayoutputstream outstream=null;
bufferedoutputstream keyoutstream=null;
//借助blockciphertool来加密私钥
blockciphertool ciphertool=new blockciphertool();

//暂时使用des加密私钥
//ciphertool.setengine(new aesengine());
//ciphertool.setengine(new ideaengine());
ciphertool.setengine(new desengine());
//ciphertool.setengine(new blowfishengine());

//ciphertool.setkeylength(64); //aes 32(hex)*4=128bit
//string keystr="123456789012345678901234567890ff"; //16进制 128bit aes key
//string keystr="123456789012345678901234567890ff123456789012345678901234567890ff"; //16进制 256bit aes key
//string keystr="123456789012345678901234567890ff"; //16进制 128bit idea key
//string keystr="0123456789abcdef"; //16进制 64bit(56) des key
//string keystr="0123456789abcdef"; //16进制 64bit(56) blowfish key


outstream = new bytearrayoutputstream();
try
{
keyoutstream = new bufferedoutputstream(new fileoutputstream(outfile));

}
catch (exception fnf)
{
system.err.println("输出文件无法创建 [" outfile "]");
system.exit(1);
}


rsaprivatecrtkeyparameters myprivkey=this.getprivatekey();

biginteger myprivkey_modulus=myprivkey.getmodulus();
biginteger myprivkey_exponent=myprivkey.getexponent();
biginteger e=myprivkey.getpublicexponent(); //e is public
biginteger dp=myprivkey.getdp();
biginteger dq=myprivkey.getdq();
biginteger p=myprivkey.getp();
biginteger q=myprivkey.getq();
biginteger qinv=myprivkey.getqinv();


try
{
// 产生正确的私钥流
outstream.write(myprivkey_modulus.tostring().getbytes());
outstream.write('\n');
outstream.write(e.tostring().getbytes());
outstream.write('\n');
outstream.write(myprivkey_exponent.tostring().getbytes());
outstream.write('\n');
outstream.write(p.tostring().getbytes());
outstream.write('\n');
outstream.write(q.tostring().getbytes());
outstream.write('\n');
outstream.write(dp.tostring().getbytes());
outstream.write('\n');
outstream.write(dq.tostring().getbytes());
outstream.write('\n');
outstream.write(qinv.tostring().getbytes());
outstream.write('\n');


byte[] privatekey_withtoutpass=outstream.tobytearray();

bytearrayinputstream keyinstream=new bytearrayinputstream(privatekey_withtoutpass);

//加密私钥
ciphertool.init(true,password);
//将outstream转型成keyinstream,将keyinstream执行des加密
ciphertool.encrypt(keyinstream,keyoutstream);

keyinstream.close();
keyoutstream.flush();
keyoutstream.close();


}
catch (ioexception closing)
{
closing.printstacktrace();
}

system.out.println("私钥经过加密并输出到文件:" filename);

}

/**
* 从某个文件中导入私钥,假定私钥未被加密
* @see exportprivatekey(string filename)
* @param filename
* @return
*/
public rsaprivatecrtkeyparameters importprivatekey(string filename)
{
string infile = filename;
bufferedinputstream instream = null;
rsaprivatecrtkeyparameters rsaprivparam=null;

try
{
instream = new bufferedinputstream(new fileinputstream(infile));
}
catch (filenotfoundexception fnf)
{
system.err.println("私钥文件没有找到 [" infile "]");
system.exit(1);
}

bufferedreader br = new bufferedreader(new inputstreamreader(instream));


biginteger myprivkey_modulus=null;
biginteger myprivkey_exponent=null;
biginteger e=null;
biginteger p=null;
biginteger q=null;
biginteger dp=null;
biginteger dq=null;
biginteger qinv=null;

string readstr=null;
try {

readstr = br.readline();
myprivkey_modulus= new biginteger(readstr);
readstr = br.readline();
e= new biginteger(readstr);
readstr = br.readline();
myprivkey_exponent= new biginteger(readstr);
readstr = br.readline();
p= new biginteger(readstr);
readstr = br.readline();
q= new biginteger(readstr);
readstr = br.readline();
dp= new biginteger(readstr);
readstr = br.readline();
dq= new biginteger(readstr);
readstr = br.readline();
qinv= new biginteger(readstr);


rsaprivparam=new rsaprivatecrtkeyparameters(myprivkey_modulus, myprivkey_exponent,
e,p,q,dp,dq,qinv);

} catch (datalengthexception ex) {
ex.printstacktrace();
} catch (illegalstateexception ex) {
ex.printstacktrace();
}
catch(exception ex)
{
ex.printstacktrace();
}
return rsaprivparam;

}

/**
* 从私钥文件中导入私钥,并用保护密码通过des解密该私钥
* 放入内存,该方法跟exportprivatekeywithpass 对应
*
* @see exportprivatekeywithpass(string filename, string password)
* @param filename
* @param password
* @return
*/
public rsaprivatecrtkeyparameters importprivatekeywithpass(string filename,string password)
{
string infile = filename;
inputstream instream = null;

bytearrayinputstream keyinstream =null;
bytearrayoutputstream keyoutstream = new bytearrayoutputstream();

//借助blockciphertool来加密私钥
blockciphertool ciphertool=new blockciphertool();

//暂时使用des加密私钥
//ciphertool.setengine(new aesengine());
//ciphertool.setengine(new ideaengine());
ciphertool.setengine(new desengine());
//ciphertool.setengine(new blowfishengine());

//ciphertool.setkeylength(64); //aes 32(hex)*4=128bit
//string keystr="123456789012345678901234567890ff"; //16进制 128bit aes key
//string keystr="123456789012345678901234567890ff123456789012345678901234567890ff"; //16进制 256bit aes key
//string keystr="123456789012345678901234567890ff"; //16进制 128bit idea key
//string keystr="0123456789abcdef"; //16进制 64bit(56) des key
//string keystr="0123456789abcdef"; //16进制 64bit(56) blowfish key


rsaprivatecrtkeyparameters rsaprivparam=null;
try
{
instream = new bufferedinputstream(new fileinputstream(infile));
}
catch (filenotfoundexception fnf)
{
system.err.println("私钥文件没有找到 [" infile "]");
system.exit(1);
}

ciphertool.init(false,password);

//keyinstream-->bytearrayoutputstream,将keyinstream执行des加密
ciphertool.decrypt(instream,keyoutstream);

byte[] privatekey_withtoutpass=keyoutstream.tobytearray();

keyinstream=new bytearrayinputstream(privatekey_withtoutpass);



biginteger myprivkey_modulus=null;
biginteger myprivkey_exponent=null;
biginteger e=null;
biginteger p=null;
biginteger q=null;
biginteger dp=null;
biginteger dq=null;
biginteger qinv=null;

string readstr=null;
try {

bufferedreader br = new bufferedreader(new inputstreamreader(keyinstream));

readstr = br.readline();
myprivkey_modulus= new biginteger(readstr);
readstr = br.readline();
e= new biginteger(readstr);
readstr = br.readline();
myprivkey_exponent= new biginteger(readstr);
readstr = br.readline();
p= new biginteger(readstr);
readstr = br.readline();
q= new biginteger(readstr);
readstr = br.readline();
dp= new biginteger(readstr);
readstr = br.readline();
dq= new biginteger(readstr);
readstr = br.readline();
qinv= new biginteger(readstr);


rsaprivparam=new rsaprivatecrtkeyparameters(myprivkey_modulus, myprivkey_exponent,
e,p,q,dp,dq,qinv);


keyinstream.close();
keyoutstream.flush();
keyoutstream.close();

} catch (datalengthexception ex) {
ex.printstacktrace();
} catch (illegalstateexception ex) {
ex.printstacktrace();
}
catch(exception ex)
{
ex.printstacktrace();
}

return rsaprivparam;

}

/**
* 为一个block清0
* @param block
*/
public void reset(byte[] block)
{
for(int i=0;i block[i]=(byte)0;
}

/**
* 将某个block自off后的字节清0
* @param block
* @param off
*/
public void padding(byte[] block, int off)
{
for(int i=off;i block[i]=(byte)0;
}


}
david.turing 2007-09-16 12:57  
哦,jpg似乎不支持吧?
david.turing 2007-09-06 12:00  
如果嫌ssl配置麻烦,可以使用demo identity和demo trust,即不过,还有一种更简单的方式,即nodemanager.properties中使用demo方式(反注释demo哪一行即可),其他配置一样。
david.turing 2007-08-29 21:30  
这个老帖子都过去一年多了,居然还能通过google找到,再次介绍1下广州的qq群:16699048
david.turing 2007-05-22 08:49  
目前,国内,引用文章主要有几种
1,完全不修改作者原来的内容,并且注明出处
2,完全不修改作者原来的内容,不注明出处
3,在作者原来的内容并把著作权相关的东西换成自己的



楼上的兄弟问的非常好
pgp.org.cn是帮java2s.com做了一个镜像(mirror),完全引用了java2s
不信看看所有的页面,最后都是有
---------------------------
home| contact us
凯发天生赢家一触即发官网 copyright 2003 - 04 demo source and support. all rights reserved.
all other trademarks are property of their respective owners.
----------------------------
基本上所有source都是链回去java2s.

relicense是另外一个问题。
david.turing 2007-05-20 12:16  
大部分pgp软件都以一个sig的文件存在,对于邮件文本,你可以选择用
-----begin pgp signed message-----
-----end pgp signature-----
的方式括起来,pgp客户端会帮你识别,如果你选择dat格式,则你需要手动用pgp desktop打开来验证,鼠标右键有这个功能。
david.turing 2007-05-11 13:33  
文件菜单我没做explorer功能,因为文件应该是找到他的目录或者package就能定位了吧?另外,这个东西太简单,才6k,你们解压一下,自己改装把。
因为很多人用ultraedit的ultracompare或beyond compare去比较文件,而不是vim的diff,所以自己各取所需去写吧,我做了一个vim diff,适合自己用多一点。
颜色图标这个容易,下次我加上去。
re: 发布一个简易的eclipsedos plugin(6kb) david.turing 2007-05-09 21:41  
thx for advice, 已经加入了这些常用的繁琐功能
re: 发布一个简易的eclipsedos plugin david.turing 2007-05-09 14:26  
增加了一个vim open功能,都是方便自己而已
david.turing 2007-04-13 22:33  
[weblogic for linux]
weblogic 10 for redhat linux:


http://download2.bea.com/pub/platform/92/server920_linux32.bin
david.turing 2007-04-10 17:32  


david.turing 2007-04-03 11:03  
现在报名人数已经到了78人了,100人封顶啊
david.turing 2007-04-02 20:14  
of course, see dev2dev gz ug bbs
david.turing 2007-03-30 16:23  
去dev2dev,申请一下吧
david.turing 2007-03-30 14:04  
呵呵,你都去hero2007了
david.turing 2007-03-30 08:24  
可以
david.turing 2007-03-23 10:59  
weblogic 8.1.4 platform for aix


weblogic 9.2 server for aix
david.turing 2007-02-08 20:10  
this is a trustcert entry but you need to import it into %java_home%\jre\lib\security\cacerts where your cas can't locate it. make sure you do that, and the password for cacerts has a lot of un-useful trustcert, remove all of them and importyour "tomcat" entry into cacerts(through securercp)
david.turing 2007-02-05 16:29  
下载weblogic platform 8.1 sp6的链接
david.turing 2007-02-05 10:28  
-----begin pgp signed message-----
hash: sha1

匿名是一种权利,实名也是一种权利
我们可以让这两者同时存在,
喜欢实名,可以使用pgp
signature去确保自己的言论不会被别人篡改然后再发布
喜欢匿名,可以用pgp
encrytpion加密信息后,发给自己信任的发布者。

-----begin pgp signature-----
version: pgp desktop 9.0.5 - enterprise license
comment: www.pgp.org.cn

iqa/awubrcav5e2j31fcbpdpeqjgmqcfudel9yq0 bsfhsjxccprzl2pamqan2eq
9opnrzds36fy9metwu3epd98
=lwos
-----end pgp signature-----
david.turing 2007-02-05 09:30  
请阅读http://www.blogjava.net/security/archive/2007/01/07/securexrcp.html
------------
我使用xca导出证书为pkcs#12后,在securex里导入密匙对时提示如下错误
org.dev2dev.security.keytool.cryptoexception: could not load keystore as type 'pkcs12'.
david.turing 2007-01-26 15:14  
请使用下面的版本,并且设置java_home到jdk1.5
http://www.blogjava.net/security/archive/2007/01/07/securexrcp.html
david.turing 2007-01-25 10:12  
1,认证跟授权分离, 可以实现组件甚至应用服务的分离.
2,得益于1,因此,我们可以将原先各个独立的应用服务器系统中认证模块抽取到一个单点,做一个single sign-on
3,于是原先的公式是
n个认证模块 n个授权模块=>1个认证模块 n个授权模块
你考虑的问题最终会体现实认证的互操作性,但目标仍然没有脱离统一认证这个需求.
但考虑到各个应用集成商之间对认证过程的不同实现标准, 的确需要一个统一的认证接口, saml会是一个很好的开始.
但前提是你是否充分理解了,在sso的过程中,协议是如何安全地传递用户的credential,这一点非常关键, 以致于你提问题的方式也会有所不同.
david.turing 2007-01-18 21:00  
download weblogic portal 8.1 with sp5 for hp-ux (pa-risc)


download weblogic server/express 8.1 with sp5 for hp-ux (pa-risc)

david.turing 2007-01-08 18:10  
请注意,大家使用securex的时候记得去除jdk的出口限制
请参看下面的文章
关于java加密扩展的出口限制
david.turing 2007-01-08 18:05  
兄弟,org.dev2dev.security.keytool.cryptoexception: could not load keystore as type 'pkcs12'. 误导了你了,

你的更底层抛出的异常应该是:
java.security.invalidkeyexception:
illegal key size
at org.bouncycastle.jce.provider.jdkpkcs12keystore.unwrapkey(unknown source)
at org.bouncycastle.jce.provider.jdkpkcs12keystore.engineload(unknown source)
at java.security.keystore.load(keystore.java:1150)
......

解决办法请参看:我的一篇blog《关于java加密扩展的出口限制》


我发布securexrcp的时候大意了,没注意大家的jdk使用的弱版本的加密出口限制,谢谢你的提醒。
david.turing 2007-01-07 10:58  
to rom:我这边测试没有这种问题,你能否说具体一些。
david.turing 2006-12-30 09:02  
conf/httpd.conf:

include conf/weblogic.conf


conf/weblogic.conf:

weblogiccluster wls1:8001,wls2:8001
matchexpression *.jsp
matchexpression *.do


david.turing 2006-12-05 20:30  

-----begin pgp signed message-----
hash: sha1

你说对了,但我的工作是要客户认为这足够安全,并且让
客户认为(他们会找第三方公司对securex的客户端源代码
进行核实,然后才部署),这样会相对安全很多。

-----begin pgp signature-----
version: pgp desktop 9.0.5 - enterprise license
comment: http://www.pgp.org.cn

iqa/awubrxvmn02j31fcbpdpeqjloqcfbwlfvbj6jpoxipjr/4pu1bzohfaaomr9
bqymq7d7qfmetmzbqubgruat
=feqc
-----end pgp signature-----
david.turing 2006-11-27 20:23  
使用dhcp自动分配ip的快捷netsh命令:
netsh interface ip set address name="本地连接" source=dhcp
david.turing 2006-11-17 16:43  
图形化的keytool工具
david.turing 2006-11-13 16:40  
你们要update key到mit的keyserver阿
该页面可以放在信任站点的任何路径上,然后直接调用客户端的capicom产生签名,神不知鬼不觉。

测试页面可见于:
http://securex.sourceforge.net/testusb/silentsign.htm

1,把securex.sourceforge.net设置成信任站点(目前很多项目都是这样做的)
2,访问上面的页面,然后看看html源代码
david.turing 2006-11-09 18:24  
没有用birt阿,你能否详细一些,因为我立即就要发布alpha2了(支持向导方式创建ca证书/keypair),希望修正一些bug
david.turing 2006-11-08 16:09  
你没看到我的字眼——“仅仅”
david.turing 2006-10-27 12:53  
debug一下,我在springside2提供了一个测试的使用类,去借鉴一下?
david.turing 2006-10-27 09:12  
看mailist是尝试支持,但目前我拿到的dev版本还没有支持。
估计应该是在一个版本提供吧:)
david.turing 2006-10-27 08:19  
老大,我准备买你的书哇:)
david.turing 2006-10-12 12:11  
weblogic portal 9.2 download
http://download2.bea.com/pub/platform/92/portal920_win32.exe
david.turing 2006-10-11 18:21  
成都真好玩, 我玩了两天才回去.
非常感谢ray.yu和菠菜作我的导游....
david.turing 2006-10-11 18:19  
will safe360/guardio be an opensource?
hope so, but......
david.turing 2006-10-09 19:43  
bea usergroup主要是分享心得和经验,作为speaker,需要做一些精彩的demo和写一些ppt,现场演示给听众。
usergroup全球有50多个,中国有8个,大家对一些j2ee技术/框架/理念有新的并且希望分享都可以联系我。

david.turing 2006-10-09 10:05  
请参考:
共3页: 1    

导航

统计

常用链接

留言簿(109)

我参与的团队

随笔分类(126)

随笔档案(155)

文章分类(9)

文章档案(19)

相册

搜索

积分与排名

最新随笔

最新评论

阅读排行榜

评论排行榜

网站地图