@Test public void testAbstain() { SecurityContext context = mock(SecurityContext.class); when(context.user()).thenReturn(Optional.empty()); when(context.service()).thenReturn(Optional.empty()); SecurityEnvironment se = SecurityEnvironment.create(); ProviderRequest request = mock(ProviderRequest.class); when(request.securityContext()).thenReturn(context); when(request.env()).thenReturn(se); OutboundProviderSync ops = new OutboundProviderSync(); OutboundSecurityResponse response = ops.syncOutbound(request, SecurityEnvironment.create(), EndpointConfig.create()); assertThat(response.status(), is(SecurityResponse.SecurityStatus.ABSTAIN)); }
@Override protected OutboundSecurityResponse syncOutbound(ProviderRequest providerRequest, SecurityEnvironment outboundEnv, EndpointConfig outboundEndpointConfig) { return providerRequest.securityContext() .user() .map(Subject::principal) .map(Principal::getName) .map(name -> OutboundSecurityResponse .withHeaders(Map.of("X-AUTH-USER", List.of(name)))) .orElse(OutboundSecurityResponse.abstain()); }
OutboundProviderSync extends SynchronousProvider implements OutboundSecurityProvider { @Override protected OutboundSecurityResponse syncOutbound(ProviderRequest providerRequest, SecurityEnvironment outboundEnv, EndpointConfig outboundEndpointConfig) { return providerRequest.securityContext() .user() .map(Subject::principal) .map(Principal::getName) .map(name -> OutboundSecurityResponse .withHeaders(Map.of("X-AUTH-USER", List.of(name)))) .orElse(OutboundSecurityResponse.abstain()); } }
OutboundProviderSync extends SynchronousProvider implements OutboundSecurityProvider { @Override protected OutboundSecurityResponse syncOutbound(ProviderRequest providerRequest, SecurityEnvironment outboundEnv, EndpointConfig outboundEndpointConfig) { return providerRequest.securityContext() .user() .map(Subject::principal) .map(Principal::getName) .map(name -> OutboundSecurityResponse .withHeaders(Map.of("X-AUTH-USER", List.of(name)))) .orElse(OutboundSecurityResponse.abstain()); }  }
OutboundProviderSync extends SynchronousProvider implements OutboundSecurityProvider { @Override protected OutboundSecurityResponse syncOutbound(ProviderRequest providerRequest, SecurityEnvironment outboundEnv, EndpointConfig outboundEndpointConfig) { return providerRequest.securityContext() .user() .map(Subject::principal) .map(Principal::getName) .map(name -> OutboundSecurityResponse .withHeaders(Map.of("X-AUTH-USER", List.of(name)))) .orElse(OutboundSecurityResponse.abstain()); }   }
OutboundProviderSync extends SynchronousProvider implements OutboundSecurityProvider { @Override protected OutboundSecurityResponse syncOutbound(ProviderRequest providerRequest, SecurityEnvironment outboundEnv, EndpointConfig outboundEndpointConfig) { return providerRequest.securityContext() .user() .map(Subject::principal) .map(Principal::getName) .map(name -> OutboundSecurityResponse .withHeaders(Map.of("X-AUTH-USER", List.of(name)))) .orElse(OutboundSecurityResponse.abstain()); }    }