This commit is contained in:
Lucio Lelii 2016-10-26 07:48:56 +00:00
parent 5ac0bf67d1
commit f4971155f5
4 changed files with 24 additions and 22 deletions

View File

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

View File

@ -1,5 +1,6 @@
package org.gcube.common.authorization.client.proxy;
import java.io.File;
import java.util.List;
import java.util.Map;
@ -39,6 +40,6 @@ public interface AuthorizationProxy {
Map<String, String> retrieveApiKeys() throws Exception;
//File getSymmKey(String filePath) throws Exception;
File getSymmKey(String filePath) throws Exception;
}

View File

@ -4,6 +4,8 @@ import static org.gcube.common.authorization.client.Constants.CONTEXT_PARAM;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
@ -340,7 +342,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
}
}
/*
@Override
public File getSymmKey(String filePath) throws Exception{
final String methodPath = "/symmKey/";
@ -351,7 +353,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
URL url = new URL(callUrl.toString());
HttpURLConnection connection = makeRequest(url, "GET", true);
connection.setDoInput(true);
if (connection.getResponseCode()!=200) throw new Exception("error retrieving policies");
if (connection.getResponseCode()!=200) throw new Exception("error retrieving key");
if (connection.getContentLengthLong()<=0) return null;
String resourceName = (String)connection.getHeaderField("resource-name");
@ -359,7 +361,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
toReturnFile.createNewFile();
try(InputStream stream = (InputStream)connection.getContent();
OutputStream os = new FileOutputStream(filePath)){
OutputStream os = new FileOutputStream(toReturnFile)){
int read = 0;
byte[] bytes = new byte[1024];
@ -370,7 +372,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
}
return toReturnFile;
}*/
}
private HttpURLConnection makeRequest(URL url, String method, boolean includeTokenInHeader) throws Exception{
HttpURLConnection connection;

View File

@ -20,7 +20,7 @@ public class CallTest {
@Test
public void resolveNodeToken() throws Exception{
System.out.println(resolveToken("d7a6b96b-97eb-40fd-96ff-c8e5f37a91c7-98187548")); //81caac0f-8a0d-4923-9312-7ff0eb3f2d5e|98187548"));
System.out.println(resolveToken("a7caa51b-6979-4b1d-abc6-449365b8350a-98187548")); //81caac0f-8a0d-4923-9312-7ff0eb3f2d5e|98187548"));
}
@Test
@ -36,7 +36,6 @@ public class CallTest {
authorizationService().addPolicies(policies);
}
@Test
public void getPolicies() throws Exception{
SecurityTokenProvider.instance.set(requestTestToken("/gcube/devNext/NextNext"));
@ -57,12 +56,12 @@ public class CallTest {
public void createKeyWithError() throws Exception {
authorizationService().generateApiKey("TEST");
}
/*
@Test
public void getSymmKey() throws Exception{
SecurityTokenProvider.instance.set(_requestNodeToken());
authorizationService().getSymmKey("/tmp");
}*/
}
@Test
@ -85,13 +84,13 @@ public class CallTest {
public String _requestNodeToken() throws Exception {
SecurityTokenProvider.instance.set(requestTestToken("/gcube"));
String token = authorizationService().requestActivation(new ContainerInfo("mynode",8080), "/gcube/devSec");
String token = authorizationService().requestActivation(new ContainerInfo("dlib29.isti.cnr.it",8080), "/gcube/devsec");
return token;
}
@Test
public void createTestToken() throws Exception {
System.out.println(requestTestToken("/gcube/devNext/NextNext"));
System.out.println(requestTestToken("/gcube/devsec/devVRE"));
}
private String requestTestToken(String context) throws Exception{