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


Java BasicTextEncryptor类代码示例

本文整理汇总了Java中org.jasypt.util.text.BasicTextEncryptor的典型用法代码示例。如果您正苦于以下问题:Java BasicTextEncryptor类的具体用法?Java BasicTextEncryptor怎么用?Java BasicTextEncryptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getEncryptor

import org.jasypt.util.text.BasicTextEncryptor; //导入依赖的package包/类
private static Optional<BasicTextEncryptor> getEncryptor(Optional<String> masterPassword) {
  Optional<BasicTextEncryptor> encryptor;
  if (masterPassword.isPresent()) {
    encryptor = Optional.of(new BasicTextEncryptor());
    try {
      encryptor.get().setPassword(masterPassword.get());
    } catch (Exception e) {
      LOG.error("Failed to set master password for encryptor", e);
      encryptor = Optional.absent();
    }
  } else {
    encryptor = Optional.absent();
  }

  return encryptor;
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:17,代码来源:PasswordManager.java

示例2: 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;
}
 
开发者ID:zoltanvi,项目名称:password-manager,代码行数:24,代码来源:PasswordManagerController.java

示例3: 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");
	}
}
 
开发者ID:att,项目名称:dmaap-framework,代码行数:25,代码来源:MirrorMakerAgent.java

示例4: PasswordManager

import org.jasypt.util.text.BasicTextEncryptor; //导入依赖的package包/类
private PasswordManager(Optional<String> masterPassword, boolean useStrongEncryptor) {
  if (masterPassword.isPresent()) {
    this.encryptor = useStrongEncryptor ? Optional.of((TextEncryptor) new StrongTextEncryptor())
        : Optional.of((TextEncryptor) new BasicTextEncryptor());
    try {

      // setPassword() needs to be called via reflection since the TextEncryptor interface doesn't have this method.
      this.encryptor.get().getClass().getMethod("setPassword", String.class).invoke(this.encryptor.get(),
          masterPassword.get());
    } catch (Exception e) {
      LOG.error("Failed to set master password for encryptor", e);
      this.encryptor = Optional.absent();
    }
  } else {
    this.encryptor = Optional.absent();
  }
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:18,代码来源:PasswordManager.java

示例5: 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, "");
        }
    }
}
 
开发者ID:GlitchCog,项目名称:ChatGameFontificator,代码行数:23,代码来源:FontificatorProperties.java

示例6: 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, "");
        }
    }
}
 
开发者ID:GlitchCog,项目名称:ChatGameFontificator,代码行数:22,代码来源:FontificatorProperties.java

示例7: encryptPassword

import org.jasypt.util.text.BasicTextEncryptor; //导入依赖的package包/类
/**
 * Encrypt a password. A master password must have been provided in the constructor.
 * @param plain A plain password to be encrypted.
 * @return The encrypted password.
 */
public static String encryptPassword(String plain, Optional<String> masterPassword) {
  Optional<BasicTextEncryptor> encryptor = getEncryptor(masterPassword);
  Preconditions.checkArgument(getEncryptor(masterPassword).isPresent(), ERROR_ENCRY_MSG);

  try {
    return encryptor.get().encrypt(plain);
  } catch (Exception e) {
    throw new RuntimeException("Failed to encrypt password", e);
  }
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:16,代码来源:PasswordManager.java

示例8: decryptPassword

import org.jasypt.util.text.BasicTextEncryptor; //导入依赖的package包/类
/**
 * Decrypt an encrypted password. A master password must have been provided in the constructor.
 * @param encrypted An encrypted password.
 * @return The decrypted password.
 */
public static String decryptPassword(String encrypted, Optional<String> masterPassword) {
  Optional<BasicTextEncryptor> encryptor = getEncryptor(masterPassword);
  Preconditions
    .checkArgument(encryptor.isPresent(), ERROR_DECRY_MSG);

  try {
    return encryptor.get().decrypt(encrypted);
  } catch (Exception e) {
    throw new RuntimeException("Failed to decrypt password " + encrypted, e);
  }
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:17,代码来源:PasswordManager.java

示例9: loginUser

import org.jasypt.util.text.BasicTextEncryptor; //导入依赖的package包/类
/** Logging in the user */
 private void loginUser(){
     Executors.newSingleThreadExecutor().execute(() ->
     {
         String usrnm = gui.getLogin().getTxtUsername().getText();
         String pwd = String.valueOf(gui.getLogin().getTxtPass1().getPassword());

         if(usrnm.length() != 0 && pwd.length() != 0){
             PasswordManagerGUI.setSessionUsername(usrnm);
             PasswordManagerGUI.setSessionPassword(pwd);
             String uppercase_username = ((usrnm + "   ").toUpperCase());
             PasswordManagerGUI.getLblUser().setText(uppercase_username);
             BasicTextEncryptor encryptor = new BasicTextEncryptor();
             encryptor.setPassword(pwd);

             try{
                 if(encryptor.decrypt(dao.getPassword(usrnm)).equals(PasswordManagerGUI.getSessionPassword())){
                     System.out.println("Successfully logged in!");
                     gui.switchToPass();
                     JOptionPane.showMessageDialog(gui.getPanel(),
                             "Successfully logged in as " + usrnm + "!",
                             "Login", JOptionPane.PLAIN_MESSAGE);
                     gui.switchToLoggedIn();
                 }

             } catch(EncryptionOperationNotPossibleException xx){
                 JOptionPane.showMessageDialog(gui.getPanel(),
                         "Wrong password!",
                         "Password", JOptionPane.ERROR_MESSAGE);
             }catch(NullPointerException x) {
                 JOptionPane.showMessageDialog(gui.getPanel(),
                         "This username not exist!",
                         "Username", JOptionPane.ERROR_MESSAGE);
             }
         }
     });
}
 
开发者ID:zoltanvi,项目名称:password-manager,代码行数:38,代码来源:PasswordManagerController.java

示例10: 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();
			}
		}
	}

}
 
开发者ID:att,项目名称:dmaap-framework,代码行数:40,代码来源:MirrorMakerAgent.java

示例11: 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);
}
 
开发者ID:reportportal,项目名称:service-tfs,代码行数:10,代码来源:TfsServiceApp.java

示例12: 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);

}
 
开发者ID:SchweizerischeBundesbahnen,项目名称:releasetrain,代码行数:10,代码来源:EncryptorImpl.java

示例13: 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);
}
 
开发者ID:SchweizerischeBundesbahnen,项目名称:releasetrain,代码行数:9,代码来源:EncryptorImpl.java

示例14: 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);
}
 
开发者ID:jandy-team,项目名称:jandy,代码行数:14,代码来源:Main.java

示例15: 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);
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:15,代码来源:PasswordManagerTest.java


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