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

Java EncryptionOperationNotPossibleException类代码示例

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

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



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

示例1: encrypt

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
public static String encrypt(final String plain) {
    if (!EncryptionSecretKeyChecker.useEncryption() || (plain == null) || plain.isEmpty()) {
        return plain;
    }
    if (s_encryptor == null) {
        initialize();
    }
    String encryptedString = null;
    try {
        encryptedString = s_encryptor.encrypt(plain);
    } catch (final EncryptionOperationNotPossibleException e) {
        s_logger.debug("Error while encrypting: " + plain);
        throw e;
    }
    return encryptedString;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:17,代码来源:DBEncryptionUtil.java


示例2: decrypt

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
public static String decrypt(final String encrypted) {
    if (!EncryptionSecretKeyChecker.useEncryption() || (encrypted == null) || encrypted.isEmpty()) {
        return encrypted;
    }
    if (s_encryptor == null) {
        initialize();
    }

    String plain = null;
    try {
        plain = s_encryptor.decrypt(encrypted);
    } catch (final EncryptionOperationNotPossibleException e) {
        s_logger.debug("Error while decrypting: " + encrypted);
        throw e;
    }
    return plain;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:18,代码来源:DBEncryptionUtil.java


示例3: testStrongEncryptionAndDecryption

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
@Test
public void testStrongEncryptionAndDecryption() 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());
  state.setProp(ConfigurationKeys.ENCRYPT_USE_STRONG_ENCRYPTOR, true);
  try{
    StrongTextEncryptor encryptor = new StrongTextEncryptor();
    encryptor.setPassword(masterPassword);
    String encrypted = encryptor.encrypt(password);
    encrypted = "ENC(" + encrypted + ")";
    String decrypted = PasswordManager.getInstance(state).readPassword(encrypted);
    Assert.assertEquals(decrypted, password);
  }
  catch (EncryptionOperationNotPossibleException e) {
    //no strong encryption is supported
  }
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:21,代码来源:PasswordManagerTest.java


示例4: fromHexadecimal

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
public static byte[] fromHexadecimal(final String message) {
    if (message == null) {
        return null;
    }
    if ((message.length() % 2) != 0) {
        throw new EncryptionOperationNotPossibleException();
    }
    try {
        final byte[] result = new byte[message.length() / 2];
        for (int i = 0; i < message.length(); i = i + 2) {
            final int first = Integer.parseInt("" + message.charAt(i), 16);
            final int second = Integer.parseInt("" + message.charAt(i + 1), 16);
            result[i/2] = (byte) (0x0 + ((first & 0xff) << 4) + (second & 0xff));
        }
        return result;
    } catch (Exception e) {
        throw new EncryptionOperationNotPossibleException();
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:20,代码来源:CommonUtils.java


示例5: shouldWrapExceptionOnEncryptionError

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
@Test
public void shouldWrapExceptionOnEncryptionError() {
    // given
    StandardEnvironment environment = new StandardEnvironment();
    Properties props = new Properties();
    props.put("propertyDecryption.password", "NOT-A-PASSWORD");
    props.put("someProperty", "{encrypted}NOT-ENCRYPTED");
    environment.getPropertySources().addFirst(new PropertiesPropertySource("test-env", props));

    exception.expect(RuntimeException.class);
    exception.expectMessage("Unable to decrypt property value '{encrypted}NOT-ENCRYPTED'");
    exception.expectCause(isA(EncryptionOperationNotPossibleException.class));

    ApplicationEnvironmentPreparedEvent event = new ApplicationEnvironmentPreparedEvent(new SpringApplication(), new String[0], environment);

    // when
    listener.onApplicationEvent(event);

    // then -> exception
}
 
开发者ID:lukashinsch,项目名称:spring-properties-decrypter,代码行数:21,代码来源:DecryptingPropertiesApplicationListenerTest.java


示例6: AuthToken

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
public AuthToken(String key,String token) throws AuthenticationException {
    try {
        logger.info("En: " + token);
        token = decrypt(token, key);
        logger.info("De: " + token);
        String[] parts = token.split("(\\|)");
        for (String s : parts){
            logger.info("Part: " + s);
        }
        userId = parts[1];
        expirationDate = Long.parseLong(parts[2]);
    } catch (EncryptionOperationNotPossibleException e){
        e.printStackTrace();
        throw new AuthenticationException("Failed to create AuthToken",e);
    }
}
 
开发者ID:williamwebb,项目名称:divide,代码行数:17,代码来源:AuthTokenUtils.java


示例7: processValues

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
private Map<String, Object> processValues(Map<String, Object> properties, List<Value> values, boolean revert, boolean remove) {
    Map<String, Object> processed = new HashMap<>();
    for (Value value : values) {
        String key = value.getName();
        String property = getProperty(properties, key, isOptional(value));
        if (property != null && !property.isEmpty() && isEncrypted(value)) {
            if (revert) {
                try {
                    property = encryptor.decrypt(property);
                } catch (EncryptionOperationNotPossibleException ignored) {
                    property = legacyEncryptor.decrypt(property);
                }
            } else {
                property = encryptor.encrypt(property);
            }
        }
        if (isSensitve(value)) {
            if (!remove) {
                processed.put(key, property);
            }
        } else {
            processed.put(key, property);
        }
    }
    return processed;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:27,代码来源:CredentialDefinitionService.java


示例8: encryptIpSecPresharedKeysOfRemoteAccessVpn

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
private void encryptIpSecPresharedKeysOfRemoteAccessVpn(Connection conn) {
    try (
            PreparedStatement selectStatement = conn.prepareStatement("SELECT id, ipsec_psk FROM `cloud`.`remote_access_vpn`");
            ResultSet resultSet = selectStatement.executeQuery();
        ) {
        while (resultSet.next()) {
            Long rowId = resultSet.getLong(1);
            String preSharedKey = resultSet.getString(2);
            try {
                preSharedKey = DBEncryptionUtil.decrypt(preSharedKey);
            } catch (EncryptionOperationNotPossibleException ignored) {
                s_logger.debug("The ipsec_psk preshared key id=" + rowId + "in remote_access_vpn is not encrypted, encrypting it.");
            }
            try (PreparedStatement updateStatement = conn.prepareStatement("UPDATE `cloud`.`remote_access_vpn` SET ipsec_psk=? WHERE id=?");) {
                updateStatement.setString(1, DBEncryptionUtil.encrypt(preSharedKey));
                updateStatement.setLong(2, rowId);
                updateStatement.executeUpdate();
            }
        }
    } catch (SQLException e) {
        throw new CloudRuntimeException("Unable to update the remote_access_vpn's preshared key ipsec_psk column", e);
    }
    s_logger.debug("Done encrypting remote_access_vpn's ipsec_psk column");
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:25,代码来源:Upgrade450to451.java


示例9: encrypt

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
public static String encrypt(String plain) {
    if (!EncryptionSecretKeyChecker.useEncryption() || (plain == null) || plain.isEmpty()) {
        return plain;
    }
    if (s_encryptor == null) {
        initialize();
    }
    String encryptedString = null;
    try {
        encryptedString = s_encryptor.encrypt(plain);
    } catch (EncryptionOperationNotPossibleException e) {
        s_logger.debug("Error while encrypting: " + plain);
        throw e;
    }
    return encryptedString;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:17,代码来源:DBEncryptionUtil.java


示例10: decrypt

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
public static String decrypt(String encrypted) {
    if (!EncryptionSecretKeyChecker.useEncryption() || (encrypted == null) || encrypted.isEmpty()) {
        return encrypted;
    }
    if (s_encryptor == null) {
        initialize();
    }

    String plain = null;
    try {
        plain = s_encryptor.decrypt(encrypted);
    } catch (EncryptionOperationNotPossibleException e) {
        s_logger.debug("Error while decrypting: " + encrypted);
        throw e;
    }
    return plain;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:18,代码来源:DBEncryptionUtil.java


示例11: decryptOne

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
public String decryptOne(String encPassword, String key) {
	String result = null;
	if(JmsHelper.isStringNullOrEmpty(encPassword) || key == null || key.equals("")) {
		throw new IllegalArgumentException("EncryptedText or password cannot be null or empty");
	}
	
	decryptor = new StandardPBEStringEncryptor();
	
	try {
		decryptor.setPassword(key);
		result = decryptor.decrypt(encPassword);
	} catch (EncryptionOperationNotPossibleException ex) {
		//Absorb this exception 
	}
	return result;
}
 
开发者ID:OpenSecurityResearch,项目名称:jmsdigger,代码行数:17,代码来源:JmsPasswordOps.java


示例12: decrypt

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
public String decrypt(String encryptedText) {
	String result = null;
	if(encryptedText == null) 
		throw new IllegalArgumentException("Encrypted text cannot be null");

	if(passwords.size() == 0) 
		throw new IllegalArgumentException("No password list provided");
	
	for(String pass : passwords) {
		//New object is required for each decryption attempt
		decryptor = new StandardPBEStringEncryptor();
		try {
			decryptor.setPassword(pass);
			result = decryptor.decrypt(encryptedText);
		} catch (EncryptionOperationNotPossibleException ex) {
			//Absorb this exception to be able to run through a large number of passwords 
		}
	}			
	// A null value for the result indicates that encrypted 
	// text could not be decrypted with the provided passwords
	return result;
}
 
开发者ID:OpenSecurityResearch,项目名称:jmsdigger,代码行数:23,代码来源:JmsPasswordOps.java


示例13: loginUser

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的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


示例14: decryptAsNeeded

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
/**
 * Decrypt a potentially encrypted value.
 * 
 * @param value
 *            The encrypted value to decrypt if not <code>null</code>.
 * @return the decrypted value.
 */
public String decryptAsNeeded(final String value) {
	try {
		// Try a decryption
		return decrypt(value);
	} catch (final EncryptionOperationNotPossibleException e) { // NOSONAR - Ignore raw value
		// Value could be encrypted, but was not
		return value;
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:17,代码来源:CryptoHelper.java


示例15: encryptAsNeeded

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
/**
 * Encrypt a clear value. Try to decrypt the value, and if succeed, return the formal parameter without encrypting
 * again the value.
 * 
 * @param value
 *            A potentially raw value to encrypt.
 * @return The encrypted value, or formal parameter if was already encrypted.
 */
public String encryptAsNeeded(final String value) {
	try {
		// Try a decryption
		decrypt(value);

		// Value is already encrypted
		return value;
	} catch (final EncryptionOperationNotPossibleException e) { // NOSONAR - Ignore raw value
		// Value could be encrypted, but was not
		return encrypt(value);
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:21,代码来源:CryptoHelper.java


示例16: encryptAsNeeded

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
/**
 * Test encrypt.
 */
@Test
public void encryptAsNeeded() {
	final StringEncryptor stringEncryptor = Mockito.mock(StringEncryptor.class);
	Mockito.when(stringEncryptor.decrypt("value")).thenThrow(new EncryptionOperationNotPossibleException());
	Mockito.when(stringEncryptor.encrypt("value")).thenReturn("encrypted");
	final CryptoHelper securityHelper = new CryptoHelper();
	securityHelper.setEncryptor(stringEncryptor);
	Assert.assertEquals("encrypted", securityHelper.encryptAsNeeded("value"));
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:13,代码来源:CryptoHelperTest.java


示例17: decryptAsNeededAlreadyDecrypted

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
/**
 * Test decrypt a raw value.
 */
@Test
public void decryptAsNeededAlreadyDecrypted() {
	final StringEncryptor stringEncryptor = Mockito.mock(StringEncryptor.class);
	Mockito.when(stringEncryptor.decrypt("value")).thenThrow(new EncryptionOperationNotPossibleException());
	final CryptoHelper securityHelper = new CryptoHelper();
	securityHelper.setEncryptor(stringEncryptor);
	Assert.assertEquals("value", securityHelper.decryptAsNeeded("value"));
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:12,代码来源:CryptoHelperTest.java


示例18: getSystemSettingOptional

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
/**
 * Get system setting optional. The database call is executed in a
 * programmatic transaction.
 *
 * @param name the system setting name.
 * @param defaultValue the default value for the system setting.
 * @return an optional system setting value.
 */
private Optional<Serializable> getSystemSettingOptional( String name, Serializable defaultValue )
{
    SystemSetting setting = transactionTemplate.execute( new TransactionCallback<SystemSetting>()
    {
        public SystemSetting doInTransaction( TransactionStatus status )
        {
            return systemSettingStore.getByName( name );
        }
    } );

    if ( setting != null && setting.hasValue() )
    {
        if ( isConfidential( name ) )
        {
            try
            {
                return Optional.of( pbeStringEncryptor.decrypt( (String) setting.getValue() ) );
            }
            catch ( EncryptionOperationNotPossibleException e ) // Most likely this means the value is not encrypted, or not existing
            {
                log.warn( "Could not decrypt system setting '" + name + "'" );
                return Optional.empty();
            }
        }
        else
        {
            return Optional.of( setting.getValue() );
        }
    }
    else
    {
        return Optional.ofNullable( defaultValue );
    }
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:43,代码来源:DefaultSystemSettingManager.java


示例19: resolvePropertyValue

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
@Override
public String resolvePropertyValue(String value) {
    String actualValue = value;
    if (detector.isEncrypted(value)) {
        try {
            actualValue = encryptor.decrypt(detector.unwrapEncryptedValue(value.trim()));
        } catch (EncryptionOperationNotPossibleException e) {
            throw new DecryptionException("Decryption of Properties failed,  make sure encryption/decryption " +
                    "passwords match", e);
        }
    }
    return actualValue;
}
 
开发者ID:ulisesbocchio,项目名称:jasypt-spring-boot,代码行数:14,代码来源:DefaultPropertyResolver.java


示例20: runTask

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; //导入依赖的package包/类
@Override
protected void runTask(List<String> tokens) throws Exception {
    if (password == null || input == null) {
        context.printException(new IllegalArgumentException("input and password parameters are mandatory"));
        return;
    }
    encryptor.setPassword(password);
    try {
        context.print("Decrypted text: " + encryptor.decrypt(input));
    } catch (EncryptionOperationNotPossibleException e) {
        context.print("ERROR: Text cannot be decrypted, check your input and password and try again!");
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:14,代码来源:DecryptCommand.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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