Checking whether the password is already present in another source

In this post under Passay, I will show how to check whether the password is already used in another source. Below is the complete main class for your reference. Main class 1 package defaultPackage; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 import org.passay.PasswordData; 7 import org.passay.PasswordData.SourceReference; 8 import org.passay.PasswordValidator; 9 import org.passay.RuleResult; 10…… Continue reading Checking whether the password is already present in another source

Accessing array in SpEL

In this post under Spring SpEL, I will show how to access array elements in SpEL expressions. For our example I will use the two beans. Below is the class structure of them Bean1 class package spel.package2; import org.springframework.stereotype.Component; @Component public class Bean1 { private int[] values = new int[] {1, 2, 3, 4}; public…… Continue reading Accessing array in SpEL

SpEL Simple example

In this post under Spring SpEL, I will give a simple example that shows how to access bean properties and use literal values in SpEL expressions. SpEL (Spring Expression Language) is an expression language that supports querying and manipulating objects at runtime. This expression language is written within “${ and “}” when used inside annotation…… Continue reading SpEL Simple example

Basic Search in LDAP

In this post under Java LDAP, I will show with example how to perform a basic search for entries in LDAP. I have below ldap tree. In this ldap tree under development department with dn “ou=dev”, I have three developers “user1”, “user2”, and “user3”. “user1” has “description” attribute with value “Softwareengineer 2” whereas “user2” and…… Continue reading Basic Search in LDAP

Searching an array for a particular element

In this post under Java Collections, I will show with example how to search an array for a specific element. Please note there is a precondition that must be satisfied before searching an array. The precondition is that the array should already be sorted. Java “Arrays” class provides “binarySearch” method which does the searching. This…… Continue reading Searching an array for a particular element

Arrays to List conversion

In this post under Java Collections, I will explain with example how to convert an array to list. Please note this conversion is possible if the array is a collection of objects and not primitive elements. To achieve our goal, we use “Arrays” class static method “asList”. This method returns a list backed by the…… Continue reading Arrays to List conversion

Mapping between objects with default value

In this post under MapStruct, I will show with example how to map two objects with default value. Let me further elaborate the requirement. We have “Student” class and we have to map the instance of “Student” class to an instance of “StudentDTO” class. During mapping if the value of “className” attribute in “Student” class…… Continue reading Mapping between objects with default value

Checking whether the password is already used in your application

In this post under Passay, I will show with example how to check whether a user entered password is already used in the application or not. Below is the complete main code for your reference Main class 1 package defaultPackage; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 import org.passay.HistoryRule; 7 import org.passay.PasswordData; 8…… Continue reading Checking whether the password is already used in your application

Converting Collection to unmodifiable Set

In this post under Java, I will show with example how to convert a collection to unmodifiable set. To convert a collection to an immutable Set, we take help of “Set” interface static method “copyOf”. Below is the complete code for your reference. Main class 1 package core.collection; 2 3 import java.util.ArrayList; 4 import java.util.List;…… Continue reading Converting Collection to unmodifiable Set