@Test public void nullIfHeaderNotPresent() throws Exception { when(request.getHeader(AUTHORIZATION)).thenReturn(null); assertThat(underTest.extract(request), is(nullValue())); }
@Nullable @Override public String extract(final HttpServletRequest request) { final String headerValue = request.getHeader(AUTHORIZATION); if (headerValue != null && headerValue.startsWith("Bearer ")) { List<String> parts = Lists.newArrayList(Splitter.on(' ').split(headerValue)); if (parts.size() == 2 && "Bearer".equals(parts.get(0)) && matchesFormat(parts)) { return parts.get(1).replaceAll(format + ".", ""); } } return null; }
BearerToken implements ApiKeyExtractor { @Nullable @Override public String extract(final HttpServletRequest request) { final String headerValue = request.getHeader(AUTHORIZATION); if (headerValue != null && headerValue.startsWith("Bearer ")) { List<String> parts = Lists.newArrayList(Splitter.on(' ').split(headerValue)); if (parts.size() == 2 && "Bearer".equals(parts.get(0)) && matchesFormat(parts)) { return parts.get(1).replaceAll(format + ".", ""); } } return null; } }
BearerToken implements ApiKeyExtractor { @Nullable @Override public String extract(final HttpServletRequest request) { final String headerValue = request.getHeader(AUTHORIZATION); if (headerValue != null && headerValue.startsWith("Bearer ")) { List<String> parts = Lists.newArrayList(Splitter.on(' ').split(headerValue)); if (parts.size() == 2 && "Bearer".equals(parts.get(0)) && matchesFormat(parts)) { return parts.get(1).replaceAll(format + ".", ""); } } return null; } BearerToken(final String format); }
BearerToken implements ApiKeyExtractor { @Nullable @Override public String extract(final HttpServletRequest request) { final String headerValue = request.getHeader(AUTHORIZATION); if (headerValue != null && headerValue.startsWith("Bearer ")) { List<String> parts = Lists.newArrayList(Splitter.on(' ').split(headerValue)); if (parts.size() == 2 && "Bearer".equals(parts.get(0)) && matchesFormat(parts)) { return parts.get(1).replaceAll(format + ".", ""); } } return null; } BearerToken(final String format); @Nullable @Override String extract(final HttpServletRequest request); }
BearerToken implements ApiKeyExtractor { @Nullable @Override public String extract(final HttpServletRequest request) { final String headerValue = request.getHeader(AUTHORIZATION); if (headerValue != null && headerValue.startsWith("Bearer ")) { List<String> parts = Lists.newArrayList(Splitter.on(' ').split(headerValue)); if (parts.size() == 2 && "Bearer".equals(parts.get(0)) && matchesFormat(parts)) { return parts.get(1).replaceAll(format + ".", ""); } } return null; } BearerToken(final String format); @Nullable @Override String extract(final HttpServletRequest request);  }