• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TextEncryptor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: PasswordManager

import org.jasypt.util.text.TextEncryptor; //导入依赖的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


示例2: FindConfigFileService

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
protected FindConfigFileService(final FilterProvider filterProvider,
                                final TextEncryptor textEncryptor,
                                final JsonSerializer<FieldPath> fieldPathSerializer,
                                final JsonDeserializer<FieldPath> fieldPathDeserializer) {

    final ObjectMapper objectMapper = new Jackson2ObjectMapperBuilder()
        .featuresToEnable(SerializationFeature.INDENT_OUTPUT)
        .mixIns(customMixins())
        .serializersByType(ImmutableMap.of(FieldPath.class, fieldPathSerializer))
        .deserializersByType(ImmutableMap.of(FieldPath.class, fieldPathDeserializer))
        .createXmlMapper(false)
        .build();

    setConfigFileLocation(CONFIG_FILE_LOCATION);
    setConfigFileName(CONFIG_FILE_NAME);
    setDefaultConfigFile(getDefaultConfigFile());
    setMapper(objectMapper);
    setTextEncryptor(textEncryptor);
    setFilterProvider(filterProvider);
}
 
开发者ID:hpe-idol,项目名称:find,代码行数:21,代码来源:FindConfigFileService.java


示例3: main

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
public static void main(String[] args) throws ParseException {
  CommandLine cl = parseArgs(args);
  if (shouldPrintUsageAndExit(cl)) {
    printUsage();
    return;
  }
  String masterPassword = getMasterPassword(cl);
  TextEncryptor encryptor = getEncryptor(cl, masterPassword);

  if (cl.hasOption(ENCRYPTED_PWD_OPTION)) {
    Matcher matcher = ENCRYPTED_PATTERN.matcher(cl.getOptionValue(ENCRYPTED_PWD_OPTION));
    if (matcher.find()) {
      String encrypted = matcher.group(1);
      System.out.println(encryptor.decrypt(encrypted));
    } else {
      throw new RuntimeException("Input encrypted password does not match pattern \"ENC(...)\"");
    }
  } else if (cl.hasOption(PLAIN_PWD_OPTION)){
    System.out.println("ENC(" + encryptor.encrypt(cl.getOptionValue(PLAIN_PWD_OPTION)) + ")");
  } else {
    printUsage();
    throw new RuntimeException(String.format("Must provide -%s or -%s option.", PLAIN_PWD_OPTION, ENCRYPTED_PWD_OPTION));
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:25,代码来源:CLIPasswordEncryptor.java


示例4: decode

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
private synchronized String decode(final String encodedValue) {
    
    if (!PropertyValueEncryptionUtils.isEncryptedValue(encodedValue)) {
        return encodedValue;
    }
    final EncryptablePropertiesEncryptorRegistry registry =
        EncryptablePropertiesEncryptorRegistry.getInstance();
    final StringEncryptor stringEncryptor = registry.getStringEncryptor(this);
    if (stringEncryptor != null) {
        return PropertyValueEncryptionUtils.decrypt(encodedValue, stringEncryptor);
        
    }
    final TextEncryptor textEncryptor = registry.getTextEncryptor(this);
    if (textEncryptor != null) {
        return PropertyValueEncryptionUtils.decrypt(encodedValue, textEncryptor);
    }
    
    /*
     * If neither a StringEncryptor nor a TextEncryptor can be retrieved
     * from the registry, this means that this EncryptableProperties
     * object has been serialized and then deserialized in a different
     * classloader and virtual machine, which is an unsupported behaviour. 
     */
    throw new EncryptionOperationNotPossibleException(
            "Neither a string encryptor nor a text encryptor exist " +
            "for this instance of EncryptableProperties. This is usually " +
            "caused by the instance having been serialized and then " +
            "de-serialized in a different classloader or virtual machine, " +
            "which is an unsupported behaviour (as encryptors cannot be " +
            "serialized themselves)");
    
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:33,代码来源:EncryptableProperties.java


示例5: encrypt

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
public static String encrypt(
        final String decodedValue, final TextEncryptor encryptor) {
    return 
        ENCRYPTED_VALUE_PREFIX + 
        encryptor.encrypt(decodedValue) +
        ENCRYPTED_VALUE_SUFFIX;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:8,代码来源:PropertyValueEncryptionUtils.java


示例6: HodFindConfigFileService

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
@Autowired
public HodFindConfigFileService(
        final FilterProvider filterProvider,
        final TextEncryptor textEncryptor,
        final JsonSerializer<FieldPath> fieldPathSerializer,
        final JsonDeserializer<FieldPath> fieldPathDeserializer) {
    super(filterProvider, textEncryptor, fieldPathSerializer, fieldPathDeserializer);
}
 
开发者ID:hpe-idol,项目名称:find,代码行数:9,代码来源:HodFindConfigFileService.java


示例7: IdolFindConfigFileService

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
@Autowired
public IdolFindConfigFileService(
        final FilterProvider filterProvider,
        final TextEncryptor textEncryptor,
        final JsonSerializer<FieldPath> fieldPathSerializer,
        final JsonDeserializer<FieldPath> fieldPathDeserializer,
        final IdolConfigUpdateHandler idolConfigUpdateHandler
) {
    super(filterProvider, textEncryptor, fieldPathSerializer, fieldPathDeserializer);

    this.idolConfigUpdateHandler = idolConfigUpdateHandler;
}
 
开发者ID:hpe-idol,项目名称:find,代码行数:13,代码来源:IdolFindConfigFileService.java


示例8: textEncryptor

import org.jasypt.util.text.TextEncryptor; //导入依赖的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;
}
 
开发者ID:hpe-idol,项目名称:find,代码行数:15,代码来源:ConfigFileConfiguration.java


示例9: decrypt

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
public static String decrypt(
        final String encodedValue, final TextEncryptor encryptor) {
    return encryptor.decrypt(getInnerEncryptedValue(encodedValue.trim()));
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:5,代码来源:PropertyValueEncryptionUtils.java


示例10: getTextEncryptor

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
TextEncryptor getTextEncryptor(final EncryptableProperties prop) {
    return (TextEncryptor) this.textEncryptors.get(prop.getIdent());
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:4,代码来源:EncryptablePropertiesEncryptorRegistry.java


示例11: setTextEncryptor

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
void setTextEncryptor(final EncryptableProperties prop, final TextEncryptor encryptor) {
    this.textEncryptors.put(prop.getIdent(), encryptor);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:4,代码来源:EncryptablePropertiesEncryptorRegistry.java


示例12: withEncryptedPasswords

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
@Override
public HodFindConfig withEncryptedPasswords(final TextEncryptor encryptor) {
    return this;
}
 
开发者ID:hpe-idol,项目名称:find,代码行数:5,代码来源:HodFindConfig.java


示例13: withDecryptedPasswords

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
@Override
public HodFindConfig withDecryptedPasswords(final TextEncryptor encryptor) {
    return this;
}
 
开发者ID:hpe-idol,项目名称:find,代码行数:5,代码来源:HodFindConfig.java


示例14: EncryptableProperties

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
/**
 * <p>
 * Creates an <tt>EncryptableProperties</tt> instance which will use
 * the passed {@link TextEncryptor} object to decrypt encrypted values,
 * and the passed defaults as default values (may contain encrypted values).
 * </p>
 * 
 * @param defaults default values for properties (may be encrypted).
 * @param textEncryptor the {@link TextEncryptor} to be used do decrypt
 *                      values. It can not be null.
 */
public EncryptableProperties(final Properties defaults, final TextEncryptor textEncryptor) {
    super(defaults);
    CommonUtils.validateNotNull(textEncryptor, "Encryptor cannot be null");
    final EncryptablePropertiesEncryptorRegistry registry =
        EncryptablePropertiesEncryptorRegistry.getInstance();
    registry.setTextEncryptor(this, textEncryptor);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:19,代码来源:EncryptableProperties.java


示例15: setTextEncryptor

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
/**
 * If {@link T} is not a {@link PasswordsConfig}, this property need not be set.
 *
 * @param textEncryptor The {@link TextEncryptor} used to encrypt passwords.
 */
public void setTextEncryptor(final TextEncryptor textEncryptor) {
    this.textEncryptor = textEncryptor;
}
 
开发者ID:hpe-idol,项目名称:java-configuration-impl,代码行数:9,代码来源:BaseConfigFileService.java


示例16: withEncryptedPasswords

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
/**
 * @param encryptor object responsible for password encryption
 * @return A copy of this config with passwords encrypted by the supplied {@link TextEncryptor},
 * or this if the config has no passwords
 */
T withEncryptedPasswords(TextEncryptor encryptor);
 
开发者ID:hpe-idol,项目名称:java-configuration-impl,代码行数:7,代码来源:PasswordsConfig.java


示例17: withDecryptedPasswords

import org.jasypt.util.text.TextEncryptor; //导入依赖的package包/类
/**
 * @param encryptor object responsible for password encryption
 * @return A copy of this config with passwords decrypted by the supplied {@link TextEncryptor},
 * or this if the config has no passwords
 */
T withDecryptedPasswords(TextEncryptor encryptor);
 
开发者ID:hpe-idol,项目名称:java-configuration-impl,代码行数:7,代码来源:PasswordsConfig.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConnectionState类代码示例发布时间:2022-05-23
下一篇:
Java FenceUpdateRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap