use of org.apereo.cas.web.BrowserSessionStorage in project cas by apereo.
the class BrowserWebStorageSessionStoreTests method verifyOperation.
@Test
public void verifyOperation() {
val store = new BrowserWebStorageSessionStore(webflowCipherExecutor);
val request = new MockHttpServletRequest();
val ctx = new JEEContext(request, new MockHttpServletResponse());
store.set(ctx, "key1", "value1");
store.set(ctx, "key2", List.of("HelloWorld"));
store.set(ctx, "key3", 1234567);
store.set(ctx, "dummy", new Dummy());
var session = store.getTrackableSession(ctx);
assertTrue(session.isPresent());
store.renewSession(ctx);
val trackableSession = (BrowserSessionStorage) session.get();
store.buildFromTrackableSession(ctx, trackableSession.getPayload());
assertTrue(store.get(ctx, "key1").isPresent());
assertTrue(store.get(ctx, "key2").isPresent());
assertTrue(store.get(ctx, "key3").isPresent());
assertTrue(store.get(ctx, "dummy").isPresent());
}
use of org.apereo.cas.web.BrowserSessionStorage in project cas by apereo.
the class SSOSamlIdPProfileCallbackHandlerControllerWithBrowserStorageTests method verifyResumeFromStorage.
@Test
public void verifyResumeFromStorage() throws Exception {
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val authn = getAuthnRequest();
authn.setProtocolBinding(SAMLConstants.SAML2_POST_BINDING_URI);
val xml = SamlUtils.transformSamlObject(openSamlConfigBean, getAuthnRequest()).toString();
request.getSession().setAttribute(SamlProtocolConstants.PARAMETER_SAML_REQUEST, EncodingUtils.encodeBase64(xml));
request.getSession().setAttribute(SamlProtocolConstants.PARAMETER_SAML_RELAY_STATE, UUID.randomUUID().toString());
val context = new MessageContext();
context.setMessage(getAuthnRequest());
request.getSession().setAttribute(MessageContext.class.getName(), SamlIdPAuthenticationContext.from(context).encode());
request.addParameter(CasProtocolConstants.PARAMETER_TICKET, "ST-1234567890");
val payload = samlIdPDistributedSessionStore.getTrackableSession(new JEEContext(request, response)).map(BrowserSessionStorage.class::cast).map(BrowserSessionStorage::getPayload).orElseThrow();
request.addParameter(BrowserSessionStorage.KEY_SESSION_STORAGE, payload);
val mv = controller.handleCallbackProfileRequestPost(response, request);
assertNull(mv);
assertEquals(HttpStatus.SC_OK, response.getStatus());
}
Aggregations