private String decode( String string ) throws UnsupportedEncodingException { byte[] bytes = Base64.decodeBase64( string ); EncryptionResult result = EncryptionResult.fromByteArray(bytes); byte[] clear = cryptoService.decryptForCluster(clusterName, EncryptUriDescriptor.PASSWORD_ALIAS, result.cipher, result.iv, result.salt); if (clear != null) { return new String(clear, StandardCharsets.UTF_8); } return null; } }
String decode( String string ) throws UnsupportedEncodingException { byte[] bytes = Base64.decodeBase64( string ); EncryptionResult result = EncryptionResult.fromByteArray(bytes); byte[] clear = null; try { clear = encryptor.decrypt( result.salt, result.iv, result.cipher); } catch (Exception e) { log.unableToDecryptValue(e); } if (clear != null) { return new String(clear, StandardCharsets.UTF_8); } return null; } }
String decode( String string ) throws UnsupportedEncodingException { byte[] bytes = Base64.decodeBase64( string ); EncryptionResult result = EncryptionResult.fromByteArray(bytes); byte[] clear = null; try { clear = encryptor.decrypt( result.salt, result.iv, result.cipher); } catch (Exception e) { log.unableToDecryptValue(e); } if (clear != null) { return new String(clear, StandardCharsets.UTF_8); } return null; } }
private Serializable uncompressDecryptBase64(final String v) { if (v != null && v.length() > 0) { byte[] bytes = Base64.decodeBase64(v); EncryptionResult result = EncryptionResult.fromByteArray(bytes); byte[] clear = cryptoService.decryptForCluster(this.clusterName, PAC4J_PASSWORD, result.cipher, result.iv, result.salt); if (clear != null) { try { return javaSerializationHelper.unserializeFromBytes(unCompress(clear)); } catch (IOException e) { throw new TechnicalException(e); } } } return null; }
private Serializable uncompressDecryptBase64(final String v) { if (v != null && !v.isEmpty()) { byte[] bytes = Base64.decodeBase64(v); EncryptionResult result = EncryptionResult.fromByteArray(bytes); byte[] clear = cryptoService.decryptForCluster(this.clusterName, PAC4J_PASSWORD, result.cipher, result.iv, result.salt); if (clear != null) { try { return javaSerializationHelper.unserializeFromBytes(unCompress(clear)); } catch (IOException e) { throw new TechnicalException(e); } } } return null; }