@VisibleForTesting
  URL getAuthenticationUrl(@Nullable Credential credential, Map<String, String> repositoryScopes)
      throws MalformedURLException {
    return isOAuth2Auth(credential)
        ? new URL(realm) // Required parameters will be sent via POST .
        : new URL(realm + "?" + getServiceScopeRequestParameters(repositoryScopes));
  }
Authenticates permission to pull and push.

@param credential the credential used to authenticate
@return an {@code Authorization} authenticating the push
@throws RegistryAuthenticationFailedException if authentication fails
@throws RegistryCredentialsNotSentException if authentication failed and credentials were not
    sent over plain HTTP
jib-core/src/main/java/com/google/cloud/tools/jib/registry/RegistryAuthenticator.java