I\'m trying to use bouncycastle to encrypt a file using a public key. I\'ve registered the provider programatically:
Security.addProvider(new BouncyCastlePro
You have a BouncyCastle Security provider installation problem, you need to either
$JAVA_HOME/jre/lib/security/java.security
file as a provider (be sure that you add it to the JRE you use when running, eg. if you have multiple JRE's/JDK's installed)eg.
security.provider.2=org.bouncycastle.jce.provider.BouncyCastleProvider
(and renumber the security providers below it - don't put it as the highest priority provider).
$JAVA_HOME/jre/lib/security/java.policy
should be "unlimited" (you can probably download an unlimited policy file from the Java homepage).You need to add javapns.jar and bcprove-jdk15on-1.47.jar file in your lib folder
import javapns.Push;
import org.apache.log4j.BasicConfigurator;
public class SendPushNotification {
public static void main(String[] args) {
try {
BasicConfigurator.configure();
Push.alert("Hello World!", "Cetificate.p12", "password", false,
"mydeviceToken");
} catch (Exception e) {
System.out.println(e);
}
}
}
In my case it worked fine one time, but then later I got ClassNotFoundException when trying to use BC. I restarted Tomcat and then it worked fine.
I think if you redeploy the app, like you do often while developing, it stops working. JNI is another thing which suffers from this problem.
In our case this isn't a problem. We never redeploy on the test and production systems. I prefer shipping the jar with the app instead of having to manually copy it to the container lib directory.