Browse Source

Pull request #39: 无JIRA任务 修复一些demo编译问题,已经程序数据集逻辑不严谨问题(getColumnName可能报错NPE)

Merge in PG/plugin-report-doc-demo from ~ZACK/plugin-report-doc-demo:release/10.0 to release/10.0

* commit 'bff933481e54ff32e1b7d907c1f91cab605bb4e0':
  无JIRA任务 修复一些demo编译问题,已经程序数据集逻辑不严谨问题(getColumnName可能报错NPE)
release/10.0
zack 4 years ago
parent
commit
fdab845093
  1. 2
      src/main/java/com/fr/data/ParamTableDataDemo.java
  2. 2
      src/main/java/com/fr/output/OutputExcel.java
  3. 15
      src/main/java/com/fr/privilege/RSAUtil.java

2
src/main/java/com/fr/data/ParamTableDataDemo.java

@ -50,11 +50,13 @@ public class ParamTableDataDemo extends AbstractTableData {
*/
@Override
public int getColumnCount() {
init();
return columnNum;
}
@Override
public String getColumnName(int columnIndex) {
init();
return columnNames[columnIndex];
}

2
src/main/java/com/fr/output/OutputExcel.java

@ -9,9 +9,9 @@ import com.fr.stable.ArrayUtils;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;

15
src/main/java/com/fr/privilege/RSAUtil.java

@ -1,5 +1,8 @@
package com.fr.privilege;
import com.fr.third.org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -19,8 +22,6 @@ import java.security.spec.InvalidKeySpecException;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;
import javax.crypto.Cipher;
/**
* RSA 工具类提供加密解密生成密钥对等方法
* 需要到http://www.bouncycastle.org下载bcprov-jdk14-123.jar。
@ -36,7 +37,7 @@ public class RSAUtil {
public static KeyPair generateKeyPair() throws Exception {
try {
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA",
new org.bouncycastle.jce.provider.BouncyCastleProvider());
new BouncyCastleProvider());
final int KEY_SIZE = 1024;// 没什么好说的了,这个值关系到块加密的大小,可以更改,但是不要太大,否则效率会低
keyPairGen.initialize(KEY_SIZE, new SecureRandom());
KeyPair keyPair = keyPairGen.generateKeyPair();
@ -79,7 +80,7 @@ public class RSAUtil {
KeyFactory keyFac = null;
try {
keyFac = KeyFactory.getInstance("RSA",
new org.bouncycastle.jce.provider.BouncyCastleProvider());
new BouncyCastleProvider());
} catch (NoSuchAlgorithmException ex) {
throw new Exception(ex.getMessage());
}
@ -106,7 +107,7 @@ public class RSAUtil {
KeyFactory keyFac = null;
try {
keyFac = KeyFactory.getInstance("RSA",
new org.bouncycastle.jce.provider.BouncyCastleProvider());
new BouncyCastleProvider());
} catch (NoSuchAlgorithmException ex) {
throw new Exception(ex.getMessage());
}
@ -133,7 +134,7 @@ public class RSAUtil {
public static byte[] encrypt(PublicKey pk, byte[] data) throws Exception {
try {
Cipher cipher = Cipher.getInstance("RSA",
new org.bouncycastle.jce.provider.BouncyCastleProvider());
new BouncyCastleProvider());
cipher.init(Cipher.ENCRYPT_MODE, pk);
int blockSize = cipher.getBlockSize();// 获得加密块大小,如:加密前数据为128个byte,而key_size=1024
// 加密块大小为127
@ -177,7 +178,7 @@ public class RSAUtil {
public static byte[] decrypt(PrivateKey pk, byte[] raw) throws Exception {
try {
Cipher cipher = Cipher.getInstance("RSA",
new org.bouncycastle.jce.provider.BouncyCastleProvider());
new BouncyCastleProvider());
cipher.init(cipher.DECRYPT_MODE, pk);
int blockSize = cipher.getBlockSize();
ByteArrayOutputStream bout = new ByteArrayOutputStream(64);

Loading…
Cancel
Save