当前位置: 首页>>代码示例>>Java>>正文


Java StandardPBEStringEncryptor.setAlgorithm方法代码示例

本文整理汇总了Java中org.jasypt.encryption.pbe.StandardPBEStringEncryptor.setAlgorithm方法的典型用法代码示例。如果您正苦于以下问题:Java StandardPBEStringEncryptor.setAlgorithm方法的具体用法?Java StandardPBEStringEncryptor.setAlgorithm怎么用?Java StandardPBEStringEncryptor.setAlgorithm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jasypt.encryption.pbe.StandardPBEStringEncryptor的用法示例。


在下文中一共展示了StandardPBEStringEncryptor.setAlgorithm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
private static void initialize() {
    final Properties dbProps = DbProperties.getDbProperties();

    if (EncryptionSecretKeyChecker.useEncryption()) {
        final String dbSecretKey = dbProps.getProperty("db.cloud.encrypt.secret");
        if (dbSecretKey == null || dbSecretKey.isEmpty()) {
            throw new CloudRuntimeException("Empty DB secret key in db.properties");
        }

        s_encryptor = new StandardPBEStringEncryptor();
        s_encryptor.setAlgorithm("PBEWithMD5AndDES");
        s_encryptor.setPassword(dbSecretKey);
    } else {
        throw new CloudRuntimeException("Trying to encrypt db values when encrytion is not enabled");
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:17,代码来源:DBEncryptionUtil.java

示例2: initializeNewEngine

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
/**
 * Initialize engine for first time use. This method created a new random data encryption passphrase which is shown
 * to no one.
 */
private void initializeNewEngine() {
	// Generate a new data passphrase
	String newDataPassphrase = generateNewDataPassphrase();
	// Encrypt the data passphrase with the key passphrase
	final StandardPBEStringEncryptor dataPassEncryptor = new StandardPBEStringEncryptor();
	dataPassEncryptor.setProviderName(CryptoConstants.BOUNCY_CASTLE_PROVIDER_NAME);
	dataPassEncryptor.setAlgorithm(CryptoConstants.STRONG_ALGO);
	dataPassEncryptor.setPassword(getKeyPassphrase());
	String encryptedNewDataPassphrase = dataPassEncryptor.encrypt(newDataPassphrase);

	// Persist the new engine config
	try {
		MutableRepositoryItem newCryptoEngineItem = getCryptoRepository().createItem(getCryptoEngineIdentifier(),
				CryptoConstants.CRYPTO_ENGINE_ITEM_DESC);
		newCryptoEngineItem.setPropertyValue(CryptoConstants.DESCRIPTION_PROP_NAME, getCryptoEngineDescription());
		newCryptoEngineItem.setPropertyValue(CryptoConstants.ENC_DATA_KEY_PROP_NAME, encryptedNewDataPassphrase);
		newCryptoEngineItem.setPropertyValue(CryptoConstants.KEY_DATE_PROP_NAME, new Date());
		getCryptoRepository().addItem(newCryptoEngineItem);
	} catch (RepositoryException e) {
		if (isLoggingError()) {
			logError("CryptoEngine.initializeEngine: " + "unable to create new crypto engine config item.", e);
		}
	}
}
 
开发者ID:sparkred-insight,项目名称:ATGCrypto,代码行数:29,代码来源:CryptoEngine.java

示例3: initialize

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
private static void initialize() {
    final Properties dbProps = DbProperties.getDbProperties();

    if (EncryptionSecretKeyChecker.useEncryption()) {
        String dbSecretKey = dbProps.getProperty("db.cloud.encrypt.secret");
        if (dbSecretKey == null || dbSecretKey.isEmpty()) {
            throw new CloudRuntimeException("Empty DB secret key in db.properties");
        }

        s_encryptor = new StandardPBEStringEncryptor();
        s_encryptor.setAlgorithm("PBEWithMD5AndDES");
        s_encryptor.setPassword(dbSecretKey);
    } else {
        throw new CloudRuntimeException("Trying to encrypt db values when encrytion is not enabled");
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:17,代码来源:DBEncryptionUtil.java

示例4: testEncrypt

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
@Test
public void testEncrypt()
{
    StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
    encryptor.setProvider(new BouncyCastleProvider());
    encryptor.setAlgorithm("PBEWITHSHA256AND256BITAES-CBC-BC");
    encryptor.setPassword("[email protected][email protected]");
    encryptor.setKeyObtentionIterations(1000);

    String clearText = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
    System.out.println("clearText.length="+clearText.length());
    System.out.println("clearText="+clearText);
    String encryptedText = encryptor.encrypt(clearText);
    System.out.println("encryptedText.length="+encryptedText.length());
    System.out.println("encryptedText="+encryptedText);
    assertEquals(encryptedText.length(), 172);
    String decryptedText = encryptor.decrypt(encryptedText);
    assertEquals(decryptedText, clearText);
}
 
开发者ID:alfameCom,项目名称:salasanasiilo,代码行数:20,代码来源:JasyptBCAESEncryptionTest.java

示例5: standardPBEStringEncryptor

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
@Test
public void standardPBEStringEncryptor() {
    for (String algorithm : PBEAlgorithms) {
        if (log.isDebugEnabled())
            log.debug("StandardPBEStringEncryptor Algorithm = [{}]", algorithm);

        try {
            StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
            encryptor.setPassword("debop");
            encryptor.setAlgorithm(algorithm);

            String encryptedText = encryptor.encrypt(PLAIN_TEXT);
            String decryptedText = encryptor.decrypt(encryptedText);

            Assert.assertEquals(PLAIN_TEXT, decryptedText);
        } catch (Exception e) {
            log.error(algorithm + "은 지원하지 않습니다.", e);
        }
    }
}
 
开发者ID:debop,项目名称:debop4j,代码行数:21,代码来源:JasyptTest.java

示例6: main

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
public static void main(String... args) {
  try (Scanner scanner = new Scanner(System.in)) {
    String plain = scanner.nextLine();

    String password = System.getenv("BOD_ENCRYPTION_PASSWORD");
    if (password == null) {
      System.err.println("BOD_ENCRYPTION_PASSWORD not set");
      System.exit(1);
    }

    StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
    encryptor.setAlgorithm("PBEWithMD5AndTripleDES");
    encryptor.setPassword(password);

    System.out.println("Encrypted value: " + encryptor.encrypt(plain));
  }
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:18,代码来源:Encrypt.java

示例7: initialize

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
/**
 * Initializes the decryptMethod, generates a new data passphrase, and sets up the local encryptor component.
 *
 * @throws SecurityException
 *             the security exception
 * @throws NoSuchMethodException
 *             the no such method exception
 */
private void initialize() throws SecurityException, NoSuchMethodException {
	if (isLoggingDebug()) {
		logDebug("RekeyEngine.initialize:" + "starting....");
	}
	// Add the BouncyCastle JCE Security provider
	Security.addProvider(new BouncyCastleProvider());

	// Generate new data passphrase
	this.mNewDataPassphrase = generateNewDataPassphrase();
	if (isLoggingDebug()) {
		logDebug("RekeyEngine.initialize:" + "new data passphrase was generated:" + this.mNewDataPassphrase);
	}
	// Setup the decryptor
	Class[] decryptMethodArgs = new Class[1];
	decryptMethodArgs[0] = String.class;
	Method decryptMethod = getDecryptorComponent().getClass().getMethod(getDecryptorMethod(), decryptMethodArgs);
	this.mDecryptMethod = decryptMethod;
	if (isLoggingDebug()) {
		logDebug("RekeyEngine.initialize:" + "decryptMethod is setup.");
	}

	// Setup the encryptor
	StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
	encryptor.setProviderName(CryptoConstants.BOUNCY_CASTLE_PROVIDER_NAME);
	encryptor.setAlgorithm(CryptoConstants.STRONG_ALGO);
	encryptor.setPassword(this.mNewDataPassphrase);
	this.mEncryptor = encryptor;
	if (isLoggingDebug()) {
		logDebug("RekeyEngine.initialize:" + "encryptor is setup.");
	}
}
 
开发者ID:sparkred-insight,项目名称:ATGCrypto,代码行数:40,代码来源:RekeyEngine.java

示例8: AESEncryptor

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
public AESEncryptor() {
	encrytor = new StandardPBEStringEncryptor();
	encrytor.setAlgorithm("PBEWithMD5AndDES");

	// Ideally the password should not be maintained directly in the
	// source code, but rather kept someplace secure
	encrytor.setPassword("ZgPiPSCdq88K8Mfay7T7IA");
}
 
开发者ID:GSLabDev,项目名称:OTPManager,代码行数:9,代码来源:AESEncryptor.java

示例9: AESEncryptorImpl

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
public AESEncryptorImpl() {
	encrytor = new StandardPBEStringEncryptor();
	encrytor.setAlgorithm("PBEWithMD5AndDES");

	// Ideally the password should not be maintained directly in the
	// source code, but rather kept someplace secure
	encrytor.setPassword("ZgPiPSCdq88K8Mfay7T7IA");
}
 
开发者ID:GSLabDev,项目名称:OTPManager,代码行数:9,代码来源:AESEncryptorImpl.java

示例10: initEncryptor

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
private synchronized void initEncryptor() {
    if (encryptor == null) {
        ObjectHelper.notEmpty("password", password);
        StandardPBEStringEncryptor pbeStringEncryptor = new StandardPBEStringEncryptor();
        pbeStringEncryptor.setPassword(password);
        if (algorithm != null) {
            pbeStringEncryptor.setAlgorithm(algorithm);
            log.debug(format("Initialized encryptor using %s algorithm and provided password", algorithm));
        } else {
            log.debug(format("Initialized encryptor using default algorithm and provided password"));
        }
        encryptor = pbeStringEncryptor;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:JasyptPropertiesParser.java

示例11: getEncryptor

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
/**
 * Gets the encryptor.
 *
 * @param symmetricKey
 *            the symmetric key
 * @return the encryptor
 */
private static StandardPBEStringEncryptor getEncryptor(final String symmetricKey) {
	Security.addProvider(new BouncyCastleProvider());
	final StandardPBEStringEncryptor mySecondEncryptor = new StandardPBEStringEncryptor();
	mySecondEncryptor.setProviderName(BC_PROVIDER_NAME);
	mySecondEncryptor.setAlgorithm(PBEWITHSHA256AND128BITAES_CBC_BC);
	mySecondEncryptor.setPassword(symmetricKey);
	return mySecondEncryptor;
}
 
开发者ID:Hack23,项目名称:cia,代码行数:16,代码来源:EncryptProperty.java

示例12: encrypt

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
@Override
public String encrypt(final String plainText) {
    final StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
    encryptor.setPassword(SECURE_STRING);
    encryptor.setAlgorithm(SECURE_ALGORITHM);

    String result = plainText;
    try {
        result = encryptor.encrypt(plainText);
    } catch (EncryptionOperationNotPossibleException e) {
        log.error("Unable to encrypt",
                  e);
    }
    return result;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:16,代码来源:DefaultPasswordServiceImpl.java

示例13: decrypt

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
@Override
public String decrypt(final String encryptedText) {
    final StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
    encryptor.setPassword(SECURE_STRING);
    encryptor.setAlgorithm(SECURE_ALGORITHM);

    String result = encryptedText;
    try {
        result = encryptor.decrypt(encryptedText);
    } catch (EncryptionOperationNotPossibleException e) {
        log.error("Unable to decrypt",
                  e);
    }
    return result;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:16,代码来源:DefaultPasswordServiceImpl.java

示例14: getConfigurationEncryptor

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
private static StandardPBEStringEncryptor getConfigurationEncryptor(String password) {
    StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
    encryptor.setProvider(new BouncyCastleProvider());
    encryptor.setAlgorithm(ALGORITHM);
    encryptor.setPassword(password);
    encryptor.setKeyObtentionIterations(KEY_OBTENTION_ITERATIONS);
    return encryptor;
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:9,代码来源:EncryptablePropertiesConfigurer.java

示例15: encryptToHexadecimalString

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; //导入方法依赖的package包/类
/**
 * Encrypt a Message Text to a Hexadecimal String usable for a WEB Url.
 *
 * @param message to be encrypted
 * @return String of a Encrypted Hexadecimal String
 */
public static String encryptToHexadecimalString(String message) {
    initializeDefaultCryptographyProvider();
    StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
    encryptor.setPassword(SALT_PW);
    encryptor.setAlgorithm(BC_ALGORITHM_NAME_PBE_MD5_TRIPLE_DES);
    encryptor.setKeyObtentionIterations(KEY_OBTENTION_ITERATIONS);
    encryptor.setStringOutputType(STRING_OUTPUT_TYPE_HEXADECIMAL);
    return encryptor.encrypt(message);
}
 
开发者ID:jaschenk,项目名称:jeffaschenk-commons,代码行数:16,代码来源:SecurityServiceProviderUtility.java


注:本文中的org.jasypt.encryption.pbe.StandardPBEStringEncryptor.setAlgorithm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。