How apache/shiro works
Apache Shiro is a Java security framework. An application obtains a Subject, which represents its current user context; authentication establishes identity, authorization checks access, and sessions can retain subject state between interactions. Realms provide account and authorization data, with implementations for sources such as JDBC, LDAP, and text configuration. The repository also provides standalone hashing and cipher services, plus INI-based configuration. The graph reflects these documented product areas and the available source excerpts; most runtime wiring beyond the sampled session, hashing, cipher, and configuration code is inferred from Shiro’s documented responsibilities and is not shown as detailed internal calls.
Main entry points: Subject.java Subject context · DefaultSessionManager.java Session manager · IniSecurityManagerFactory.java INI factory · DefaultSecurityManager.java Security manager
Components 21
Subject API
- Subject context
core/src/main/java/org/apache/shiro/subject/Subject.java - Security utilities
core/src/main/java/org/apache/shiro/SecurityUtils.java
Identity and Access
- Security manager
core/src/main/java/org/apache/shiro/mgt/DefaultSecurityManager.java - Authentication
core/src/main/java/org/apache/shiro/authc/pam/ModularRealmAuthenticator.java - Auth tokens
core/src/main/java/org/apache/shiro/authc/AuthenticationToken.java - Realm providers
core/src/main/java/org/apache/shiro/realm/Realm.java - Authorization
core/src/main/java/org/apache/shiro/authz/ModularRealmAuthorizer.java - Permissions
core/src/main/java/org/apache/shiro/authz/permission/WildcardPermission.java - Method protection
core/src/main/java/org/apache/shiro/authz/aop/AnnotationsAuthorizingMethodInterceptor.java
Session Management
- Session manager
core/src/main/java/org/apache/shiro/session/mgt/DefaultSessionManager.java - Storage policy
core/src/main/java/org/apache/shiro/mgt/DefaultSessionStorageEvaluator.java - Session storage
core/src/main/java/org/apache/shiro/session/mgt/eis/SessionDAO.java - Cache
cache/src/main/java/org/apache/shiro/cache/Cache.java
Cryptography
- Hash service
crypto/hash/src/main/java/org/apache/shiro/crypto/hash/DefaultHashService.java - Hash algorithms
crypto/hash/src/main/java/org/apache/shiro/crypto/hash/HashProvider.java - Cipher service
crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/JcaCipherService.java
Configuration
- INI factory
core/src/main/java/org/apache/shiro/ini/IniSecurityManagerFactory.java - Object builder
config/ogdl/src/main/java/org/apache/shiro/config/ogdl/ReflectionBuilder.java - INI configuration
config/core/src/main/java/org/apache/shiro/config/Ini.java
Other components
- Application
- Identity source
Connections 22
- Application → Security utilities: obtains context
- Security utilities → Subject context: returns subject
- Subject context → Security manager: delegates security
- Subject context → Auth tokens: submits credentials
- Security manager → Authentication: delegates authentication
- Authentication → Realm providers: consults realms
- Realm providers → Identity source: reads identity data
- Security manager → Authorization: delegates access checks
- Authorization → Realm providers: consults authorization data
- Authorization → Permissions: evaluates permissions
- Method protection → Subject context: checks subject access
- Subject context → Session manager: requests session
- Session manager → Storage policy: checks storage policy
- Session manager → Session storage: stores sessions
- Session manager → Cache: may cache sessions
- Application → Hash service: requests hash
- Hash service → Hash algorithms: selects implementation
- Application → Cipher service: requests encryption
- Application → INI factory: configures framework
- INI factory → INI configuration: reads configuration
- INI factory → Object builder: builds configured objects
- INI factory → Security manager: creates manager