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:
- 浏览: 2542381 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
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 468NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 330Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 428Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 377Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 468NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 414Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 331Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 243GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 445GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 321GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 307Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 310Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 286Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 303Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 279NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 256Python Library 2019(1)requests ... -
NodeJS Installation 2019
2019-10-20 02:57 565NodeJS Installation 2019 Insta ... -
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts
2019-10-18 10:57 257Monitor Tool 2019(2)Monit on Mu ... -
Sqlite Database 2019(1)Sqlite3 Installation and Docker phpsqliteadmin
2019-09-05 11:24 361Sqlite Database 2019(1)Sqlite3 ... -
Supervisor 2019(2)Ubuntu and Multiple Services
2019-08-19 10:53 364Supervisor 2019(2)Ubuntu and Mu ...
相关推荐
BouncyCastle是一个强大的Java安全库,它为加密、数字签名、证书处理以及许多其他安全功能提供了全面的支持。在Android开发中,BouncyCastle扮演着重要角色,特别是在处理SSL/TLS连接、加密通信以及生成和验证X.509...
**Bouncy Castle简介** Bouncy Castle是一个开源的Java加密库,提供了广泛的加密算法、协议实现以及相关的工具。这个jar包是专门为Java开发者设计的,它弥补了Java标准加密API(如JCE)在某些功能上的不足,使得...
** org.bouncycastle 加密算法包详解 ** `org.bouncycastle` 是一个开源的 Java 库,专门用于实现各种加密算法和相关的安全服务。它提供了广泛的加密功能,包括对称和非对称加密、数字签名、哈希函数、证书管理、...
《BouncyCastle.Crypto.dll:理解.NET平台的加密利器》 在网络安全日益重要的今天,加密技术扮演了至关重要的角色。BouncyCastle库是Java和.NET平台上广泛使用的加密库之一,而"BouncyCastle.Crypto.dll"正是.NET...
BouncyCastle.Crypto.dll 是一个专门用于加密和解密操作的动态链接库,适用于C#编程语言。这个版本1.8.6是在2020年2月21日发布,是BouncyCastle库的最新迭代,为开发者提供了强大的安全功能。 BouncyCastle库本身是...
BouncyCastle.dll 是一个在C#环境中广泛使用的开源加密库,它为.NET Framework提供了一整套强大的加密功能。这个库是基于Bouncy Castle项目,这是一个跨平台的Java和.NET加密库,提供了各种加密算法、密码协议和PKI...
《BouncyCastle1.59帮助文档:深入理解与CHM制作详解》 BouncyCastle,作为Java和.NET平台上广泛使用的开源加密库,为开发者提供了丰富的加密算法、密码学标准接口以及证书处理功能。这份“BouncyCastle1.59帮助...
**BouncyCastle.Crypto.dll** 是一个开源的加密库,主要为.NET Framework和.NET Core提供加密功能。在版本1.8.1中,这个库继续为开发者提供了广泛的密码学算法和安全服务。BouncyCastle 不仅限于.NET平台,它也支持...
《BouncyCastle.Crypto.dll:理解与应用》 在信息技术领域,加密库是保障数据安全的重要工具,而BouncyCastle.Crypto.dll就是这样一个强大的加密库,尤其在.NET框架下广泛被开发者所使用。BouncyCastle项目,作为一...
《BouncyCastle.Crypto.dll 1.8.2:深入解析加密库的奥秘》 在信息技术领域,安全是至关重要的。特别是在网络通信、数据存储和传输等方面,强大的加密技术是保障信息安全的基础。BouncyCastle.Crypto.dll是这样一个...
《深入解析BouncyCastle.Crypto.dll与iTextSharp.dll在软件开发中的应用》 在软件开发领域,尤其是涉及加密和PDF处理的项目中,BouncyCastle.Crypto.dll和iTextSharp.dll是两个不可或缺的库。这两个DLL文件为开发者...
BouncyCastle是JAVA专属库,但出来了C#的库。这个非常实用。仅仅一个dll文件
**Bouncy Castle 1.64 API 深度解析** Bouncy Castle 是一个开源的 Java 安全库,提供了一整套加密算法、证书、SSL/TLS 协议以及 PKCS#7、PKCS#12、OpenSSL、CMS、S/MIME 和 X.509 的实现。在 1.64 版本中,这个库...
在这个集合包中,我们找到了四个不同版本的BouncyCastle相关jar文件,分别如下: 1. **bcprov-jdk16-1.46.jar**:这是BouncyCastle的主要提供者包,主要用于Java平台。"bcprov"代表BouncyCastle Provider,"jdk16...
在C#编程环境中,虽然.NET框架提供了内置的安全类如RSACryptoServiceProvider,但在某些场景下,如与Java平台交互或者需要更灵活的加密库时,可能会选择第三方库,例如BouncyCastle。BouncyCastle是一个强大的开源...
本文将详细讲解如何使用C#语言和BouncyCastle库来实现带原文数据的PKCS#7签名。 PKCS#7(Public-Key Cryptography Standards #7)是由RSA Security提出的一种标准,它定义了证书、证书撤销列表(CRL)的格式以及...
《深入解析org.bouncycastle:Java安全加密与证书权威库》 在Java开发中,安全性是不可或缺的一部分,尤其是在处理敏感数据、网络通信以及数字签名时。`org.bouncycastle`库是一个强大的开源加密库,为Java开发者...