Skip to content

Commit 3036dd7

Browse files
author
Steve Cody
committed
Improve debug logging
1 parent 76c413b commit 3036dd7

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/main/java/lti/oauth/OAuthFilter.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res
6363
, FilterChain fc) throws ServletException, IOException {
6464

6565
logger.debug("In OAuthFilter");
66-
logger.debug(req.getMethod());
66+
logger.debug("Method Type: " + req.getMethod());
6767

6868
// Only apply the filter to LTI tool launches (HTTP POSTS)
6969
// Seems like there would be a way to configure the filter to
@@ -75,17 +75,21 @@ protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res
7575
String consumerKey = alphaSortedMap.get(OAuthUtil.CONSUMER_KEY_PARAM);
7676

7777
Tenant tenant = tenantRepository.findByConsumersOauthConsumerKey(consumerKey);
78-
78+
logger.debug("consumerKey: " + consumerKey);
7979

8080

8181
if (tenant == null) {
82+
logger.debug("tenant was null for consumerKey: " + consumerKey);
8283
res.sendRedirect("/errorpage");
8384
return;
8485
}
8586

87+
logger.debug("TenantFound: " + tenant.toString());
88+
8689
Set<Consumer> consumers = tenant.getConsumers();
8790

8891
if (consumers == null || consumers.isEmpty()) {
92+
logger.debug("OAUTH_MISSING_KEY");
8993
throw new MissingTenantException("OAUTH_MISSING_KEY");
9094
}
9195

@@ -101,6 +105,10 @@ protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res
101105
logger.error(e.getMessage(), e);
102106
throw new ServletException("OAUTH_CALCULATION_ERROR");
103107
}
108+
109+
logger.debug("Signature: " + signature);
110+
logger.debug("Calculated Signature: " + calculatedSignature);
111+
104112

105113
// retry by switch prefix between https and http
106114
if (!signature.equals(calculatedSignature)) {
@@ -122,6 +130,9 @@ protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res
122130
logger.error(e.getMessage(), e);
123131
throw new ServletException("OAUTH_CALCULATION_ERROR");
124132
}
133+
134+
logger.debug("recalculatedSignature Signature: " + recalculatedSignature);
135+
125136
if (!signature.equals(recalculatedSignature)) {
126137
throw new AuthorizationServiceException("OAUTH_SIGNATURE_MISMATCH");
127138
}

src/main/java/od/ExceptionFilter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public class ExceptionFilter extends OncePerRequestFilter {
4242
private static final Logger logger = LoggerFactory.getLogger(ExceptionFilter.class);
4343

4444
@Override
45-
protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain fc) throws ServletException, IOException {
46-
logger.debug("In ExceptionFilter");
45+
protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain fc) throws ServletException, IOException {
4746

4847
try {
4948
fc.doFilter(req, res);
@@ -58,12 +57,15 @@ protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res,
5857
catch (MissingCookieException missingCookieException) {
5958
// getting a little creative with the status code here
6059
// want to distiguish from unauthorized
60+
logger.debug("Missing Cookie Exception", missingCookieException);
6161
res.sendError(HttpStatus.NOT_ACCEPTABLE.value(), "COOKIE_ERROR");
6262
}
6363
catch (AuthorizationServiceException authorizationServiceException) {
64+
logger.debug("AuthorizationServiceException", authorizationServiceException);
6465
res.sendError(HttpStatus.UNAUTHORIZED.value(), "AUTHORIZATION_ERROR");
6566
}
6667
catch(Throwable t) {
68+
logger.debug("some throwable ", t);
6769
res.sendError(HttpStatus.INTERNAL_SERVER_ERROR.value(), "GENERAL_ERROR");
6870
}
6971

0 commit comments

Comments
 (0)