@Test public void testIsAccessAllowed_Disabled() { underTest = new AntiCsrfHelper(false, ""); assertThat(underTest.isAccessAllowed(httpServletRequest), is(true)); verifyZeroInteractions(httpServletRequest); }
public boolean isAccessAllowed(final HttpServletRequest httpRequest) { if (!enabled) { return true; } return isSafeHttpMethod(httpRequest) || isMultiPartFormDataPost(httpRequest) || isNotBrowserRequest(httpRequest) || isAntiCsrfTokenValid(httpRequest, Optional.ofNullable(httpRequest.getHeader(ANTI_CSRF_TOKEN_NAME))); }
AntiCsrfHelper extends ComponentSupport { public boolean isAccessAllowed(final HttpServletRequest httpRequest) { if (!enabled) { return true; } return isSafeHttpMethod(httpRequest) || isMultiPartFormDataPost(httpRequest) || isNotBrowserRequest(httpRequest) || isAntiCsrfTokenValid(httpRequest, Optional.ofNullable(httpRequest.getHeader(ANTI_CSRF_TOKEN_NAME))); } }
AntiCsrfHelper extends ComponentSupport { public boolean isAccessAllowed(final HttpServletRequest httpRequest) { if (!enabled) { return true; } return isSafeHttpMethod(httpRequest) || isMultiPartFormDataPost(httpRequest) || isNotBrowserRequest(httpRequest) || isAntiCsrfTokenValid(httpRequest, Optional.ofNullable(httpRequest.getHeader(ANTI_CSRF_TOKEN_NAME))); } @Inject  AntiCsrfHelper(
      @Named("${nexus.security.anticsrftoken.enabled:-true}") final boolean enabled,
      @Named("${nexus.security.anticsrftoken.whitelist}") @Nullable final String whitelist); }
AntiCsrfHelper extends ComponentSupport { public boolean isAccessAllowed(final HttpServletRequest httpRequest) { if (!enabled) { return true; } return isSafeHttpMethod(httpRequest) || isMultiPartFormDataPost(httpRequest) || isNotBrowserRequest(httpRequest) || isAntiCsrfTokenValid(httpRequest, Optional.ofNullable(httpRequest.getHeader(ANTI_CSRF_TOKEN_NAME))); } @Inject  AntiCsrfHelper(
      @Named("${nexus.security.anticsrftoken.enabled:-true}") final boolean enabled,
      @Named("${nexus.security.anticsrftoken.whitelist}") @Nullable final String whitelist); boolean isAccessAllowed(final HttpServletRequest httpRequest); void requireValidToken(final HttpServletRequest httpRequest, @Nullable final String token); boolean isEnabled(); }
AntiCsrfHelper extends ComponentSupport { public boolean isAccessAllowed(final HttpServletRequest httpRequest) { if (!enabled) { return true; } return isSafeHttpMethod(httpRequest) || isMultiPartFormDataPost(httpRequest) || isNotBrowserRequest(httpRequest) || isAntiCsrfTokenValid(httpRequest, Optional.ofNullable(httpRequest.getHeader(ANTI_CSRF_TOKEN_NAME))); } @Inject  AntiCsrfHelper(
      @Named("${nexus.security.anticsrftoken.enabled:-true}") final boolean enabled,
      @Named("${nexus.security.anticsrftoken.whitelist}") @Nullable final String whitelist); boolean isAccessAllowed(final HttpServletRequest httpRequest); void requireValidToken(final HttpServletRequest httpRequest, @Nullable final String token); boolean isEnabled(); static final String ENABLED; static final String ERROR_MESSAGE_TOKEN_MISMATCH; static final String ANTI_CSRF_TOKEN_NAME; }