我收到加密例外。
我正在跑步
我将Oracle JCE Policy jar安装到我的$ JAVA_HOME / lib / security目录中:
$ ls -l $JAVA_HOME/lib/security
total 16
-rw-r--r--@ 1 root wheel 2487 Oct 9 17:21 US_export_policy.jar
-rw-r--r--@ 1 root wheel 2500 Oct 9 17:21 local_policy.jar
这是例外:
com.distributedfinance.mbi.bai.lookup.AccountLookupSpec > constructor missing encryptor FAILED
19:05:00.431 [DEBUG] [TestEventLogger] java.lang.IllegalArgumentException: Unable to initialize due to invalid secret key
19:05:00.431 [DEBUG] [TestEventLogger] at org.springframework.security.crypto.encrypt.CipherUtils.initCipher(CipherUtils.java:110)
19:05:00.431 [DEBUG] [TestEventLogger] at org.springframework.security.crypto.encrypt.AesBytesEncryptor.encrypt(AesBytesEncryptor.java:65)
19:05:00.431 [DEBUG] [TestEventLogger] at org.springframework.security.crypto.encrypt.HexEncodingTextEncryptor.encrypt(HexEncodingTextEncryptor.java:36)
19:05:00.431 [DEBUG] [TestEventLogger] at com.distributedfinance.mbi.bai.lookup.AccountLookupSpec.setup(AccountLookupSpec.groovy:26)
19:05:00.431 [DEBUG] [TestEventLogger]
19:05:00.431 [DEBUG] [TestEventLogger] Caused by:
19:05:00.431 [DEBUG] [TestEventLogger] java.security.InvalidKeyException: Illegal key size
19:05:00.431 [DEBUG] [TestEventLogger] at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1034)
19:05:00.431 [DEBUG] [TestEventLogger] at javax.crypto.Cipher.implInit(Cipher.java:800)
19:05:00.431 [DEBUG] [TestEventLogger] at javax.crypto.Cipher.chooseProvider(Cipher.java:859)
19:05:00.432 [DEBUG] [TestEventLogger] at javax.crypto.Cipher.init(Cipher.java:1370)
19:05:00.432 [DEBUG] [TestEventLogger] at javax.crypto.Cipher.init(Cipher.java:1301)
19:05:00.432 [DEBUG] [TestEventLogger] at org.springframework.security.crypto.encrypt.CipherUtils.initCipher(CipherUtils.java:105)
19:05:00.432 [DEBUG] [TestEventLogger] ... 3 more
代码段:
import com.distributedfinance.mbi.payment.repository.AccountRepository
import com.distributedfinance.mbi.domain.Account
import org.springframework.security.crypto.encrypt.Encryptors
import org.springframework.security.crypto.encrypt.TextEncryptor
class AccountLookupSpec extends Specification {
public static final Logger LOGGER = LoggerFactory.getLogger(AccountLookupSpec.class)
AccountLookup accountL ookup
List<Account> accounts
AccountRepository accountRepository
TextEncryptor encryptor
def setup() {
accountRepository = Mock()
encryptor = Encryptors.text("password", "991239bab013")
accounts = new ArrayList<Account>()
Account account = new Account()
account.setAccountNumber(encryptor.encrypt("1234567890"))
}
...
}
答案 0 :(得分:7)
这个问题最常见的原因是/ lib / security没有安装Java密码术扩展(JCE)无限强度管辖区政策文件
Download the Java 7 jar from here
Download the Java 8 jar from here
按照自述文件操作,您应该启动并运行
答案 1 :(得分:1)
其他原因可能发生:
答案 2 :(得分:0)
这是下载JCE 8的命令。
curl -q -L -C - -b "oraclelicense=accept-securebackup-cookie" -o /tmp/jce_policy-8.zip \
-O http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip && \
unzip -oj -d /usr/lib/jvm/java-8-oracle/jre/lib/security \
/tmp/jce_policy-8.zip \*/\*.jar \
&& rm /tmp/jce_policy-8.zip
这假设您在/usr/lib/jvm/java-8-oracle
处拥有Oracle JVM 8。
答案 3 :(得分:0)
这可能是在VERSION mismatch of JAVA JRE
上出现的问题
我已通过将JRE版本从jdk1.8.0_111\jre
升级到jdk1.8.0_181\jre
来解决
希望您不必再有其他库。