Skip to content

Commit fef363f

Browse files
committed
Rename UserSecretReference to SecretReference and fix some small issues
1 parent 063440f commit fef363f

File tree

14 files changed

+83
-133
lines changed

14 files changed

+83
-133
lines changed

polaris-core/src/main/java/org/apache/polaris/core/connection/AuthenticationParametersDpo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.apache.polaris.core.admin.model.OAuthClientCredentialsParameters;
3030
import org.apache.polaris.core.admin.model.SigV4AuthenticationParameters;
3131
import org.apache.polaris.core.connection.iceberg.IcebergCatalogPropertiesProvider;
32-
import org.apache.polaris.core.secrets.UserSecretReference;
32+
import org.apache.polaris.core.secrets.SecretReference;
3333

3434
/**
3535
* The internal persistence-object counterpart to AuthenticationParameters defined in the API model.
@@ -71,7 +71,7 @@ public AuthenticationType getAuthenticationType() {
7171

7272
public static AuthenticationParametersDpo fromAuthenticationParametersModelWithSecrets(
7373
AuthenticationParameters authenticationParameters,
74-
Map<String, UserSecretReference> secretReferences) {
74+
Map<String, SecretReference> secretReferences) {
7575
final AuthenticationParametersDpo config;
7676
switch (authenticationParameters.getAuthenticationType()) {
7777
case OAUTH:

polaris-core/src/main/java/org/apache/polaris/core/connection/BearerAuthenticationParametersDpo.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.apache.iceberg.rest.auth.OAuth2Properties;
2626
import org.apache.polaris.core.admin.model.AuthenticationParameters;
2727
import org.apache.polaris.core.admin.model.BearerAuthenticationParameters;
28-
import org.apache.polaris.core.secrets.UserSecretReference;
28+
import org.apache.polaris.core.secrets.SecretReference;
2929
import org.apache.polaris.core.secrets.UserSecretsManager;
3030

3131
/**
@@ -35,16 +35,16 @@
3535
public class BearerAuthenticationParametersDpo extends AuthenticationParametersDpo {
3636

3737
@JsonProperty(value = "bearerTokenReference")
38-
private final UserSecretReference bearerTokenReference;
38+
private final SecretReference bearerTokenReference;
3939

4040
public BearerAuthenticationParametersDpo(
4141
@JsonProperty(value = "bearerTokenReference", required = true) @Nonnull
42-
UserSecretReference bearerTokenReference) {
42+
SecretReference bearerTokenReference) {
4343
super(AuthenticationType.BEARER.getCode());
4444
this.bearerTokenReference = bearerTokenReference;
4545
}
4646

47-
public @Nonnull UserSecretReference getBearerTokenReference() {
47+
public @Nonnull SecretReference getBearerTokenReference() {
4848
return bearerTokenReference;
4949
}
5050

polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionConfigInfoDpo.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.fasterxml.jackson.databind.DeserializationFeature;
2828
import com.fasterxml.jackson.databind.ObjectMapper;
2929
import jakarta.annotation.Nonnull;
30+
import jakarta.annotation.Nullable;
3031
import java.net.MalformedURLException;
3132
import java.net.URI;
3233
import java.net.URL;
@@ -38,7 +39,7 @@
3839
import org.apache.polaris.core.connection.iceberg.IcebergCatalogPropertiesProvider;
3940
import org.apache.polaris.core.connection.iceberg.IcebergRestConnectionConfigInfoDpo;
4041
import org.apache.polaris.core.identity.dpo.ServiceIdentityInfoDpo;
41-
import org.apache.polaris.core.secrets.UserSecretReference;
42+
import org.apache.polaris.core.secrets.SecretReference;
4243
import org.slf4j.Logger;
4344
import org.slf4j.LoggerFactory;
4445

@@ -74,7 +75,7 @@ public ConnectionConfigInfoDpo(
7475
@JsonProperty(value = "uri", required = true) @Nonnull String uri,
7576
@JsonProperty(value = "authenticationParameters", required = true) @Nonnull
7677
AuthenticationParametersDpo authenticationParameters,
77-
@JsonProperty(value = "serviceIdentity", required = false) @Nonnull
78+
@JsonProperty(value = "serviceIdentity", required = false) @Nullable
7879
ServiceIdentityInfoDpo serviceIdentity) {
7980
this(connectionTypeCode, uri, authenticationParameters, serviceIdentity, true);
8081
}
@@ -83,7 +84,7 @@ protected ConnectionConfigInfoDpo(
8384
int connectionTypeCode,
8485
@Nonnull String uri,
8586
@Nonnull AuthenticationParametersDpo authenticationParameters,
86-
@Nonnull ServiceIdentityInfoDpo serviceIdentity,
87+
@Nullable ServiceIdentityInfoDpo serviceIdentity,
8788
boolean validateUri) {
8889
this.connectionTypeCode = connectionTypeCode;
8990
this.uri = uri;
@@ -111,7 +112,7 @@ public AuthenticationParametersDpo getAuthenticationParameters() {
111112
return authenticationParameters;
112113
}
113114

114-
public @Nonnull ServiceIdentityInfoDpo getServiceIdentity() {
115+
public @Nullable ServiceIdentityInfoDpo getServiceIdentity() {
115116
return serviceIdentity;
116117
}
117118

@@ -156,7 +157,7 @@ protected void validateUri(String uri) {
156157
*/
157158
public static ConnectionConfigInfoDpo fromConnectionConfigInfoModelWithSecrets(
158159
ConnectionConfigInfo connectionConfigurationModel,
159-
Map<String, UserSecretReference> secretReferences) {
160+
Map<String, SecretReference> secretReferences) {
160161
ConnectionConfigInfoDpo config = null;
161162
final AuthenticationParametersDpo authenticationParameters;
162163
switch (connectionConfigurationModel.getConnectionType()) {

polaris-core/src/main/java/org/apache/polaris/core/connection/OAuthClientCredentialsParametersDpo.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import org.apache.iceberg.rest.auth.OAuth2Util;
3636
import org.apache.polaris.core.admin.model.AuthenticationParameters;
3737
import org.apache.polaris.core.admin.model.OAuthClientCredentialsParameters;
38-
import org.apache.polaris.core.secrets.UserSecretReference;
38+
import org.apache.polaris.core.secrets.SecretReference;
3939
import org.apache.polaris.core.secrets.UserSecretsManager;
4040

4141
/**
@@ -53,7 +53,7 @@ public class OAuthClientCredentialsParametersDpo extends AuthenticationParameter
5353
private final String clientId;
5454

5555
@JsonProperty(value = "clientSecretReference")
56-
private final UserSecretReference clientSecretReference;
56+
private final SecretReference clientSecretReference;
5757

5858
@JsonProperty(value = "scopes")
5959
private final List<String> scopes;
@@ -62,7 +62,7 @@ public OAuthClientCredentialsParametersDpo(
6262
@JsonProperty(value = "tokenUri", required = false) @Nullable String tokenUri,
6363
@JsonProperty(value = "clientId", required = true) @Nonnull String clientId,
6464
@JsonProperty(value = "clientSecretReference", required = true) @Nonnull
65-
UserSecretReference clientSecretReference,
65+
SecretReference clientSecretReference,
6666
@JsonProperty(value = "scopes", required = false) @Nullable List<String> scopes) {
6767
super(AuthenticationType.OAUTH.getCode());
6868

@@ -82,7 +82,7 @@ public OAuthClientCredentialsParametersDpo(
8282
return clientId;
8383
}
8484

85-
public @Nonnull UserSecretReference getClientSecretReference() {
85+
public @Nonnull SecretReference getClientSecretReference() {
8686
return clientSecretReference;
8787
}
8888

polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import org.apache.polaris.core.config.BehaviorChangeConfiguration;
4444
import org.apache.polaris.core.connection.ConnectionConfigInfoDpo;
4545
import org.apache.polaris.core.context.CallContext;
46-
import org.apache.polaris.core.secrets.UserSecretReference;
46+
import org.apache.polaris.core.secrets.SecretReference;
4747
import org.apache.polaris.core.storage.FileStorageConfigurationInfo;
4848
import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
4949
import org.apache.polaris.core.storage.aws.AwsStorageConfigurationInfo;
@@ -327,7 +327,7 @@ private void validateMaxAllowedLocations(
327327

328328
public Builder setConnectionConfigInfoDpoWithSecrets(
329329
ConnectionConfigInfo connectionConfigurationModel,
330-
Map<String, UserSecretReference> secretReferences) {
330+
Map<String, SecretReference> secretReferences) {
331331
if (connectionConfigurationModel != null) {
332332
ConnectionConfigInfoDpo config =
333333
ConnectionConfigInfoDpo.fromConnectionConfigInfoModelWithSecrets(

polaris-core/src/main/java/org/apache/polaris/core/identity/dpo/AwsIamServiceIdentityInfoDpo.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@
2626
import org.apache.polaris.core.admin.model.AwsIamServiceIdentityInfo;
2727
import org.apache.polaris.core.admin.model.ServiceIdentityInfo;
2828
import org.apache.polaris.core.identity.ServiceIdentityType;
29-
import org.apache.polaris.core.secrets.ServiceSecretReference;
29+
import org.apache.polaris.core.secrets.SecretReference;
3030

3131
/**
3232
* Persistence-layer representation of an AWS IAM service identity used by Polaris.
3333
*
3434
* <p>This class models an AWS IAM identity (either a user or role) and extends {@link
35-
* ServiceIdentityInfoDpo}. It is typically used internally to store both the identity metadata
36-
* (such as the IAM ARN) and a reference to the actual credential (e.g., via {@link
37-
* ServiceSecretReference}).
35+
* ServiceIdentityInfoDpo}. It is typically used internally to store a reference to the actual
36+
* credential (e.g., via {@link SecretReference}).
37+
*
38+
* <p>During the runtime, it will be resolved to an actual ResolvedAwsIamServiceIdentityInfo object
39+
* which contains the actual service identity info (e.g., the IAM user arn) and the corresponding
40+
* credential.
3841
*
3942
* <p>Instances of this class are convertible to the public API model {@link
4043
* AwsIamServiceIdentityInfo}.
@@ -44,7 +47,7 @@ public class AwsIamServiceIdentityInfoDpo extends ServiceIdentityInfoDpo {
4447
@JsonCreator
4548
public AwsIamServiceIdentityInfoDpo(
4649
@JsonProperty(value = "identityInfoReference", required = false) @Nullable
47-
ServiceSecretReference identityInfoReference) {
50+
SecretReference identityInfoReference) {
4851
super(ServiceIdentityType.AWS_IAM.getCode(), identityInfoReference);
4952
}
5053

polaris-core/src/main/java/org/apache/polaris/core/identity/dpo/ServiceIdentityInfoDpo.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@
2727
import jakarta.annotation.Nullable;
2828
import org.apache.polaris.core.admin.model.ServiceIdentityInfo;
2929
import org.apache.polaris.core.identity.ServiceIdentityType;
30-
import org.apache.polaris.core.secrets.ServiceSecretReference;
30+
import org.apache.polaris.core.secrets.SecretReference;
3131

3232
/**
3333
* The internal persistence-object counterpart to ServiceIdentityInfo defined in the API model.
3434
* Important: JsonSubTypes must be kept in sync with {@link ServiceIdentityType}.
35+
*
36+
* <p>During the runtime, it will be resolved to an actual ResolvedServiceIdentityInfo object which
37+
* contains the actual service identity info and the corresponding credential.
3538
*/
3639
@JsonTypeInfo(
3740
use = JsonTypeInfo.Id.NAME,
@@ -44,12 +47,12 @@ public abstract class ServiceIdentityInfoDpo {
4447
private final int identityTypeCode;
4548

4649
@JsonProperty(value = "identityInfoReference")
47-
private final ServiceSecretReference identityInfoReference;
50+
private final SecretReference identityInfoReference;
4851

4952
public ServiceIdentityInfoDpo(
5053
@JsonProperty(value = "identityTypeCode", required = true) int identityTypeCode,
5154
@JsonProperty(value = "identityInfoReference", required = false) @Nullable
52-
ServiceSecretReference identityInfoReference) {
55+
SecretReference identityInfoReference) {
5356
this.identityTypeCode = identityTypeCode;
5457
this.identityInfoReference = identityInfoReference;
5558
}
@@ -64,7 +67,7 @@ public ServiceIdentityType getIdentityType() {
6467
}
6568

6669
@JsonProperty
67-
public ServiceSecretReference getIdentityInfoReference() {
70+
public SecretReference getIdentityInfoReference() {
6871
return identityInfoReference;
6972
}
7073

polaris-core/src/main/java/org/apache/polaris/core/secrets/UserSecretReference.java renamed to polaris-core/src/main/java/org/apache/polaris/core/secrets/SecretReference.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
* the stored "secret material" as well as the referencePayload and any associated keys used for
5252
* encryption.
5353
*/
54-
public class UserSecretReference {
54+
public class SecretReference {
5555
@JsonProperty(value = "urn")
5656
private final String urn;
5757

@@ -74,7 +74,7 @@ public class UserSecretReference {
7474
Pattern.compile("^" + TYPE_SPECIFIC_IDENTIFIER_REGEX + "$");
7575

7676
/**
77-
* Precompiled regex pattern for validating and parsing UserSecretReference URNs. Expected format:
77+
* Precompiled regex pattern for validating and parsing SecretReference URNs. Expected format:
7878
* urn:polaris-secret:<secret-manager-type>:<identifier1>(:<identifier2>:...).
7979
*
8080
* <p>Groups:
@@ -98,15 +98,15 @@ public class UserSecretReference {
9898
/**
9999
* @param urn A string which should be self-sufficient to retrieve whatever secret material that
100100
* is stored in the remote secret store and also to identify an implementation of the
101-
* UserSecretsManager which is capable of interpreting this concrete UserSecretReference.
102-
* Should be of the form:
101+
* UserSecretsManager which is capable of interpreting this concrete SecretReference. Should
102+
* be of the form:
103103
* 'urn:polaris-secret:&lt;secret-manager-type&gt;:&lt;type-specific-identifier&gt;
104104
* @param referencePayload Optionally, any additional information that is necessary to fully
105105
* reconstitute the original secret based on what is retrieved by the {@code urn}; this
106106
* payload may include hashes/checksums, encryption key ids, OTP encryption keys, additional
107107
* protocol/version specifiers, etc., which are implementation-specific.
108108
*/
109-
public UserSecretReference(
109+
public SecretReference(
110110
@JsonProperty(value = "urn", required = true) @Nonnull String urn,
111111
@JsonProperty(value = "referencePayload") @Nullable Map<String, String> referencePayload) {
112112
Preconditions.checkArgument(
@@ -117,8 +117,7 @@ public UserSecretReference(
117117
}
118118

119119
/**
120-
* Validates whether the given URN string matches the expected format for UserSecretReference
121-
* URNs.
120+
* Validates whether the given URN string matches the expected format for SecretReference URNs.
122121
*
123122
* @param urn The URN string to validate.
124123
* @return true if the URN is valid, false otherwise.
@@ -164,13 +163,13 @@ public static String buildUrnString(
164163
}
165164

166165
/**
167-
* Since UserSecretReference objects are specific to UserSecretManager implementations, the
166+
* Since SecretReference objects are specific to UserSecretManager implementations, the
168167
* "secret-manager-type" portion of the URN should be used to validate that a URN is valid for a
169168
* given implementation and to dispatch to the correct implementation at runtime if multiple
170169
* concurrent implementations are possible in a given runtime environment.
171170
*/
172171
@JsonIgnore
173-
public String getUserSecretManagerType() {
172+
public String getSecretManagerType() {
174173
Matcher matcher = URN_PATTERN.matcher(urn);
175174
Preconditions.checkState(matcher.matches(), "Invalid secret URN: " + urn);
176175
return matcher.group(1);
@@ -203,10 +202,10 @@ public int hashCode() {
203202

204203
@Override
205204
public boolean equals(Object obj) {
206-
if (obj == null || !(obj instanceof UserSecretReference)) {
205+
if (obj == null || !(obj instanceof SecretReference)) {
207206
return false;
208207
}
209-
UserSecretReference that = (UserSecretReference) obj;
208+
SecretReference that = (SecretReference) obj;
210209
return Objects.equals(this.getUrn(), that.getUrn())
211210
&& Objects.equals(this.getReferencePayload(), that.getReferencePayload());
212211
}

polaris-core/src/main/java/org/apache/polaris/core/secrets/ServiceSecretReference.java

Lines changed: 0 additions & 53 deletions
This file was deleted.

polaris-core/src/main/java/org/apache/polaris/core/secrets/UnsafeInMemorySecretsManager.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public class UnsafeInMemorySecretsManager implements UserSecretsManager {
4848
/** {@inheritDoc} */
4949
@Override
5050
@Nonnull
51-
public UserSecretReference writeSecret(
52-
@Nonnull String secret, @Nonnull PolarisEntityCore forEntity) {
51+
public SecretReference writeSecret(@Nonnull String secret, @Nonnull PolarisEntityCore forEntity) {
5352
// For illustrative purposes and to exercise the control flow of requiring both the stored
5453
// secret as well as the secretReferencePayload to recover the original secret, we'll use
5554
// basic XOR encryption and store the randomly generated key in the reference payload.
@@ -97,15 +96,15 @@ public UserSecretReference writeSecret(
9796
// key is ever shared and/or the key isn't a one-time-pad of the same length as the source
9897
// secret.
9998
referencePayload.put(ENCRYPTION_KEY, encryptedSecretKeyBase64);
100-
UserSecretReference secretReference = new UserSecretReference(secretUrn, referencePayload);
99+
SecretReference secretReference = new SecretReference(secretUrn, referencePayload);
101100
return secretReference;
102101
}
103102

104103
/** {@inheritDoc} */
105104
@Override
106105
@Nonnull
107-
public String readSecret(@Nonnull UserSecretReference secretReference) {
108-
String secretManagerType = secretReference.getUserSecretManagerType();
106+
public String readSecret(@Nonnull SecretReference secretReference) {
107+
String secretManagerType = secretReference.getSecretManagerType();
109108
Preconditions.checkState(
110109
secretManagerType.equals(SECRET_MANAGER_TYPE),
111110
"Invalid secret manager type, expected: "
@@ -148,7 +147,7 @@ public String readSecret(@Nonnull UserSecretReference secretReference) {
148147

149148
/** {@inheritDoc} */
150149
@Override
151-
public void deleteSecret(@Nonnull UserSecretReference secretReference) {
150+
public void deleteSecret(@Nonnull SecretReference secretReference) {
152151
rawSecretStore.remove(secretReference.getUrn());
153152
}
154153
}

0 commit comments

Comments
 (0)