dennishuo commented on code in PR #1305: URL: https://github.com/apache/polaris/pull/1305#discussion_r2041501704
########## polaris-core/src/main/java/org/apache/polaris/core/connection/AuthenticationType.java: ########## @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.core.connection; + +public enum AuthenticationType { Review Comment: Done. Note that in existing places where we use `int` codes, we explicitly store the codes first-class in the entity model's top-level fields, whereas here we're using the enum to match the pattern of `JsonSubType` hierarchy, so we also depend on annotation magic. This means the update to support the int values here also means `AuthenticationParametersDpo` will have kind of ugly annotations that need to be manually kept in sync: +/** + * The internal persistence-object counterpart to AuthenticationParameters defined in the API + * model. Important: JsonSubTypes must be kept in sync with {@link AuthenticationType}. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "authenticationTypeCode", visible = true) @JsonSubTypes({ - @JsonSubTypes.Type(value = OAuthClientCredentialsParametersDpo.class, name = "OAUTH"), - @JsonSubTypes.Type(value = BearerAuthenticationParametersDpo.class, name = "BEARER"), + @JsonSubTypes.Type(value = OAuthClientCredentialsParametersDpo.class, name = "1"), + @JsonSubTypes.Type(value = BearerAuthenticationParametersDpo.class, name = "2"), }) Of course, we already had to manually keep it in sync before, it just happened to be with strings that were a little more accessible (`OAUTH, BEARER`) since they matched the primary enum name. In any case, I agree int codes will be more future-proof for our persisted data, even if it means it'll be a bit harder to debug at a glance. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
