Skip to main content

Posts

Showing posts from March, 2023

Aspect Oriented Programming

AOP - Aspect Oriented Programming In enterprise applications, developers often need to implement cross-cutting concerns such as logging, auditing, security, performance monitoring, and transaction management. Embedding this logic inside every business method leads to duplicate code, poor maintainability, and increased development effort. Aspect-Oriented Programming (AOP) solves this problem by separating cross-cutting concerns from the core business logic. These concerns are implemented as Aspects , allowing centralized management without modifying the business code. Real-world Examples Application Logging Auditing Performance Monitoring Security Checks Exception Handling Transaction Management (@Transactional) AOP Architecture Client Request │ ▼ Before Advice │ ▼ Business Method │ ┌────────...

Spring 3.0 Security

Spring 3.0 FornLogin Example  This post will help us to configure the spring security for the form login.  Spring Boot Main Class  package com.alpha.spring.security ; import org.springframework.boot.SpringApplication ; import org.springframework.boot.autoconfigure. SpringBootApplication ; @SpringBootApplication public class SpringSecurityApplication { public static void main (String[] args) { SpringApplication.run(SpringSecurityApplication. class, args) ; } } Controller  @PreAuthorize( " hasAuthority( 'ROLE_USER' ) " )  This annotation will help us to do method level authorization in order to achieve this we have to add  @EnableMethodSecurity in the configuration  package com.alpha.spring.security.controller ; import java.util.Arrays ; import java.util.List ; import org.springframework.security.access.prepost.PreAuthorize ; import org.springframework.web.bind.annotation.RequestMapping ; import org.springframework.web.bind.annotation.RestCo...