adb014 commented on code in PR #1143: URL: https://github.com/apache/guacamole-client/pull/1143#discussion_r3092887198
########## extensions/guacamole-vault/modules/guacamole-vault-openbao/src/main/java/org/apache/guacamole/vault/openbao/conf/OpenBaoConfigurationService.java: ########## @@ -0,0 +1,122 @@ +/* + * 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.guacamole.vault.openbao.conf; + +import com.google.inject.Inject; +import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.environment.Environment; +import org.apache.guacamole.vault.conf.VaultConfigurationService; + +/** + * Service for retrieving OpenBao configuration from guacamole.properties. + */ +public class OpenBaoConfigurationService extends VaultConfigurationService { + + /** + * The Guacamole server environment. + */ + @Inject + private Environment environment; + + /** + * Creates a new OpenBaoConfigurationService. + */ + public OpenBaoConfigurationService() { + super("openbao-token-mapping.yml", "guacamole.properties.openbao"); + } + + /** + * Returns the OpenBao server URL. + * + * @return The OpenBao server URL (e.g., "http://localhost:8200"). + * @throws GuacamoleException + * If the property is not defined in guacamole.properties. + */ + public String getServerUrl() throws GuacamoleException { + return environment.getRequiredProperty(OpenBaoConfig.OPENBAO_SERVER_URL); + } + + /** + * Returns the OpenBao authentication token. + * + * @return The OpenBao authentication token. + * @throws GuacamoleException + * If the property is not defined in guacamole.properties. + */ + public String getToken() throws GuacamoleException { Review Comment: If you do then code in my proposed spring implementation is changed to. this.vaultTemplate = new VaultTemplate( endpoint, new AppRoleAuthentication( confService.getRoleID(), new AppRoleAuthenticationOptions() .setSecretId(confService.getSecretID()) ) ); -- 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]
