@Test void getAuthentication() { when(ledgersUserMgmt.validate(anyString())).thenReturn(ResponseEntity.ok(getBearer())); UserAuthentication result = service.getAuthentication(TOKEN); assertThat(result).isEqualTo(new UserAuthentication(getBearer())); }
@Override public UserAuthentication getAuthentication(String accessToken) { if (StringUtils.isBlank(accessToken)) { return null; } BearerTokenTO bearerToken = null; try { authInterceptor.setAccessToken(accessToken); ResponseEntity<BearerTokenTO> responseEntity = ledgersUserMgmt.validate(accessToken); if (responseEntity.getStatusCode() == HttpStatus.OK) { bearerToken = responseEntity.getBody(); } } finally { authInterceptor.setAccessToken(null); } if (bearerToken == null) { debug("Token is not valid."); return null; } return new UserAuthentication(bearerToken); }
TokenAuthenticationServiceImpl implements TokenAuthenticationService { @Override public UserAuthentication getAuthentication(String accessToken) { if (StringUtils.isBlank(accessToken)) { return null; } BearerTokenTO bearerToken = null; try { authInterceptor.setAccessToken(accessToken); ResponseEntity<BearerTokenTO> responseEntity = ledgersUserMgmt.validate(accessToken); if (responseEntity.getStatusCode() == HttpStatus.OK) { bearerToken = responseEntity.getBody(); } } finally { authInterceptor.setAccessToken(null); } if (bearerToken == null) { debug("Token is not valid."); return null; } return new UserAuthentication(bearerToken); } }
TokenAuthenticationServiceImpl implements TokenAuthenticationService { @Override public UserAuthentication getAuthentication(String accessToken) { if (StringUtils.isBlank(accessToken)) { return null; } BearerTokenTO bearerToken = null; try { authInterceptor.setAccessToken(accessToken); ResponseEntity<BearerTokenTO> responseEntity = ledgersUserMgmt.validate(accessToken); if (responseEntity.getStatusCode() == HttpStatus.OK) { bearerToken = responseEntity.getBody(); } } finally { authInterceptor.setAccessToken(null); } if (bearerToken == null) { debug("Token is not valid."); return null; } return new UserAuthentication(bearerToken); }  }
TokenAuthenticationServiceImpl implements TokenAuthenticationService { @Override public UserAuthentication getAuthentication(String accessToken) { if (StringUtils.isBlank(accessToken)) { return null; } BearerTokenTO bearerToken = null; try { authInterceptor.setAccessToken(accessToken); ResponseEntity<BearerTokenTO> responseEntity = ledgersUserMgmt.validate(accessToken); if (responseEntity.getStatusCode() == HttpStatus.OK) { bearerToken = responseEntity.getBody(); } } finally { authInterceptor.setAccessToken(null); } if (bearerToken == null) { debug("Token is not valid."); return null; } return new UserAuthentication(bearerToken); }  @Override UserAuthentication getAuthentication(String accessToken); }
TokenAuthenticationServiceImpl implements TokenAuthenticationService { @Override public UserAuthentication getAuthentication(String accessToken) { if (StringUtils.isBlank(accessToken)) { return null; } BearerTokenTO bearerToken = null; try { authInterceptor.setAccessToken(accessToken); ResponseEntity<BearerTokenTO> responseEntity = ledgersUserMgmt.validate(accessToken); if (responseEntity.getStatusCode() == HttpStatus.OK) { bearerToken = responseEntity.getBody(); } } finally { authInterceptor.setAccessToken(null); } if (bearerToken == null) { debug("Token is not valid."); return null; } return new UserAuthentication(bearerToken); }  @Override UserAuthentication getAuthentication(String accessToken);  }