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