This commit is contained in:
Lucio Lelii 2018-02-22 17:13:45 +00:00
parent b8a9f6c610
commit 63f585888e
3 changed files with 7 additions and 11 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.0.2-SNAPSHOT</version>
<name>authorization service client library</name>
<parent>

View File

@ -50,6 +50,6 @@ public interface AuthorizationProxy {
Map<String, String> retrieveExternalServiceGenerated() throws Exception;
void removeAllReleatedToken(UserInfo client, String context) throws Exception;
void removeAllReleatedToken(String clientId, String context) throws Exception;
}

View File

@ -1,6 +1,7 @@
package org.gcube.common.authorization.client.proxy;
import static org.gcube.common.authorization.client.Constants.CONTEXT_PARAM;
import static org.gcube.common.authorization.client.Constants.CLIENT_ID_PARAM;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
@ -186,25 +187,20 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
}
@Override
public void removeAllReleatedToken(UserInfo client, String context) throws Exception{
public void removeAllReleatedToken(String clientId, String context) throws Exception{
String methodPath = "/token/user";
int infrastructureHash = Utils.getInfrastructureHashfromContext(context);
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append("?")
.append(CONTEXT_PARAM).append("=").append(context);
.append(CONTEXT_PARAM).append("=").append(context).append("&").append(CLIENT_ID_PARAM).append("=").append(clientId);
URL url = new URL(callUrl.toString());
HttpURLConnection connection = makeRequest(url, "DELETE", false);
connection.setDoOutput(true);
//connection.setDoOutput(false);
connection.setDoInput(true);
connection.setRequestProperty("Content-type", "application/xml");
try(OutputStream os = new BufferedOutputStream(connection.getOutputStream())){
Binder.getContext().createMarshaller().marshal(client, os);
}
log.debug("response code for "+callUrl.toString()+" is "+connection.getResponseCode()+" "+connection.getResponseMessage());
if (connection.getResponseCode()!=200) throw new Exception("error contacting authorization service");
if (connection.getResponseCode()!=200 && connection.getResponseCode()!=204) throw new Exception("error contacting authorization service");
}