使用加密数据的Apache Shiro身份验证

时间:2018-12-13 10:02:22

标签: shiro

我可以通过传递用户名和密码来使用Apache Shiro对用户进行身份验证。但是,如果我已经传递了加密数据,那么我将如何实现呢? 我尝试了以下方法:

 public static void main(String[] args) {

    Factory<SecurityManager> factory = new IniSecurityManagerFactory("classpath:shiro.ini");
    SecurityManager securityManager = factory.getInstance();

    SecurityUtils.setSecurityManager(securityManager);

    JcaCipherService jcaCipherService =new DefaultBlockCipherService("RSA") ;
    jcaCipherService.decrypt("UOK4yfsmoavRDq+5NiYuMh2s2KC9GBzUCra4MGIx+7ERbdb0IRGsQZxDza7kir/OAupq18Vzm8cZzaHoKeC/TA==".getBytes(), "MIIBVwIBADANBgkqhk".getBytes());

但这是否给我以下错误:

Exception in thread "main" org.apache.shiro.crypto.CryptoException: Unable to acquire a Java JCA Cipher instance using javax.crypto.Cipher.getInstance( "RSA/CBC/PKCS5Padding" ). RSA under this configuration is required for the org.apache.shiro.crypto.DefaultBlockCipherService instance to function.
at org.apache.shiro.crypto.JcaCipherService.newCipherInstance(JcaCipherService.java:414)
at org.apache.shiro.crypto.JcaCipherService.initNewCipher(JcaCipherService.java:591)
at org.apache.shiro.crypto.JcaCipherService.crypt(JcaCipherService.java:444)
at org.apache.shiro.crypto.JcaCipherService.decrypt(JcaCipherService.java:390)
at org.apache.shiro.crypto.JcaCipherService.decrypt(JcaCipherService.java:382)
at com.thbs.esb.authenticate.Authenticate.main(Authenticate.java:24)   


Caused by: java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/CBC/PKCS5Padding
at javax.crypto.Cipher.getInstance(Cipher.java:539)
at org.apache.shiro.crypto.JcaCipherService.newCipherInstance(JcaCipherService.java:408)
... 5 more

0 个答案:

没有答案