Change log level in to DEBUG

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-access/gcube-geoserver-connector@164487 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
pasquale.vitale 2018-02-21 10:45:45 +00:00
parent a3542ce8f2
commit 056184ab99
3 changed files with 28 additions and 28 deletions

View File

@ -49,7 +49,7 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
@Override
public void handleRequest(RequestEvent e) {
logger.warn("Handling request");
logger.debug("Handling request");
HttpServletRequest httpServletRequest = e.request();
// get host from ApplicationContext
@ -57,15 +57,15 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
// get token from request
String token = getToken(httpServletRequest);
logger.warn("Retrieve token from request = " + token);
logger.debug("Retrieve token from request = " + token);
if (StringUtils.hasText(token)) {
logger.warn("Token found: " + token);
logger.debug("Token found: " + token);
if (validateToken(token)) {
// retrieve endpoint to get credentials in GeoServer
String endpoint = getEndpoint(token);
logger.warn("Endpoint found: " + endpoint);
logger.debug("Endpoint found: " + endpoint);
// TODO - Can be the endpoint stored in the cache object?
if (StringUtils.hasText(endpoint)) {
@ -75,7 +75,7 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
// check current token with tokenCache
if (token.equals(tokenCache)) {
logger.warn("Set credentials attribute retrieved from cache " + usernameCache + " "
logger.debug("Set credentials attribute retrieved from cache " + usernameCache + " "
+ passwordCache);
httpServletRequest.setAttribute(AuthenticationUtils.USERNAME, usernameCache);
httpServletRequest.setAttribute(AuthenticationUtils.PASSWORD, passwordCache);
@ -85,7 +85,7 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
+ AuthenticationUtils.GCUBE_QUERY_STRING + "=" + token;
// put credentials in the filter
AccessibleCredentialsEntity accessibleCredentials = restClient.getAccessibleCredentials(url);
logger.warn("Credentials: " + accessibleCredentials.getUsername() + "/"
logger.debug("Credentials: " + accessibleCredentials.getUsername() + "/"
+ accessibleCredentials.getPassword());
httpServletRequest.setAttribute(AuthenticationUtils.USERNAME,
accessibleCredentials.getUsername());
@ -93,10 +93,10 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
accessibleCredentials.getPassword());
// set/update data in the cache
logger.warn("Put token in the cache: " + token);
logger.debug("Put token in the cache: " + token);
gCubeCache.put(AuthenticationUtils.TOKEN_CACHE, token);
logger.warn("Put also username and password in the cache");
logger.debug("Put also username and password in the cache");
gCubeCache.put(AuthenticationUtils.USERNAME, accessibleCredentials.getUsername());
gCubeCache.put(AuthenticationUtils.PASSWORD, accessibleCredentials.getPassword());
}
@ -106,7 +106,7 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
RequestError.request_not_authorized_error.fire("Invalid token in the request");
}
} else {
logger.warn("Token not present in the request: NO/OP");
logger.trace("Token not present in the request: No/op");
}
}
@ -121,14 +121,14 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
// case 1 - get token from gcube-token query-string
String gCubeToken = httpServletRequest.getParameter(AuthenticationUtils.GCUBE_QUERY_STRING);
if (StringUtils.hasText(gCubeToken)) {
logger.warn("Get token from query-string");
logger.debug("Get token from query-string");
return gCubeToken;
}
// case 2 - get token from gcube-token header
gCubeToken = httpServletRequest.getHeader(AuthenticationUtils.GCUBE_QUERY_STRING);
if (StringUtils.hasText(gCubeToken)) {
logger.warn("Get token from gcube-token header");
logger.debug("Get token from gcube-token header");
return gCubeToken;
}
@ -136,7 +136,7 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
String authorization = httpServletRequest.getHeader(AuthenticationUtils.AUTHORIZATION);
if (StringUtils.hasText(authorization)
&& StringUtils.startsWithIgnoreCase(authorization, AuthenticationUtils.BASIC)) {
logger.warn("Get token from basic authorization header");
logger.debug("Get token from basic authorization header");
// header = Authorization: Basic base64credentials
String base64Credentials = StringUtils.delete(authorization, AuthenticationUtils.BASIC);
String credentials = new String(Base64.getDecoder().decode(StringUtils.trimWhitespace(base64Credentials)));
@ -146,22 +146,22 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
return values[1];
}
logger.warn("gcube-token not found in query-string, in header and in basic authorization header");
logger.debug("gcube-token not found in query-string, in header and in basic authorization header");
// case 4 - get token from HTML form in the password field
gCubeToken = httpServletRequest.getParameter(AuthenticationUtils.PASSWORD);
if (StringUtils.hasText(gCubeToken)) {
logger.warn("Get token from HTML form (in the password field)");
logger.debug("Get token from HTML form (in the password field)");
String user = httpServletRequest.getParameter(AuthenticationUtils.USERNAME);
logger.warn("Get username from HTML form: " + user);
logger.debug("Get username from HTML form: " + user);
if (StringUtils.hasText(user) && user.equals(getUser(gCubeToken))) //check username
return gCubeToken;
logger.warn("Username doesn't match with ClientInfo of gcube");
logger.debug("Username doesn't match with ClientInfo of gcube");
} else
logger.warn("gcube-token also not found in the HTML form in the password field");
logger.debug("gcube-token also not found in the HTML form in the password field");
return null;
}
@ -171,7 +171,7 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
try {
AuthorizationEntry authorizationEntry = authorizationService().get(token);
String scope = authorizationEntry.getContext();
logger.warn("Set scope in to " + scope);
logger.debug("Set scope in to " + scope);
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(token);
@ -189,7 +189,7 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
List<GCoreEndpoint> gCoreEndpoints = client.submit(query);
int size = gCoreEndpoints.size();
logger.warn("gCoreEndpoints size = " + size);
logger.debug("gCoreEndpoints size = " + size);
if (size > 0) {//I get only the first. Usually it must be only one
GCoreEndpoint gCoreEndpoint = gCoreEndpoints.get(0);
@ -209,14 +209,14 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
AuthorizationEntry authorizationEntry = authorizationService().get(token);
return authorizationEntry.getClientInfo().getId();
} catch (Exception ex) {
logger.error("Error in getUser() method: " + ex.getMessage());
logger.debug("Error in getUser() method: " + ex.getMessage());
}
return null;
}
private boolean validateToken(String token) {
// TODO How to implement the validation of the token
logger.warn("Validate token in progress...");
logger.debug("Validate token in progress...");
return true;
}
}

View File

@ -22,13 +22,13 @@ public class GeoServerFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
logger.warn("init() method");
logger.debug("init() method");
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
logger.warn("doFilter() method");
logger.debug("doFilter() method");
ServletRequestWrapper request = new ServletRequestWrapper((HttpServletRequest) servletRequest);
HttpServletResponse response = (HttpServletResponse) servletResponse;
@ -44,11 +44,11 @@ public class GeoServerFilter implements Filter {
+ Base64.getEncoder().encodeToString(token.getBytes());
request.addHeader(AuthenticationUtils.AUTHORIZATION, basic_authentication);
logger.warn("Added authorization header : " + request.getHeader(AuthenticationUtils.AUTHORIZATION));
logger.debug("Added authorization header : " + request.getHeader(AuthenticationUtils.AUTHORIZATION));
request.addParameter(AuthenticationUtils.USERNAME, username);
request.addParameter(AuthenticationUtils.PASSWORD, password);
logger.warn("Added parameters in the request : " + username +"/" + password);
logger.debug("Added parameters in the request : " + username +"/" + password);
}
filterChain.doFilter(request, response);
@ -56,7 +56,7 @@ public class GeoServerFilter implements Filter {
@Override
public void destroy() {
logger.warn("destroy() method");
logger.debug("destroy() method");
}
}

View File

@ -13,12 +13,12 @@ public class GCubeRestClient {
public AccessibleCredentialsEntity getAccessibleCredentials(String url) {
logger.warn("REST call to URL: " + url);
logger.debug("REST call to URL: " + url);
RestTemplate restTemplate = new RestTemplate();
try {
String response = restTemplate.getForObject(url, String.class);
logger.warn("JSON response: \n" + response);
logger.debug("JSON response: \n" + response);
JSONObject jsonObject = JSONObject.fromObject(response);
return (AccessibleCredentialsEntity) JSONObject.toBean(jsonObject, AccessibleCredentialsEntity.class);