code: private URI redirectUriUsing(Authentication authentication) {
          URI redirectUri;
  
          Object details = authentication.getDetails();
          if (details != null && OAuth2WebAuthenticationDetails.class.isAssignableFrom(details.getClass())
                  && !oAuth2ServiceProperties.getRedirectUri().isAbsolute()) {
              OAuth2WebAuthenticationDetails oAuth2WebAuthenticationDetails = (OAuth2WebAuthenticationDetails) details;
              redirectUri = UriBuilder.fromPath(oAuth2WebAuthenticationDetails.getContextPath())
                      .path(oAuth2ServiceProperties.getRedirectUri().toString())
                      .scheme(oAuth2WebAuthenticationDetails.getScheme())
                      .host(oAuth2WebAuthenticationDetails.getHost())
                      .port(oAuth2WebAuthenticationDetails.getPort())
                      .build();
          } else {
              redirectUri = oAuth2ServiceProperties.getRedirectUri();
          }
  
          return redirectUri;
      }
docs: If a dynamic scheme, host, port, and context path was set then use it to generate the redirect URI.
  Uses the details on the {@link OAuth2WebAuthenticationDetails} combined with
  {@link OAuth2ServiceProperties#getRedirectUri()}.
  @param authentication    The {@link Authentication} token.
  @return  The dynamic redirect URI, or {@code null} if one could not be obtained.