| | |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.RestoreConfig; |
| | | |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.CipherInputStream; |
| | | import javax.crypto.CipherOutputStream; |
| | | import javax.crypto.Mac; |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | |
| | | // output stream. |
| | | if (encrypt) |
| | | { |
| | | String cipherAlgorithm = cryptoManager.getPreferredCipherAlgorithm(); |
| | | String cipherAlgorithm = cryptoManager.getPreferredCipherTransformation(); |
| | | backupProperties.put(BACKUP_PROPERTY_CIPHER_ALGORITHM, cipherAlgorithm); |
| | | |
| | | Cipher cipher; |
| | | try |
| | | { |
| | | cipher = cryptoManager.getPreferredCipher(Cipher.ENCRYPT_MODE); |
| | | outputStream |
| | | = cryptoManager.getCipherOutputStream(outputStream); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | | } |
| | | |
| | | outputStream = new CipherOutputStream(outputStream, cipher); |
| | | } |
| | | |
| | | |
| | |
| | | String cipherAlgorithm = |
| | | backupProperties.get(BACKUP_PROPERTY_CIPHER_ALGORITHM); |
| | | |
| | | Cipher cipher; |
| | | try |
| | | { |
| | | cipher = cryptoManager.getCipher(cipherAlgorithm, Cipher.DECRYPT_MODE); |
| | | inputStream = cryptoManager.getCipherInputStream(inputStream); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | | } |
| | | |
| | | inputStream = new CipherInputStream(inputStream, cipher); |
| | | } |
| | | |
| | | |
| | |
| | | String cipherAlgorithm = |
| | | backupProperties.get(BACKUP_PROPERTY_CIPHER_ALGORITHM); |
| | | |
| | | Cipher cipher; |
| | | try |
| | | { |
| | | cipher = cryptoManager.getCipher(cipherAlgorithm, Cipher.DECRYPT_MODE); |
| | | inputStream = cryptoManager.getCipherInputStream(inputStream); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | | } |
| | | |
| | | inputStream = new CipherInputStream(inputStream, cipher); |
| | | } |
| | | |
| | | |