use of org.apereo.cas.qr.authentication.QRAuthenticationTokenCredential in project cas by apereo.
the class QRAuthenticationValidateTokenActionTests method verifyOperation.
@Test
public void verifyOperation() throws Exception {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
request.addParameter(TokenConstants.PARAMETER_NAME_TOKEN, "token");
request.addParameter("deviceId", "abcdefgh987654321");
val result = qrAuthenticationValidateWebSocketChannelAction.execute(context);
assertEquals(result.getId(), CasWebflowConstants.TRANSITION_ID_FINALIZE);
assertTrue(WebUtils.getCredential(context) instanceof QRAuthenticationTokenCredential);
}
use of org.apereo.cas.qr.authentication.QRAuthenticationTokenCredential in project cas by apereo.
the class QRAuthenticationValidateTokenAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext);
val token = request.getParameter(TokenConstants.PARAMETER_NAME_TOKEN);
val deviceId = request.getParameter("deviceId");
LOGGER.debug("Received QR token [{}] with device identifier [{}]", token, deviceId);
val credential = new QRAuthenticationTokenCredential(token, deviceId);
WebUtils.putCredential(requestContext, credential);
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_FINALIZE);
}
Aggregations