class AuthenticationService {

    public Optional<String> getJwtTokenFromRequest(HttpServletRequest request) {
        Optional<String> fromCookie = getJwtTokenFromCookie(request);
        if (!fromCookie.isPresent()) {
            return extractJwtTokenFromAuthorizationHeader(request.getHeader(HttpHeaders.AUTHORIZATION));
        }
        return fromCookie;
    }

}