BouncyCastle and Scala Configuration File with Grails
Recently, I finish a task about bouncy castle and scala jar dependencies with configuration file. Certainly, I met some problem. So I made a note here.
1. BouncyCastle Security Provider
First, I need to made some changes to my files under JAVA_HOME to enable the security provider.
Here is the JAVA_HOME directory in my MAC pro.
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
And I need to download bcprov-jdk16-1.46.jar and copy it to my directory
$JAVA_HOME/lib/ext
Then I need to edit the security file here.
$JAVA_HOME/lib/security/java.security
Adding the follow lines:
security.provider.11=org.bouncycastle.jce.provider.BouncyCastleProvider
2. Version Conflict
But I still get some error messages as follow:
Error Message 1:
Exception while try to send push notifications at user time:
java.lang.IllegalArgumentException: org.bouncycastle.jce.provider.symmetric
at java.lang.ClassLoader.definePackage(ClassLoader.java:1451)
at java.net.URLClassLoader.definePackage(URLClassLoader.java:348)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:249)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
alternatively, sometimes error message is as follow:
Error Message 2:
java.lang.IllegalArgumentException: org.bouncycastle.jcajce.provider.symmetric
at java.lang.ClassLoader.definePackage(ClassLoader.java:1451)
at java.net.URLClassLoader.definePackage(URLClassLoader.java:348)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:249)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.codehaus.groovy.tools.RootLoader.oldFindClass(RootLoader.java:152)
at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:124)
at org.codehaus.groovy.grails.cli.support.GrailsRootLoader.loadClass(GrailsRootLoader.java:43)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.bouncycastle.jce.provider.BouncyCastleProvider.loadAlgorithms(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider.setup(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider.access$000(Unknown Source)
Solution:
I google for a while, but still I can not find any useful answer. So I begin to read the source codes of bouncy castle. I found that it should be version conflict. Since the package name changes from version 1.5 to 1.6. The version information are as follow:
1.5
org/bouncycastle/jcajce/provider/symmetric/
1.6
org/bouncycastle/jce/provider/symmetric/
And I got 2 different version of jars under my war/WEB-INF/lib directory. They are installed from the ivy plugin.
/Users/carl/.ivy2/cache/org.bouncycastle/bcprov-jdk15on
/Users/carl/.ivy2/cache/org.bouncycastle/bcprov-jdk16
So my solution is to exclude them in my war packages. Since I am using grails in this project. I will do like this.
In the BuildConfig.groovy file, put something like this under dependencies as follow:
…snip…
dependencies {
runtime('com.sillycat:projectname_api_2.10:0.1.6'){
excludes([ group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '147'],
[ group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.46'])
}
}
That fix the problem.
3. Publish my Scala jar to Local Maven
>sbt publish-local
This will publish the jar package to ivy local directory.
Change the build.sbt as follow:
publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/.m2/repository"))
>sbt publish
This will publish the jar package to maven local directory.
4. Grails Running Configuration
The reference.conf is inside the jar package, sometimes, we need to overwrite some items in that, so we try to create a file named application.conf and run the command as follow:
>export GRAILS_OPTS="-Dconfig.file=/Users/carl/project/conf/application.conf -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
>grails run-app
And one more tip, if you grails ORM tells you that
013-07-17 16:45:00,369 [pool-1-thread-41] ERROR org.hibernate.LazyInitializationException - could not initialize proxy - no Sessionex org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at Skipped non-Digby elements.(:35)
Make sure you place (lazy: false) in the object property.
References:
- 浏览: 2489360 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
发表评论
-
NodeJS12 and Zlib
2020-04-01 07:44 433NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 295Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 378Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 337Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 419NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 365Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 294Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 211GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 394GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 278GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 266Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 267Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 255Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 240Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 238NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 228Python Library 2019(1)requests ... -
NodeJS Installation 2019
2019-10-20 02:57 519NodeJS Installation 2019 Insta ... -
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts
2019-10-18 10:57 232Monitor Tool 2019(2)Monit on Mu ... -
Sqlite Database 2019(1)Sqlite3 Installation and Docker phpsqliteadmin
2019-09-05 11:24 324Sqlite Database 2019(1)Sqlite3 ... -
Supervisor 2019(2)Ubuntu and Multiple Services
2019-08-19 10:53 323Supervisor 2019(2)Ubuntu and Mu ...
相关推荐
bouncycastle jar包
BouncyCastle的相关资源包,若生成x509证书则需要此资源包,里面包含两个,版本是1.62
BouncyCastle是JAVA专属库,但出来了C#的库。这个非常实用。仅仅一个dll文件
BouncyCastle 加密算法.net组件 版本10.0
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.6.
org.bouncycastle完整资源包,有需要的可以下
解决org/bouncycastle/jce/provider/bouncycastlepr错误专用。
org.bouncycastle 加密算法包,csdn上很多这个包的下载都不全,我这完整包里包含了9个jar包 1.69官网最新版本
bouncy castle(轻量级密码术包)是一种用于 Java 平台的开放源码的轻量...因为 Bouncy Castle 被设计成轻量级的,所以从 J2SE 1.4 到 J2ME(包括 MIDP)平台,它都可以运行。它是在 MIDP 上运行的唯一完整的密码术包。
BouncyCastle dll库 1.8.6版
bouncy castle(轻量级密码术包)是一种用于 Java 平台的开放源码的轻量级密码术包。它支持大量的密码术算法,并提供 JCE 1.2.1 的实现。
借助 BouncyCastle 在C#里 实现Java中的PKCS7 签名和验签 仅做参考,如有问题欢迎指出。
Bouncy Castle Crypto.dll是一个C#实现的加密包。一款加解密的工具类,可以在C#程序中添加依赖项。
C# BouncyCastle.Crypto.dll用于SM4、SM2加密