Source:
public OidcAuthenticator(final OidcConfiguration configuration, final OidcClient client) { CommonHelper.assertNotNull("configuration", configuration); CommonHelper.assertNotNull("client", client); this.configuration = configuration; this.client = client; final List<ClientAuthenticationMethod> metadataMethods = configuration.findProviderMetadata().getTokenEndpointAuthMethods(); final ClientAuthenticationMethod chosenMethod; final ClientAuthenticationMethod configurationMethod = configuration.getClientAuthenticationMethod(); final ClientAuthenticationMethod preferredMethod; if (configurationMethod == null || SUPPORTED_METHODS.contains(configurationMethod)) { preferredMethod = configurationMethod; } else { preferredMethod = null; logger.warn("Configured authentication method ({}) is not supported.", configurationMethod); } if (CommonHelper.isNotEmpty(metadataMethods)) { if (preferredMethod != null && metadataMethods.contains(preferredMethod)) { chosenMethod = preferredMethod; } else { Optional<ClientAuthenticationMethod> firstSupported = metadataMethods.stream().filter((m) -> SUPPORTED_METHODS.contains(m)).findFirst(); if (firstSupported.isPresent()) { chosenMethod = firstSupported.get(); if (preferredMethod != null) { logger.warn( "Preferred authentication method ({}) not supported by provider according to provider metadata." + " Defaulting to: {}", metadataMethods, chosenMethod); } } else { chosenMethod = ClientAuthenticationMethod.getDefault(); logger.warn("None of the Token endpoint provider metadata authentication methods ({}) are supported." + " Defaulting to: {}", metadataMethods, chosenMethod); } } } else { chosenMethod = preferredMethod != null ? preferredMethod : ClientAuthenticationMethod.getDefault(); logger.warn("Provider metadata does not provide Token endpoint authentication methods. Using: {}", chosenMethod); } final ClientID _clientID = new ClientID(configuration.getClientId()); final Secret _secret = new Secret(configuration.getSecret()); if (ClientAuthenticationMethod.CLIENT_SECRET_POST.equals(chosenMethod)) { clientAuthentication = new ClientSecretPost(_clientID, _secret); } else if (ClientAuthenticationMethod.CLIENT_SECRET_BASIC.equals(chosenMethod)) { clientAuthentication = new ClientSecretBasic(_clientID, _secret); } else { throw new TechnicalException("Unsupported client authentication method: " + chosenMethod); } }

Target:
public OidcAuthenticator(final OidcConfiguration configuration, final OidcClient client) { CommonHelper.assertNotNull("configuration", configuration); CommonHelper.assertNotNull("client", client); this.configuration = configuration; this.client = client; final List<ClientAuthenticationMethod> metadataMethods = configuration.findProviderMetadata().getTokenEndpointAuthMethods(); final ClientAuthenticationMethod preferredMethod = getPreferredAuthenticationMethod(configuration); final ClientAuthenticationMethod chosenMethod; if (CommonHelper.isNotEmpty(metadataMethods)) { if (preferredMethod != null) { if (metadataMethods.contains(preferredMethod)) { chosenMethod = preferredMethod; } else { throw new TechnicalException( "Preferred authentication method (" + preferredMethod + ") not supported " + "by provider according to provider metadata (" + metadataMethods + ")."); } } else { chosenMethod = firstSupportedMethod(metadataMethods); } } else { chosenMethod = preferredMethod != null ? preferredMethod : ClientAuthenticationMethod.getDefault(); logger.info("Provider metadata does not provide Token endpoint authentication methods. Using: {}", chosenMethod); } final ClientID _clientID = new ClientID(configuration.getClientId()); final Secret _secret = new Secret(configuration.getSecret()); if (ClientAuthenticationMethod.CLIENT_SECRET_POST.equals(chosenMethod)) { clientAuthentication = new ClientSecretPost(_clientID, _secret); } else if (ClientAuthenticationMethod.CLIENT_SECRET_BASIC.equals(chosenMethod)) { clientAuthentication = new ClientSecretBasic(_clientID, _secret); } else { throw new TechnicalException("Unsupported client authentication method: " + chosenMethod); } }