tokenHttpRequest.setConnectTimeout(oidcConnectTimeout); tokenHttpRequest.setReadTimeout(oidcReadTimeout); final UserInfoResponse response = UserInfoResponse.parse(request.toHTTPRequest().send());
private OIDCProviderMetadata retrieveOidcProviderMetadata(final String discoveryUri) throws IOException, ParseException { final URL url = new URL(discoveryUri); final HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.GET, url); httpRequest.setConnectTimeout(oidcConnectTimeout); httpRequest.setReadTimeout(oidcReadTimeout); final HTTPResponse httpResponse = httpRequest.send(); if (httpResponse.getStatusCode() != 200) { throw new IOException("Unable to download OpenId Connect Provider metadata from " + url + ": Status code " + httpResponse.getStatusCode()); } final JSONObject jsonObject = httpResponse.getContentAsJSONObject(); return OIDCProviderMetadata.parse(jsonObject); }
httpRequest.setAccept(MediaType.APPLICATION_JSON_VALUE); httpRequest.setConnectTimeout(30000); httpRequest.setReadTimeout(30000); tokenResponse = com.nimbusds.oauth2.sdk.TokenResponse.parse(httpRequest.send()); } catch (ParseException | IOException ex) { OAuth2Error oauth2Error = new OAuth2Error(INVALID_TOKEN_RESPONSE_ERROR_CODE,
@Override public void applyTo(HTTPRequest httpRequest) throws SerializeException { if (httpRequest.getMethod() != HTTPRequest.Method.POST) throw new SerializeException("The HTTP request method must be POST"); ContentType ct = httpRequest.getContentType(); if (ct == null) throw new SerializeException("Missing HTTP Content-Type header"); if (!ct.match(CommonContentTypes.APPLICATION_URLENCODED)) throw new SerializeException( "The HTTP Content-Type header must be " + CommonContentTypes.APPLICATION_URLENCODED); Map<String, String> params = httpRequest.getQueryParameters(); params.putAll(toParameters()); String queryString = URLUtils.serializeParameters(params); httpRequest.setQuery(queryString); }
HTTPRequest request = new HTTPRequest(method, url); request.setContentType(sr.getContentType()); request.setHeader(headerName, sr.getHeader(headerName)); request.setQuery(sr.getQueryString()); request.setQuery(queryString); request.setQuery(body.toString());
private JWTClaimsSet fetchOidcProfile(BearerAccessToken accessToken) { final UserInfoRequest userInfoRequest = new UserInfoRequest(configuration.findProviderMetadata().getUserInfoEndpointURI(), accessToken); final HTTPRequest userInfoHttpRequest = userInfoRequest.toHTTPRequest(); try { final HTTPResponse httpResponse = userInfoHttpRequest.send(); logger.debug("Token response: status={}, content={}", httpResponse.getStatusCode(), httpResponse.getContent()); final UserInfoResponse userInfoResponse = UserInfoResponse.parse(httpResponse); if (userInfoResponse instanceof UserInfoErrorResponse) { logger.error("Bad User Info response, error={}", ((UserInfoErrorResponse) userInfoResponse).getErrorObject()); throw new AuthenticationException(); } else { final UserInfoSuccessResponse userInfoSuccessResponse = (UserInfoSuccessResponse) userInfoResponse; final JWTClaimsSet userInfoClaimsSet; if (userInfoSuccessResponse.getUserInfo() != null) { userInfoClaimsSet = userInfoSuccessResponse.getUserInfo().toJWTClaimsSet(); } else { userInfoClaimsSet = userInfoSuccessResponse.getUserInfoJWT().getJWTClaimsSet(); } return userInfoClaimsSet; } } catch (IOException | ParseException | java.text.ParseException | AuthenticationException e) { throw new TechnicalException(e); } } }
httpRequest.setAccept(MediaType.APPLICATION_JSON_VALUE); httpRequest.setConnectTimeout(30000); httpRequest.setReadTimeout(30000); tokenResponse = com.nimbusds.oauth2.sdk.TokenResponse.parse(httpRequest.send()); } catch (ParseException | IOException ex) { OAuth2Error oauth2Error = new OAuth2Error(INVALID_TOKEN_RESPONSE_ERROR_CODE,
@Override public void applyTo(HTTPRequest httpRequest) throws SerializeException { if (httpRequest.getMethod() != HTTPRequest.Method.POST) throw new SerializeException("The HTTP request method must be POST"); ContentType ct = httpRequest.getContentType(); if (ct == null) throw new SerializeException("Missing HTTP Content-Type header"); if (!ct.match(CommonContentTypes.APPLICATION_URLENCODED)) throw new SerializeException( "The HTTP Content-Type header must be " + CommonContentTypes.APPLICATION_URLENCODED); Map<String, String> params = httpRequest.getQueryParameters(); params.putAll(toParameters()); String queryString = URLUtils.serializeParameters(params); httpRequest.setQuery(queryString); }
tokenHttpRequest.setConnectTimeout(oidcConnectTimeout); tokenHttpRequest.setReadTimeout(oidcReadTimeout); final TokenResponse response = OIDCTokenResponseParser.parse(tokenHttpRequest.send());
private OIDCProviderMetadata retrieveOidcProviderMetadata(final String discoveryUri) throws IOException, ParseException { final URL url = new URL(discoveryUri); final HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.GET, url); httpRequest.setConnectTimeout(oidcConnectTimeout); httpRequest.setReadTimeout(oidcReadTimeout); final HTTPResponse httpResponse = httpRequest.send(); if (httpResponse.getStatusCode() != 200) { throw new IOException("Unable to download OpenId Connect Provider metadata from " + url + ": Status code " + httpResponse.getStatusCode()); } final JSONObject jsonObject = httpResponse.getContentAsJSONObject(); return OIDCProviderMetadata.parse(jsonObject); }
@Override public void applyTo(HTTPRequest httpRequest) throws SerializeException { if (httpRequest.getMethod() != HTTPRequest.Method.POST) throw new SerializeException("The HTTP request method must be POST"); ContentType ct = httpRequest.getContentType(); if (ct == null) throw new SerializeException("Missing HTTP Content-Type header"); if (!ct.match(CommonContentTypes.APPLICATION_URLENCODED)) throw new SerializeException( "The HTTP Content-Type header must be " + CommonContentTypes.APPLICATION_URLENCODED); Map<String, String> params = httpRequest.getQueryParameters(); params.putAll(toParameters()); String queryString = URLUtils.serializeParameters(params); httpRequest.setQuery(queryString); }
tokenHttpRequest.setConnectTimeout(oidcConnectTimeout); tokenHttpRequest.setReadTimeout(oidcReadTimeout); final UserInfoResponse response = UserInfoResponse.parse(request.toHTTPRequest().send());
tokenHttpRequest.setConnectTimeout(oidcConnectTimeout); tokenHttpRequest.setReadTimeout(oidcReadTimeout); final TokenResponse response = OIDCTokenResponseParser.parse(tokenHttpRequest.send());
this.clientAuthentication, new AuthorizationCodeGrant(code, new URI(computedCallbackUrl))); HTTPRequest tokenHttpRequest = request.toHTTPRequest(); tokenHttpRequest.setConnectTimeout(configuration.getConnectTimeout()); tokenHttpRequest.setReadTimeout(configuration.getReadTimeout()); final HTTPResponse httpResponse = tokenHttpRequest.send(); logger.debug("Token response: status={}, content={}", httpResponse.getStatusCode(), httpResponse.getContent());
(BearerAccessToken) accessToken); final HTTPRequest userInfoHttpRequest = userInfoRequest.toHTTPRequest(); userInfoHttpRequest.setConnectTimeout(configuration.getConnectTimeout()); userInfoHttpRequest.setReadTimeout(configuration.getReadTimeout()); final HTTPResponse httpResponse = userInfoHttpRequest.send(); logger.debug("Token response: status={}, content={}", httpResponse.getStatusCode(), httpResponse.getContent());