@Test(expected = AuthenticationServiceException.class) public void testAuthenticeShouldThrowException() { ZosmfService zosmfService = getZosmfServiceSpy(); doThrow(new RestClientException("any exception")).when(restTemplate).exchange( anyString(), (HttpMethod) any(), (HttpEntity<?>) any(), (Class<?>) any() ); zosmfService.authenticate(new UsernamePasswordAuthenticationToken("user", "pass")); }
public AuthenticationResponse authenticate(Authentication authentication) { AuthenticationResponse authenticationResponse; if (authenticationEndpointExists(HttpMethod.POST)) { authenticationResponse = issueAuthenticationRequest( authentication, getURI(getZosmfServiceId()) + ZOSMF_AUTHENTICATE_END_POINT, HttpMethod.POST); } else { String zosmfInfoURIEndpoint = getURI(getZosmfServiceId()) + ZOSMF_INFO_END_POINT; authenticationResponse = issueAuthenticationRequest( authentication, zosmfInfoURIEndpoint, HttpMethod.GET); authenticationResponse.setDomain(getZosmfRealm(zosmfInfoURIEndpoint)); } return authenticationResponse; }
ZosmfService extends AbstractZosmfService { public AuthenticationResponse authenticate(Authentication authentication) { AuthenticationResponse authenticationResponse; if (authenticationEndpointExists(HttpMethod.POST)) { authenticationResponse = issueAuthenticationRequest( authentication, getURI(getZosmfServiceId()) + ZOSMF_AUTHENTICATE_END_POINT, HttpMethod.POST); } else { String zosmfInfoURIEndpoint = getURI(getZosmfServiceId()) + ZOSMF_INFO_END_POINT; authenticationResponse = issueAuthenticationRequest( authentication, zosmfInfoURIEndpoint, HttpMethod.GET); authenticationResponse.setDomain(getZosmfRealm(zosmfInfoURIEndpoint)); } return authenticationResponse; } }
ZosmfService extends AbstractZosmfService { public AuthenticationResponse authenticate(Authentication authentication) { AuthenticationResponse authenticationResponse; if (authenticationEndpointExists(HttpMethod.POST)) { authenticationResponse = issueAuthenticationRequest( authentication, getURI(getZosmfServiceId()) + ZOSMF_AUTHENTICATE_END_POINT, HttpMethod.POST); } else { String zosmfInfoURIEndpoint = getURI(getZosmfServiceId()) + ZOSMF_INFO_END_POINT; authenticationResponse = issueAuthenticationRequest( authentication, zosmfInfoURIEndpoint, HttpMethod.GET); authenticationResponse.setDomain(getZosmfRealm(zosmfInfoURIEndpoint)); } return authenticationResponse; } ZosmfService(
        final AuthConfigurationProperties authConfigurationProperties,
        final DiscoveryClient discovery,
        final @Qualifier("restTemplateWithoutKeystore") RestTemplate restTemplateWithoutKeystore,
        final ObjectMapper securityObjectMapper
    ); }
ZosmfService extends AbstractZosmfService { public AuthenticationResponse authenticate(Authentication authentication) { AuthenticationResponse authenticationResponse; if (authenticationEndpointExists(HttpMethod.POST)) { authenticationResponse = issueAuthenticationRequest( authentication, getURI(getZosmfServiceId()) + ZOSMF_AUTHENTICATE_END_POINT, HttpMethod.POST); } else { String zosmfInfoURIEndpoint = getURI(getZosmfServiceId()) + ZOSMF_INFO_END_POINT; authenticationResponse = issueAuthenticationRequest( authentication, zosmfInfoURIEndpoint, HttpMethod.GET); authenticationResponse.setDomain(getZosmfRealm(zosmfInfoURIEndpoint)); } return authenticationResponse; } 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 { public AuthenticationResponse authenticate(Authentication authentication) { AuthenticationResponse authenticationResponse; if (authenticationEndpointExists(HttpMethod.POST)) { authenticationResponse = issueAuthenticationRequest( authentication, getURI(getZosmfServiceId()) + ZOSMF_AUTHENTICATE_END_POINT, HttpMethod.POST); } else { String zosmfInfoURIEndpoint = getURI(getZosmfServiceId()) + ZOSMF_INFO_END_POINT; authenticationResponse = issueAuthenticationRequest( authentication, zosmfInfoURIEndpoint, HttpMethod.GET); authenticationResponse.setDomain(getZosmfRealm(zosmfInfoURIEndpoint)); } return authenticationResponse; } 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();  }