mhkadhum commented on code in PR #12124:
URL: https://github.com/apache/cloudstack/pull/12124#discussion_r2646862507


##########
plugins/storage/object/ECS/src/main/java/org/apache/cloudstack/storage/datastore/driver/EcsObjectStoreDriverImpl.java:
##########
@@ -0,0 +1,1556 @@
+/*
+ * 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.cloudstack.storage.datastore.driver;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.inject.Inject;
+import javax.net.ssl.SSLContext;
+
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContextBuilder;
+import org.apache.http.ssl.TrustStrategy;
+import org.apache.http.util.EntityUtils;
+
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.storage.datastore.db.ObjectStoreDetailsDao;
+import org.apache.cloudstack.storage.object.BaseObjectStoreDriverImpl;
+import org.apache.cloudstack.storage.object.Bucket;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.amazonaws.services.s3.model.AccessControlList;
+import com.amazonaws.services.s3.model.BucketPolicy;
+import com.cloud.agent.api.to.BucketTO;
+import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.storage.BucketVO;
+import com.cloud.storage.dao.BucketDao;
+import com.cloud.user.Account;
+import com.cloud.user.AccountDetailsDao;
+import com.cloud.user.AccountDetailVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public class EcsObjectStoreDriverImpl extends BaseObjectStoreDriverImpl {
+    private static final Logger logger = 
LogManager.getLogger(EcsObjectStoreDriverImpl.class);
+
+    // Object store details keys
+    private static final String MGMT_URL   = "mgmt_url";      // e.g. 
https://ecs-api.example.com
+    private static final String SA_USER    = "sa_user";       // service 
account user
+    private static final String SA_PASS    = "sa_password";   // service 
account password
+    private static final String NAMESPACE  = "namespace";     // e.g. 
cloudstack
+    private static final String INSECURE   = "insecure";      // "true" to 
ignore TLS cert/host
+    private static final String S3_HOST    = "s3_host";       // S3 endpoint 
host (or URL if UI provides it)
+
+    // Per-account keys
+    private static final String AD_KEY_ACCESS = "ecs.accesskey";
+    private static final String AD_KEY_SECRET = "ecs.secretkey";
+
+    // ---- ECS token caching ----
+    private static final long DEFAULT_TOKEN_MAX_AGE_SEC = 300; // fallback if 
header missing
+    private static final long EXPIRY_SKEW_SEC = 30;           // refresh early
+    private static final ConcurrentHashMap<TokenKey, TokenEntry> TOKEN_CACHE = 
new ConcurrentHashMap<>();
+    private static final ConcurrentHashMap<TokenKey, Object> TOKEN_LOCKS = new 
ConcurrentHashMap<>();
+

Review Comment:
   I agree.
   Token management and XML parsing have been extracted into separate classes
   (EcsMgmtTokenManager and EcsXmlParser) to improve maintainability and reuse.



-- 
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]

Reply via email to