@Test public void testApplyOAuthParameters() throws Exception { OAuthParametersApplier app = new FragmentParametersApplier(); Map<String, Object> params = new HashMap<String, Object>(); params.put(OAuth.OAUTH_EXPIRES_IN, 3600l); params.put(OAuth.OAUTH_ACCESS_TOKEN, "token_authz"); params.put(OAuth.OAUTH_CODE, "code_"); params.put(OAuth.OAUTH_SCOPE, "read"); params.put(OAuth.OAUTH_STATE, "state"); params.put(OAuth.OAUTH_REFRESH_TOKEN, "token_refresh"); params.put("empty_param", ""); params.put("null_param", null); OAuthMessage message = new DummyOAuthMessage("http: app.applyOAuthParameters(message, params); String locationURI = message.getLocationUri(); Assert.assertTrue(locationURI.contains("3600")); Assert.assertTrue(locationURI.contains("token_authz")); Assert.assertTrue(locationURI.contains("code_")); Assert.assertTrue(locationURI.contains("read")); Assert.assertTrue(locationURI.contains("state")); Assert.assertFalse(locationURI.contains("token_refresh")); Assert.assertFalse(locationURI.contains("empty_param")); Assert.assertFalse(locationURI.contains("null_param")); }
public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params) throws OAuthSystemException { String messageUrl = message.getLocationUri(); if (messageUrl != null) { StringBuilder url = new StringBuilder(messageUrl); if (params.containsKey(OAuth.OAUTH_REFRESH_TOKEN)) { params.remove(OAuth.OAUTH_REFRESH_TOKEN); } String fragmentQuery = OAuthUtils.format(params.entrySet(), "UTF-8"); if (!OAuthUtils.isEmpty(fragmentQuery)) { if (params.size() > 0) { url.append("#").append(fragmentQuery); } } message.setLocationUri(url.toString()); } return message; }
FragmentParametersApplier implements OAuthParametersApplier { public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params) throws OAuthSystemException { String messageUrl = message.getLocationUri(); if (messageUrl != null) { StringBuilder url = new StringBuilder(messageUrl); if (params.containsKey(OAuth.OAUTH_REFRESH_TOKEN)) { params.remove(OAuth.OAUTH_REFRESH_TOKEN); } String fragmentQuery = OAuthUtils.format(params.entrySet(), "UTF-8"); if (!OAuthUtils.isEmpty(fragmentQuery)) { if (params.size() > 0) { url.append("#").append(fragmentQuery); } } message.setLocationUri(url.toString()); } return message; } }
FragmentParametersApplier implements OAuthParametersApplier { public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params) throws OAuthSystemException { String messageUrl = message.getLocationUri(); if (messageUrl != null) { StringBuilder url = new StringBuilder(messageUrl); if (params.containsKey(OAuth.OAUTH_REFRESH_TOKEN)) { params.remove(OAuth.OAUTH_REFRESH_TOKEN); } String fragmentQuery = OAuthUtils.format(params.entrySet(), "UTF-8"); if (!OAuthUtils.isEmpty(fragmentQuery)) { if (params.size() > 0) { url.append("#").append(fragmentQuery); } } message.setLocationUri(url.toString()); } return message; }  }
FragmentParametersApplier implements OAuthParametersApplier { public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params) throws OAuthSystemException { String messageUrl = message.getLocationUri(); if (messageUrl != null) { StringBuilder url = new StringBuilder(messageUrl); if (params.containsKey(OAuth.OAUTH_REFRESH_TOKEN)) { params.remove(OAuth.OAUTH_REFRESH_TOKEN); } String fragmentQuery = OAuthUtils.format(params.entrySet(), "UTF-8"); if (!OAuthUtils.isEmpty(fragmentQuery)) { if (params.size() > 0) { url.append("#").append(fragmentQuery); } } message.setLocationUri(url.toString()); } return message; }  OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params); }
FragmentParametersApplier implements OAuthParametersApplier { public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params) throws OAuthSystemException { String messageUrl = message.getLocationUri(); if (messageUrl != null) { StringBuilder url = new StringBuilder(messageUrl); if (params.containsKey(OAuth.OAUTH_REFRESH_TOKEN)) { params.remove(OAuth.OAUTH_REFRESH_TOKEN); } String fragmentQuery = OAuthUtils.format(params.entrySet(), "UTF-8"); if (!OAuthUtils.isEmpty(fragmentQuery)) { if (params.size() > 0) { url.append("#").append(fragmentQuery); } } message.setLocationUri(url.toString()); } return message; }  OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params);  }