gnodet-bot commented on code in PR #27767: URL: https://github.com/apache/camel/pull/27767#discussion_r4256348388
########## components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/vertx/VertxMcpPrincipal.java: ########## @@ -0,0 +1,100 @@ +/* + * 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.camel.component.mcp.server.vertx; + +import java.util.ArrayList; +import java.util.List; + +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.auth.User; + +/** + * Derives a runtime-neutral view — a caller name and role names — from a Vert.x {@link User}, so the MCP bridge can + * stamp a stable caller identity ({@code CamelMcpSecurityPrincipalName} / {@code CamelMcpSecurityPrincipalRoles}) that + * a tool route or its {@link org.apache.camel.spi.AuthorizationPolicy} can authorize on without depending on Vert.x. + */ +final class VertxMcpPrincipal { + + private VertxMcpPrincipal() { + } + + /** + * The caller name: the Vert.x {@link User#subject() subject} when set, else the {@code username} or {@code sub} + * claim of the principal, else {@code null}. + */ Review Comment: 💡 **Javadoc precision:** The Javadoc says the fallback happens "when set", but `isSet()` treats blank-but-non-null as "not set" too. A caller who passes `" "` as the subject would see the fallback to `username`/`sub` without the Javadoc explaining why. Consider: ```suggestion * The caller name: the Vert.x {@link User#subject() subject} when non-null and non-blank, else the {@code username} * or {@code sub} claim of the principal when non-null and non-blank, else {@code null}. ``` -- 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]
