Removing debug messages

This commit is contained in:
Katerina Iatropoulou 2020-12-07 11:19:20 +00:00
parent e38d0964c2
commit 6284ef2d2e
7 changed files with 34 additions and 39 deletions

View File

@ -63,7 +63,7 @@ public class JwksDeserializer implements JsonDeserializer<Jwks> {
"}"; "}";
Jwks jwks = gson.fromJson(jwksJson, Jwks.class); Jwks jwks = gson.fromJson(jwksJson, Jwks.class);
for(Key key:jwks.getKeys()) { for(Key key:jwks.getKeys()) {
System.out.println(key.getE()); //System.out.println(key.getE());
} }
} }
} }

View File

@ -87,7 +87,7 @@ public class PersonalTokenServlet extends HttpServlet {
HttpResponse response = httpclient.execute(httpDelete); HttpResponse response = httpclient.execute(httpDelete);
if (response.getStatusLine().getStatusCode()!=200) { if (response.getStatusLine().getStatusCode()!=200) {
logger.warn("Could not delete old refresh tokens." + response.getStatusLine().getStatusCode()); logger.warn("Could not delete old refresh tokens." + response.getStatusLine().getStatusCode());
System.out.println("Could not delete old refresh tokens." + response.getStatusLine().getStatusCode());//TODO should I throw exception? //System.out.println("Could not delete old refresh tokens." + response.getStatusLine().getStatusCode());//TODO should I throw exception?
} }
} }
} }
@ -111,7 +111,6 @@ public class PersonalTokenServlet extends HttpServlet {
} }
} }
System.out.println("Old refresh tokens... " + oldRefreshTokens);
return oldRefreshTokens; return oldRefreshTokens;
} }
} }

View File

@ -54,7 +54,7 @@ public class RegisterServiceServlet extends HttpServlet {
String idParam = request.getParameter("id"); String idParam = request.getParameter("id");
if (idParam != null && !idParam.isEmpty()) { // EDIT CASE if (idParam != null && !idParam.isEmpty()) { // EDIT CASE
System.out.println("In edit"); //System.out.println("In edit");
try { try {
int id = Integer.parseInt(idParam); int id = Integer.parseInt(idParam);
RegisteredService registeredService = registeredServicesUtils.getRegisteredServiceDao().fetchRegisteredServiceById(id); RegisteredService registeredService = registeredServicesUtils.getRegisteredServiceDao().fetchRegisteredServiceById(id);
@ -66,13 +66,13 @@ public class RegisterServiceServlet extends HttpServlet {
} else { } else {
if (registeredService == null) { if (registeredService == null) {
System.out.println("No service found!"); //System.out.println("No service found!");
request.getSession().setAttribute("message", "Not valid registered service with given id " + id + "."); request.getSession().setAttribute("message", "Not valid registered service with given id " + id + ".");
response.sendRedirect("./registeredServices"); response.sendRedirect("./registeredServices");
logger.warn("Not valid registered service with " + id + "id."); logger.warn("Not valid registered service with " + id + "id.");
} else { } else {
System.out.println("Not authorized"); //System.out.println("Not authorized");
request.getSession().setAttribute("message", "Not authorized to edit the registered service with id " + id + "."); request.getSession().setAttribute("message", "Not authorized to edit the registered service with id " + id + ".");
response.sendRedirect("./registeredServices"); response.sendRedirect("./registeredServices");
logger.warn("Not authorized to edit the service with " + id + "id."); logger.warn("Not authorized to edit the service with " + id + "id.");
@ -80,13 +80,13 @@ public class RegisterServiceServlet extends HttpServlet {
} }
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
System.out.println("WRONG FORMAT"); //System.out.println("WRONG FORMAT");
request.getSession().setAttribute("message", "Invalid service id."); request.getSession().setAttribute("message", "Invalid service id.");
response.sendRedirect("./registeredServices"); response.sendRedirect("./registeredServices");
logger.error("Invalid service id.", nfe); logger.error("Invalid service id.", nfe);
} catch (SQLException sqle) { } catch (SQLException sqle) {
System.out.println("SQL PROBLEM"); //System.out.println("SQL PROBLEM");
request.getSession().setAttribute("message", "Could not fetch registered service."); request.getSession().setAttribute("message", "Could not fetch registered service.");
response.sendRedirect("./registeredServices"); response.sendRedirect("./registeredServices");
logger.error("Could not fetch registered service.", sqle); logger.error("Could not fetch registered service.", sqle);
@ -106,9 +106,9 @@ public class RegisterServiceServlet extends HttpServlet {
} }
private void updateFormFields(HttpServletRequest request, String serviceName, String keyType, ServiceResponse serviceResponse) { private void updateFormFields(HttpServletRequest request, String serviceName, String keyType, ServiceResponse serviceResponse) {
System.out.println("UPDATING FORM"); //System.out.println("UPDATING FORM");
request.getSession().setAttribute("first_name", serviceName); request.getSession().setAttribute("first_name", serviceName);
System.out.println("Service response URI " + serviceResponse.getJwksUri()); //System.out.println("Service response URI " + serviceResponse.getJwksUri());
request.getSession().setAttribute("key_type", keyType); request.getSession().setAttribute("key_type", keyType);
if (keyType != null) { if (keyType != null) {
if (keyType.equals("uri")) { if (keyType.equals("uri")) {
@ -120,7 +120,7 @@ public class RegisterServiceServlet extends HttpServlet {
} else { } else {
key = new Key(); key = new Key();
} }
System.out.println("Service response keys " + serviceResponse.getJwksUri()); //System.out.println("Service response keys " + serviceResponse.getJwksUri());
Gson gson = new GsonBuilder().setPrettyPrinting().create(); Gson gson = new GsonBuilder().setPrettyPrinting().create();
request.getSession().setAttribute("value", gson.toJson(key)); request.getSession().setAttribute("value", gson.toJson(key));
} }
@ -137,9 +137,9 @@ public class RegisterServiceServlet extends HttpServlet {
boolean canProceed = true; boolean canProceed = true;
String mode = request.getParameter("mode").trim(); String mode = request.getParameter("mode").trim();
System.out.println("Mode was " + mode); //System.out.println("Mode was " + mode);
checkmode(mode); checkmode(mode);
System.out.println("Mode is " + mode); //System.out.println("Mode is " + mode);
String serviceId = request.getParameter("id"); String serviceId = request.getParameter("id");
@ -173,7 +173,7 @@ public class RegisterServiceServlet extends HttpServlet {
request.getSession().setAttribute("value", jwksString); request.getSession().setAttribute("value", jwksString);
if (jwks.getKeys() == null || jwks.getKeys().length == 0) { if (jwks.getKeys() == null || jwks.getKeys().length == 0) {
System.out.println("Something wrong with the keys."); //System.out.println("Something wrong with the keys.");
request.getSession().setAttribute("value_error", true); request.getSession().setAttribute("value_error", true);
canProceed = false; canProceed = false;
} }
@ -207,7 +207,7 @@ public class RegisterServiceServlet extends HttpServlet {
serverRequestJSON = createServiceJson(null, name, email, jwks); serverRequestJSON = createServiceJson(null, name, email, jwks);
} }
if(serverRequestJSON != null) { if(serverRequestJSON != null) {
System.out.println("SERVER JSON " + serverRequestJSON); //System.out.println("SERVER JSON " + serverRequestJSON);
serverMessage = tokenUtils.registerService(serverRequestJSON); serverMessage = tokenUtils.registerService(serverRequestJSON);
logger.debug(serverMessage); logger.debug(serverMessage);
if (serverMessage == null) { if (serverMessage == null) {
@ -252,7 +252,7 @@ public class RegisterServiceServlet extends HttpServlet {
response.sendRedirect("./registeredServices"); response.sendRedirect("./registeredServices");
} else { } else {
System.out.println("In edit..."); //System.out.println("In edit...");
try { try {
serviceIdInt = Integer.parseInt(serviceId); serviceIdInt = Integer.parseInt(serviceId);
if (!registeredServicesUtils.isAuthorized(authentication.getSub(), serviceIdInt)) { if (!registeredServicesUtils.isAuthorized(authentication.getSub(), serviceIdInt)) {
@ -272,13 +272,13 @@ public class RegisterServiceServlet extends HttpServlet {
serverRequestJSON = createServiceJson(registeredService.getClientId(), name, email, jwks); serverRequestJSON = createServiceJson(registeredService.getClientId(), name, email, jwks);
} }
if (serverRequestJSON != null) { if (serverRequestJSON != null) {
System.out.println("SERVER JSON " + serverRequestJSON); //System.out.println("SERVER JSON " + serverRequestJSON);
HttpResponse resp = tokenUtils.updateService(registeredService.getClientId(), serverRequestJSON, registeredService.getRegistrationAccessToken()); HttpResponse resp = tokenUtils.updateService(registeredService.getClientId(), serverRequestJSON, registeredService.getRegistrationAccessToken());
if (resp.getStatusLine().getStatusCode() == 200) { if (resp.getStatusLine().getStatusCode() == 200) {
System.out.println("NAME >>>>" + name); //System.out.println("NAME >>>>" + name);
registeredService.setName(name); registeredService.setName(name);
System.out.println("Client Id " + registeredService.getClientId()); //System.out.println("Client Id " + registeredService.getClientId());
try { try {
registeredServicesUtils.getRegisteredServiceDao().update(registeredService); registeredServicesUtils.getRegisteredServiceDao().update(registeredService);
} catch (SQLException sqle) { } catch (SQLException sqle) {
@ -392,7 +392,7 @@ public class RegisterServiceServlet extends HttpServlet {
GsonBuilder builder = new GsonBuilder(); GsonBuilder builder = new GsonBuilder();
builder.serializeNulls(); builder.serializeNulls();
Gson gson = builder.create(); Gson gson = builder.create();
System.out.println("Created json " + serviceJSON); //System.out.println("Created json " + serviceJSON);
return gson.toJson(serviceJSON); return gson.toJson(serviceJSON);
} }
@ -406,7 +406,7 @@ public class RegisterServiceServlet extends HttpServlet {
GsonBuilder builder = new GsonBuilder(); GsonBuilder builder = new GsonBuilder();
builder.serializeNulls(); builder.serializeNulls();
Gson gson = builder.create(); Gson gson = builder.create();
System.out.println("Created json " + serviceJSON); //System.out.println("Created json " + serviceJSON);
return gson.toJson(serviceJSON); return gson.toJson(serviceJSON);
} }
@ -420,7 +420,7 @@ public class RegisterServiceServlet extends HttpServlet {
GsonBuilder builder = new GsonBuilder(); GsonBuilder builder = new GsonBuilder();
builder.serializeNulls(); builder.serializeNulls();
Gson gson = builder.create(); Gson gson = builder.create();
System.out.println("Created json " + serviceJSON); //System.out.println("Created json " + serviceJSON);
return gson.toJson(serviceJSON); return gson.toJson(serviceJSON);
} }

View File

@ -67,7 +67,7 @@ public class RegisterServlet extends HttpServlet {
String gRecaptchaResponse = request.getParameter("g-recaptcha-response"); String gRecaptchaResponse = request.getParameter("g-recaptcha-response");
boolean isRecaptchaVerified = VerifyRecaptcha.verify(gRecaptchaResponse, secret); boolean isRecaptchaVerified = VerifyRecaptcha.verify(gRecaptchaResponse, secret);
//System.out.println("RESPONSE " + gRecaptchaResponse); ////System.out.println("RESPONSE " + gRecaptchaResponse);
if (organization == null){ if (organization == null){
logger.info("organization is null"); logger.info("organization is null");

View File

@ -55,7 +55,7 @@ public class RegisteredServicesServlet extends HttpServlet {
try { try {
registeredServices = registeredServicesUtils. registeredServices = registeredServicesUtils.
getRegisteredServiceDao().fetchAllRegisteredServicesByOwner(userId); getRegisteredServiceDao().fetchAllRegisteredServicesByOwner(userId);
System.out.println("LOAD REGISTERED SERVICES. " + registeredServices.size()); //System.out.println("LOAD REGISTERED SERVICES. " + registeredServices.size());
if (registeredServices.isEmpty()) { if (registeredServices.isEmpty()) {
request.getSession().setAttribute("showEmptyList", true); request.getSession().setAttribute("showEmptyList", true);
@ -74,7 +74,7 @@ public class RegisteredServicesServlet extends HttpServlet {
name.append(authentication.getUserInfo().getFamilyName().charAt(0)); name.append(authentication.getUserInfo().getFamilyName().charAt(0));
request.getSession().setAttribute("name", name.toString()); request.getSession().setAttribute("name", name.toString());
request.getSession().setAttribute("reachedLimit", reachedLimit); request.getSession().setAttribute("reachedLimit", reachedLimit);
System.out.println("REACHED LIMIT??? " + reachedLimit); //System.out.println("REACHED LIMIT??? " + reachedLimit);
request.getSession().setAttribute("services", serviceResponses); request.getSession().setAttribute("services", serviceResponses);
request.getSession().setAttribute("keys", serviceKey); request.getSession().setAttribute("keys", serviceKey);
@ -102,7 +102,7 @@ public class RegisteredServicesServlet extends HttpServlet {
private String extractJSONJwk(Jwks jwks) { private String extractJSONJwk(Jwks jwks) {
Gson gson = new GsonBuilder().setPrettyPrinting().create(); Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println(gson.toJson(jwks)); //System.out.println(gson.toJson(jwks));
return gson.toJson(jwks); return gson.toJson(jwks);
} }
@ -112,7 +112,7 @@ public class RegisteredServicesServlet extends HttpServlet {
getContext().getAuthentication(); getContext().getAuthentication();
String id = request.getParameter("id"); String id = request.getParameter("id");
System.out.println("POST " +id); //System.out.println("POST " +id);
if (id!=null && !id.isEmpty()) { if (id!=null && !id.isEmpty()) {
try { try {
@ -120,7 +120,7 @@ public class RegisteredServicesServlet extends HttpServlet {
if (!registeredService.getOwner().equals(authentication.getSub())) { if (!registeredService.getOwner().equals(authentication.getSub())) {
request.getSession().setAttribute("message", "You are not allowed to delete the service."); request.getSession().setAttribute("message", "You are not allowed to delete the service.");
System.out.println("BLOCKED " + registeredService.getOwner() + " >> " + authentication.getSub()); //System.out.println("BLOCKED " + registeredService.getOwner() + " >> " + authentication.getSub());
response.sendRedirect("./registeredServices"); response.sendRedirect("./registeredServices");
return; return;
} }
@ -128,18 +128,18 @@ public class RegisteredServicesServlet extends HttpServlet {
HttpResponse resp = tokenUtils.deleteService(registeredService.getClientId(), registeredService.getRegistrationAccessToken()); HttpResponse resp = tokenUtils.deleteService(registeredService.getClientId(), registeredService.getRegistrationAccessToken());
int statusCode = resp.getStatusLine().getStatusCode(); int statusCode = resp.getStatusLine().getStatusCode();
System.out.println("STATUS CODE " + statusCode); //System.out.println("STATUS CODE " + statusCode);
if (statusCode != 204) { if (statusCode != 204) {
logger.error("Unable to delete the service. Status code was " + statusCode); logger.error("Unable to delete the service. Status code was " + statusCode);
request.getSession().setAttribute("message", "Fail to delete the service. Status " + statusCode); request.getSession().setAttribute("message", "Fail to delete the service. Status " + statusCode);
System.out.println("AAI blocked"); //System.out.println("AAI blocked");
response.sendRedirect("./registeredServices"); response.sendRedirect("./registeredServices");
return; return;
} else { } else {
registeredServicesUtils.getRegisteredServiceDao().delete(Integer.parseInt(id)); registeredServicesUtils.getRegisteredServiceDao().delete(Integer.parseInt(id));
request.getSession().setAttribute("success", "The service was successfully deleted."); request.getSession().setAttribute("success", "The service was successfully deleted.");
System.out.println("HERE HERE"); //System.out.println("HERE HERE");
} }
} catch (SQLException sqle) { } catch (SQLException sqle) {

View File

@ -25,14 +25,10 @@ public class RegisteredServicesUtils {
} }
public boolean isAuthorized(String userid, int id) throws SQLException { public boolean isAuthorized(String userid, int id) throws SQLException {
System.out.println("I AM HERE....");
RegisteredService registeredService = registeredServiceDao.fetchRegisteredServiceById(id); RegisteredService registeredService = registeredServiceDao.fetchRegisteredServiceById(id);
if (registeredService == null) { if (registeredService == null) {
return false; //no harm in accessing nothing return false; //no harm in accessing nothing
} }
System.out.println("....and HERE");
System.out.println(registeredService.getClientId());
System.out.println(registeredService.getOwner());
return registeredService.getOwner().equals(userid); return registeredService.getOwner().equals(userid);
} }

View File

@ -39,7 +39,7 @@ public class TokenUtils {
CloseableHttpClient httpclient = HttpClients.createDefault(); CloseableHttpClient httpclient = HttpClients.createDefault();
HttpResponse httpResponse = httpclient.execute(httppost); HttpResponse httpResponse = httpclient.execute(httppost);
System.out.println("HTTP RESPONSE " + httpResponse.getStatusLine().getStatusCode()); //System.out.println("HTTP RESPONSE " + httpResponse.getStatusLine().getStatusCode());
if (httpResponse.getStatusLine().getStatusCode() == 201) { if (httpResponse.getStatusLine().getStatusCode() == 201) {
//logger.debug(IOUtils.toString(httpResponse.getEntity().getContent(), StandardCharsets.UTF_8.name())); //logger.debug(IOUtils.toString(httpResponse.getEntity().getContent(), StandardCharsets.UTF_8.name()));
return IOUtils.toString(httpResponse.getEntity().getContent(), StandardCharsets.UTF_8.name()); return IOUtils.toString(httpResponse.getEntity().getContent(), StandardCharsets.UTF_8.name());
@ -62,7 +62,7 @@ public class TokenUtils {
public HttpResponse deleteService(String serviceId, String registeredAccessToken) throws IOException { public HttpResponse deleteService(String serviceId, String registeredAccessToken) throws IOException {
System.out.println("DELETE " + issuer + "register/"+serviceId); //System.out.println("DELETE " + issuer + "register/"+serviceId);
HttpDelete httpDelete = new HttpDelete(issuer + "register/"+serviceId); HttpDelete httpDelete = new HttpDelete(issuer + "register/"+serviceId);
httpDelete.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); httpDelete.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
httpDelete.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + registeredAccessToken); httpDelete.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + registeredAccessToken);
@ -72,14 +72,14 @@ public class TokenUtils {
} }
public ServiceResponse getRegisteredService(String serviceId, String registeredAccessToken) throws IOException { public ServiceResponse getRegisteredService(String serviceId, String registeredAccessToken) throws IOException {
System.out.println("ISSUER " + issuer); //System.out.println("ISSUER " + issuer);
HttpGet httpGet = new HttpGet(issuer + "register/"+ serviceId); HttpGet httpGet = new HttpGet(issuer + "register/"+ serviceId);
httpGet.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + registeredAccessToken); httpGet.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + registeredAccessToken);
CloseableHttpClient httpclient = HttpClients.createDefault(); CloseableHttpClient httpclient = HttpClients.createDefault();
HttpResponse httpResponse = httpclient.execute(httpGet); HttpResponse httpResponse = httpclient.execute(httpGet);
String registeredService = IOUtils.toString(httpResponse.getEntity().getContent(), StandardCharsets.UTF_8.name()); String registeredService = IOUtils.toString(httpResponse.getEntity().getContent(), StandardCharsets.UTF_8.name());
System.out.println(registeredService); //System.out.println(registeredService);
return new Gson().fromJson(registeredService,ServiceResponse.class); return new Gson().fromJson(registeredService,ServiceResponse.class);
} }