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


Java EncryptionOperationNotPossibleException类代码示例

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


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


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