This commit is contained in:
Lucio Lelii 2016-05-02 16:43:20 +00:00
parent 6c28e4233a
commit 25d931a9a1
2 changed files with 8 additions and 10 deletions

View File

@ -11,9 +11,7 @@ import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.gcube.common.authorization.client.Binder; import org.gcube.common.authorization.client.Binder;
import org.gcube.common.authorization.client.exceptions.ObjectNotFound; import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
@ -32,7 +30,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
private static Logger log = LoggerFactory.getLogger(AuthorizationProxy.class); private static Logger log = LoggerFactory.getLogger(AuthorizationProxy.class);
private static Map<String, AuthorizationEntryCache> cache = new HashMap<String, AuthorizationEntryCache>(); //private static Map<String, AuthorizationEntryCache> cache = new HashMap<String, AuthorizationEntryCache>();
private List<AuthorizationEndpoint> endpoints; private List<AuthorizationEndpoint> endpoints;
@ -88,8 +86,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
@Override @Override
public AuthorizationEntry get(String token) throws ObjectNotFound, Exception{ public AuthorizationEntry get(String token) throws ObjectNotFound, Exception{
if (cache.containsKey(token) && cache.get(token).isValid()) /*if (cache.containsKey(token) && cache.get(token).isValid())
return cache.get(token).getEntry(); return cache.get(token).getEntry();*/
final String methodPath = "/retrieve/"; final String methodPath = "/retrieve/";
@ -104,7 +102,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
try(InputStream stream = (InputStream)connection.getContent();){ try(InputStream stream = (InputStream)connection.getContent();){
AuthorizationEntry entry = (AuthorizationEntry)Binder.getContext().createUnmarshaller().unmarshal(stream); AuthorizationEntry entry = (AuthorizationEntry)Binder.getContext().createUnmarshaller().unmarshal(stream);
cache.put(token, new AuthorizationEntryCache(entry)); //cache.put(token, new AuthorizationEntryCache(entry));
return entry; return entry;
} }

View File

@ -19,7 +19,7 @@ public class CallTest {
@Test @Test
public void call() throws Exception{ public void call() throws Exception{
try{ try{
System.out.println(authorizationService().get("82a84741-debe-4c90-a907-c429c8272071")); System.out.println(authorizationService().get("3b34750e-d39b-4d3c-924d-efcf7cc907c1"));
}catch(ObjectNotFound onf){ }catch(ObjectNotFound onf){
onf.printStackTrace(); onf.printStackTrace();
} }
@ -28,8 +28,8 @@ public class CallTest {
@Test @Test
public void requestToken() throws Exception { public void requestToken() throws Exception {
//ScopeProvider.instance.set("/gcube/devsec"); //ScopeProvider.instance.set("/gcube/devsec");
String token = authorizationService().generateToken(new UserInfo("luca.frosini", new ArrayList<String>()), "/gcube"); System.out.println( authorizationService().generateToken(new UserInfo("testckan", new ArrayList<String>()), "/gcube"));
System.out.println("token is: "+token);
} }
@Test @Test