Skip to content

Conversation

@hyunw9
Copy link
Contributor

@hyunw9 hyunw9 commented Oct 26, 2025

Motivation:

AccessTokenClient and RoleTokenClient are currently declared as package-private, preventing users of the Armeria library from directly instantiating or using these classes.

As wrote in #6431, some users may want to obtain only the Athenz token for use with non-Armeria clients.

This PR provides flexibility by exposing these classes as public API, allowing users to fetch tokens directly.

Modifications:

armeria/athenz/src/main/java/com/linecorp/armeria/client/athenz/AccessTokenClient.java

Changed final class AccessTokenClient to public final class AccessTokenClient.

armeria/athenz/src/main/java/com/linecorp/armeria/client/athenz/RoleTokenClient.java

Changed final class RoleTokenClient to public final class RoleTokenClient.

Result:

Closes #6431

After this PR is merged, users will be able to directly import and instantiate com.linecorp.armeria.client.athenz.AccessTokenClient and com.linecorp.armeria.client.athenz.RoleTokenClient.

import com.linecorp.armeria.common.util.Exceptions;

final class AccessTokenClient implements TokenClient {
public final class AccessTokenClient implements TokenClient {
Copy link
Contributor

@ikhoon ikhoon Nov 4, 2025

Choose a reason for hiding this comment

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

Adding the public keyword doesn’t necessarily mean the user can use it right away.

  • TokenClient client is still in private.
  • There are no public constructors or builder methods to create AccessTokenClient or `RoleTokenClient.

Suggestion:

  • Should we only make TokenClient public class? Let's keep AccessTokenClient and RoleTokenClient package-private.
  • Override as method to obtain an instance of TokenClient in AthenzClient?

Copy link
Contributor

@ikhoon ikhoon Nov 4, 2025

Choose a reason for hiding this comment

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

I realized that overriding as is not a feasible solution as AthenzClient.newDecorator() returns a function. Instead, let's add a factory method TokenClient.

public interface TokenClient {

    TokenClient of(....) {
        if (tokenType.isRoleToken()) {
            return new RoleTokenClient(ztsBaseClient, domainName, roleNames, refreshBefore);
        } else {
            return new AccessTokenClient(ztsBaseClient, domainName, roleNames, refreshBefore);
        }
    }

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose Athenz TokenClient as public API

2 participants