@Test public void testValidateJwt() { JwtPayload mockJwtPayload = new JwtPayload(); mockJwtPayload.setUserId(USER_ID); doReturn(mockJwtPayload).when(jwtAuthentication) .parseJwtPayload(CONFIGURATION_ID, MOCK_APP_TOKEN); ResponseEntity response = appAuthenticationResource.validate(CONFIGURATION_ID, REQUEST_VALIDATE); assertEquals(mockJwtPayload.getUserId(), response.getBody()); }
@PostMapping(value = "/validate") public ResponseEntity validate(@PathVariable String configurationId, @RequestBody String body) { JsonNode node = getJsonNode(JWT, VALIDATE, body); String jwt = node.path(JWT).asText(); validateRequiredParameter(jwt, JWT, VALIDATE); try { JwtPayload jwtPayload = jwtAuthentication.parseJwtPayload(configurationId, jwt); return ResponseEntity.ok().body(jwtPayload.getUserId()); } catch (Exception e) { ErrorResponse response = new ErrorResponse( HttpStatus.UNAUTHORIZED.value(), logMessage.getMessage(UNAUTHORIZED_JWT, jwt, e.getMessage())); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response); } }
ApplicationAuthenticationResource { @PostMapping(value = "/validate") public ResponseEntity validate(@PathVariable String configurationId, @RequestBody String body) { JsonNode node = getJsonNode(JWT, VALIDATE, body); String jwt = node.path(JWT).asText(); validateRequiredParameter(jwt, JWT, VALIDATE); try { JwtPayload jwtPayload = jwtAuthentication.parseJwtPayload(configurationId, jwt); return ResponseEntity.ok().body(jwtPayload.getUserId()); } catch (Exception e) { ErrorResponse response = new ErrorResponse( HttpStatus.UNAUTHORIZED.value(), logMessage.getMessage(UNAUTHORIZED_JWT, jwt, e.getMessage())); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response); } } }
ApplicationAuthenticationResource { @PostMapping(value = "/validate") public ResponseEntity validate(@PathVariable String configurationId, @RequestBody String body) { JsonNode node = getJsonNode(JWT, VALIDATE, body); String jwt = node.path(JWT).asText(); validateRequiredParameter(jwt, JWT, VALIDATE); try { JwtPayload jwtPayload = jwtAuthentication.parseJwtPayload(configurationId, jwt); return ResponseEntity.ok().body(jwtPayload.getUserId()); } catch (Exception e) { ErrorResponse response = new ErrorResponse( HttpStatus.UNAUTHORIZED.value(), logMessage.getMessage(UNAUTHORIZED_JWT, jwt, e.getMessage())); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response); } }  }
ApplicationAuthenticationResource { @PostMapping(value = "/validate") public ResponseEntity validate(@PathVariable String configurationId, @RequestBody String body) { JsonNode node = getJsonNode(JWT, VALIDATE, body); String jwt = node.path(JWT).asText(); validateRequiredParameter(jwt, JWT, VALIDATE); try { JwtPayload jwtPayload = jwtAuthentication.parseJwtPayload(configurationId, jwt); return ResponseEntity.ok().body(jwtPayload.getUserId()); } catch (Exception e) { ErrorResponse response = new ErrorResponse( HttpStatus.UNAUTHORIZED.value(), logMessage.getMessage(UNAUTHORIZED_JWT, jwt, e.getMessage())); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response); } }  @PostMapping(value = "/authenticate") ResponseEntity authenticate(@PathVariable String configurationId,
      @RequestBody String body); @PostMapping(value = "/validate") ResponseEntity validate(@PathVariable String configurationId, @RequestBody String body); @PostMapping(value = "/tokens/validate") ResponseEntity validateTokens(@PathVariable String configurationId,
      @RequestBody String body); }
ApplicationAuthenticationResource { @PostMapping(value = "/validate") public ResponseEntity validate(@PathVariable String configurationId, @RequestBody String body) { JsonNode node = getJsonNode(JWT, VALIDATE, body); String jwt = node.path(JWT).asText(); validateRequiredParameter(jwt, JWT, VALIDATE); try { JwtPayload jwtPayload = jwtAuthentication.parseJwtPayload(configurationId, jwt); return ResponseEntity.ok().body(jwtPayload.getUserId()); } catch (Exception e) { ErrorResponse response = new ErrorResponse( HttpStatus.UNAUTHORIZED.value(), logMessage.getMessage(UNAUTHORIZED_JWT, jwt, e.getMessage())); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response); } }  @PostMapping(value = "/authenticate") ResponseEntity authenticate(@PathVariable String configurationId,
      @RequestBody String body); @PostMapping(value = "/validate") ResponseEntity validate(@PathVariable String configurationId, @RequestBody String body); @PostMapping(value = "/tokens/validate") ResponseEntity validateTokens(@PathVariable String configurationId,
      @RequestBody String body);  }