我得到的錯誤在gradle測試代碼。此行代碼生成異常:account.setAccountNumber(encryptor.encrypt(「999999999」))。錯誤:導致:java.security.InvalidKeyException在AccountLookupSpec.groovy
這個帖子可能涉及:
What is the correct way to configure a spring TextEncryptor for use on Heroku
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
我在的IntelliJ IDEA
$ gradle -version
------------------------------------------------------------
Gradle 2.3-20141027185330+0000
------------------------------------------------------------
Build time: 2014-10-27 18:53:30 UTC
Build number: none
Revision: f8200ecfed690fe7e2183d60a2afa85069678fa3
Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_05 (Oracle Corporation 25.5-b02)
OS: Mac OS X 10.11 x86_64
$ gradle clean build
運行Java 1.8 ...
:測試
com.distributedfinance.mbi.bai.lookup.AccountLookupSpec > constructor missing encryptor FAILED
java.lang.IllegalArgumentException at AccountLookupSpec.groovy:26
Caused by: java.security.InvalidKeyException at AccountLookupSpec.groovy:26
唯一的例外是在Groovy代碼:
AccountLookup accountLookup
List<Account> accounts
AccountRepository accountRepository
TextEncryptor encryptor
def setup() {
accountRepository = Mock()
encryptor = Encryptors.text("password", "blahblahbla")
***account.setAccountNumber(encryptor.encrypt("999999999"))***
...
def "constructor missing encryptor"() {
when:
new AccountLookup(null, accountRepository)
then:
IllegalArgumentException e = thrown()
e.getMessage() == "Encryptor is null"
}
我試圖通過在Groovy代碼(設置斷點在 '連接' 從IntelliJ IDEA的調試這一點,也「聽」模式):
$ export GRADLE_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
$ gradle build
Listening for transport dt_socket at address: 5005
但我從來沒有達到我的斷點。
任何想法?
如果您列出了Spring標籤,您可能會省下一些努力。以前從未見過TextEncryptor。 – billjamesdev