@Test void testValidateJwtSvid_nullToken() { try { JwtSvid jwtSvid = workloadApiClient.validateJwtSvid(null, "aud1"); } catch (NullPointerException e) { assertEquals("token is marked non-null but is null", e.getMessage()); } catch (JwtSvidException e) { fail(); } }
@Override public JwtSvid validateJwtSvid(@NonNull final String token, @NonNull final String audience) throws JwtSvidException { val request = createJwtSvidRequest(token, audience); Workload.ValidateJWTSVIDResponse response; try (val cancellableContext = Context.current().withCancellation()) { response = cancellableContext.call(() -> workloadApiBlockingStub.validateJWTSVID(request)); } catch (Exception e) { throw new JwtSvidException("Error validating JWT SVID", e); } if (response == null || StringUtils.isBlank(response.getSpiffeId())) { throw new JwtSvidException("Error validating JWT SVID. Empty response from Workload API"); } return JwtSvid.parseInsecure(token, Collections.singleton(audience)); }
DefaultWorkloadApiClient implements WorkloadApiClient { @Override public JwtSvid validateJwtSvid(@NonNull final String token, @NonNull final String audience) throws JwtSvidException { val request = createJwtSvidRequest(token, audience); Workload.ValidateJWTSVIDResponse response; try (val cancellableContext = Context.current().withCancellation()) { response = cancellableContext.call(() -> workloadApiBlockingStub.validateJWTSVID(request)); } catch (Exception e) { throw new JwtSvidException("Error validating JWT SVID", e); } if (response == null || StringUtils.isBlank(response.getSpiffeId())) { throw new JwtSvidException("Error validating JWT SVID. Empty response from Workload API"); } return JwtSvid.parseInsecure(token, Collections.singleton(audience)); } }
DefaultWorkloadApiClient implements WorkloadApiClient { @Override public JwtSvid validateJwtSvid(@NonNull final String token, @NonNull final String audience) throws JwtSvidException { val request = createJwtSvidRequest(token, audience); Workload.ValidateJWTSVIDResponse response; try (val cancellableContext = Context.current().withCancellation()) { response = cancellableContext.call(() -> workloadApiBlockingStub.validateJWTSVID(request)); } catch (Exception e) { throw new JwtSvidException("Error validating JWT SVID", e); } if (response == null || StringUtils.isBlank(response.getSpiffeId())) { throw new JwtSvidException("Error validating JWT SVID. Empty response from Workload API"); } return JwtSvid.parseInsecure(token, Collections.singleton(audience)); } private  DefaultWorkloadApiClient(final SpiffeWorkloadAPIStub workloadApiAsyncStub,
                                     final SpiffeWorkloadAPIBlockingStub workloadApiBlockingStub,
                                     final ManagedChannelWrapper managedChannel,
                                     final ExponentialBackoffPolicy exponentialBackoffPolicy,
                                     final ScheduledExecutorService retryExecutor,
                                     final ExecutorService executorService);   DefaultWorkloadApiClient(final SpiffeWorkloadAPIStub workloadApiAsyncStub,
                             final SpiffeWorkloadAPIBlockingStub workloadApiBlockingStub,
                             final ManagedChannelWrapper managedChannel,
                             final ExponentialBackoffPolicy backoffPolicy); }
DefaultWorkloadApiClient implements WorkloadApiClient { @Override public JwtSvid validateJwtSvid(@NonNull final String token, @NonNull final String audience) throws JwtSvidException { val request = createJwtSvidRequest(token, audience); Workload.ValidateJWTSVIDResponse response; try (val cancellableContext = Context.current().withCancellation()) { response = cancellableContext.call(() -> workloadApiBlockingStub.validateJWTSVID(request)); } catch (Exception e) { throw new JwtSvidException("Error validating JWT SVID", e); } if (response == null || StringUtils.isBlank(response.getSpiffeId())) { throw new JwtSvidException("Error validating JWT SVID. Empty response from Workload API"); } return JwtSvid.parseInsecure(token, Collections.singleton(audience)); } private  DefaultWorkloadApiClient(final SpiffeWorkloadAPIStub workloadApiAsyncStub,
                                     final SpiffeWorkloadAPIBlockingStub workloadApiBlockingStub,
                                     final ManagedChannelWrapper managedChannel,
                                     final ExponentialBackoffPolicy exponentialBackoffPolicy,
                                     final ScheduledExecutorService retryExecutor,
                                     final ExecutorService executorService);   DefaultWorkloadApiClient(final SpiffeWorkloadAPIStub workloadApiAsyncStub,
                             final SpiffeWorkloadAPIBlockingStub workloadApiBlockingStub,
                             final ManagedChannelWrapper managedChannel,
                             final ExponentialBackoffPolicy backoffPolicy); static WorkloadApiClient newClient(); static WorkloadApiClient newClient(@NonNull final ClientOptions options); @Override X509Context fetchX509Context(); @Override void watchX509Context(@NonNull final Watcher<X509Context> watcher); @Override JwtSvid fetchJwtSvid(@NonNull String audience, String... extraAudience); @Override JwtSvid fetchJwtSvid(@NonNull final SpiffeId subject,
                                @NonNull final String audience,
                                final String... extraAudience); @Override JwtBundleSet fetchJwtBundles(); @Override JwtSvid validateJwtSvid(@NonNull final String token, @NonNull final String audience); @Override void watchJwtBundles(@NonNull final Watcher<JwtBundleSet> watcher); @Override void close(); }
DefaultWorkloadApiClient implements WorkloadApiClient { @Override public JwtSvid validateJwtSvid(@NonNull final String token, @NonNull final String audience) throws JwtSvidException { val request = createJwtSvidRequest(token, audience); Workload.ValidateJWTSVIDResponse response; try (val cancellableContext = Context.current().withCancellation()) { response = cancellableContext.call(() -> workloadApiBlockingStub.validateJWTSVID(request)); } catch (Exception e) { throw new JwtSvidException("Error validating JWT SVID", e); } if (response == null || StringUtils.isBlank(response.getSpiffeId())) { throw new JwtSvidException("Error validating JWT SVID. Empty response from Workload API"); } return JwtSvid.parseInsecure(token, Collections.singleton(audience)); } private  DefaultWorkloadApiClient(final SpiffeWorkloadAPIStub workloadApiAsyncStub,
                                     final SpiffeWorkloadAPIBlockingStub workloadApiBlockingStub,
                                     final ManagedChannelWrapper managedChannel,
                                     final ExponentialBackoffPolicy exponentialBackoffPolicy,
                                     final ScheduledExecutorService retryExecutor,
                                     final ExecutorService executorService);   DefaultWorkloadApiClient(final SpiffeWorkloadAPIStub workloadApiAsyncStub,
                             final SpiffeWorkloadAPIBlockingStub workloadApiBlockingStub,
                             final ManagedChannelWrapper managedChannel,
                             final ExponentialBackoffPolicy backoffPolicy); static WorkloadApiClient newClient(); static WorkloadApiClient newClient(@NonNull final ClientOptions options); @Override X509Context fetchX509Context(); @Override void watchX509Context(@NonNull final Watcher<X509Context> watcher); @Override JwtSvid fetchJwtSvid(@NonNull String audience, String... extraAudience); @Override JwtSvid fetchJwtSvid(@NonNull final SpiffeId subject,
                                @NonNull final String audience,
                                final String... extraAudience); @Override JwtBundleSet fetchJwtBundles(); @Override JwtSvid validateJwtSvid(@NonNull final String token, @NonNull final String audience); @Override void watchJwtBundles(@NonNull final Watcher<JwtBundleSet> watcher); @Override void close();  }