Skip to content
Snippets Groups Projects
Commit 3bc5b084 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Added URL encoding to group name in isMemberOf call

parent f7a174e5
No related branches found
No related tags found
No related merge requests found
Pipeline #1223 passed
package it.inaf.ia2.transfer.auth;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
......@@ -14,9 +18,11 @@ import org.springframework.web.client.RestTemplate;
@Component
public class GmsClient {
private static final Logger LOG = LoggerFactory.getLogger(GmsClient.class);
@Value("${gms_base_url}")
private String gmsBaseUrl;
private final RestTemplate restTemplate;
@Autowired
......@@ -27,7 +33,9 @@ public class GmsClient {
@Cacheable("gms_cache")
public boolean isMemberOf(String token, String group) {
String url = gmsBaseUrl + "/vo/search/" + group;
LOG.trace("called isMemberOf for group " + group);
String url = gmsBaseUrl + "/vo/search/" + URLEncoder.encode(group, StandardCharsets.UTF_8);
String gmsResponse = restTemplate.exchange(url, HttpMethod.GET, getEntity(token), String.class).getBody();
if (gmsResponse == null) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment