Adeptia supports encryption and decryption mechanism as part of ETL and B2B implementation. Adeptia can easily process and transfer encrypted files and data. Below is brief example of PGP encryption and decryption in a Process Flow.
Please follow the below steps for PGP encryption and decryption:
- Place the attached "PGPUtils.class" file in following location .\AdeptiaServer-5.3\ServerKernel\customClasses
- Goto following location ".\AdeptiaServer-5.3\ServerKernel" and create a folder with name “keys”.
- Put the public key and secret key file (.asc file) keys folder created in above step.
Process Flow Design steps for Encryption:
- Create a File Source activity from where you will pick the source file that needs to be encrypted.
- Create a custom plug-in activity and write below code in it for generating encrypted stream.
import java.security.Security;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.io.*;
File publicKeyFile = null;
FileInputStream fis_pubK = null;try{
// Reads the public key file
publicKeyFile = new File("./keys/public.asc"); //Provide the public key file name in place of public.asc
fis_pubK = new FileInputStream(publicKeyFile);
// Adding security provider
Security.addProvider(new BouncyCastleProvider());
// Encryption of Source Data
PGPUtils.encrypt(inputStream, fis_pubK, service.getOutputStream(), true);
}
catch(Exception e){
service.getLogger().error("Error:: "+e.getMessage(),e);
throw e;
}finally{
if(fis_pubK != null){
fis_pubK.close();
fis_pubK = null;
}
publicKeyFile = null;
}
-
Create a File Target activity where the encrypted file will be placed.
Design Structure of encryption Process Flow should be similar to:
Process Flow Design steps for Decryption:
-
Create a File Source activity to read the encrypted file.
- Create a custom plug-in activity and write below code in it for generating decrypted stream.
import java.security.Security;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.io.*;FileInputStream fis_pvtK = null;
File privateKeyFile = null;
try{
// Reading secret key file
privateKeyFile = new File("./keys/secret.asc"); // Provide the name of secret key file in place of secret.asc
fis_pvtK = new FileInputStream(privateKeyFile );
// Password os secret key
String privateKeyPassword = "p@ssw0rd"; //Provide password of secret key in double quotes
// Adding security provider
Security.addProvider(new BouncyCastleProvider());
// Decryption of source data
PGPUtils.decrypt(inputStream, fis_pvtK, privateKeyPassword , service.getOutputStream(), true);
}
catch(Exception e){
service.getLogger().error("Error:: "+e.getMessage(),e);
throw e;
}finally{
if(fis_pvtK != null){
fis_pvtK.close();
fis_pvtK = null;
}
privateKeyFile = null;
}
- Create a File Target activity where the decrypted file is to be placed.
Design Structure of Decryption Process Flow should be similar to:
Note: In process flow make sure that you have created multiple stream from file source activity to custom plug-in activity and custom plug-in activity to file target activities. Also check if the Consume Stream and Generate Stream properties of custom plug-in activity are set to “true”.
Comments
0 comments
Article is closed for comments.