@Test public void testInbound() { ProviderRequest inboundRequest = createInboundRequest("Authorization", "bearer " + TOKEN_VALUE); AuthenticationResponse response = provider.syncAuthenticate(inboundRequest); assertThat(response.user(), is(not(Optional.empty()))); response.user().ifPresent(subject -> { Principal principal = subject.principal(); assertThat(principal.getName(), is(name)); assertThat(principal.id(), is(userId)); }); }
@Override protected AuthenticationResponse syncAuthenticate(ProviderRequest providerRequest) { Optional<String> maybeToken; try { maybeToken = tokenHandler.extractToken(providerRequest.env().headers()); } catch (Exception e) { return failInvalidRequest(e); } SecurityContext sContext = providerRequest.securityContext(); return maybeToken .map(token -> cachedResponse(token, sContext.tracer(), sContext.tracingSpan())) .orElseGet(this::failNoToken); }
GoogleTokenProvider extends SynchronousProvider implements AuthenticationProvider, OutboundSecurityProvider { @Override protected AuthenticationResponse syncAuthenticate(ProviderRequest providerRequest) { Optional<String> maybeToken; try { maybeToken = tokenHandler.extractToken(providerRequest.env().headers()); } catch (Exception e) { return failInvalidRequest(e); } SecurityContext sContext = providerRequest.securityContext(); return maybeToken .map(token -> cachedResponse(token, sContext.tracer(), sContext.tracingSpan())) .orElseGet(this::failNoToken); } }
GoogleTokenProvider extends SynchronousProvider implements AuthenticationProvider, OutboundSecurityProvider { @Override protected AuthenticationResponse syncAuthenticate(ProviderRequest providerRequest) { Optional<String> maybeToken; try { maybeToken = tokenHandler.extractToken(providerRequest.env().headers()); } catch (Exception e) { return failInvalidRequest(e); } SecurityContext sContext = providerRequest.securityContext(); return maybeToken .map(token -> cachedResponse(token, sContext.tracer(), sContext.tracingSpan())) .orElseGet(this::failNoToken); } private  GoogleTokenProvider(Builder builder); }
GoogleTokenProvider extends SynchronousProvider implements AuthenticationProvider, OutboundSecurityProvider { @Override protected AuthenticationResponse syncAuthenticate(ProviderRequest providerRequest) { Optional<String> maybeToken; try { maybeToken = tokenHandler.extractToken(providerRequest.env().headers()); } catch (Exception e) { return failInvalidRequest(e); } SecurityContext sContext = providerRequest.securityContext(); return maybeToken .map(token -> cachedResponse(token, sContext.tracer(), sContext.tracingSpan())) .orElseGet(this::failNoToken); } private  GoogleTokenProvider(Builder builder); static GoogleTokenProvider create(Config config); static Builder builder(); @Override boolean isOutboundSupported(ProviderRequest providerRequest,
                                       SecurityEnvironment outboundEnv,
                                       EndpointConfig outboundConfig); }
GoogleTokenProvider extends SynchronousProvider implements AuthenticationProvider, OutboundSecurityProvider { @Override protected AuthenticationResponse syncAuthenticate(ProviderRequest providerRequest) { Optional<String> maybeToken; try { maybeToken = tokenHandler.extractToken(providerRequest.env().headers()); } catch (Exception e) { return failInvalidRequest(e); } SecurityContext sContext = providerRequest.securityContext(); return maybeToken .map(token -> cachedResponse(token, sContext.tracer(), sContext.tracingSpan())) .orElseGet(this::failNoToken); } private  GoogleTokenProvider(Builder builder); static GoogleTokenProvider create(Config config); static Builder builder(); @Override boolean isOutboundSupported(ProviderRequest providerRequest,
                                       SecurityEnvironment outboundEnv,
                                       EndpointConfig outboundConfig);  }