List of usage examples for java.security Security addProvider
public static int addProvider(Provider provider)
From source file:MainClass.java
public static KeyPair generateKeyPair(long seed) throws Exception { Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); KeyPairGenerator keyGenerator = KeyPairGenerator.getInstance("DSA"); SecureRandom rng = SecureRandom.getInstance("SHA1PRNG", "SUN"); rng.setSeed(seed);//from ww w . ja va 2s . c o m keyGenerator.initialize(1024, rng); return (keyGenerator.generateKeyPair()); }
From source file:com.dianxin.imessage.common.util.SignUtil.java
public static PrivateKey getPrivateKey(String keypath) { if (privateKey != null) return privateKey; log.debug("???"); Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); try {//from w w w. j a v a 2 s .c o m FileReader fileReader = new FileReader(keypath); char[] cbuf = new char[40960]; fileReader.read(cbuf, 0, 40960); PEMReader reader = new PEMReader(new StringReader(new String(cbuf))); KeyPair keyPair = (KeyPair) reader.readObject(); privateKey = keyPair.getPrivate(); reader.close(); } catch (Exception e) { log.warn("??", e); } return privateKey; }
From source file:com.amazonaws.services.s3.internal.crypto.CryptoRuntime.java
public static void enableBouncyCastle() { try {/*from www .j av a 2 s .co m*/ @SuppressWarnings("unchecked") Class<Provider> c = (Class<Provider>) Class.forName(BC_PROVIDER_FQCN); Provider provider = c.newInstance(); Security.addProvider(provider); } catch (Exception e) { LogFactory.getLog(CryptoRuntime.class).debug("Bouncy Castle not available", e); } }
From source file:com.pieframework.runtime.utils.CertificateUtils.java
public static String encryptPassword(String rdpPassword, X509Certificate certificate) { Security.addProvider(new BouncyCastleProvider()); String encryptedPassword = ""; //get PrivateKey And certificate from pfx file try {/*from w ww. j av a2 s .c om*/ certificate.checkValidity(); CMSEnvelopedDataGenerator envDataGen = new CMSEnvelopedDataGenerator(); envDataGen.addKeyTransRecipient(certificate); CMSProcessable envData = new CMSProcessableByteArray(rdpPassword.getBytes()); CMSEnvelopedData enveloped = envDataGen.generate(envData, CMSEnvelopedDataGenerator.DES_EDE3_CBC, "BC"); byte[] data = enveloped.getEncoded(); encryptedPassword = new String(Base64.encodeBase64(data)); } catch (Exception e) { e.printStackTrace(); } return encryptedPassword; }
From source file:eu.contrail.security.DelegatedUserCertClientTest.java
@BeforeClass public static void setUpClass() throws Exception { Security.addProvider(new BouncyCastleProvider()); }
From source file:test.integ.be.fedict.trust.CodeSigningTest.java
@BeforeClass public static void setUp() throws Exception { Security.addProvider(new BouncyCastleProvider()); }
From source file:com.nkapps.billing.services.ProviderFactoryImpl.java
@Override public Provider getProvider() { if (provider != null) { return provider; }/*from w w w . j a v a 2 s. c o m*/ provider = Security.getProvider("BC"); if (provider == null) { BouncyCastleProvider bcp = new BouncyCastleProvider(); // configure fake provider Security.addProvider(bcp); provider = bcp; } return provider; }
From source file:test.unit.be.fedict.trust.OnlineCrlRepositoryTest.java
@BeforeClass public static void oneTimeSetUp() throws Exception { Security.addProvider(new BouncyCastleProvider()); }
From source file:org.viafirma.nucleo.inicio.SecurityProvidersUtils.java
/** * Inicializa los proveedores criptograficos para corregir problemas con las * distintas maquinas virtuales/*from w ww.j a v a 2 s . c om*/ */ public static void initProviders() { BouncyCastleProvider bc = new BouncyCastleProvider(); // Eliminamos el proveedor para evitar que se solapen si ya existia uno. Security.removeProvider(bc.getName()); Security.addProvider(bc); log.info("Lista de proveedores disponible:" + Arrays.asList(Security.getProviders())); addHMACAlgorithm(bc, "SHA2", "org.bouncycastle.jce.provider.JCEMac$SHA256", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA256"); addHMACAlias(bc, "SHA2", PKCSObjectIdentifiers.id_hmacWithSHA256); Security.addProvider(bc); }
From source file:org.globus.gsi.jsse.SSLConfiguratorTest.java
@BeforeClass public static void setup() throws Exception { Security.addProvider(new GlobusProvider()); }