This commit is contained in:
Lucio Lelii 2018-02-21 15:22:14 +00:00
parent b4c40c4507
commit b8a9f6c610
4 changed files with 27 additions and 7 deletions

View File

@ -22,11 +22,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>

View File

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

View File

@ -185,6 +185,28 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
return Utils.addInfrastructureHashToToken(token, infrastructureHash);
}
@Override
public void removeAllReleatedToken(UserInfo client, 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);
URL url = new URL(callUrl.toString());
HttpURLConnection connection = makeRequest(url, "DELETE", false);
connection.setDoOutput(true);
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");
}
@Override
public String generateApiKey(String apiQualifier) throws Exception {

View File

@ -11,7 +11,7 @@ public class Utils {
private static final String REAL_TOKEN_REGEXPR ="([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(-[0-9]+)?";
protected static int getInfrastructureHashfromContext(String context) {
try{
String infrastructure = context.split("/")[1];
@ -46,7 +46,7 @@ public class Utils {
String realToken = matcher.group(1);
return realToken;
}catch(Exception e){
throw new RuntimeException("token required for this method", e);
throw new RuntimeException("valid token required for this method", e);
}
}
}