git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/authorization-common-client@131430 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7a21492162
commit
9748b7af14
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue