標籤:style bean error log prot UI with more security
2017-04-08 11:55:33,010 WARN [org.apache.shiro.mgt.AbstractRememberMeManager] - There was a failure while trying to retrieve remembered principals. This could be due to a configuration problem or corrupted principals. This could also be due to a recently changed encryption key, if you are using a shiro.ini file, this property would be ‘securityManager.rememberMeManager.cipherKey‘ see: http://shiro.apache.org/web.html#Web-RememberMeServices. The remembered identity will be forgotten and not used for this request. 2017-04-08 11:55:33,023 WARN [org.apache.shiro.mgt.DefaultSecurityManager] - Delegate RememberMeManager instance of type [org.apache.shiro.web.mgt.CookieRememberMeManager] threw an exception during getRememberedPrincipals(). org.apache.shiro.crypto.CryptoException: Unable to execute ‘doFinal‘ with cipher instance [[email protected]].at org.apache.shiro.crypto.JcaCipherService.crypt(JcaCipherService.java:462)at org.apache.shiro.crypto.JcaCipherService.crypt(JcaCipherService.java:445)at org.apache.shiro.crypto.JcaCipherService.decrypt(JcaCipherService.java:390)at org.apache.shiro.crypto.JcaCipherService.decrypt(JcaCipherService.java:382)at org.apache.shiro.mgt.AbstractRememberMeManager.decrypt(AbstractRememberMeManager.java:482)at org.apache.shiro.mgt.AbstractRememberMeManager.convertBytesToPrincipals(AbstractRememberMeManager.java:419)at org.apache.shiro.mgt.AbstractRememberMeManager.getRememberedPrincipals(AbstractRememberMeManager.java:386)at org.apache.shiro.mgt.DefaultSecurityManager.getRememberedIdentity(DefaultSecurityManager.java:604)at org.apache.shiro.mgt.DefaultSecurityManager.resolvePrincipals(DefaultSecurityManager.java:492)at org.apache.shiro.mgt.DefaultSecurityManager.createSubject(DefaultSecurityManager.java:342)at org.apache.shiro.subject.Subject$Builder.buildSubject(Subject.java:846)at org.apache.shiro.web.subject.WebSubject$Builder.buildWebSubject(WebSubject.java:148)at org.apache.shiro.web.servlet.AbstractShiroFilter.createSubject(AbstractShiroFilter.java:292)at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:359)at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082)at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:745)Caused by: javax.crypto.BadPaddingException: Given final block not properly paddedat com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811)at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313)at javax.crypto.Cipher.doFinal(Cipher.java:2087)at org.apache.shiro.crypto.JcaCipherService.crypt(JcaCipherService.java:459)... 33 more
解決方案:
在自訂Realm中添加
<property name="storedCredentialsHexEncoded" value="true"/>
1 <bean id="sHA1Realm" class="cn.lonecloud.realms.SHA1Realm"> 2 <!--配置密碼編譯演算法--> 3 <property name="credentialsMatcher"> 4 <!--shiro加密策略MD5--> 5 <bean class="org.apache.shiro.authc.credential.HashedCredentialsMatcher"> 6 <!--加密的策略--> 7 <property name="hashAlgorithmName" value="SHA1"/> 8 <!--加密的次數--> 9 <property name="hashIterations" value="10"/>10 <property name="storedCredentialsHexEncoded" value="true"/>11 </bean>12 </property>13 </bean>
Shiro報錯-[org.apache.shiro.mgt.AbstractRememberMeManager] - There was a failure while trying to retrieve remembered principals.