Posts

Showing posts from April, 2023

How to Write&Read csv file in Java?

Image
use OpenCSV OpenCSV is able to serialize .csv files into preset and reusable schemas implemented as annotated Java pojo beans <!-- https://mvnrepository.com/artifact/com.opencsv/opencsv --> <dependency> <groupId>com.opencsv</groupId> <artifactId>opencsv</artifactId> <version>5.7.1</version> </dependency> Write CSV Read CSV opencsv –  

How to do AES encryption&decryption in java?

Image
show you the code: Base64 UrlEncoder for query parameter the key and iv are configured in properties in base64 format. So I use Base64 Decoder decode them before create SecretKeySpec and IvParameterSpec. new SecretKeySpec(Base64.getDecoder().decode(aliasKey), "AES"), new IvParameterSpec(Base64.getDecoder().decode(aliasIv))); Since I am using AES to encrypt query parameter which will be transport via internet. so I use Base64 UrlEncoder for encrption and UrlDecoder for decryption. return Ba  

How to write integration tests against LDAP in your spring boot java application?

Image
The answer is to use an embedded ldap server. spring-ldap-test bring an embedded ldap server based on ApacheDS or UnboundID. In this post, I will demo how I use UnboundID and spring-ldap-test to do testing against an embedded LDAP server. The UnboundID LDAP SDK for Java is a fast, powerful, user-friendly, and completely free Java library for communicating with LDAP directory servers. It offers better performance, better ease of use, and more features than other Java-based LDAP APIs. It is act  

How to do PGP decryption in Java?

Image
In my previous post, I mentioned how to encrypt data with PGP public key. In this post, I will tell you how to decrypt the data with PGP private key. You need a PGP key pair to test the encryption and decryption and see it works. Check this post to generate the PGP key pair. Read|Load PGPPrivateKey from file don't forget the deps before you write your code. Check the encrypt post for it. Notes: The userId is the Real name + email address in format like: `Real <Email>` , you were asked to pro