Table Of Contents

Previous topic

6. Security for TERASOLUNA Global Framework

Next topic

6.2. [coming soon] Spring Security Tutorial

This Page

6.1. Spring Security Overview


This version is already obsolete. Please check the latest guideline.

6.1.1. Overview

Two main functionalities namely, “Authentication” and “Authorization” are provided by Spring Security
for the security of applications.
Authentication functionality identifies a user and thus prevents unauthorized access through spoofing.
Authorization functionality controls the access to system resources
according to the authority of the authenticated (logged-in) user.
Spring Security overview is shown in diagram below.
Spring Security Overview

Picture - Spring Security Overview

Spring Security implements authorization and authentication processes
with help of a group of ServletFilters that interact across several levels.
Further, it also provides password hashing functionality, JSP authorized tag library etc. Authentication

Authentication is the action that checks validity of a request. When connecting to the network or server,
through combination of user name and password, it further verifies whether the user has the required authority and
also whether the person to be authenticated is really the user himself.
For the details on how to use authentication in Spring Security, refer to [coming soon] Authentication. Password hashing

In password hashing, the original password is replaced with a hash value that is derived from the plaintext password using hash function.
For the details on how to use it in Spring Security, refer Password Hashing. Authorization

Authorization is the functionality to verify whether the authenticated user is allowed to use the resource that he is trying to access,
using access control process.
For the details on how to use authorization in Spring Security, refer to Authorization.

6.1.2. How to use

Following settings need to be defined for using Spring Security. pom.xml settings

To use Spring Security, following dependency needs to be added to pom.xml.
    <artifactId>terasoluna-gfw-security-core</artifactId>  <!-- (1) -->

    <artifactId>terasoluna-gfw-security-web</artifactId>  <!-- (2) -->
Sr. No. Description
terasoluna-gfw-security-core is not web dependent. As a result, when using from a domain layer project,
only terasoluna-gfw-security-core should be added to dependency.
terasoluna-gfw-web provides web related functionalities. It is dependent on terasoluna-gfw-security-core as well. Hence,
for Web projects, only terasoluna-gfw-security-web should be added to dependency. Web.xml settings

   <param-value>  <!-- (1) -->
   <filter-name>springSecurityFilterChain</filter-name>  <!-- (2) -->
   <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>  <!-- (3) -->
   <url-pattern>/*</url-pattern>  <!-- (4) -->
Sr. No. Description
In addition to applicationContext.xml, add the Spring Security configuration file to
the class path in contextConfigLocation. In this guideline, it is “spring-security.xml” file.
filter-name should be defined as the Bean name to be used internally in Spring Security, namely, “springSecurityFilterChain”.
Spring Security filter settings to enable various functionalities.
Enable the settings for all requests. spring-security.xml settings

spring-security.xml is placed under the path specified in web.xml.
Normally, it is set in src/main/resources/META-INF/spring/spring-security.xml.
Please refer subsequent chapters for detailed explanation, as the following example is just a template.
  • spring-mvc.xml

    <beans xmlns=""
        <sec:http  use-expressions="true">  <!-- (1) -->
        <!-- omitted -->

    Sr. No.


    Spring EL expressions of access attribute can be enabled by setting use-expressions=”true”.


    For the Spring EL expressions enabled by use-expressions=”true”, please refer the following.

    Expression-Based Access Control