本文整理汇总了Java中org.jasypt.util.text.BasicTextEncryptor.setPassword方法的典型用法代码示例。如果您正苦于以下问题:Java BasicTextEncryptor.setPassword方法的具体用法?Java BasicTextEncryptor.setPassword怎么用?Java BasicTextEncryptor.setPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jasypt.util.text.BasicTextEncryptor
的用法示例。
在下文中一共展示了BasicTextEncryptor.setPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPassw
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
public List<Password> getPassw(String username){
List<Password> passwords = new ArrayList<>();
List<Password> encryptedPasswords = dao.getUserPasswords(username);
BasicTextEncryptor encryptor = new BasicTextEncryptor();
encryptor.setPassword(PasswordManagerGUI.getSessionPassword());
for (Password temp : encryptedPasswords) {
try {
Password decryptedPassword = new Password();
decryptedPassword.setUsername(username);
decryptedPassword.setWebpage(encryptor.decrypt(temp.getWebpage()));
decryptedPassword.setP_username(encryptor.decrypt(temp.getP_username()));
decryptedPassword.setP_password(encryptor.decrypt(temp.getP_password()));
passwords.add(decryptedPassword);
} catch (Exception x){
x.printStackTrace();
}
}
//System.out.println(passwords);
return passwords;
}
示例2: main
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
public static void main(String[] args) {
if (args != null && args.length == 2) {
if (args[0].equals("-encrypt")) {
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(secret);
String plainText = textEncryptor.encrypt(args[1]);
System.out.println("Encrypted Password is :" + plainText);
return;
}
} else if (args != null && args.length > 0) {
System.out.println(
"Usage: ./mmagent to run with the configuration \n -encrypt <password> to Encrypt Password for config ");
return;
}
MirrorMakerAgent agent = new MirrorMakerAgent();
if (agent.checkStartup()) {
logger.info("mmagent started, loading properties");
agent.checkAgentProcess();
agent.readAgentTopic();
} else {
System.out.println(
"ERROR: mmagent startup unsuccessful, please make sure the mmagenthome /etc/mmagent.config is set and mechid have the rights to the topic");
}
}
示例3: encryptProperty
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
public void encryptProperty(String key)
{
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(ENC_PASSWORD);
final String decryptedValue = getProperty(key);
if (decryptedValue != null && !decryptedValue.isEmpty())
{
try
{
final String encryptedValue = textEncryptor.encrypt(decryptedValue);
setProperty(key, encryptedValue);
}
catch (Exception e)
{
final String errorMessage = "Error encrypting value for " + key + " property";
logger.error(errorMessage, e);
ChatWindow.popup.handleProblem(errorMessage);
setProperty(key, "");
}
}
}
示例4: decryptProperty
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
public void decryptProperty(String key)
{
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(ENC_PASSWORD);
final String encryptedValue = getProperty(key);
if (encryptedValue != null && !encryptedValue.isEmpty())
{
try
{
final String decryptedValue = textEncryptor.decrypt(encryptedValue);
setProperty(key, decryptedValue);
}
catch (Exception e)
{
final String errorMessage = "Error decrypting value for " + key + " property";
logger.error(errorMessage, e);
ChatWindow.popup.handleProblem(errorMessage);
setProperty(key, "");
}
}
}
示例5: loadProperties
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
private void loadProperties() {
InputStream input = null;
try {
input = new FileInputStream(mmagenthome + "/etc/mmagent.config");
mirrorMakerProperties.load(input);
Gson g = new Gson();
if (mirrorMakerProperties.getProperty("mirrormakers") == null) {
this.mirrorMakers = new ListMirrorMaker();
ArrayList<MirrorMaker> list = this.mirrorMakers.getListMirrorMaker();
list = new ArrayList<MirrorMaker>();
this.mirrorMakers.setListMirrorMaker(list);
} else {
this.mirrorMakers = g.fromJson(mirrorMakerProperties.getProperty("mirrormakers"),
ListMirrorMaker.class);
}
this.kafkahome = mirrorMakerProperties.getProperty("kafkahome");
this.topicURL = mirrorMakerProperties.getProperty("topicURL");
this.topicname = mirrorMakerProperties.getProperty("topicname");
this.mechid = mirrorMakerProperties.getProperty("mechid");
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(secret);
//this.password = textEncryptor.decrypt(mirrorMakerProperties.getProperty("password"));
this.password = mirrorMakerProperties.getProperty("password");
} catch (IOException ex) {
// ex.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
// e.printStackTrace();
}
}
}
}
示例6: externalSystemStrategy
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
@Override
public ExternalSystemStrategy externalSystemStrategy() {
System.setProperty("com.microsoft.tfs.jni.native.base-directory", nativePath);
BasicTextEncryptor encyptor = new BasicTextEncryptor();
encyptor.setPassword(ENCRYPTOR_DEFAULT_PASS);
return new TfsSdkStrategy(context.getBean(InternalTicketAssembler.class),
tfsFieldBuilders(), encyptor);
}
示例7: decrypt
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
public static String decrypt(final String encryptedVal) {
if (encryptedVal == null) {
return null;
}
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(MY_ENCRIPTED_PASSWORD);
return textEncryptor.decrypt(encryptedVal);
}
示例8: encrypt
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
public static String encrypt(final String valueEnc) {
if (valueEnc == null) {
return null;
}
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(MY_ENCRIPTED_PASSWORD);
return textEncryptor.encrypt(valueEnc);
}
示例9: main
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
public static void main(String[] args) {
String password = args.length >= 1 ? args[0] : "strong";
String text = args.length >= 2 ? args[1] : "i am hero";
PasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();
String encryptedPassword = passwordEncryptor.encryptPassword(password);
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(encryptedPassword);
String myEncryptedText = textEncryptor.encrypt(text);
System.out.println(myEncryptedText);
}
示例10: testBasicEncryptionAndDecryption
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
@Test
public void testBasicEncryptionAndDecryption() throws IOException {
String password = UUID.randomUUID().toString();
String masterPassword = UUID.randomUUID().toString();
File masterPwdFile = getMasterPwdFile(masterPassword);
State state = new State();
state.setProp(ConfigurationKeys.ENCRYPT_KEY_LOC, masterPwdFile.toString());
BasicTextEncryptor encryptor = new BasicTextEncryptor();
encryptor.setPassword(masterPassword);
String encrypted = encryptor.encrypt(password);
encrypted = "ENC(" + encrypted + ")";
String decrypted = PasswordManager.getInstance(state).readPassword(encrypted);
Assert.assertEquals(decrypted, password);
}
示例11: init
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
/**
* Initial config for the Crypt Service
*/
public void init(){
logger.info("initial crypt service configuration");
//TODO check JCE extensions for StringTextEncryptor
BasicTextEncryptor bte=new BasicTextEncryptor();
bte.setPassword(this.basePassword);
this.textEncryptor=bte;
}
示例12: textEncryptor
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
@Bean
public TextEncryptor textEncryptor() {
final FactoryBean<String> passwordFactory = new TextEncryptorPasswordFactory();
final BasicTextEncryptor basicTextEncryptor = new BasicTextEncryptor();
try {
basicTextEncryptor.setPassword(passwordFactory.getObject());
} catch(final Exception e) {
throw new BeanInitializationException("Failed to initialize TextEncryptor for some reason", e);
}
return basicTextEncryptor;
}
示例13: setEncryptedPassphrase
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
private void setEncryptedPassphrase(String plainPassphrase, State state) throws IOException {
String masterPassword = UUID.randomUUID().toString();
createMasterPwdFile(masterPassword);
state.setProp(ConfigurationKeys.ENCRYPT_KEY_LOC, this.masterPwdFile.toString());
state.setProp(ConfigurationKeys.ENCRYPT_USE_STRONG_ENCRYPTOR, false);
BasicTextEncryptor encryptor = new BasicTextEncryptor();
encryptor.setPassword(masterPassword);
String encrypted = encryptor.encrypt(plainPassphrase);
state.setProp("converter.decrypt.passphrase", "ENC(" + encrypted + ")");
}
示例14: encryptMessage
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
/**
* Encrypt Message into a Base 64 String Data
*
* @param message to be encrypted
* @return String BASE64 encoded Encrypted String of Message.
*/
public static String encryptMessage(String message) {
initializeDefaultCryptographyProvider();
BasicTextEncryptor basicTextEncryptor = new BasicTextEncryptor();
basicTextEncryptor.setPassword(SALT_PW);
return basicTextEncryptor.encrypt(message);
}
示例15: decryptMessage
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
/**
* DeCrypt a BASE64 Encoded Encrypted Message to Plain text.
*
* @param encryptedMessage
* @return String - Decrypted Message String
*/
public static String decryptMessage(String encryptedMessage) {
initializeDefaultCryptographyProvider();
BasicTextEncryptor basicTextEncryptor = new BasicTextEncryptor();
basicTextEncryptor.setPassword(SALT_PW);
return basicTextEncryptor.decrypt(encryptedMessage);
}