|
|
|
@ -36,6 +36,7 @@ import org.gcube.common.authorization.library.provider.ContainerInfo;
|
|
|
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
|
|
|
import org.gcube.common.authorization.library.provider.ServiceInfo;
|
|
|
|
|
import org.gcube.common.authorization.library.provider.UserInfo;
|
|
|
|
|
import org.gcube.common.authorization.library.utils.ListMapper;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
@ -185,7 +186,36 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
|
|
|
|
|
|
|
|
|
|
return Utils.addInfrastructureHashToToken(token, infrastructureHash);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setTokenRoles(String token, List<String> roles) throws Exception {
|
|
|
|
|
|
|
|
|
|
String realToken = Utils.getRealToken(token);
|
|
|
|
|
String methodPath = String.format("/token/user/%s/roles",realToken);
|
|
|
|
|
|
|
|
|
|
int infrastructureHash = Utils.getInfrastructureHashFromToken(token, endpoints.getDefaultInfrastructure());
|
|
|
|
|
|
|
|
|
|
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath);
|
|
|
|
|
|
|
|
|
|
URL url = new URL(callUrl.toString());
|
|
|
|
|
HttpURLConnection connection = makeRequest(url, "PUT", false);
|
|
|
|
|
connection.setDoOutput(true);
|
|
|
|
|
connection.setDoInput(true);
|
|
|
|
|
connection.setRequestProperty("Content-type", "application/xml");
|
|
|
|
|
|
|
|
|
|
ListMapper listmapper = new ListMapper();
|
|
|
|
|
listmapper.setList(roles);
|
|
|
|
|
try(OutputStream os = new BufferedOutputStream(connection.getOutputStream())){
|
|
|
|
|
Binder.getContext().createMarshaller().marshal(listmapper, os);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.debug("response code for "+callUrl.toString()+" is "+connection.getResponseCode()+" "+connection.getResponseMessage());
|
|
|
|
|
|
|
|
|
|
if (connection.getResponseCode()!=200) throw new Exception("error contacting authorization service");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void removeAllReleatedToken(String clientId, String context) throws Exception{
|
|
|
|
|
String methodPath = "/token/user";
|
|
|
|
|