使用Java Embedded的SHA1 BPEL

时间:2018-07-30 10:56:59

标签: java java-7 soa sha1 bpel

所以我试图使用Java嵌入式对BPEL服务中的某些代码进行哈希处理,

    XMLElement pwdElement = (XMLElement)getVariableData("setVar","/n8SetVar","/ns8:pwd");  
            String text = pwdElement.getTextContent();  
MessageDigest md;  
md = MessageDigest.getInstance("SHA-1");  
byte[] data = new byte[40];  
md.update(text.getBytes("iso-8859-1"), 0, text.length());  
data = md.digest();  

StringBuffer buf = new StringBuffer();  
for (int i = 0; i < data.length; i++) {  
    int halfbyte = (data[i] >>> 4) & 0x0F;  
    int two_halfs = 0;  
    do {  
        if ((0 <= halfbyte) && (halfbyte <= 9)) {  
            buf.append((char) ('0' + halfbyte));  
        } else {  
            buf.append((char) ('a' + (halfbyte - 10)));  
        }  
        halfbyte = data[i] & 0x0F;  
    } while (two_halfs++ < 1);  
}  

String result = buf.toString(); 

我也已经在BPEL流程中导入了库,但是仍然出现错误。

<import location="oracle.xml.parser.v2.XMLElement" importType="http://schemas.oracle.com/bpel/extension/java"/>
 <import location="java.security.MessageDigest" importType="http://schemas.oracle.com/bpel/extension/java"/>  
 <import location="java.security.NoSuchAlgorithmException" importType="http://schemas.oracle.com/bpel/extension/java"/>  
<import location="java.io.UnsupportedEncodingException" importType="http://schemas.oracle.com/bpel/extension/java"/>

有人可以帮我吗?

顺便说一句,我不能放log4j来发现一些错误,因为这不是本地主机,

0 个答案:

没有答案