In this post under Lombok, I will explain with example the purpose of “@Getter(lazy=true)” annotation. In many cases, the values of Pojo class instance variables are fixed. In some cases, these values have to be computed at runtime. We can add a getter method which when called first time, will compute the value once and…… Continue reading Using @Getter(lazy=true) example
Author: sumanthprabhakar
Changing scopes to @Component annotated class
In this post under Spring Core, I will show with example how to change the scope of class annotated with “@Component” annotation. By default whenever we annotate a class with “@Component” annotation the scope of the bean is set to “singleton”. We can change this by the help of “@Scope” annotation which is also applied…… Continue reading Changing scopes to @Component annotated class
Generating an TOTP
In this post I will show with example how to generate TOTP. TOTP is based on HOTP but instead of using counter, TOTP uses the current time as the counter in addition to secret key So TOTP = HOTP(secret key, current time). Similar to HOTP in client server scenario both client and server has to…… Continue reading Generating an TOTP
Changing the hotp length
Under OTP, I showed with example how to generate an hotp. By default the length of the hotp generated will be 6. We can change that to any number between 6 and 8. In this post under OTP, I will show with example how to change hotp length to 8. Below is the complete main…… Continue reading Changing the hotp length
Verifying the HOTP
In this post, I will show with example how to verify HOTP. In my previous posts, under OTP I showed with example how to generate HOTP. To verify an HOTP we can use non-static overloaded “verify” methods in “HOTP” class. Below is the complete code for your reference. Main Class 1 package defaultPackage;2 3 import…… Continue reading Verifying the HOTP
Changing the algorithm when generating hotp
In previous post, I showed with example how to generate an HOTP. I also mentioned in my previous post, how the framework by default using SHA-1 algorithm to generate the otp. I this post under OTP, I will show with example how to change the default algorithm. Below is the code for your reference. Main…… Continue reading Changing the algorithm when generating hotp
Generating HOTP example
In this post I will show with example how to generate HOTP. I will be using open source otp framework written by “BastiaanJansen” using Java programming language. Below is the link to the GitHub project https://github.com/BastiaanJansen/otp-java HOTP is generated using two input parameters1) a secret2) a counter Below is the main method that shows how…… Continue reading Generating HOTP example
Configuring StatisticsListener (using interceptor)
In this post under Spring Retry, I will show with example how to configure StatisticsListener using interceptor. Below is the complete xml code which shows how to configure StatisticsListener using interceptor. XML Code 1 <?xml version=”1.0″ encoding=”UTF-8″?>2 <beans xmlns=”http://www.springframework.org/schema/beans”3 xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”4 xmlns:aop = “http://www.springframework.org/schema/aop”5 xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd6 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd”>7 <aop:config>8 <aop:pointcut id=”transactional” expression=”execution(* defaultPackage.Service1.executeWithException(..))”/>9 <aop:advisor pointcut-ref=”transactional” advice-ref=”retryAdvice”/>10…… Continue reading Configuring StatisticsListener (using interceptor)
ignoreIfMissing method example
In this post under DotEnv I will show with example what is the purpose of “ignoreIfMissing” method with an example. In my previous posts I showed with example how to load environment files whether it is “.env” file or custom env file like “custom-file.env”. The default behavior of DotEnv framework is that if the environment…… Continue reading ignoreIfMissing method example
Wiring together @Bean annotated beans using setter approach
In this post under Spring Core, I will explain with example how to wire two beans annotated with @Bean annotation using setter methods. For our example lets take the below two classes. Bean1 package package12; public class Bean1 { private Bean2 bean2; public Bean1() { } public void setBean2(Bean2 bean2) { this.bean2 = bean2; }…… Continue reading Wiring together @Bean annotated beans using setter approach