• Cryptocurrency
  • Earnings
  • Enterprise
  • About TechBooky
  • Submit Article
  • Advertise Here
  • Contact Us
TechBooky
  • African
  • AI
  • Metaverse
  • Gadgets
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
  • African
  • AI
  • Metaverse
  • Gadgets
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
TechBooky
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Home Programming

Understanding The Spring Security Architecture

Contributor by Contributor
September 23, 2019
in Programming
Share on FacebookShare on Twitter

Developed since Ben Alex and team in 2003, Spring Security is a framework that helps provide authorization and authentication to Java applications. The official release date of stable Spring Security was April 2008. With 3.9k stars and 3.3k for Github, its popularity is amply self-explanatory.

However, before you dive deep into the intricacies of Spring Security framework, you need to understand the basics of the same. Since the main job of Spring Security is to secure web applications that is what we’re going to focus on throughout this article. Also, we assume you are aware of Spring Boot before jumping to Spring Security as it provides for a default stage to work with. Nevertheless, all principles discussed herein will apply to applications not built using Spring Boot as well.

 

Runtime Environment for Spring Security

As per the existing Spring Security architecture, Java 5.0 or higher is needed to run Spring Security successfully. The great part about this is that one need not include any special files in their Java Runtime Environments. Spring is a very self-contained framework and hence you need not put the Spring Security folders in any specific classpath locations. While this sounds super cool, how does the fact that all your files will be contained in the application itself (EJB) sound? That’s right, while running an EJB container you need not conjure up special files or configuration files in a server classloader.

Copy your JAR, WAR, EAR directly from one computer to another and it will work perfectly fine, thanks to the incredible architecture of Spring Security.

 

Building Blocks of Spring Security

Spring Security is mainly built upon:

  • SecurityContextHolder, an object that uses ThreadLocal to store the security context of a process. It provides access to SecurityContext.
  • SecurityContext which holds the object Authentication. It requests for the metadata and security information of the object.
  • Authentication represents the principle requesting for access.
  • GrantedAuthority which holds information regarding what permission is granted to whom throughout the application.
  • UserDetails which holds information to build up Authentication.
  • Pass a String to it and it will make a UserDetail which will, in turn, help generate an Authentication object.

 

Authentication and Authorization

A basic application security problem is primarily about who has the access to information and what is he allowed to do with it? The latter is the authentication problem while the former refers to the authorization problem. Spring Security is a great tool to separate both these problems and tackle them efficiently. 

Authentication

Authentication has one main interface: AuthenticationManager which has just one method: authenticate. It can do three things: return a bool authentication value, throw an exception if there is an invalid value detected, as well as return a null when it encounters ambiguity.

Here’s what a standard authentication scenario looks like:

  • A login screen is displayed asking for username and password.
  • A system in place recognizes successfully if the password for the given username is correct.
  • List of roles and permissions for the user is obtained.
  • A security context is established.
  • The user proceeds towards performing tasks once validated. Then comes the role of access specifiers and the system moves on to the process of authorization.

There are a number of classes, interfaces and instances that make this happen. The main ones are UserPasswordAuthenticationToken, AuthenticationManager, Authentication, and SecurityContextHolder. SecurityContextHolder.getContext().setAuthentication(…​) is the method used for step number four.

Authorization

Sometimes, authorization is also known as access control. The ring leader here is AccessDecisionManager. The method ‘decide’ takes the object requesting access and assesses its metadata and decides whether or not a particular action can be performed by the object. 

This is how a web app authorization process looks like:

  • The user clicks on a link on the home page.
  • Request is sent to the server who realizes the user is requesting for a protected piece of information/resource.
  • The server sends back the message that you must authenticate. This means the server will probably redirect you to a webpage. If your browser authenticates you via cookies, it’s a different story.
  • The browser will send back your authentication information to the server.
  • The server will make sure that your credentials are right. If not, access will be denied.
  • Now, you will be either allowed to access the resource or will be served with a “403: Forbidden” HTTP error code.

Note: The three main classes to carry out the above steps are ExecptionTranslationFilter, AuthenticationEntryPoint, and AuthenitcationManager.

 

Closing Thoughts

Spring Security is a comprehensive framework with a solid architecture that allows you to integrate Servlet APIs. It is a great choice for Java applications. To put it simply for millennials who began their careers with Python instead of Java, Spring Security does what Django does for your Python application and more. OAuth2, OpenSSL, Let’s Encrypt, and Auth0 are other frameworks out there in the market attempting to do what Spring Security does.

Companies like Monkey Exchange, Debut, Monbanquet, AfricanStock, ZapLabs, OfferPointer, Mubasher.info, Site, Insoft and so many more make use of Spring Security in their technology Stack. And thanks to its open source status, if you’re getting started with Spring Security you have over twenty thousand answered questions on Stackoverflow waiting to assist you.

 

About author: Professionals of Java Development in India have shared this article to brief you about Understanding the Spring Security Architecture.

Related Posts:

  • google-intel-confidential-computing-more-s.max-2000×2000
    Google Cloud Reported More Than 10 Bugs On Intel’s…
  • 54864b620653bb3f721c8c73ab513568
    TikTok Launches "Security Checkup" Tool to Protect…
  • apple-and-google-featured-image
    Apple Intelligence and Google Gemini Integration Is…
  • Logo-Google-Cloud (1)
    Google To Start Distributing Secured Open-Source…
  • pci security
    How To Begin With PCI Data Security Compliance
  • 20160729063100-Cyber-security
    Important Cybersecurity Tips For SaaS Startups
  • Cloud-Security-Breaches-webinar-hero-image
    The Role Of IP Addresses In Cloud Security
  • New-lock-tech-security-303570139
    Open Source Security Needs Automation As Usage Increases

Discover more from TechBooky

Subscribe to get the latest posts sent to your email.

Tags: AuthenticationjavaprogrammingsecuritySpring SecuritySpring Security Architecturetech tips
Contributor

Contributor

Posts by contributors. You can send in a post to be reviewed and published to info@techbooky.com

BROWSE BY CATEGORIES

Select Category

    Receive top tech news directly in your inbox

    subscription from
    Loading

    Freshly Squeezed

    • Truecaller Filters Verified Business Messages May 12, 2025
    • ChatGPT Deep Research Now Links to GitHub Repos May 12, 2025
    • Microsoft Offers Guide to Fix Windows Blue Screen Errors May 12, 2025
    • We’ve Invested $10b in Nigeria so Far – MTN May 12, 2025
    • Tech Hype vs. Reality – When Big Tech Missed the Mark Pt. 3 May 11, 2025
    • Google’s Antitrust Showdown, AI vs. Search, and other Headlines May 11, 2025

    Browse Archives

    May 2025
    MTWTFSS
     1234
    567891011
    12131415161718
    19202122232425
    262728293031 
    « Apr    

    Quick Links

    • About TechBooky
    • Advertise Here
    • Contact us
    • Submit Article
    • Privacy Policy

    Recent News

    Truecaller Filters Verified Business Messages

    Truecaller Filters Verified Business Messages

    May 12, 2025
    ChatGPT Deep Research Now Links to GitHub Repos

    ChatGPT Deep Research Now Links to GitHub Repos

    May 12, 2025
    Microsoft Offers Guide to Fix Windows Blue Screen Errors

    Microsoft Offers Guide to Fix Windows Blue Screen Errors

    May 12, 2025
    The NCC Commissioned MTNN To Lease Spectrums From NTEL And Renew Its 3G Spectrum

    We’ve Invested $10b in Nigeria so Far – MTN

    May 12, 2025
    Tech Hype vs. Reality – When Big Tech Missed the Mark Pt. 1

    Tech Hype vs. Reality – When Big Tech Missed the Mark Pt. 3

    May 11, 2025
    Google’s Antitrust Showdown, AI vs. Search, and other Headlines

    Google’s Antitrust Showdown, AI vs. Search, and other Headlines

    May 11, 2025
    • Login

    © 2021 Design By Tech Booky Elite

    Generic selectors
    Exact matches only
    Search in title
    Search in content
    Post Type Selectors
    • African
    • Artificial Intelligence
    • Gadgets
    • Metaverse
    • Tips
    • About TechBooky
    • Advertise Here
    • Submit Article
    • Contact us

    © 2021 Design By Tech Booky Elite

    Discover more from TechBooky

    Subscribe now to keep reading and get access to the full archive.

    Continue reading

    We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok