Blog

Base64 Stream Examples in Java

The following examples use Apache’s Commons Codec library which is available on Maven Central by using the following dependency in your pom.xml file. Reading and Writing a Base64 String Example The following code will allow you to read or decode a Base64 encoded String in Java. This is useful for data that is short or limited in …

Enabling host verification in Netty

By default, Netty version 4 and lower are configured with Host verification disabled. While this is helpful during debugging or developing an application, it can become a security issue if brought in production. There are a number of steps involved in certificate verification, one of these is to compare the hostname of the client or …

Spring JdbcAggregateTemplate Example

Spring’s JdbcAggregateTemplate gives you more granular control over the operations that are being performed on your database. JdbcAggregateTemplate exposes operations that are used by Spring Repositories internally, allowing you to invoke database operations that would not otherwise be available using a standard JDBC Repository. This template can be useful for situations when you want to …

Spring JDBC BeforeSaveCallback Example

When using Spring JDBC, there are a number of callbacks available to the developer that can be used to intercept various lifecycle stages of entities within the scope of JDBC. BeforeSaveCallback is used in Spring after an insert or update operation but before the actual database operation has occurred. This gives you the opportunity check …

Spring AsyncRestTemplate is now Deprecated

As part of the Spring 5.0 release, a large number of the Asynchronous HTTP classes have been deprecated in favor of Spring’s new reactive ClientRequest and WebClient classes. Here is a before and after on how you can update your RestTemplate code to the latest non-deprecated way of performing API calls in Spring. Deprecated AsyncRestTemplate Example Here …

Common Maven fixes for transitive CVEs

CVE-2021-29425 - commons-io vulnerability fix Apache commons-io versions 2.6 or below contain a vulnerability in the FileNameUtils class that opens an application up to directory traversal attacks. Paths containing ../ will not be normalized resulting in a path being passed that could cause the application to access files unintended by the developer. Older versions of …

Forwarded Headers Example in Spring

When configuring one or more Spring Boot applications behind a netscaler, load balancer, or reverse proxy, it is possible that the URI’s presented at the browser level do not align with those which are being referenced within Spring. In such a configuration, it is helpful to have the external URL. Take for example a situation …