Removing debug messages
This commit is contained in:
parent
e38d0964c2
commit
6284ef2d2e
|
@ -63,7 +63,7 @@ public class JwksDeserializer implements JsonDeserializer<Jwks> {
|
|||
"}";
|
||||
Jwks jwks = gson.fromJson(jwksJson, Jwks.class);
|
||||
for(Key key:jwks.getKeys()) {
|
||||
System.out.println(key.getE());
|
||||
//System.out.println(key.getE());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class PersonalTokenServlet extends HttpServlet {
|
|||
HttpResponse response = httpclient.execute(httpDelete);
|
||||
if (response.getStatusLine().getStatusCode()!=200) {
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -54,7 +54,7 @@ public class RegisterServiceServlet extends HttpServlet {
|
|||
String idParam = request.getParameter("id");
|
||||
|
||||
if (idParam != null && !idParam.isEmpty()) { // EDIT CASE
|
||||
System.out.println("In edit");
|
||||
//System.out.println("In edit");
|
||||
try {
|
||||
int id = Integer.parseInt(idParam);
|
||||
RegisteredService registeredService = registeredServicesUtils.getRegisteredServiceDao().fetchRegisteredServiceById(id);
|
||||
|
@ -66,13 +66,13 @@ public class RegisterServiceServlet extends HttpServlet {
|
|||
|
||||
} else {
|
||||
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 + ".");
|
||||
response.sendRedirect("./registeredServices");
|
||||
logger.warn("Not valid registered service with " + id + "id.");
|
||||
|
||||
} 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 + ".");
|
||||
response.sendRedirect("./registeredServices");
|
||||
logger.warn("Not authorized to edit the service with " + id + "id.");
|
||||
|
@ -80,13 +80,13 @@ public class RegisterServiceServlet extends HttpServlet {
|
|||
}
|
||||
|
||||
} catch (NumberFormatException nfe) {
|
||||
System.out.println("WRONG FORMAT");
|
||||
//System.out.println("WRONG FORMAT");
|
||||
request.getSession().setAttribute("message", "Invalid service id.");
|
||||
response.sendRedirect("./registeredServices");
|
||||
logger.error("Invalid service id.", nfe);
|
||||
|
||||
} catch (SQLException sqle) {
|
||||
System.out.println("SQL PROBLEM");
|
||||
//System.out.println("SQL PROBLEM");
|
||||
request.getSession().setAttribute("message", "Could not fetch registered service.");
|
||||
response.sendRedirect("./registeredServices");
|
||||
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) {
|
||||
System.out.println("UPDATING FORM");
|
||||
//System.out.println("UPDATING FORM");
|
||||
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);
|
||||
if (keyType != null) {
|
||||
if (keyType.equals("uri")) {
|
||||
|
@ -120,7 +120,7 @@ public class RegisterServiceServlet extends HttpServlet {
|
|||
} else {
|
||||
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();
|
||||
request.getSession().setAttribute("value", gson.toJson(key));
|
||||
}
|
||||
|
@ -137,9 +137,9 @@ public class RegisterServiceServlet extends HttpServlet {
|
|||
boolean canProceed = true;
|
||||
|
||||
String mode = request.getParameter("mode").trim();
|
||||
System.out.println("Mode was " + mode);
|
||||
//System.out.println("Mode was " + mode);
|
||||
checkmode(mode);
|
||||
System.out.println("Mode is " + mode);
|
||||
//System.out.println("Mode is " + mode);
|
||||
|
||||
String serviceId = request.getParameter("id");
|
||||
|
||||
|
@ -173,7 +173,7 @@ public class RegisterServiceServlet extends HttpServlet {
|
|||
request.getSession().setAttribute("value", jwksString);
|
||||
|
||||
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);
|
||||
canProceed = false;
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ public class RegisterServiceServlet extends HttpServlet {
|
|||
serverRequestJSON = createServiceJson(null, name, email, jwks);
|
||||
}
|
||||
if(serverRequestJSON != null) {
|
||||
System.out.println("SERVER JSON " + serverRequestJSON);
|
||||
//System.out.println("SERVER JSON " + serverRequestJSON);
|
||||
serverMessage = tokenUtils.registerService(serverRequestJSON);
|
||||
logger.debug(serverMessage);
|
||||
if (serverMessage == null) {
|
||||
|
@ -252,7 +252,7 @@ public class RegisterServiceServlet extends HttpServlet {
|
|||
response.sendRedirect("./registeredServices");
|
||||
|
||||
} else {
|
||||
System.out.println("In edit...");
|
||||
//System.out.println("In edit...");
|
||||
try {
|
||||
serviceIdInt = Integer.parseInt(serviceId);
|
||||
if (!registeredServicesUtils.isAuthorized(authentication.getSub(), serviceIdInt)) {
|
||||
|
@ -272,13 +272,13 @@ public class RegisterServiceServlet extends HttpServlet {
|
|||
serverRequestJSON = createServiceJson(registeredService.getClientId(), name, email, jwks);
|
||||
}
|
||||
if (serverRequestJSON != null) {
|
||||
System.out.println("SERVER JSON " + serverRequestJSON);
|
||||
//System.out.println("SERVER JSON " + serverRequestJSON);
|
||||
HttpResponse resp = tokenUtils.updateService(registeredService.getClientId(), serverRequestJSON, registeredService.getRegistrationAccessToken());
|
||||
if (resp.getStatusLine().getStatusCode() == 200) {
|
||||
System.out.println("NAME >>>>" + name);
|
||||
//System.out.println("NAME >>>>" + name);
|
||||
registeredService.setName(name);
|
||||
|
||||
System.out.println("Client Id " + registeredService.getClientId());
|
||||
//System.out.println("Client Id " + registeredService.getClientId());
|
||||
try {
|
||||
registeredServicesUtils.getRegisteredServiceDao().update(registeredService);
|
||||
} catch (SQLException sqle) {
|
||||
|
@ -392,7 +392,7 @@ public class RegisterServiceServlet extends HttpServlet {
|
|||
GsonBuilder builder = new GsonBuilder();
|
||||
builder.serializeNulls();
|
||||
Gson gson = builder.create();
|
||||
System.out.println("Created json " + serviceJSON);
|
||||
//System.out.println("Created json " + serviceJSON);
|
||||
return gson.toJson(serviceJSON);
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ public class RegisterServiceServlet extends HttpServlet {
|
|||
GsonBuilder builder = new GsonBuilder();
|
||||
builder.serializeNulls();
|
||||
Gson gson = builder.create();
|
||||
System.out.println("Created json " + serviceJSON);
|
||||
//System.out.println("Created json " + serviceJSON);
|
||||
return gson.toJson(serviceJSON);
|
||||
}
|
||||
|
||||
|
@ -420,7 +420,7 @@ public class RegisterServiceServlet extends HttpServlet {
|
|||
GsonBuilder builder = new GsonBuilder();
|
||||
builder.serializeNulls();
|
||||
Gson gson = builder.create();
|
||||
System.out.println("Created json " + serviceJSON);
|
||||
//System.out.println("Created json " + serviceJSON);
|
||||
return gson.toJson(serviceJSON);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public class RegisterServlet extends HttpServlet {
|
|||
String gRecaptchaResponse = request.getParameter("g-recaptcha-response");
|
||||
|
||||
boolean isRecaptchaVerified = VerifyRecaptcha.verify(gRecaptchaResponse, secret);
|
||||
//System.out.println("RESPONSE " + gRecaptchaResponse);
|
||||
////System.out.println("RESPONSE " + gRecaptchaResponse);
|
||||
|
||||
if (organization == null){
|
||||
logger.info("organization is null");
|
||||
|
|
|
@ -55,7 +55,7 @@ public class RegisteredServicesServlet extends HttpServlet {
|
|||
try {
|
||||
registeredServices = registeredServicesUtils.
|
||||
getRegisteredServiceDao().fetchAllRegisteredServicesByOwner(userId);
|
||||
System.out.println("LOAD REGISTERED SERVICES. " + registeredServices.size());
|
||||
//System.out.println("LOAD REGISTERED SERVICES. " + registeredServices.size());
|
||||
|
||||
if (registeredServices.isEmpty()) {
|
||||
request.getSession().setAttribute("showEmptyList", true);
|
||||
|
@ -74,7 +74,7 @@ public class RegisteredServicesServlet extends HttpServlet {
|
|||
name.append(authentication.getUserInfo().getFamilyName().charAt(0));
|
||||
request.getSession().setAttribute("name", name.toString());
|
||||
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("keys", serviceKey);
|
||||
|
@ -102,7 +102,7 @@ public class RegisteredServicesServlet extends HttpServlet {
|
|||
|
||||
private String extractJSONJwk(Jwks jwks) {
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
System.out.println(gson.toJson(jwks));
|
||||
//System.out.println(gson.toJson(jwks));
|
||||
return gson.toJson(jwks);
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ public class RegisteredServicesServlet extends HttpServlet {
|
|||
getContext().getAuthentication();
|
||||
String id = request.getParameter("id");
|
||||
|
||||
System.out.println("POST " +id);
|
||||
//System.out.println("POST " +id);
|
||||
|
||||
if (id!=null && !id.isEmpty()) {
|
||||
try {
|
||||
|
@ -120,7 +120,7 @@ public class RegisteredServicesServlet extends HttpServlet {
|
|||
|
||||
if (!registeredService.getOwner().equals(authentication.getSub())) {
|
||||
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");
|
||||
return;
|
||||
}
|
||||
|
@ -128,18 +128,18 @@ public class RegisteredServicesServlet extends HttpServlet {
|
|||
HttpResponse resp = tokenUtils.deleteService(registeredService.getClientId(), registeredService.getRegistrationAccessToken());
|
||||
|
||||
int statusCode = resp.getStatusLine().getStatusCode();
|
||||
System.out.println("STATUS CODE " + statusCode);
|
||||
//System.out.println("STATUS CODE " + statusCode);
|
||||
|
||||
if (statusCode != 204) {
|
||||
logger.error("Unable to delete the service. Status code was " + 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");
|
||||
return;
|
||||
} else {
|
||||
registeredServicesUtils.getRegisteredServiceDao().delete(Integer.parseInt(id));
|
||||
request.getSession().setAttribute("success", "The service was successfully deleted.");
|
||||
System.out.println("HERE HERE");
|
||||
//System.out.println("HERE HERE");
|
||||
}
|
||||
|
||||
} catch (SQLException sqle) {
|
||||
|
|
|
@ -25,14 +25,10 @@ public class RegisteredServicesUtils {
|
|||
}
|
||||
|
||||
public boolean isAuthorized(String userid, int id) throws SQLException {
|
||||
System.out.println("I AM HERE....");
|
||||
RegisteredService registeredService = registeredServiceDao.fetchRegisteredServiceById(id);
|
||||
if (registeredService == null) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public class TokenUtils {
|
|||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
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) {
|
||||
//logger.debug(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 {
|
||||
|
||||
System.out.println("DELETE " + issuer + "register/"+serviceId);
|
||||
//System.out.println("DELETE " + issuer + "register/"+serviceId);
|
||||
HttpDelete httpDelete = new HttpDelete(issuer + "register/"+serviceId);
|
||||
httpDelete.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
|
||||
httpDelete.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + registeredAccessToken);
|
||||
|
@ -72,14 +72,14 @@ public class TokenUtils {
|
|||
}
|
||||
|
||||
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.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + registeredAccessToken);
|
||||
|
||||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
HttpResponse httpResponse = httpclient.execute(httpGet);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue