Category: Spring

  • Spring Data JPA

    Spring Data JPA provides a more cleaner approach of using JPA for DAO layer. It removes boilerplate code and developers can concentrate on actual logic. Our DataModel First create a maven project and add below dependencies: [sourcecode language=”xml”] <project xmlns="http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; <modelVersion>4.0.0</modelVersion> <groupId>com.mumz.test.springdata.jpa</groupId> <artifactId>SpringDataJPA</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <spring.version>3.2.4.RELEASE</spring.version> <spring.data.version>1.3.4.RELEASE</spring.data.version> <hibernate.version>4.2.5.FINAL</hibernate.version> <jpa.version>1.0.1.FINAL</jpa.version> <querydsl.version>3.2.3</querydsl.version> <junit.version>4.8.2</junit.version> </properties>…

  • Integrating Primefaces and Spring Security

    Following all previous steps we always configured JSF and Spring. In case we use third party library like Primefaces you will have to configure resources required by Primefaces manually in Spring Security xml. Extending example at if we had Primefaces lib in our project we will have to add below configuration to jsfspring-sec-security-config.xml [sourcecode language=”xml”]…

  • Integrating Spring Security 3.1 and JSF 2.0

    Today in this tutorial we will integrate our JSF 2.0 application with Spring Security 3.1. We will be using the basic security feature of Spring Security and later on we will expand on this. What we need JDK Eclipse Spring Core Spring Security Some additional jars Project Creation Create a new “Dynamic Web Project” In…

  • Integrate LDAP and Spring Security 3.1 for Authentication and Authorization in a JSF 2.0 Application.

    Backtracking all our previous tutorial you will notice we always had our user definition with password placed in our database. Not every time this will be the case and frequently we will have to integrate our application with LDAP. In this tutorial we will integrate our earlier application with Apache Directory Services. If you don’t…

  • Secure your business layer with Spring Security Annotation

    In the last post we secured our business layer with JSR-250 annotation. Spring Security provides similar functionality. In this tutorial we will use @PreAuthorize annotation to secure our business model built earlier. First change is in our BusinessModel.java where we move from @RolesAllowed to @PreAuthorize, one reason why you would need Spring Security annotation is…

  • Audit Framework with Spring AOP and JPA

    Every now and then we come across a common requirement of building an Audit framework. In simple words it means whenever a record is added, edited or removed there should be an entry made in a separate table so that different actions of users can be monitored. Today in this tutorial we will build an…

  • Accessing method arguments using Spring AOP

    Earlier we used Spring AOP to weave common logging functionality to our BookShelf add and remove methods. But those were plain log statements, what if we want to log which Book is being added/removed. Spring AOP provides @Around advice which can be used to get this use case working. First we will enhance our Book.java…

  • Spring AOP using Annotation

    AOP a.k.a Aspect Oriented programming using Spring is a common usage now. In a nutshell it provides common functionality to be weaved into beans. Functionalities like logging before and after method is executed instead of being part of actual method implementation can be wired. Some important notes about AOP with Spring: Spring AOP is implemented…

  • Secure your business layer with JSR-250 and Spring Security in a JSF application

    In the previouspost we looked at the different option that we have as part of Java EE and Spring security framework. In this tutorial we will see how we can leverage JSR-250 security annotation. To being with you need the source code from previous post. With some code behind us, let’s see how JSR-250 can…

  • Business Layer Security with Java EE and Spring

    If you have read previous tutorial about Spring Security and JSF you would have noticed that all this time we have been speaking about securing our web layer. What about business layer ? In this post we will go through few ways of securing our business layer, and then in subsequent post we will see…