Example usage for java.security Provider put

List of usage examples for java.security Provider put

Introduction

In this page you can find the example usage for java.security Provider put.

Prototype

@Override
public synchronized Object put(Object key, Object value) 

Source Link

Document

Sets the key property to have the specified value .

Usage

From source file:org.apache.xml.security.test.encryption.BaltimoreEncTest.java

/**
 * Method test_five_data_3des_cbc_rsa_oaep
 *
 * Check the merlin-enc-five element data test for 3DES with
 * RSA key wrap (OAEP and no parameters)
 *
 *//*w w  w  . jav a  2  s  . c  om*/

public void test_five_data_3des_cbc_rsa_oaep() throws Exception {

    // Work-around for the fact that BC currently doesn't support
    // the standard JCE name for oaep padding
    java.security.Provider bc = java.security.Security.getProvider("BC");
    if (bc != null)
        bc.put("Alg.Alias.Cipher.RSA/ECB/OAEPWithSHA1AndMGF1Padding", "RSA/OAEP");

    if (haveISOPadding) {
        String filename = "data/ie/baltimore/merlin-examples/merlin-xmlenc-five/encrypt-data-tripledes-cbc-rsa-oaep-mgf1p.xml";

        byte[] decrypt = decryptData(filename);
        checkDecryptedData(decrypt);
    } else {
        log.warn(
                "Skipping test test_five_data_3des_cbc_rsa_oaep as necessary crypto algorithms are not available");
    }
}

From source file:org.cesecore.keys.token.BaseCryptoToken.java

private void setProvider(Provider prov) {
    if (prov != null) {
        String pName = prov.getName();
        if (pName.startsWith("LunaJCA")) {
            // Luna Java provider does not contain support for RSA/ECB/PKCS1Padding but this is
            // the same as the alias below on small amounts of data
            prov.put("Alg.Alias.Cipher.RSA/NONE/NoPadding", "RSA//NoPadding");
            prov.put("Alg.Alias.Cipher.1.2.840.113549.1.1.1", "RSA//NoPadding");
            prov.put("Alg.Alias.Cipher.RSA/ECB/PKCS1Padding", "RSA//PKCS1v1_5");
            prov.put("Alg.Alias.Cipher.1.2.840.113549.3.7", "DES3/CBC/PKCS5Padding");
        }/*from  ww  w  . j av  a 2  s.  co m*/
        if (Security.getProvider(pName) == null) {
            Security.addProvider(prov);
        }
        if (Security.getProvider(pName) == null) {
            throw new ProviderException("Not possible to install provider: " + pName);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("No provider passed to setProvider()");
        }
    }
}

From source file:org.ejbca.core.model.ca.catoken.BaseCAToken.java

private void setProvider(Provider prov) {
    if (prov != null) {
        String pName = prov.getName();
        if (pName.startsWith("LunaJCA")) {
            // Luna Java provider does not contain support for RSA/ECB/PKCS1Padding but this is 
            // the same as the alias below on small amounts of data  
            prov.put("Alg.Alias.Cipher.RSA/NONE/NoPadding", "RSA//NoPadding");
            prov.put("Alg.Alias.Cipher.1.2.840.113549.1.1.1", "RSA//NoPadding");
            prov.put("Alg.Alias.Cipher.RSA/ECB/PKCS1Padding", "RSA//PKCS1v1_5");
            prov.put("Alg.Alias.Cipher.1.2.840.113549.3.7", "DES3/CBC/PKCS5Padding");
        }/* ww w  .  ja v a2 s  .  co  m*/
        if (Security.getProvider(pName) == null) {
            Security.addProvider(prov);
        }
        if (Security.getProvider(pName) == null) {
            throw new ProviderException("Not possible to install provider: " + pName);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("No provider passed to setProvider()");
        }
    }
}