Java Code Examples for org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse#getAccessToken()
The following examples show how to use
org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse#getAccessToken() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RetryingOAuth.java From openapi-generator with Apache License 2.0 | 6 votes |
public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException { if (getAccessToken() == null || getAccessToken().equals(requestAccessToken)) { try { OAuthJSONAccessTokenResponse accessTokenResponse = oAuthClient.accessToken(tokenRequestBuilder.buildBodyMessage()); if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) { setAccessToken(accessTokenResponse.getAccessToken()); return !getAccessToken().equals(requestAccessToken); } } catch (OAuthSystemException | OAuthProblemException e) { throw new IOException(e); } } return false; }
Example 2
Source File: RetryingOAuth.java From openapi-generator with Apache License 2.0 | 6 votes |
public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException { if (getAccessToken() == null || getAccessToken().equals(requestAccessToken)) { try { OAuthJSONAccessTokenResponse accessTokenResponse = oAuthClient.accessToken(tokenRequestBuilder.buildBodyMessage()); if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) { setAccessToken(accessTokenResponse.getAccessToken()); return !getAccessToken().equals(requestAccessToken); } } catch (OAuthSystemException | OAuthProblemException e) { throw new IOException(e); } } return false; }
Example 3
Source File: RetryingOAuth.java From eve-esi with Apache License 2.0 | 6 votes |
public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException { if (getAccessToken() == null || getAccessToken().equals(requestAccessToken)) { try { OAuthJSONAccessTokenResponse accessTokenResponse = oAuthClient.accessToken(tokenRequestBuilder .buildBodyMessage()); if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) { setAccessToken(accessTokenResponse.getAccessToken()); return !getAccessToken().equals(requestAccessToken); } } catch (OAuthSystemException | OAuthProblemException e) { throw new IOException(e); } } return false; }
Example 4
Source File: OAuth.java From openapi-generator with Apache License 2.0 | 5 votes |
public synchronized void updateAccessToken(RequestTemplate template) { OAuthJSONAccessTokenResponse accessTokenResponse; try { accessTokenResponse = oauthClient.accessToken(tokenRequestBuilder.buildBodyMessage()); } catch (Exception e) { throw new RetryableException(e.getMessage(), e,null); } if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) { setAccessToken(accessTokenResponse.getAccessToken(), accessTokenResponse.getExpiresIn()); if (accessTokenListener != null) { accessTokenListener.notify((BasicOAuthToken) accessTokenResponse.getOAuthToken()); } } }
Example 5
Source File: OidcAuthenticator.java From entando-components with GNU Lesser General Public License v3.0 | 5 votes |
private void fetchAndProcessToken(HttpServletRequest req, String code) throws OAuthSystemException, OAuthProblemException, ApsSystemException { OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient()); OAuthClientRequest oAuthClientRequest = this.oidcHelper.buildOauthRequest(req, code); OAuthJSONAccessTokenResponse oAuthResponse = oAuthClient.resource(oAuthClientRequest, OAuth.HttpMethod.POST, OAuthJSONAccessTokenResponse.class); _logger.info("----------------------TOKEN------------------- "); String accessToken = oAuthResponse.getAccessToken(); _logger.info("accessToken -> " + accessToken); UserDetails cdpUser = this.oidcHelper.getOidcUser(oAuthResponse.getAccessToken()); HttpSession session = req.getSession(); session.setAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER, cdpUser); }
Example 6
Source File: OAuth.java From docusign-java-client with MIT License | 5 votes |
public synchronized void updateAccessToken() { OAuthJSONAccessTokenResponse accessTokenResponse; try { accessTokenResponse = oauthClient.accessToken(tokenRequestBuilder.buildBodyMessage()); } catch (Exception e) { throw new ClientHandlerException(e.getMessage(), e); } if (accessTokenResponse != null) { // FIXME: This does not work in case of non HTTP 200 :-( oauthClient needs to return the plain HTTP resonse if (accessTokenResponse.getResponseCode() != Response.Status.OK.getStatusCode()) { throw new ClientHandlerException("Error while requesting an access token, received HTTP code: " + accessTokenResponse.getResponseCode()); } if (accessTokenResponse.getAccessToken() == null) { throw new ClientHandlerException("Error while requesting an access token. No 'access_token' found."); } if (accessTokenResponse.getExpiresIn() == null) { throw new ClientHandlerException("Error while requesting an access token. No 'expires_in' found."); } setAccessToken(accessTokenResponse.getAccessToken(), accessTokenResponse.getExpiresIn()); if (this.accessTokenListener != null) { this.accessTokenListener.notify((BasicOAuthToken)accessTokenResponse.getOAuthToken()); } } else { // in case of HTTP error codes accessTokenResponse is null, thus no check of accessTokenResponse.getResponseCode() possible :-( throw new ClientHandlerException("Error while requesting an access token. No accessTokenResponse object recieved, maybe a non HTTP 200 received?"); } }