use of com.okta.authn.sdk.http.RequestContext in project okta-auth-java by okta.
the class ReadmeSnippets method headersAndQuery.
private void headersAndQuery() {
List<Header> headers = new ArrayList<>();
// set any header
headers.add(new Header("aHeaderName", "aValue"));
// X-Forwarded-For
headers.add(Header.xForwardedFor("10.10.0.1"));
// X-Device-Fingerprint
headers.add(Header.xDeviceFingerprint("your-finger-print"));
List<QueryParameter> queryParameters = new ArrayList<>();
// set query param
queryParameters.add(new QueryParameter("aQueryParam", "aValue"));
RequestContext requestContext = new RequestContext(headers, queryParameters);
}
use of com.okta.authn.sdk.http.RequestContext in project okta-auth-java by okta.
the class EmailAuthenticationController method handlePost.
@RequestMapping(value = "/verify-email-authenticator", method = RequestMethod.POST)
public ModelAndView handlePost(@RequestParam(value = "passcode") final String passcode, @RequestParam(value = "factorId") final String factorId, @RequestParam(value = "stateToken") final String stateToken) {
final ModelAndView modelAndView = new ModelAndView("home");
final AuthenticationResponse authenticationResponse;
try {
final VerifyPassCodeFactorRequest verifyPassCodeFactorRequest = authenticationClient.instantiate(VerifyPassCodeFactorRequest.class);
verifyPassCodeFactorRequest.setStateToken(stateToken);
verifyPassCodeFactorRequest.setPassCode(passcode);
RequestContext requestContext = new RequestContext();
// false by default
requestContext.addQuery("rememberDevice", "true");
authenticationResponse = authenticationClient.verifyFactor(factorId, verifyPassCodeFactorRequest, requestContext, ignoringStateHandler);
} catch (final AuthenticationException e) {
logger.error("Verify Email Factor Error - Status: {}, Code: {}, Message: {}", e.getStatus(), e.getCode(), e.getMessage());
final ModelAndView errorView = new ModelAndView();
errorView.addObject("error", e.getStatus() + ":" + e.getCode() + ":" + e.getMessage());
return errorView;
}
modelAndView.addObject("authenticationResponse", authenticationResponse);
return modelAndView;
}
Aggregations