git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/authorization-common-client@132459 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fb3f20124f
commit
a8d2daf9f1
|
@ -193,11 +193,10 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
|
|||
|
||||
StringBuilder callUrl;
|
||||
|
||||
callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath);
|
||||
if (context!=null) callUrl.append("?context=").append(context);
|
||||
|
||||
callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append("?context=").append(context);
|
||||
|
||||
URL url = new URL(callUrl.toString());
|
||||
HttpURLConnection connection = makeRequest(url, "PUT", true);
|
||||
HttpURLConnection connection = makeRequest(url, "PUT", false);
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
connection.setRequestProperty("Content-type", "application/xml");
|
||||
|
@ -224,7 +223,36 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
|
|||
@Override
|
||||
public String requestActivation(ContainerInfo container) throws Exception {
|
||||
|
||||
return requestActivation(container, null);
|
||||
String methodPath = "/token/node";
|
||||
|
||||
int infrastructureHash = Utils.getInfrastructureHashFromToken(SecurityTokenProvider.instance.get(), endpoints.getDefaultInfrastructure());
|
||||
|
||||
StringBuilder callUrl;
|
||||
|
||||
callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath);
|
||||
|
||||
URL url = new URL(callUrl.toString());
|
||||
HttpURLConnection connection = makeRequest(url, "PUT", true);
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
connection.setRequestProperty("Content-type", "application/xml");
|
||||
|
||||
try(OutputStream os = new BufferedOutputStream(connection.getOutputStream())){
|
||||
Binder.getContext().createMarshaller().marshal(container, os);
|
||||
}
|
||||
|
||||
log.debug("response code is "+connection.getResponseCode());
|
||||
|
||||
if (connection.getResponseCode()!=200) throw new Exception("error contacting authorization service");
|
||||
String token= "";
|
||||
try(BufferedReader reader = new BufferedReader(new InputStreamReader((InputStream)connection.getContent()))){
|
||||
StringBuilder result = new StringBuilder();
|
||||
String line;
|
||||
while((line = reader.readLine()) != null)
|
||||
result.append(line);
|
||||
token = result.toString();
|
||||
}
|
||||
return Utils.addInfrastructureHashToToken(token, infrastructureHash);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -80,8 +80,7 @@ public class CallTest {
|
|||
}
|
||||
|
||||
public String _requestNodeToken() throws Exception {
|
||||
SecurityTokenProvider.instance.set(requestTestToken("/gcube/devNext/NextNext"));
|
||||
String token = authorizationService().requestActivation(new ContainerInfo("mynode",8080));
|
||||
String token = authorizationService().requestActivation(new ContainerInfo("mynode",8080), "/gcube/devSec");
|
||||
return token;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue