Example usage for org.bouncycastle.jce.provider BouncyCastleProvider BouncyCastleProvider

List of usage examples for org.bouncycastle.jce.provider BouncyCastleProvider BouncyCastleProvider

Introduction

In this page you can find the example usage for org.bouncycastle.jce.provider BouncyCastleProvider BouncyCastleProvider.

Prototype

public BouncyCastleProvider() 

Source Link

Document

Construct a new provider.

Usage

From source file:dk.itst.oiosaml.sp.service.util.UtilsTest.java

License:Mozilla Public License

private ByteArrayOutputStream generateKeystore(Credential cred, X509Certificate cert) throws KeyStoreException,
        NoSuchProviderException, IOException, NoSuchAlgorithmException, CertificateException {
    Security.addProvider(new BouncyCastleProvider());
    KeyStore store = KeyStore.getInstance("JKS");
    store.load(null, null);//from w  ww.  ja v  a2  s  . c  om
    store.setKeyEntry("saml", cred.getPrivateKey(), "test".toCharArray(), new Certificate[] { cert });
    store.setCertificateEntry("samltest", cert);

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    store.store(bos, "test".toCharArray());
    bos.close();
    return bos;
}

From source file:domains.donuts.module.backend.BackendServlet.java

License:Open Source License

@Override
public void init() {
    Security.addProvider(new BouncyCastleProvider());

    try {// w w  w.j  a va2s. c om
        metricReporter.startAsync().awaitRunning(10, TimeUnit.SECONDS);
        logger.info("Started up MetricReporter");
    } catch (TimeoutException timeoutException) {
        logger.severefmt("Failed to initialize MetricReporter: %s", timeoutException);
    }
}

From source file:domains.donuts.module.tools.ToolsServlet.java

License:Open Source License

@Override
public void init() {
    Security.addProvider(new BouncyCastleProvider());
}

From source file:dorkbox.util.crypto.Crypto.java

License:Apache License

public static void addProvider() {
    // make sure we only add it once (in case it's added elsewhere...)
    Provider provider = Security.getProvider(BouncyCastleProvider.PROVIDER_NAME);
    if (provider == null) {
        Security.addProvider(new BouncyCastleProvider());
    }/*from w w w .j  av  a2 s  .com*/
}

From source file:dorkbox.util.crypto.CryptoX509.java

License:Apache License

public static void addProvider() {
    // make sure we only add it once (in case it's added elsewhere...)
    Provider provider = Security.getProvider("BC");
    if (provider == null) {
        Security.addProvider(new BouncyCastleProvider());
    }//from w w w  . ja  va 2 s .co m
}

From source file:ec.gov.informatica.firmadigital.signature.BouncyCastleSignatureProcessor.java

License:Open Source License

public BouncyCastleSignatureProcessor(KeyStore keyStore) {
    this.keyStore = keyStore;
    Security.addProvider(new BouncyCastleProvider());
}

From source file:ec.rubrica.pdf.Sign.java

License:Open Source License

public static void main(String[] args) throws Exception {
    AccessController.doPrivileged(new PrivilegedAction<Void>() {
        public Void run() {
            Security.addProvider(new BouncyCastleProvider());
            return null;
        }/*from  ww w  . j av a2s.  co m*/
    });

    // Create a PDF:
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Document document = new Document();
    PdfWriter.getInstance(document, baos);
    document.open();
    document.add(new Paragraph("Hello World!"));
    document.close();
    byte[] pdf = baos.toByteArray();

    // Sign it!
    KeyStoreProvider keyStoreProvider = new WindowsKeyStoreProvider();
    KeyStore keyStore = keyStoreProvider.getKeystore();
    List<Alias> signingAliases = KeyStoreUtilities.getSigningAliases(keyStore);

    int i = 1;

    for (Alias alias : signingAliases) {
        System.out.println("alias=" + alias);
        System.out.println("------------------------------------------------------");

        PrivateKey pk = (PrivateKey) keyStore.getKey(alias.getAlias(), null);
        Certificate[] chain = keyStore.getCertificateChain(alias.getAlias());
        System.out.println("chain.length=" + chain.length);
        byte[] signedPdf = FirmaPDF.firmar(pdf, pk, chain, new TSAClientBancoCentral(null));

        // Verificar
        FirmaPDF.verificar(signedPdf);
    }
}

From source file:ec.rubrica.util.BouncyCastleUtils.java

License:Open Source License

/**
 * Inicializa el Proveedor de Seguridad BouncyCastle
 *//*from   w w w.  j  av  a2 s.  c om*/
public static void initializeBouncyCastle() {
    AccessController.doPrivileged(new PrivilegedAction<Void>() {
        public Void run() {
            Security.addProvider(new BouncyCastleProvider());
            return null;
        }
    });
}

From source file:edu.amrita.selabs.cumulus.lib.test.CryptoTest.java

License:Open Source License

@Before
public void setupBC() {
    Security.addProvider(new BouncyCastleProvider());
}

From source file:edu.kit.dama.util.CryptUtil.java

License:Apache License

/**
 * Hidden constuctor.//from  w  ww  . j  a v  a  2s .  co m
 *
 * @param pSecret The secret used for the SecretKeySpec. The secret must
 * have a length of 128, 192 or 256 bits.
 */
private CryptUtil(byte[] pSecret) {
    try {
        SecretKeySpec skeySpec = new SecretKeySpec(pSecret, "AES");
        deCipher = Cipher.getInstance("AES/CBC/PKCS5Padding", new BouncyCastleProvider());
        deCipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(new byte[16]));
        enCipher = Cipher.getInstance("AES/CBC/PKCS5Padding", new BouncyCastleProvider());
        enCipher.init(Cipher.ENCRYPT_MODE, skeySpec, new IvParameterSpec(new byte[16]));
    } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException
            | InvalidAlgorithmParameterException e) {
        throw new IllegalStateException("Failed to create cipher instances.", e);
    }
}