Skip to content

chore: Refactor x509Provider to create a shared Utils class for Mtls#1907

Open
vverman wants to merge 7 commits intogoogleapis:mainfrom
vverman:refactor-x509-provider
Open

chore: Refactor x509Provider to create a shared Utils class for Mtls#1907
vverman wants to merge 7 commits intogoogleapis:mainfrom
vverman:refactor-x509-provider

Conversation

@vverman
Copy link
Contributor

@vverman vverman commented Mar 24, 2026

Fixes #1745

Addressed a concern raised by Andy refer.

Now X509Provider only exposes the necessary methods needed by the MtlsProvider interface

@vverman vverman requested review from a team as code owners March 24, 2026 02:24
@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Mar 24, 2026
@vverman vverman force-pushed the refactor-x509-provider branch from 1500bea to f78ed98 Compare March 24, 2026 03:02
@vverman vverman requested a review from lqiu96 March 24, 2026 03:04
Comment on lines +65 to +68
public X509Provider(
EnvironmentProvider envProvider,
PropertyProvider propProvider,
String certConfigPathOverride) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can leave this in a future refactor PR if this is a lot of work. Thoughts on creating a builder? Constructor only takes in the builder and we won't have to change the constructor signature in the future.

This was envProvider and propProvider can be set in the builder to be package-private for the tests. Only certConfigPathOverride would be public

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion.

I think we can leave this one out for now because I don't think the argument list is big enough to justify the Builder's inclusion and we don't anticipate any changes to X509Provider (in the short-term).

In case this changes, we can implement it then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's keep as-is. I can look into this later when I get more time and change this as this is marked with InternalApi.

@@ -0,0 +1,10 @@
package com.google.auth.oauth2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add header here.

The EnvProvider and PropertyProvider classes that are public because they're used between the mtls/ and oauth2/ folders. Can you add @InternalApi?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bumping. missing a header here as well

*
* <p>For internal use only.
*/
public class SystemEnvironmentProvider implements EnvironmentProvider, Serializable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq, what is the difference between SystemEnvironmentProvider and EnvironmentProvider?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An EnvProvider is an interface which can be implemented by test-classes to pass in their own env variables.

The SystemEnvProvider implements this EnvProvider and implements the associated functions such that the env-variables are fetched from the system env.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Can you add @internalapi to this class and for SystemPropertyProvider?

@lqiu96
Copy link
Member

lqiu96 commented Mar 24, 2026

feat: Refactor x509Provider

Since this is a refactor, I'm going to change the title to chore: ... to reflect the type of change in the release notes. Thank you for helping with our backlog!

@lqiu96 lqiu96 changed the title feat: Refactor x509Provider chore: Refactor x509Provider to create a shared Utils class for Mtls Mar 24, 2026
@marcosgtz7
Copy link

marcosgtz7 commented Mar 24, 2026 via email

@@ -0,0 +1,24 @@
package com.google.auth.oauth2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a header

@@ -0,0 +1,22 @@
package com.google.auth.oauth2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

header needed here as well

import java.util.HashMap;
import java.util.Map;

public class TestPropertyProvider implements PropertyProvider {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq, is this TestPropertyProvider used anywhere in the tests? If not, can we remove it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auth: Refactor X509Provider

3 participants