List of usage examples for org.springframework.util MultiValueMap add
void add(K key, @Nullable V value);
From source file:org.springframework.security.oauth.examples.sparklr.oauth.RemoteTokenServices.java
@SuppressWarnings("rawtypes") private Map<String, Object> requestTokenInfo(String path, HttpMethod method, String accessToken, HttpHeaders headers) {// w w w . j a v a 2 s . co m Map<String, Object> result; if (headers.getContentType() == null) { headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); } if (method == HttpMethod.GET) { Map map = restTemplate.exchange(path, HttpMethod.GET, new HttpEntity<MultiValueMap<String, String>>(null, headers), Map.class, accessToken).getBody(); result = (Map<String, Object>) map; } else if (method == HttpMethod.POST) { MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>(); formData.add("token", accessToken); Map map = restTemplate.exchange(path, HttpMethod.POST, new HttpEntity<MultiValueMap<String, String>>(formData, headers), Map.class).getBody(); result = (Map<String, Object>) map; } else { throw new IllegalArgumentException("Unsupported method " + method); } return result; }
From source file:org.springframework.security.oauth2.provider.token.RemoteResourceServerTokenServices.java
protected Map<String, Object> validateToken(String accessToken) { MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>(); formData.add("token", accessToken); HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", basicAuthHeader); if (headers.getContentType() == null) { headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); }/*www .ja v a 2 s . com*/ @SuppressWarnings("rawtypes") Map map = restTemplate.exchange(checkTokenEndpointUrl, HttpMethod.POST, new HttpEntity<MultiValueMap<String, String>>(formData, headers), Map.class).getBody(); @SuppressWarnings("unchecked") Map<String, Object> result = (Map<String, Object>) map; return result; }
From source file:org.springframework.security.oauth2.provider.token.RemoteTokenServices.java
@Override public OAuth2Authentication loadAuthentication(String accessToken) throws AuthenticationException { MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>(); formData.add("token", accessToken); HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); Map<String, Object> map = postForMap(checkTokenEndpointUrl, formData, headers); if (map.containsKey("error")) { logger.debug("check_token returned error: " + map.get("error")); throw new InvalidTokenException(accessToken); }// www . j a va 2s . c om Assert.state(map.containsKey("client_id"), "Client id must be present in response from auth server"); return tokenConverter.extractAuthentication(map); }
From source file:org.springframework.social.box.api.impl.BoxOperations.java
protected BoxFile boxFileUploadOperation(String attributes, Resource file, List<BoxFileFields> fields) { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA); MultiValueMap<String, Object> form = new LinkedMultiValueMap<String, Object>(); form.add("attributes", attributes); form.add("file", file); HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<MultiValueMap<String, Object>>(form, httpHeaders);//ww w.j ava 2s. c o m URIBuilder uriBuilder = URIBuilder.fromUri(BOX_FILE_UPLOAD_API_URL); appendFieldsParameter(fields, uriBuilder); BoxFileUploadResult boxFileUploadResult = restTemplate.postForObject(uriBuilder.build(), httpEntity, BoxFileUploadResult.class); if (boxFileUploadResult.getTotalCount() == 1) { return boxFileUploadResult.getEntries().get(0); } else { throw new ApiException(BOX_PROVIDER_NAME, "Could not verify the file was uploaded"); } }
From source file:org.springframework.social.facebook.api.impl.PagedListUtils.java
public static MultiValueMap<String, String> getPagingParameters(PagingParameters pagedListParameters) { MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>(); if (pagedListParameters.getOffset() != null) { parameters.add("offset", String.valueOf(pagedListParameters.getOffset())); }/* w w w . j a va 2 s . co m*/ if (pagedListParameters.getLimit() != null) { parameters.add("limit", String.valueOf(pagedListParameters.getLimit())); } if (pagedListParameters.getSince() != null) { parameters.add("since", String.valueOf(pagedListParameters.getSince())); } if (pagedListParameters.getUntil() != null) { parameters.add("until", String.valueOf(pagedListParameters.getUntil())); } if (pagedListParameters.getBefore() != null) { parameters.add("before", String.valueOf(pagedListParameters.getBefore())); } if (pagedListParameters.getAfter() != null) { parameters.add("after", String.valueOf(pagedListParameters.getAfter())); } return parameters; }
From source file:org.springframework.social.facebook.api.impl.UserTemplate.java
public PagedList<Reference> search(String query) { requireAuthorization();//from w w w.j a v a 2s. co m MultiValueMap<String, String> queryMap = new LinkedMultiValueMap<String, String>(); queryMap.add("q", query); queryMap.add("type", "user"); return graphApi.fetchConnections("search", null, Reference.class, queryMap); }
From source file:org.springframework.social.oauth1.SigningSupport.java
private MultiValueMap<String, String> parseFormParameters(String parameterString) { if (parameterString == null || parameterString.length() == 0) { return EmptyMultiValueMap.instance(); }/* www .ja v a 2 s .co m*/ String[] pairs = StringUtils.tokenizeToStringArray(parameterString, "&"); MultiValueMap<String, String> result = new LinkedMultiValueMap<String, String>(pairs.length); for (String pair : pairs) { int idx = pair.indexOf('='); if (idx == -1) { result.add(formDecode(pair), ""); } else { String name = formDecode(pair.substring(0, idx)); String value = formDecode(pair.substring(idx + 1)); result.add(name, value); } } return result; }
From source file:org.springframework.social.oauth1.SigningSupport.java
private MultiValueMap<String, String> union(MultiValueMap<String, String> map1, MultiValueMap<String, String> map2) { MultiValueMap<String, String> union = new LinkedMultiValueMap<String, String>(map1); Set<Entry<String, List<String>>> map2Entries = map2.entrySet(); for (Iterator<Entry<String, List<String>>> entryIt = map2Entries.iterator(); entryIt.hasNext();) { Entry<String, List<String>> entry = entryIt.next(); String key = entry.getKey(); List<String> values = entry.getValue(); for (String value : values) { union.add(key, value); }// w w w. ja va2 s . c o m } return union; }
From source file:org.springframework.social.slack.api.impl.ChatTemplate.java
@Override public SlackMessageResponse postMessage(String message, String channelNameOrId) { MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); map.add("channel", channelNameOrId); map.add("text", message); map.add("as_user", "true"); map.add("unfurl_links", "true"); SlackMessageResponse slackResponse = post("/chat.postMessage", map, SlackMessageResponse.class); return slackResponse; }
From source file:org.springframework.social.slack.api.impl.ChatTemplate.java
@Override public SlackMessageResponse meMessage(String message, String channelNameOrId) { MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); map.add("channel", channelNameOrId); map.add("text", message); SlackMessageResponse slackResponse = post("/chat.meMessage", map, SlackMessageResponse.class); return slackResponse; }