use of org.apache.shiro.crypto.CryptoException in project shiro by apache.
the class CookieRememberMeManagerTest method getRememberedPrincipalsDecryptionError.
// SHIRO-69
@Test
public void getRememberedPrincipalsDecryptionError() {
HttpServletRequest mockRequest = createNiceMock(HttpServletRequest.class);
HttpServletResponse mockResponse = createNiceMock(HttpServletResponse.class);
WebSubjectContext context = new DefaultWebSubjectContext();
context.setServletRequest(mockRequest);
context.setServletResponse(mockResponse);
expect(mockRequest.getAttribute(ShiroHttpServletRequest.IDENTITY_REMOVED_KEY)).andReturn(null);
// Simulate a bad return value here (for example if this was encrypted with a different key
final String userPCAesBase64 = "garbage";
Cookie[] cookies = new Cookie[] { new Cookie(CookieRememberMeManager.DEFAULT_REMEMBER_ME_COOKIE_NAME, userPCAesBase64) };
expect(mockRequest.getCookies()).andReturn(cookies).anyTimes();
replay(mockRequest);
CookieRememberMeManager mgr = new CookieRememberMeManager();
try {
mgr.getRememberedPrincipals(context);
} catch (CryptoException expected) {
return;
}
fail("CryptoException was expected to be thrown");
}
Aggregations