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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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
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 actively being developed and enhanced by Ping Identity and is a critical component of their Directory Server and other identity management software.
Notes: please don't specify a port for the embedded LDAP server, it will find a free port for use. Otherwise your tests might failure due to port already been bind or used. Because each spring boot test will start an embedded LDAP server.
The LDAP Data Interchange Format (LDIF) is a standard plain text data interchange format for representing Lightweight Directory Access Protocol (LDAP) directory content and update requests. LDIF conveys directory content as a set of records, one record for each object (or entry). It also represents update requests, such as Add, Modify, Delete, and Rename, as a set of records, one record for each update request. LDIF was designed in the early 1990s by Tim Howes, Mark C. Smith, and Gordon Good while at the University of Michigan.
Below employee.ldif create a few entries to be pop to the LDAP server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
That is all. Then in your spring boot tests, you should have an embedded LDAP server with the above employees entries. The LdapTemplate bean will be automatically configured for you too. I will write another post to guide you how to use LdapTemplate to do pagination search against your LDAP server.
Stay tuned!
Apache Directory Studio
I strong recommend this tool to explore your LDAP server directory while you build your spring boot java application with Spring LDAP framework.
Apache Directory Studio is a complete directory tooling platform intended to be used with any LDAP server however it is particularly designed for use with ApacheDS. It is an Eclipse RCP application, composed of several Eclipse (OSGi) plugins, that can be easily upgraded with additional ones. These plugins can even run within Eclipse itself.
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Notes: The userId is the Real name + email address in format like: `Real <Email>` , you were asked to provide these when you create the PGP key pair. Remember the password too.
Decrypt Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In order to do PGP encryption, you need the PGP public key file. In this post I will tell how to encrypt data with PGP public key in Java. Dependencies Welcome to the home of the Legion of the Bouncy Castle. A fun place to stay, if you've got some time to kill. bouncycastle.orgHome of open source libraries of the Legion of the Bouncy Castle and their Java cryptography and C# cryptography resources https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on/1.70 The Bouncy Castle Cry
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 and up.
The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, and certificate generation. This jar contains APIs for JDK 1.5 and up. The APIs can be used in conjunction with a JCE/JCA provider such as the one provided with the Bouncy Castle Cryptography APIs.
Read PGPPublicKey from file
Now we have The Bouncy Castle Java APIs, let's try to load the PGP public file into PGPPublicKey object.
The main idea is iterator the keys in the ring collection and find the key isEncryptionKey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters