Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

Commit 70db395

Browse files
author
Steven van Rossum
authored
Merge branch 'main' into main
2 parents 0d2aeba + 8b0f921 commit 70db395

27 files changed

Lines changed: 1797 additions & 114 deletions

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.33.1"
2+
".": "1.35.0"
33
}

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
# Changelog
22

3+
## [1.35.0](https://github.com/googleapis/google-auth-library-java/compare/v1.34.0...v1.35.0) (2025-05-12)
4+
5+
6+
### Features
7+
8+
* Add support for mTLS authentication via X.509 certificates ([#1736](https://github.com/googleapis/google-auth-library-java/issues/1736)) ([b347603](https://github.com/googleapis/google-auth-library-java/commit/b347603db4deabb4eb34ed14b96178c95d3e7b45))
9+
* Return X509 certificate chain as the subject token. ([#1746](https://github.com/googleapis/google-auth-library-java/issues/1746)) ([6d05be8](https://github.com/googleapis/google-auth-library-java/commit/6d05be8e5cecf62ca0952bc3ef23c527c9e0d01d))
10+
11+
12+
### Bug Fixes
13+
14+
* Handle optional fields in ExternalAccountCredentials with null JSON value gracefully ([#1706](https://github.com/googleapis/google-auth-library-java/issues/1706)) ([f1f306d](https://github.com/googleapis/google-auth-library-java/commit/f1f306dffd874741663238283deed173ce02bea9))
15+
16+
## [1.34.0](https://github.com/googleapis/google-auth-library-java/compare/v1.33.1...v1.34.0) (2025-04-29)
17+
18+
19+
### Features
20+
21+
* Implement X509 certificate provider ([#1722](https://github.com/googleapis/google-auth-library-java/issues/1722)) ([4340684](https://github.com/googleapis/google-auth-library-java/commit/4340684fe29c9e9bffa90e88d0b1746f19b623ab))
22+
* Next release from main branch is 1.34.0 ([#1698](https://github.com/googleapis/google-auth-library-java/issues/1698)) ([fe43815](https://github.com/googleapis/google-auth-library-java/commit/fe4381513db1340190c4309a53c6265718682dde))
23+
* Next release from main branch is 1.34.0 ([#1702](https://github.com/googleapis/google-auth-library-java/issues/1702)) ([4507cf9](https://github.com/googleapis/google-auth-library-java/commit/4507cf9e17e7ff40cf142056d3929c87f5742dd1))
24+
25+
26+
### Bug Fixes
27+
28+
* Do not add padding in Client-Side CAB tokens. ([#1728](https://github.com/googleapis/google-auth-library-java/issues/1728)) ([8a75ccd](https://github.com/googleapis/google-auth-library-java/commit/8a75ccd1c09191abd8ebf463bc41810a38e185f5))
29+
330
## [1.33.1](https://github.com/googleapis/google-auth-library-java/compare/v1.33.0...v1.33.1) (2025-02-25)
431

532

appengine/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.google.auth</groupId>
77
<artifactId>google-auth-library-parent</artifactId>
8-
<version>1.33.2-SNAPSHOT</version><!-- {x-version-update:google-auth-library-parent:current} -->
8+
<version>1.35.0</version><!-- {x-version-update:google-auth-library-parent:current} -->
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.google.auth</groupId>
55
<artifactId>google-auth-library-bom</artifactId>
6-
<version>1.33.2-SNAPSHOT</version><!-- {x-version-update:google-auth-library-bom:current} -->
6+
<version>1.35.0</version><!-- {x-version-update:google-auth-library-bom:current} -->
77
<packaging>pom</packaging>
88
<name>Google Auth Library for Java BOM</name>
99
<description>

cab-token-generator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.google.auth</groupId>
88
<artifactId>google-auth-library-parent</artifactId>
9-
<version>1.33.2-SNAPSHOT</version><!-- {x-version-update:google-auth-library-parent:current} -->
9+
<version>1.35.0</version><!-- {x-version-update:google-auth-library-parent:current} -->
1010
</parent>
1111

1212
<artifactId>google-auth-library-cab-token-generator</artifactId>

credentials/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.google.auth</groupId>
66
<artifactId>google-auth-library-parent</artifactId>
7-
<version>1.33.2-SNAPSHOT</version><!-- {x-version-update:google-auth-library-parent:current} -->
7+
<version>1.35.0</version><!-- {x-version-update:google-auth-library-parent:current} -->
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2025, Google Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are
6+
* met:
7+
*
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above
11+
* copyright notice, this list of conditions and the following disclaimer
12+
* in the documentation and/or other materials provided with the
13+
* distribution.
14+
*
15+
* * Neither the name of Google Inc. nor the names of its
16+
* contributors may be used to endorse or promote products derived from
17+
* this software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
32+
package com.google.auth.mtls;
33+
34+
import com.google.api.client.http.javanet.NetHttpTransport;
35+
import com.google.auth.http.HttpTransportFactory;
36+
import java.security.GeneralSecurityException;
37+
import java.security.KeyStore;
38+
import java.util.Objects;
39+
40+
/**
41+
* An HttpTransportFactory that creates {@link NetHttpTransport} instances configured for mTLS
42+
* (mutual TLS) using a specific {@link KeyStore} containing the client's certificate and private
43+
* key.
44+
*
45+
* <p><b>Warning:</b> This class is considered internal and is not intended for direct use by
46+
* library consumers. Its API and behavior may change without notice.
47+
*/
48+
public class MtlsHttpTransportFactory implements HttpTransportFactory {
49+
private final KeyStore mtlsKeyStore;
50+
51+
/**
52+
* Constructs a factory for mTLS transports.
53+
*
54+
* @param mtlsKeyStore The {@link KeyStore} containing the client's X509 certificate and private
55+
* key. This {@link KeyStore} is used for client authentication during the TLS handshake. Must
56+
* not be null.
57+
*/
58+
public MtlsHttpTransportFactory(KeyStore mtlsKeyStore) {
59+
this.mtlsKeyStore = Objects.requireNonNull(mtlsKeyStore, "mtlsKeyStore cannot be null");
60+
}
61+
62+
@Override
63+
public NetHttpTransport create() {
64+
try {
65+
// Build the mTLS transport using the provided KeyStore.
66+
return new NetHttpTransport.Builder().trustCertificates(null, mtlsKeyStore, "").build();
67+
} catch (GeneralSecurityException e) {
68+
// Wrap the checked exception in a RuntimeException because the HttpTransportFactory
69+
// interface's create() method doesn't allow throwing checked exceptions.
70+
throw new RuntimeException("Failed to initialize mTLS transport.", e);
71+
}
72+
}
73+
}

oauth2_http/java/com/google/auth/mtls/X509Provider.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class X509Provider {
5353
static final String WELL_KNOWN_CERTIFICATE_CONFIG_FILE = "certificate_config.json";
5454
static final String CLOUDSDK_CONFIG_DIRECTORY = "gcloud";
5555

56-
private String certConfigPathOverride;
56+
private final String certConfigPathOverride;
5757

5858
/**
5959
* Creates an X509 provider with an override path for the certificate configuration, bypassing the
@@ -75,6 +75,29 @@ public X509Provider() {
7575
this(null);
7676
}
7777

78+
/**
79+
* Returns the path to the client certificate file specified by the loaded workload certificate
80+
* configuration.
81+
*
82+
* <p>If the configuration has not been loaded yet (e.g., if {@link #getKeyStore()} has not been
83+
* called), this method will attempt to load it first by searching the override path, environment
84+
* variable, and well-known locations.
85+
*
86+
* @return The path to the certificate file.
87+
* @throws IOException if the certificate configuration cannot be found or loaded, or if the
88+
* configuration file does not specify a certificate path.
89+
* @throws CertificateSourceUnavailableException if the configuration file is not found.
90+
*/
91+
public String getCertificatePath() throws IOException {
92+
String certPath = getWorkloadCertificateConfiguration().getCertPath();
93+
if (Strings.isNullOrEmpty(certPath)) {
94+
// Ensure the loaded configuration actually contains the required path.
95+
throw new CertificateSourceUnavailableException(
96+
"Certificate configuration loaded successfully, but does not contain a 'certificate_file' path.");
97+
}
98+
return certPath;
99+
}
100+
78101
/**
79102
* Finds the certificate configuration file, then builds a Keystore using the X.509 certificate
80103
* and private key pointed to by the configuration. This will check the following locations in
@@ -90,9 +113,7 @@ public X509Provider() {
90113
* @throws IOException if there is an error retrieving the certificate configuration.
91114
*/
92115
public KeyStore getKeyStore() throws IOException {
93-
94116
WorkloadCertificateConfiguration workloadCertConfig = getWorkloadCertificateConfiguration();
95-
96117
InputStream certStream = null;
97118
InputStream privateKeyStream = null;
98119
SequenceInputStream certAndPrivateKeyStream = null;

0 commit comments

Comments
 (0)