當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。