@Test public void testAbstain() { SecurityEnvironment se = SecurityEnvironment.create(); EndpointConfig ep = EndpointConfig.create(); ProviderRequest request = mock(ProviderRequest.class); when(request.env()).thenReturn(se); when(request.endpointConfig()).thenReturn(ep); AtzProviderSync provider = new AtzProviderSync(); AuthorizationResponse response = provider.syncAuthorize(request); assertThat(response.status(), is(SecurityResponse.SecurityStatus.ABSTAIN)); }
@Override protected AuthorizationResponse syncAuthorize(ProviderRequest providerRequest) { return providerRequest.env().path() .map(path -> { if (path.contains("public")) { return AuthorizationResponse.permit(); } if (providerRequest.securityContext().isAuthenticated()) { return AuthorizationResponse.permit(); } else { return AuthorizationResponse.deny(); } }).orElse(AuthorizationResponse.abstain()); }
AtzProviderSync extends SynchronousProvider implements AuthorizationProvider { @Override protected AuthorizationResponse syncAuthorize(ProviderRequest providerRequest) { return providerRequest.env().path() .map(path -> { if (path.contains("public")) { return AuthorizationResponse.permit(); } if (providerRequest.securityContext().isAuthenticated()) { return AuthorizationResponse.permit(); } else { return AuthorizationResponse.deny(); } }).orElse(AuthorizationResponse.abstain()); } }
AtzProviderSync extends SynchronousProvider implements AuthorizationProvider { @Override protected AuthorizationResponse syncAuthorize(ProviderRequest providerRequest) { return providerRequest.env().path() .map(path -> { if (path.contains("public")) { return AuthorizationResponse.permit(); } if (providerRequest.securityContext().isAuthenticated()) { return AuthorizationResponse.permit(); } else { return AuthorizationResponse.deny(); } }).orElse(AuthorizationResponse.abstain()); }  }
AtzProviderSync extends SynchronousProvider implements AuthorizationProvider { @Override protected AuthorizationResponse syncAuthorize(ProviderRequest providerRequest) { return providerRequest.env().path() .map(path -> { if (path.contains("public")) { return AuthorizationResponse.permit(); } if (providerRequest.securityContext().isAuthenticated()) { return AuthorizationResponse.permit(); } else { return AuthorizationResponse.deny(); } }).orElse(AuthorizationResponse.abstain()); }   }
AtzProviderSync extends SynchronousProvider implements AuthorizationProvider { @Override protected AuthorizationResponse syncAuthorize(ProviderRequest providerRequest) { return providerRequest.env().path() .map(path -> { if (path.contains("public")) { return AuthorizationResponse.permit(); } if (providerRequest.securityContext().isAuthenticated()) { return AuthorizationResponse.permit(); } else { return AuthorizationResponse.deny(); } }).orElse(AuthorizationResponse.abstain()); }    }