use of org.springframework.util.LinkedMultiValueMap in project spring-security-oauth by spring-projects.
the class AbstractRefreshTokenSupportTests method refreshAccessToken.
private OAuth2AccessToken refreshAccessToken(String refreshToken) {
MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>();
formData.add("grant_type", "refresh_token");
formData.add("client_id", "my-trusted-client");
formData.add("refresh_token", refreshToken);
formData.add("scope", "read");
HttpHeaders headers = getTokenHeaders("my-trusted-client");
@SuppressWarnings("rawtypes") ResponseEntity<Map> response = http.postForMap(tokenPath(), headers, formData);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertTrue("Wrong cache control: " + response.getHeaders().getFirst("Cache-Control"), response.getHeaders().getFirst("Cache-Control").contains("no-store"));
@SuppressWarnings("unchecked") OAuth2AccessToken newAccessToken = DefaultOAuth2AccessToken.valueOf(response.getBody());
return newAccessToken;
}
use of org.springframework.util.LinkedMultiValueMap in project geode by apache.
the class ClientHttpRequest method getURL.
/**
* Gets the URL for the client's HTTP request.
* <p/>
*
* @param uriVariables a Map of URI path variables to values in order to expand the URI template
* into a URI.
* @return a URL as a URI referring to the location of the resource requested by the client via
* HTTP.
* @see #getURI()
* @see java.net.URI
* @see org.springframework.web.util.UriComponents
* @see org.springframework.web.util.UriComponentsBuilder
*/
public URI getURL(final Map<String, ?> uriVariables) {
final UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString(UriUtils.decode(getURI().toString()));
if (isGet() || isDelete()) {
final List<String> pathVariables = getPathVariables();
// get query parameters to append to the URI/URL based on the request parameters that are not
// path variables...
final Map<String, List<Object>> queryParameters = CollectionUtils.removeKeys(new LinkedMultiValueMap<String, Object>(getParameters()), new Filter<Map.Entry<String, List<Object>>>() {
@Override
public boolean accept(final Map.Entry<String, List<Object>> entry) {
// so that it won't interfere with the expand() call afterwards
if (entry.getKey().contains(CLIMultiStepHelper.STEP_ARGS)) {
List<Object> stepArgsList = entry.getValue();
if (stepArgsList != null) {
String stepArgs = (String) stepArgsList.remove(0);
stepArgsList.add(UriUtils.encode(stepArgs));
}
}
return !pathVariables.contains(entry.getKey());
}
});
for (final String queryParameterName : queryParameters.keySet()) {
uriBuilder.queryParam(queryParameterName, getParameters().get(queryParameterName).toArray());
}
}
return uriBuilder.build().expand(UriUtils.encode(new HashMap<String, Object>(uriVariables))).encode().toUri();
}
use of org.springframework.util.LinkedMultiValueMap in project geode by apache.
the class ClientHttpRequestJUnitTest method testCreateRequestEntityForPost.
@Test
@SuppressWarnings("unchecked")
public void testCreateRequestEntityForPost() throws Exception {
final Link expectedLink = new Link("post", toUri("http://host.domain.com:8080/app/libraries/{name}/books"), HttpMethod.POST);
final ClientHttpRequest request = new ClientHttpRequest(expectedLink);
assertEquals(expectedLink, request.getLink());
final MultiValueMap<String, Object> expectedRequestParameters = new LinkedMultiValueMap<String, Object>(4);
expectedRequestParameters.add("author", "Douglas Adams");
expectedRequestParameters.add("title", "The Hitchhiker's Guide to the Galaxy");
expectedRequestParameters.add("year", "1979");
expectedRequestParameters.add("isbn", "0345453743");
request.addHeaderValues(HttpHeader.CONTENT_TYPE.getName(), MediaType.APPLICATION_FORM_URLENCODED_VALUE);
request.addParameterValues("author", expectedRequestParameters.getFirst("author"));
request.addParameterValues("title", expectedRequestParameters.getFirst("title"));
request.addParameterValues("year", expectedRequestParameters.getFirst("year"));
request.addParameterValues("isbn", expectedRequestParameters.getFirst("isbn"));
final HttpEntity<MultiValueMap<String, Object>> requestEntity = (HttpEntity<MultiValueMap<String, Object>>) request.createRequestEntity();
assertNotNull(requestEntity);
assertNotNull(requestEntity.getHeaders());
assertEquals(MediaType.APPLICATION_FORM_URLENCODED, requestEntity.getHeaders().getContentType());
assertEquals(expectedRequestParameters, requestEntity.getBody());
}
use of org.springframework.util.LinkedMultiValueMap in project cas by apereo.
the class GoogleAuthenticatorRestHttpRequestCredentialFactoryTests method verifyCredentials.
@Test
public void verifyCredentials() {
final GoogleAuthenticatorRestHttpRequestCredentialFactory f = new GoogleAuthenticatorRestHttpRequestCredentialFactory();
final LinkedMultiValueMap body = new LinkedMultiValueMap<>();
body.add(GoogleAuthenticatorRestHttpRequestCredentialFactory.PARAMETER_NAME_GAUTH_OTP, "132456");
final List<Credential> results = f.fromRequestBody(body);
assertFalse(results.isEmpty());
assertEquals("132456", results.get(0).getId());
}
use of org.springframework.util.LinkedMultiValueMap in project gocd by gocd.
the class AgentInstances method allElasticAgentsGroupedByPluginId.
public LinkedMultiValueMap<String, ElasticAgentMetadata> allElasticAgentsGroupedByPluginId() {
LinkedMultiValueMap<String, ElasticAgentMetadata> map = new LinkedMultiValueMap<>();
for (Map.Entry<String, AgentInstance> entry : agentInstances.entrySet()) {
AgentInstance agentInstance = entry.getValue();
if (agentInstance.isElastic()) {
ElasticAgentMetadata metadata = agentInstance.elasticAgentMetadata();
map.add(metadata.elasticPluginId(), metadata);
}
}
return map;
}
Aggregations