Shiro安全框架:加密与散列策略详解

需积分: 5 1 下载量 16 浏览量 更新于2024-09-05 收藏 41KB DOCX 举报
"本文档详细介绍了Apache Shiro安全框架中的加密技术,强调了加密数据的重要性,特别是对于密码存储。Shiro提供了多种加密和编码方法,包括Base64、16进制、散列(如MD5和SHA)以及AES加密。文档提到了使用盐(salt)增强散列安全性,防止密码被轻易破解。此外,还提到了AES加密标准的广泛应用。" Apache Shiro是一个强大且易用的Java安全框架,它提供了身份验证、授权、会话管理和加密等功能。在Cryptography方面,Shiro为开发者提供了多种工具来处理数据的安全存储,特别是密码管理。 1. **密码加密存储**:在存储用户密码时,不应以明文形式存储,而是应该进行加密。这有助于防止数据泄露时用户信息被滥用。例如,600w CSDN账号泄露事件就突显了密码加密的重要性。 2. **编码/解码API**:Shiro提供了Base64和16进制的编码解码功能。Base64是一种将任意字节序列转化为可打印字符的方法,广泛用于在网络上传输包含二进制数据的信息。16进制则是每两个字符代表一个字节,方便人类阅读。 3. **散列算法**:散列算法如MD5和SHA,用于生成数据的摘要,这些摘要通常是不可逆的。散列密码前通常会添加一个盐值(salt),如用户名或ID,增加破解的难度。例如,散列密码"admin"加上盐后,生成的散列值更难以通过在线解密工具还原。 4. **AES加密**:高级加密标准(AES)是一种广泛应用的对称密钥加密算法,它提供了高安全性且效率较高。在Shiro中,可以使用AES对敏感数据进行加密和解密,确保数据在传输或存储过程中的安全。 5. **AesCipherService**:这是Shiro中用于AES加密操作的服务类,提供了加密和解密的接口,便于在应用中集成和使用。 在实际开发中,理解并合理运用这些加密手段可以有效地保护用户的隐私,提升系统的安全性。同时,Shiro的简单API设计使得在Java应用中实现这些安全措施变得相对容易。

SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details. Exception in thread "main" org.apache.shiro.config.ConfigurationException: Unable to instantiate class [org.apache.shiro.web.mgt.DefaultWebSecurityManager] for object named 'securityManager'. Please ensure you've specified the fully qualified class name correctly. at org.apache.shiro.config.ReflectionBuilder.createNewInstance(ReflectionBuilder.java:309) at org.apache.shiro.config.ReflectionBuilder$InstantiationStatement.doExecute(ReflectionBuilder.java:927) at org.apache.shiro.config.ReflectionBuilder$Statement.execute(ReflectionBuilder.java:887) at org.apache.shiro.config.ReflectionBuilder$BeanConfigurationProcessor.execute(ReflectionBuilder.java:765) at org.apache.shiro.config.ReflectionBuilder.buildObjects(ReflectionBuilder.java:260) at org.apache.shiro.config.IniSecurityManagerFactory.buildInstances(IniSecurityManagerFactory.java:167) at org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:130) at org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:108) at org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:94) at org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:46) at org.apache.shiro.config.IniFactorySupport.createInstance(IniFactorySupport.java:123) at org.apache.shiro.util.AbstractFactory.getInstance(AbstractFactory.java:47) at com.xiu.Quickstart.main(Quickstart.java:26) Caused by: org.apache.shiro.util.UnknownClassException: Unable to load class named [org.apache.shiro.web.mgt.DefaultWebSecurityManager] from the thread context, current, or system/application ClassLoaders. All heuristics have been exhausted. Class could not be found. at org.apache.shiro.util.ClassUtils.forName(ClassUtils.java:152) at org.apache.shiro.util.ClassUtils.newInstance(ClassUtils.java:168) at org.apache.shiro.config.ReflectionBuilder.createNewInstance(ReflectionBuilder.java:302) ... 12 more

2023-06-10 上传