|
31 | 31 |
|
32 | 32 | package com.google.auth.oauth2; |
33 | 33 |
|
34 | | -import static com.google.auth.oauth2.OAuth2Utils.WORKFORCE_AUDIENCE_PATTERN; |
35 | | -import static com.google.auth.oauth2.OAuth2Utils.WORKLOAD_AUDIENCE_PATTERN; |
36 | 34 | import static com.google.common.base.Preconditions.checkNotNull; |
37 | 35 |
|
38 | 36 | import com.google.api.client.http.HttpHeaders; |
39 | 37 | import com.google.api.client.json.GenericJson; |
40 | 38 | import com.google.api.client.util.Data; |
41 | | -import com.google.api.core.InternalApi; |
42 | 39 | import com.google.auth.RequestMetadataCallback; |
43 | 40 | import com.google.auth.http.HttpTransportFactory; |
44 | 41 | import com.google.common.base.MoreObjects; |
|
57 | 54 | import java.util.Locale; |
58 | 55 | import java.util.Map; |
59 | 56 | import java.util.concurrent.Executor; |
60 | | -import java.util.regex.Matcher; |
61 | 57 | import java.util.regex.Pattern; |
62 | 58 | import javax.annotation.Nullable; |
63 | 59 |
|
|
67 | 63 | * <p>Handles initializing external credentials, calls to the Security Token Service, and service |
68 | 64 | * account impersonation. |
69 | 65 | */ |
70 | | -public abstract class ExternalAccountCredentials extends GoogleCredentials |
71 | | - implements RegionalAccessBoundaryProvider { |
| 66 | +public abstract class ExternalAccountCredentials extends GoogleCredentials { |
72 | 67 |
|
73 | 68 | private static final long serialVersionUID = 8049126194174465023L; |
74 | 69 |
|
@@ -582,11 +577,6 @@ protected AccessToken exchangeExternalCredentialForAccessToken( |
582 | 577 | */ |
583 | 578 | public abstract String retrieveSubjectToken() throws IOException; |
584 | 579 |
|
585 | | - @Override |
586 | | - HttpTransportFactory getTransportFactory() { |
587 | | - return transportFactory; |
588 | | - } |
589 | | - |
590 | 580 | public String getAudience() { |
591 | 581 | return audience; |
592 | 582 | } |
@@ -630,43 +620,6 @@ public String getServiceAccountEmail() { |
630 | 620 | return ImpersonatedCredentials.extractTargetPrincipal(serviceAccountImpersonationUrl); |
631 | 621 | } |
632 | 622 |
|
633 | | - @InternalApi |
634 | | - @Override |
635 | | - public String getRegionalAccessBoundaryUrl() throws IOException { |
636 | | - if (getServiceAccountEmail() != null) { |
637 | | - return String.format( |
638 | | - OAuth2Utils.IAM_CREDENTIALS_ALLOWED_LOCATIONS_URL_FORMAT_SERVICE_ACCOUNT, |
639 | | - getServiceAccountEmail()); |
640 | | - } |
641 | | - |
642 | | - String audience = getAudience(); |
643 | | - if (audience == null) { |
644 | | - throw new IllegalStateException( |
645 | | - "The audience is null, which is not in a valid format for either a workload identity pool or a workforce pool."); |
646 | | - } |
647 | | - |
648 | | - Matcher workforceMatcher = WORKFORCE_AUDIENCE_PATTERN.matcher(audience); |
649 | | - if (workforceMatcher.matches()) { |
650 | | - String poolId = workforceMatcher.group("pool"); |
651 | | - return String.format( |
652 | | - OAuth2Utils.IAM_CREDENTIALS_ALLOWED_LOCATIONS_URL_FORMAT_WORKFORCE_POOL, poolId); |
653 | | - } |
654 | | - |
655 | | - Matcher workloadMatcher = WORKLOAD_AUDIENCE_PATTERN.matcher(audience); |
656 | | - if (workloadMatcher.matches()) { |
657 | | - String projectNumber = workloadMatcher.group("project"); |
658 | | - String poolId = workloadMatcher.group("pool"); |
659 | | - return String.format( |
660 | | - OAuth2Utils.IAM_CREDENTIALS_ALLOWED_LOCATIONS_URL_FORMAT_WORKLOAD_POOL, |
661 | | - projectNumber, |
662 | | - poolId); |
663 | | - } |
664 | | - |
665 | | - throw new IllegalStateException( |
666 | | - "The provided audience is not in a valid format for either a workload identity pool or a workforce pool." |
667 | | - + " Refer: https://docs.cloud.google.com/iam/docs/principal-identifiers"); |
668 | | - } |
669 | | - |
670 | 623 | @Nullable |
671 | 624 | public String getClientId() { |
672 | 625 | return clientId; |
|
0 commit comments