Spring EnableEncryptableProperties with Jasypt

Spring EnableEncryptableProperties with Jasypt shows an example how to avoid putting clear text password for database connection credentials in properties file. Jasypt means Java simplified encryption. Here we are going to use Spring version 4 with Jasypt (Java simplified encryption). Here we are also going to use Spring Data JPA to perform the data layer activities with database.

If you put clear text password in properties file then everybody even people who should not see password would gain access to your database and may change database tables values, structure or even may delete without your consent. So it is always better to put the password in an encypted way to avoid such unwanted issues.

Here we will create Gradle based Spring Boot application with Spring Data JPA and apply Jasypt (Java simplified encryption) to extra layer of security for your password.

Jasypt Spring Boot provides Encryption support for property sources in Spring Boot Applications. There are 3 ways to integrate Jasypt in your spring boot project:

Simply adding the starter jar jasypt-spring-boot-starter to your classpath if using @SpringBootApplication or @EnableAutoConfiguration will enable encryptable properties across the entire Spring Environment

Adding jasypt-spring-boot-starter to your classpath and adding @EnableEncryptableProperties to your main Configuration class to enable encryptable properties across the entire Spring Environment

Adding jasypt-spring-boot-starter to your classpath and declaring individual encryptable property sources with @EncrytablePropertySource

Continue reading “Spring EnableEncryptableProperties with Jasypt”

Spring EnableEncryptableProperties with Jasypt was last modified: June 14th, 2018 by Soumitra Roy Sarkar

Hackerrank Solution: 1D Array – Part 2 using Kotlin

This tutorial will show you Hackerrank 1D Array Part 2 using Kotlin.

Let’s play a game on an array! You’re standing at index 0 of an n-element array named game. From some index i (where 0 <= i < n), you can perform one of the following moves:

Move Backward: If cell i-1 exists and contains a 0, you can walk back to cell i-1.

Move Forward:

If cell i+1 contains a zero, you can walk to cell i+1.

If cell i+leap contains a zero, you can jump to cell i+leap.

If you’re standing in cell n-1 or the value of i+leap >= n, you can walk or jump off the end of the array and win the game.

In other words, you can move from index i to index i+1, i-1, or i+leap as long as the destination index is a cell containing a 0. If the destination index is greater than n-1, you win the game.

Given leap and game, complete the function in the editor below so that it returns true if you can win the game (or false if you cannot).

Continue reading “Hackerrank Solution: 1D Array – Part 2 using Kotlin”

Hackerrank Solution: 1D Array – Part 2 using Kotlin was last modified: June 10th, 2018 by Soumitra Roy Sarkar

Starting Mule Apps from Main Class in Eclipse

This tutorial will show you an example on starting mule apps from main class. You can use any IDE for building your mule apps. Here we will see how to build and start mule apps in Eclipse. You can also use Mule or Anypoint Studio to build your mule apps.

In our previous tutorial we have seen an example on building mule apps with Gradle in Eclipse. Here we will use the previous tutorial to show example on starting mule apps from main class. So basically if you don’t have Anypoint or Mule studio then also you can build your mule apps outside Mule or Anypoint studio.

Continue reading “Starting Mule Apps from Main Class in Eclipse”

Starting Mule Apps from Main Class in Eclipse was last modified: June 7th, 2018 by Soumitra Roy Sarkar

Building Mule Apps with Gradle in Eclipse

Building Mule Apps with Gradle in Eclipse, i.e., you are going to create Mule project outside Mule Studio. We will build the Mule project in Eclipse using Gradle script. Gradle is becoming more and more popularity as a build system. It combines the power of scripting with the simplicity of conventions, where customization does not end up in tons of messy configurations. Over the times we have done building Mule apps through Mule Studio using Maven plugin. Here you will create build.gradle script with your own hand to build the Mule project in Eclipse.

Continue reading “Building Mule Apps with Gradle in Eclipse”

Building Mule Apps with Gradle in Eclipse was last modified: May 31st, 2018 by Soumitra Roy Sarkar

Spring Boot Internationalization Example

Spring Boot Internationalization Example will show you how to make an web based application in different languages. Internationalization or Localization will show you the web page content based on your choosen language in which you want to view the page.

I will show here how we can switch in different langugaes like Bengali, Hindi, English, Dutch and French. You don’t need to change the language settings from the browser for switching to different languages. You are given an option to choose a language in a dropdown where the langugaes are displayed in Bengali, Hindi, English, Dutch and French. If you want you can add more languages or remove languages and accordingly you need to create separate properties file for each language and put them under classpath directory.

This application shows title, welcome message, choose language option and copyright information in Bengali, Hindi, English, Dutch and French languages. By default the selected language is English.

You may also would like to read JSF 2 Internationalisation Example

Continue reading “Spring Boot Internationalization Example”

Spring Boot Internationalization Example was last modified: May 24th, 2018 by Soumitra Roy Sarkar

SOAP over HTTPS with client certificate authentication

The tutorial, SOAP over HTTPS with client certificate authentication, will show you how we can use client certificate to handshake with server along with basic authentication for consuming the service. We have also seen how to authenticate by sending authentication information over http headers in SOAP web service but here we will use client certificate (jks file) as a security mechanism. Even you can use header authentication along with client certificate to make more secure.

I will show here both server side code or service and client side code so that server expects client to establish communication through certificate authentication. Here to consume the service you will be given client certificate (extention might be .crt or .der or .p12 or anything else), password for this certificate and username/password for basic authentication (in case if you need also header authentication).

Continue reading “SOAP over HTTPS with client certificate authentication”

SOAP over HTTPS with client certificate authentication was last modified: May 17th, 2018 by Soumitra Roy Sarkar

Validate Email Address with Regular Expression using Kotlin

This tutorial will show you how to validate email address with regular expression using Kotlin. In web applications or standalone applications where we need to send emails to intended recipients, it is recommended to check the valid email address before sending email to those particular emails for safety purpose. Here we will use regular expression (regex) to validate email address using Kotlin programming language. We will also see how to create Kotlin project in Eclipse.

Please read here how to create Kotlin project in Eclipse.

Continue reading “Validate Email Address with Regular Expression using Kotlin”

Validate Email Address with Regular Expression using Kotlin was last modified: May 11th, 2018 by Soumitra Roy Sarkar

Integrate npm web app in Spring Boot with Gradle

Integrate npm web app in spring boot with gradle is basically a multi-module project as we have seen in our earlier tutorials here with maven build in spring boot and here with maven in Eclipse. But the example on integrate npm web app in spring boot with gradle uses gradle to build the project. Here we basically create two modules one is frontend or client side called web-app and another one is backend called java-app. Obviously as the name suggests web-app, so it will contain only client side technologies to build the application whereas java-app will contain only java technologies to build the application. You don’t need to install npm going to the web-app folder manually. Npm installation and build will be automatically taken care by gradle build script. This application will also create an executable jar file once gradle build is successfully finished.

Continue reading “Integrate npm web app in Spring Boot with Gradle”

Integrate npm web app in Spring Boot with Gradle was last modified: May 7th, 2018 by Soumitra Roy Sarkar

How to Remove Namespace from XML using XSLT

In this tutorial we will see how to remove namespace from XML using XSLT. As the title suggests we will use here XSLT to remove namespace from XML. Removing namespaces from an XML document is not recommended and is in essence comparable to removing namespaces from a programming framework or library. It may risk name clashes and lose the ability to differentiate between distinct elements. But if you need to absolutely remove for some reason then consider to remove namespace from XML using XSLT.

You would also like to read similar tutorial Transforming XML to HTML using XSLT

Continue reading “How to Remove Namespace from XML using XSLT”

How to Remove Namespace from XML using XSLT was last modified: May 3rd, 2018 by Soumitra Roy Sarkar

Transforming XML to HTML using XSLT

Here we will see the example on transforming XML to HTML using XSLT. We can also use Java code to transform XML to HTML but that would require a many LoC to finish the job but using XSLT it is quite easy to transform. XSLT stands for XSL Transformations. The Extensible Stylesheet Language (XSL) is a family of recommendations and styling language for defining XML document transformation and presentation. It consists of three parts:

XSL Transformations (XSLT) : a language for transforming XML;
The XML Path Language (XPath) : an expression language used by XSLT (and many other languages) to access or refer to parts of an XML document;
XSL Formatting Objects (XSL-FO) : an XML vocabulary for specifying formatting semantics.

Continue reading “Transforming XML to HTML using XSLT”

Transforming XML to HTML using XSLT was last modified: April 29th, 2018 by Soumitra Roy Sarkar