@Test public void testAuthenticationEndpointExists() { ZosmfService zosmfService = getZosmfServiceSpy(); HttpClientErrorException responseException = new HttpClientErrorException(HttpStatus.UNAUTHORIZED); prepareAuthenticationEndpoint(zosmfService, responseException); assertTrue(zosmfService.authenticationEndpointExists(HttpMethod.POST)); }
@Cacheable("zosmfAuthenticationEndpoint") public boolean authenticationEndpointExists(HttpMethod httpMethod) { String url = getURI(getZosmfServiceId()) + ZOSMF_AUTHENTICATE_END_POINT; final HttpHeaders headers = new HttpHeaders(); headers.add(ZOSMF_CSRF_HEADER, ""); try { restTemplateWithoutKeystore.exchange(url, httpMethod, new HttpEntity<>(null, headers), String.class); } catch (HttpClientErrorException hce) { if (hce.getStatusCode().equals(HttpStatus.UNAUTHORIZED)) { return true; } else if (hce.getStatusCode().equals(HttpStatus.NOT_FOUND)) { log.warn("The check of z/OSMF JWT authentication endpoint has failed, ensure APAR PH12143 " + "(https: "Using z/OSMF info endpoint as backup."); return false; } log.warn("The check of z/OSMF JWT authentication endpoint has failed with exception", hce); } catch (RuntimeException re) { log.warn("The check of z/OSMF JWT authentication endpoint has failed with exception", re); } return false; }
ZosmfService extends AbstractZosmfService { @Cacheable("zosmfAuthenticationEndpoint") public boolean authenticationEndpointExists(HttpMethod httpMethod) { String url = getURI(getZosmfServiceId()) + ZOSMF_AUTHENTICATE_END_POINT; final HttpHeaders headers = new HttpHeaders(); headers.add(ZOSMF_CSRF_HEADER, ""); try { restTemplateWithoutKeystore.exchange(url, httpMethod, new HttpEntity<>(null, headers), String.class); } catch (HttpClientErrorException hce) { if (hce.getStatusCode().equals(HttpStatus.UNAUTHORIZED)) { return true; } else if (hce.getStatusCode().equals(HttpStatus.NOT_FOUND)) { log.warn("The check of z/OSMF JWT authentication endpoint has failed, ensure APAR PH12143 " + "(https: "Using z/OSMF info endpoint as backup."); return false; } log.warn("The check of z/OSMF JWT authentication endpoint has failed with exception", hce); } catch (RuntimeException re) { log.warn("The check of z/OSMF JWT authentication endpoint has failed with exception", re); } return false; } }
ZosmfService extends AbstractZosmfService { @Cacheable("zosmfAuthenticationEndpoint") public boolean authenticationEndpointExists(HttpMethod httpMethod) { String url = getURI(getZosmfServiceId()) + ZOSMF_AUTHENTICATE_END_POINT; final HttpHeaders headers = new HttpHeaders(); headers.add(ZOSMF_CSRF_HEADER, ""); try { restTemplateWithoutKeystore.exchange(url, httpMethod, new HttpEntity<>(null, headers), String.class); } catch (HttpClientErrorException hce) { if (hce.getStatusCode().equals(HttpStatus.UNAUTHORIZED)) { return true; } else if (hce.getStatusCode().equals(HttpStatus.NOT_FOUND)) { log.warn("The check of z/OSMF JWT authentication endpoint has failed, ensure APAR PH12143 " + "(https: "Using z/OSMF info endpoint as backup."); return false; } log.warn("The check of z/OSMF JWT authentication endpoint has failed with exception", hce); } catch (RuntimeException re) { log.warn("The check of z/OSMF JWT authentication endpoint has failed with exception", re); } return false; } ZosmfService(
        final AuthConfigurationProperties authConfigurationProperties,
        final DiscoveryClient discovery,
        final @Qualifier("restTemplateWithoutKeystore") RestTemplate restTemplateWithoutKeystore,
        final ObjectMapper securityObjectMapper
    ); }
ZosmfService extends AbstractZosmfService { @Cacheable("zosmfAuthenticationEndpoint") public boolean authenticationEndpointExists(HttpMethod httpMethod) { String url = getURI(getZosmfServiceId()) + ZOSMF_AUTHENTICATE_END_POINT; final HttpHeaders headers = new HttpHeaders(); headers.add(ZOSMF_CSRF_HEADER, ""); try { restTemplateWithoutKeystore.exchange(url, httpMethod, new HttpEntity<>(null, headers), String.class); } catch (HttpClientErrorException hce) { if (hce.getStatusCode().equals(HttpStatus.UNAUTHORIZED)) { return true; } else if (hce.getStatusCode().equals(HttpStatus.NOT_FOUND)) { log.warn("The check of z/OSMF JWT authentication endpoint has failed, ensure APAR PH12143 " + "(https: "Using z/OSMF info endpoint as backup."); return false; } log.warn("The check of z/OSMF JWT authentication endpoint has failed with exception", hce); } catch (RuntimeException re) { log.warn("The check of z/OSMF JWT authentication endpoint has failed with exception", re); } return false; } ZosmfService(
        final AuthConfigurationProperties authConfigurationProperties,
        final DiscoveryClient discovery,
        final @Qualifier("restTemplateWithoutKeystore") RestTemplate restTemplateWithoutKeystore,
        final ObjectMapper securityObjectMapper
    ); AuthenticationResponse authenticate(Authentication authentication); @Cacheable("zosmfInfo") String getZosmfRealm(String infoURIEndpoint); @Cacheable("zosmfAuthenticationEndpoint") boolean authenticationEndpointExists(HttpMethod httpMethod); void validate(TokenType type, String token); void invalidate(TokenType type, String token); JWKSet getPublicKeys(); }
ZosmfService extends AbstractZosmfService { @Cacheable("zosmfAuthenticationEndpoint") public boolean authenticationEndpointExists(HttpMethod httpMethod) { String url = getURI(getZosmfServiceId()) + ZOSMF_AUTHENTICATE_END_POINT; final HttpHeaders headers = new HttpHeaders(); headers.add(ZOSMF_CSRF_HEADER, ""); try { restTemplateWithoutKeystore.exchange(url, httpMethod, new HttpEntity<>(null, headers), String.class); } catch (HttpClientErrorException hce) { if (hce.getStatusCode().equals(HttpStatus.UNAUTHORIZED)) { return true; } else if (hce.getStatusCode().equals(HttpStatus.NOT_FOUND)) { log.warn("The check of z/OSMF JWT authentication endpoint has failed, ensure APAR PH12143 " + "(https: "Using z/OSMF info endpoint as backup."); return false; } log.warn("The check of z/OSMF JWT authentication endpoint has failed with exception", hce); } catch (RuntimeException re) { log.warn("The check of z/OSMF JWT authentication endpoint has failed with exception", re); } return false; } ZosmfService(
        final AuthConfigurationProperties authConfigurationProperties,
        final DiscoveryClient discovery,
        final @Qualifier("restTemplateWithoutKeystore") RestTemplate restTemplateWithoutKeystore,
        final ObjectMapper securityObjectMapper
    ); AuthenticationResponse authenticate(Authentication authentication); @Cacheable("zosmfInfo") String getZosmfRealm(String infoURIEndpoint); @Cacheable("zosmfAuthenticationEndpoint") boolean authenticationEndpointExists(HttpMethod httpMethod); void validate(TokenType type, String token); void invalidate(TokenType type, String token); JWKSet getPublicKeys();  }