git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/authorization-common-client@131713 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bfdb84c980
commit
c3e5848be2
|
@ -217,14 +217,15 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
|
||||||
@Override
|
@Override
|
||||||
public AuthorizationEntry get(String token) throws ObjectNotFound, Exception{
|
public AuthorizationEntry get(String token) throws ObjectNotFound, Exception{
|
||||||
String realToken = Utils.getRealToken(token);
|
String realToken = Utils.getRealToken(token);
|
||||||
|
String maskedToken= String.format("%s********",realToken.substring(0, realToken.length()-8));
|
||||||
int infrastructureHashFromToken = Utils.getInfrastructureHashFromToken(token, endpoints.getDefaultInfrastructure());
|
int infrastructureHashFromToken = Utils.getInfrastructureHashFromToken(token, endpoints.getDefaultInfrastructure());
|
||||||
AuthorizationEndpoint endpoint = getEndpoint(infrastructureHashFromToken);
|
AuthorizationEndpoint endpoint = getEndpoint(infrastructureHashFromToken);
|
||||||
|
|
||||||
if (cache.containsKey(realToken) && cache.get(realToken).isValid(endpoint.getClientCacheValidity())){
|
if (cache.containsKey(realToken) && cache.get(realToken).isValid(endpoint.getClientCacheValidity())){
|
||||||
log.trace("valid entry found in cache for token {}, returning it",String.format("%s********",realToken.substring(0, realToken.length()-8)));
|
log.trace("valid entry found in cache for token {}, returning it",maskedToken);
|
||||||
return cache.get(realToken).getEntry();
|
return cache.get(realToken).getEntry();
|
||||||
} else
|
} else
|
||||||
log.trace("invalid entry found in cache for token {}, contacting auth service",String.format("%s********",realToken.substring(0, realToken.length()-8)));
|
log.trace("invalid entry found in cache for token {}, contacting auth service",maskedToken);
|
||||||
|
|
||||||
final String methodPath = "/token/";
|
final String methodPath = "/token/";
|
||||||
|
|
||||||
|
@ -234,7 +235,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
|
||||||
URL url = new URL(callUrl.toString());
|
URL url = new URL(callUrl.toString());
|
||||||
HttpURLConnection connection = makeRequest(url, "GET", false);
|
HttpURLConnection connection = makeRequest(url, "GET", false);
|
||||||
connection.setDoInput(true);
|
connection.setDoInput(true);
|
||||||
if (connection.getResponseCode()==404) throw new ObjectNotFound("token "+token+" not found");
|
if (connection.getResponseCode()==404) throw new ObjectNotFound("token "+maskedToken+" not found");
|
||||||
if (connection.getResponseCode()!=200) throw new Exception("error contacting authorization service (error code is "+connection.getResponseCode()+")");
|
if (connection.getResponseCode()!=200) throw new Exception("error contacting authorization service (error code is "+connection.getResponseCode()+")");
|
||||||
if (connection.getContentLengthLong()<=0) return null;
|
if (connection.getContentLengthLong()<=0) return null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue