This commit is contained in:
Lucio Lelii 2016-09-16 08:00:01 +00:00
parent 7a21492162
commit 9748b7af14
3 changed files with 10 additions and 9 deletions

View File

@ -80,7 +80,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
token = result.toString();
}
return token;
return Utils.addInfrastructureHashToToken(token, infrastructureHash);
}
@Override
@ -115,7 +115,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
token = result.toString();
}
return token;
return Utils.addInfrastructureHashToToken(token, infrastructureHash);
}
@ -147,7 +147,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
token = result.toString();
}
return token;
return Utils.addInfrastructureHashToToken(token, infrastructureHash);
}
@Override
@ -184,8 +184,9 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
String methodPath = "/token/node";
int infrastructureHash = Utils.getInfrastructureHashfromContext(context);
StringBuilder callUrl =
new StringBuilder(getInternalEnpoint(Utils.getInfrastructureHashfromContext(context))).append(methodPath).append("?")
new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append("?")
.append(CONTEXT_PARAM).append("=").append(context);
URL url = new URL(callUrl.toString());
@ -210,7 +211,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
token = result.toString();
}
return token;
return Utils.addInfrastructureHashToToken(token, infrastructureHash);
}
@Override
@ -293,7 +294,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
if (includeTokenInHeader){
if (SecurityTokenProvider.instance.get()==null) throw new RuntimeException("null token passed");
connection.setRequestProperty(Constants.TOKEN_HEADER_ENTRY,SecurityTokenProvider.instance.get());
connection.setRequestProperty(Constants.TOKEN_HEADER_ENTRY,Utils.getRealToken(SecurityTokenProvider.instance.get()));
}
connection.setRequestMethod(method);
return connection;

View File

@ -35,7 +35,7 @@ public class Utils {
}
protected static String AddInfrastructureHashToToken(String token, int infrastructureHash) {
protected static String addInfrastructureHashToToken(String token, int infrastructureHash) {
return String.format("%s-%d", token, infrastructureHash);
}

View File

@ -20,12 +20,12 @@ public class CallTest {
@Test
public void resolveNodeToken() throws Exception{
System.out.println(resolveToken("c3c52f5b-ea65-4364-8357-be930763fdad-98187548")); //81caac0f-8a0d-4923-9312-7ff0eb3f2d5e|98187548"));
System.out.println(resolveToken("c3c52f5b-ea65-4364-8357-be930763fdad")); //81caac0f-8a0d-4923-9312-7ff0eb3f2d5e|98187548"));
}
@Test
public void requestNodeToken() throws Exception {
String token = authorizationService().requestActivation(new ContainerInfo("dataminer1-devnext.d4science.org",80), "/gcube/devNext/NextNext");
String token = authorizationService().requestActivation(new ContainerInfo("ckan-d-d4s.d4science.org",80), "/gcube/devNext/NextNext");
System.out.println(token);
}