Skip to content

Commit

Permalink
fixes #2 exchange completed already
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehu committed Nov 2, 2016
1 parent caa281e commit 668d632
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception {
Status status = new Status(STATUS_INVALID_REQUEST_PATH);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
}

final NormalisedPath swaggerPathString = maybeApiPath.get();
Expand All @@ -99,6 +100,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception {
Status status = new Status(STATUS_METHOD_NOT_ALLOWED);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
}
swaggerOperation = new SwaggerOperation(swaggerPathString, swaggerPath, httpMethod, operation);
swaggerOperation.setEndpoint(swaggerPathString.normalised() + "@" + httpMethod);
Expand All @@ -123,10 +125,12 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception {
Status status = new Status(STATUS_INVALID_SCOPE_TOKEN);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
} catch (ExpiredTokenException e) {
Status status = new Status(STATUS_SCOPE_TOKEN_EXPIRED);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
}
}

Expand All @@ -149,6 +153,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception {
Status status = new Status(STATUS_SCOPE_TOKEN_SCOPE_MISMATCH);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
}
} else {
// no scope token, verify scope from auth token.
Expand All @@ -160,6 +165,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception {
Status status = new Status(STATUS_INVALID_AUTH_TOKEN);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
}
if (!matchedScopes(primaryScopes, specScopes)) {
if(logger.isDebugEnabled()) {
Expand All @@ -168,6 +174,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception {
Status status = new Status(STATUS_AUTH_TOKEN_SCOPE_MISMATCH);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
}
}
}
Expand All @@ -178,15 +185,18 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception {
Status status = new Status(STATUS_INVALID_AUTH_TOKEN);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
} catch (ExpiredTokenException e) {
Status status = new Status(STATUS_AUTH_TOKEN_EXPIRED);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
}
} else {
Status status = new Status(STATUS_MISSING_AUTH_TOKEN);
exchange.setStatusCode(status.getStatusCode());
exchange.getResponseSender().send(status.toString());
return;
}
}

Expand Down

0 comments on commit 668d632

Please sign in to comment.