Apache Shiro User Manual (I) Shiro architecture introduction, apacheshiro

Source: Internet
Author: User

Apache Shiro User Manual (I) Shiro architecture introduction, apacheshiro

1. What is Shiro?
Apache Shiro is a powerful and easy-to-use Java security framework that provides functions such as authentication, authorization, encryption, and session management:

  • Authentication-user identification, often referred to as "Logon ";
  • Authorization-access control;
  • Password Encryption-protect or hide data to prevent spying;
  • Session management-time-sensitive status of each user.

Shiro can provide comprehensive security management services for any application. Shiro is much simpler than other security frameworks.

II. Introduction to Shiro Architecture
First, let's take a look at Shiro's three core components: Subject, SecurityManager, and Realms. For example:
 
Subject: "current user ". However, in Shiro, the concept of Subject is not only a person, but also a third-party process, a background Account, or other similar things. It only means "What is currently interacting with the software ". But considering most of the purposes and purposes, you can think of it as the "user" concept of Shiro.
Subject represents the security operations of the current user, and SecurityManager manages the security operations of all users.

SecurityManager: it is the core of the Shiro framework and a typical Facade mode. Shiro manages internal component instances through SecurityManager and provides various security management services.

Realm: Realm acts as a "bridge" or "connector" between Shiro and application security data ". That is to say, when performing authentication (LOGIN) and authorization (Access Control) authentication on the user, Shiro will find the user and its permission information from the Realm configured by the application.
In this sense, Realm is essentially a security-related DAO: it encapsulates the connection details of the data source and provides the relevant data to Shiro as needed. When configuring Shiro, you must specify at least one Realm for authentication and/or authorization. You can configure multiple Realm instances, but at least one is required.
Shiro has built-in Realm that can connect to a large number of secure data sources (also known as Directories), such as LDAP, relational database (JDBC), text configuration resources like INI, and attribute files. If the default Realm cannot meet your needs, you can also insert your own Realm implementation that represents the custom data source.


Shiro complete architecture diagram:

 
In addition to the Subject, SecurityManager, and Realm core components mentioned above, the main Shiro components also include:
Authenticator: authentication is the process of verifying the user's identity. A common example of this process is the "user/password" combination that everyone is familiar. Most users generally provide their usernames (clients) and their supported passwords (certificates) when logging on to the software system ). If the password (or password representation) stored in the system matches the password provided by the user, they are considered certified.
Authorizer: authorization is essentially Access Control-controls the content that a user can access an application, such as resources and Web pages.
SessionManager: In the security framework field, Apache Shiro provides something unique: Session APIs can be used consistently at any application or architecture layer. That is, Shiro provides a session programming paradigm for any application-from small background independent applications to large cluster Web applications. This means that application developers who want to use sessions do not have to be forced to use Servlet or EJB containers. Alternatively, if you are using these containers, you can also choose to use consistent session APIs at any layer to replace the Servlet or EJB mechanism.
CacheManager: Provides cache support for other Shiro components.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.