Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
securityToken
Browse files Browse the repository at this point in the history
  • Loading branch information
tuwenlin committed Aug 1, 2022
1 parent b2fe90f commit ce2efa2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ private void handleHttpRequest(FullHttpRequest request, Channel channel) throws
String workspace = HttpUtils.parseRequestParams(request.uri()).get(WORKSPACE_KEY);
String accessKeyId = request.headers().get("X-Fc-Access-Key-Id");
String keySecret = request.headers().get("X-Fc-Access-Key-Secret");
String securityToken = request.headers().get("X-Fc-Security-Token");
String endpoint = HttpUtils.buildOSSEndpoint(request.headers().get("X-Fc-Region"));
if (StringUtil.isNullOrEmpty(workspace)) {
workspace = UUID.randomUUID().toString();
connectionManager.initIdea(workspace, accessKeyId, keySecret, endpoint);
connectionManager.initIdea(workspace, accessKeyId, keySecret, securityToken, endpoint);
doRedirect(workspace, channel);
} else {
connectionManager.initIdea(workspace, accessKeyId, keySecret, endpoint);
connectionManager.initIdea(workspace, accessKeyId, keySecret, securityToken, endpoint);
transportRequest(request, channel);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public void setUnConnectioned(Channel channel) {
}
}

public void initIdea(String workspace, String accessKeyId, String secretKey, String endPoint) {
public void initIdea(String workspace, String accessKeyId, String secretKey, String securityToken, String endPoint) {
OSSManager ossManager = WORKSPACE_OSS_MAP.computeIfAbsent(workspace,
(k) -> new OSSManager(endPoint, accessKeyId, secretKey, workspace));
(k) -> new OSSManager(endPoint, accessKeyId, secretKey, workspace, securityToken));
ossManager.batchDownload(IDEA_PROJECT_PATCH, IDEA_PROJECT_PATCH);
ossManager.batchDownload(IDEA_CONFIG_PATCH, IDEA_CONFIG_PATCH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,28 @@ public class OSSManager {

private String accessKeySecret;

private String securityToken;

private String workspace;

private String bucketName = "twl-serverless";

private static OSSClientBuilder ossClientBuilder = new OSSClientBuilder();

public OSSManager(String endpoint, String accessKeyId, String accessKeySecret, String workspace) {
public OSSManager(String endpoint, String accessKeyId, String accessKeySecret, String workspace, String securityToken) {
this.endpoint = endpoint;
this.accessKeyId = accessKeyId;
this.accessKeySecret = accessKeySecret;
this.securityToken = securityToken;
this.workspace = workspace;
}

public OSSManager(String endpoint, String accessKeyId, String accessKeySecret, String workspace) {
this(endpoint, accessKeyId, accessKeySecret, workspace, null);
}

public void batchUploadFile(File parentFile) {
OSS ossClient = ossClientBuilder.build(endpoint, accessKeyId, accessKeySecret);
OSS ossClient = ossClientBuilder.build(endpoint, accessKeyId, accessKeySecret, securityToken);
try {
if (parentFile.isDirectory()) {
File[] files = parentFile.listFiles();
Expand Down

0 comments on commit ce2efa2

Please sign in to comment.