com.nimbusds.jose.crypto.bc.BouncyCastleProviderSingleton Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nimbus-jose-jwt Show documentation
Show all versions of nimbus-jose-jwt Show documentation
Java library for Javascript Object Signing and Encryption (JOSE) and
JSON Web Tokens (JWT)
package com.nimbusds.jose.crypto.bc;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
/**
* BouncyCastle JCA provider singleton, intended to prevent memory leaks by
* ensuring a single instance is loaded at all times. Application code that
* needs a BouncyCastle JCA provider should use the {@link #getInstance()}
* method to obtain an instance.
*
* @author Vladimir Dzhuvinov
*/
public final class BouncyCastleProviderSingleton {
/**
* The BouncyCastle provider, lazily instantiated.
*/
private static BouncyCastleProvider bouncyCastleProvider;
/**
* Prevents external instantiation.
*/
private BouncyCastleProviderSingleton() { }
/**
* Returns a BouncyCastle JCA provider instance.
*
* @return The BouncyCastle JCA provider instance.
*/
public static BouncyCastleProvider getInstance() {
if (bouncyCastleProvider != null) {
return bouncyCastleProvider;
} else {
bouncyCastleProvider = new BouncyCastleProvider();
return bouncyCastleProvider;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy