Spring Security Web Failure Handler Using Super Class SimpleUrlAuthenticationFailureHandler

Custom Spring Security Web failure handler..

/**
 * @author Wasim Ansari
 *
 */

    <!-- custom form security developed using spring -->
    <security:http auto-config="true" use-expressions="true" >
    <!-- When we working on ip address validation through role at that time you can use hasIpAddress validation with access security interceptor -->
<!-- <security:intercept-url pattern="/successurl/**" access="hasAnyRole('ROLE_ADMIN', 'ROLE_USER') and hasIpAddress('127.0.0.1')" /> -->

<security:intercept-url pattern="/successurl/**" access="hasAnyRole('ROLE_ADMIN', 'ROLE_USER')" />

<security:form-login login-page="/login" always-use-default-target="true"
    authentication-success-handler-ref="customAuthSuccessHandler" authentication-failure-handler-ref="customAuthFailureHandler" />

<security:session-management invalid-session-url="/loginfailed" >
    <!-- <security:concurrency-control expired-url="/loginfailed" max-sessions="1" error-if-maximum-exceeded="true"  /> -->
    <security:concurrency-control expired-url="/loginfailed"  />
</security:session-management>

<security:logout invalidate-session="true" success-handler-ref="customLogoutSuccessHandler" delete-cookies="JSESSIONID"  />
<!-- by default , on back click link session will be destroyed.. -->
<!-- <security:logout invalidate-session="true" success-handler-ref="customLogoutSuccessHandler" delete-cookies="JSESSIONID"  /> -->
</security:http>

Spring security - Bean dependencies .


Server Side Pagination Using Spring

Controller class -
List<UserInfo> loadUserInfoDetails = service.getAllUserInfoDetails();
    if(loadUserInfoDetails.size() > CommonUtils.PAGE_MAX_VALUE) {
    int pageNumberRequest = 0;
    if( !request.getParameter("page").isEmpty() ) {
    pageNumberRequest = Integer.parseInt(request.getParameter("page"));
    }
    commonPaginationService.makePaginationLogic(CommonUtils.PAGE_MIN_VALUE, CommonUtils.PAGE_MAX_VALUE, loadUserInfoDetails, mav, pageNumberRequest);
    }
    mav.setViewName("admin/welcome");


Custom Security Via Hashing Password, Use Express For Roles & Handle Browser Cashe.

Servlet configuration To Manage MVC architecture.

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:int-security="http://www.springframework.org/schema/integration/security"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:security="http://www.springframework.org/schema/security"
    xmlns:jms="http://www.springframework.org/schema/jms" xmlns:amq="http://activemq.apache.org/schema/core"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/integration/security http://www.springframework.org/schema/integration/security/spring-integration-security-2.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
        http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
        http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">