/*
 * oxAuth is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

package org.xdi.oxauth.model.util;

import java.security.Provider;
import java.security.Security;

import org.apache.log4j.Logger;
import org.bouncycastle.jce.provider.BouncyCastleProvider;

public class SecurityProviderUtility {

	private static final Logger log = Logger.getLogger(JwtUtil.class);

	public static void installBCProvider(boolean silent) {
		Provider provider = Security.getProvider(BouncyCastleProvider.PROVIDER_NAME);
		if (provider == null) {
			if (!silent) {
				log.info("Adding Bouncy Castle Provider");
			}

			Security.addProvider(new BouncyCastleProvider());
		} else {
			if (!silent) {
				log.info("Bouncy Castle Provider was added already");
			}
		}
	}

	public static void installBCProvider() {
		installBCProvider(false);
	}

}

@@ -179,39 +179,8 @@
 l;%0A%0A
-import java.security.Provider;%0A
 impo
@@ -408,16 +408,76 @@
 lass);%0A%0A
+%09private static BouncyCastleProvider bouncyCastleProvider;%0A%0A
 %09public 
@@ -530,27 +530,53 @@
 %7B%0A%09%09
-Provider p
+bouncyCastleProvider = (BouncyCastleP
 rovider
- =
+)
  Sec
@@ -636,17 +636,29 @@
 ;%0A%09%09if (
-p
+bouncyCastleP
 rovider 
@@ -739,16 +739,70 @@
 ;%0A%09%09%09%7D%0A%0A
+%09%09%09bouncyCastleProvider = new BouncyCastleProvider();%0A
 %09%09%09Secur
@@ -817,21 +817,17 @@
 rovider(
-new B
+b
 ouncyCas
@@ -837,18 +837,16 @@
 Provider
-()
 );%0A%09%09%7D e
@@ -1012,12 +1012,109 @@
 lse);%0A%09%7D
+%0A%09%0A%09public static BouncyCastleProvider getInstance() %7B%0A%09    return bouncyCastleProvider;%0A%09    %0A%09%7D
 %0A%0A%7D%0A

Use oxAuth JCA provider