@Test public void oAuthAuthorizerWithAccessTokenSecretHttpUrlConnection() { String accessToken = "TestAccessToken"; Config.setProperty(Config.HTTP_TRANSPORT, HTTPURLConnectionInterceptor.HTTP_URL_CONNECTION); try { URL url = new URL(URL_STRING); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); OAuth2Authorizer oauthAuthorizer = new OAuth2Authorizer(accessToken); oauthAuthorizer.authorize(conn); } catch (Exception e) { log.debug(e.getMessage()); Assert.fail("Exception should not happen"); } }
@Override public void authorize(HttpRequestBase httpRequest) throws FMSException { httpRequest.setHeader("Authorization", "Bearer " + accessToken); }
OAuth2Authorizer implements IAuthorizer { @Override public void authorize(HttpRequestBase httpRequest) throws FMSException { httpRequest.setHeader("Authorization", "Bearer " + accessToken); } }
OAuth2Authorizer implements IAuthorizer { @Override public void authorize(HttpRequestBase httpRequest) throws FMSException { httpRequest.setHeader("Authorization", "Bearer " + accessToken); } OAuth2Authorizer(String accessToken); }
OAuth2Authorizer implements IAuthorizer { @Override public void authorize(HttpRequestBase httpRequest) throws FMSException { httpRequest.setHeader("Authorization", "Bearer " + accessToken); } OAuth2Authorizer(String accessToken); @Override void authorize(HttpRequestBase httpRequest); @Override void authorize(HttpURLConnection httpUrlConnection); String getAccessToken(); void setAccessToken(String accessToken); }
OAuth2Authorizer implements IAuthorizer { @Override public void authorize(HttpRequestBase httpRequest) throws FMSException { httpRequest.setHeader("Authorization", "Bearer " + accessToken); } OAuth2Authorizer(String accessToken); @Override void authorize(HttpRequestBase httpRequest); @Override void authorize(HttpURLConnection httpUrlConnection); String getAccessToken(); void setAccessToken(String accessToken);  }