Explorar o código

build 移除v1预签名

mamingxu hai 1 mes
pai
achega
72ebe3f98f

+ 0 - 6
yyc-common-oss/pom.xml

@@ -20,11 +20,5 @@
 			<artifactId>aws-java-sdk-s3</artifactId>
 			<version>${aws.version}</version>
 		</dependency>
-		<!-- 阿里云 OSS 原生 SDK,用于生成 V1 长效签名 URL -->
-		<dependency>
-			<groupId>com.aliyun.oss</groupId>
-			<artifactId>aliyun-sdk-oss</artifactId>
-			<version>3.17.4</version>
-		</dependency>
 	</dependencies>
 </project>

+ 1 - 12
yyc-common-oss/src/main/java/net/yyc/common/oss/OssAutoConfiguration.java

@@ -18,8 +18,6 @@
 package net.yyc.common.oss;
 
 import net.yyc.common.oss.http.OssEndpoint;
-import net.yyc.common.oss.service.AliyunOssSigner;
-import net.yyc.common.oss.service.OssSigner;
 import net.yyc.common.oss.service.OssTemplate;
 import io.minio.MinioClient;
 import lombok.AllArgsConstructor;
@@ -35,7 +33,7 @@ import org.springframework.context.annotation.Bean;
  * @author 858695266
  */
 @AllArgsConstructor
-@EnableConfigurationProperties({ OssProperties.class, OssProperties2.class })
+@EnableConfigurationProperties({ OssProperties.class })
 public class OssAutoConfiguration {
 
 	private final OssProperties properties;
@@ -63,13 +61,4 @@ public class OssAutoConfiguration {
 				.build();
 	}
 
-	/**
-	 * 阿里云 OSS V1 签名 Bean(生成长有效期 URL)
-	 */
-	@Bean
-	@ConditionalOnMissingBean(OssSigner.class)
-	@ConditionalOnProperty(name = "oss2.enable", havingValue = "true", matchIfMissing = true)
-	public OssSigner aliyunOssSigner(OssProperties2 properties2) {
-		return new AliyunOssSigner(properties2);
-	}
 }

+ 0 - 85
yyc-common-oss/src/main/java/net/yyc/common/oss/OssProperties2.java

@@ -1,85 +0,0 @@
-/*
- *    Copyright (c) 2018-2025, hnqz All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * Neither the name of the pig4cloud.com developer nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * Author: hnqz
- */
-
-package net.yyc.common.oss;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-/**
- * aws 配置信息
- *
- * @author hnqz
- * @author 858695266 配置文件添加: oss: enable: true endpoint: http://127.0.0.1:9000 #
- * pathStyleAccess 采用nginx反向代理或者AWS S3 配置成true,支持第三方云存储配置成false pathStyleAccess: false
- * access-key: hnqz secret-key: hnqz bucket-name: hnqz region: custom-domain:
- * https://oss.xxx.com/hnqz
- * <p>
- * bucket 设置公共读权限
- */
-@Data
-@ConfigurationProperties(prefix = "oss2")
-public class OssProperties2 {
-
-	/**
-	 * 对象存储服务的URL
-	 */
-	private String endpoint;
-
-	/**
-	 * 自定义域名
-	 */
-	private String customDomain;
-
-	/**
-	 * true path-style nginx 反向代理和S3默认支持 pathStyle {http://endpoint/bucketname} false
-	 * supports virtual-hosted-style 阿里云等需要配置为 virtual-hosted-style
-	 * 模式{http://bucketname.endpoint}
-	 */
-	private Boolean pathStyleAccess;
-
-	/**
-	 * 应用ID
-	 */
-	private String appId;
-
-	/**
-	 * 区域
-	 */
-	private String region;
-
-	/**
-	 * Access key就像用户ID,可以唯一标识你的账户
-	 */
-	private String accessKey;
-
-	/**
-	 * Secret key是你账户的密码
-	 */
-	private String secretKey;
-
-	/**
-	 * 默认的存储桶名称
-	 */
-	private String bucketName;
-
-	/**
-	 * 对象key前缀,默认为空
-	 */
-	private String objectKeyPre;
-
-}

+ 0 - 80
yyc-common-oss/src/main/java/net/yyc/common/oss/service/AliyunOssSigner.java

@@ -1,80 +0,0 @@
-/*
- *    Copyright (c) 2018-2025, hnqz All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * Neither the name of the pig4cloud.com developer nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * Author: hnqz
- */
-
-package net.yyc.common.oss.service;
-
-import com.aliyun.oss.OSS;
-import com.aliyun.oss.OSSClientBuilder;
-import com.aliyun.oss.model.GeneratePresignedUrlRequest;
-import net.yyc.common.oss.OssProperties2;
-import lombok.extern.slf4j.Slf4j;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import java.util.Date;
-
-/**
- * 阿里云 OSS V1 签名实现(基于 oss2 配置,生成长有效期 URL)
- *
- * <p>V1 签名不强制 7 天上限,expiresSeconds 可传入任意正数(如一年)。
- *
- * @author hnqz
- */
-@Slf4j
-public class AliyunOssSigner implements OssSigner {
-
-	private final OssProperties2 properties;
-
-	private OSS ossClient;
-
-	public AliyunOssSigner(OssProperties2 properties) {
-		this.properties = properties;
-	}
-
-	@PostConstruct
-	public void init() {
-		log.info("初始化阿里云 OSS V1 签名客户端, endpoint={}, bucket={}, objectKeyPre={}",
-				properties.getEndpoint(), properties.getBucketName(), properties.getObjectKeyPre());
-		this.ossClient = new OSSClientBuilder().build(
-				properties.getEndpoint(),
-				properties.getAccessKey(),
-				properties.getSecretKey());
-	}
-
-	@Override
-	public String sign(String objectKey, long expiresSeconds) {
-		String prefix = properties.getObjectKeyPre() != null ? properties.getObjectKeyPre() : "";
-		return sign(properties.getBucketName(), prefix + objectKey, expiresSeconds);
-	}
-
-	@Override
-	public String sign(String bucket, String objectKey, long expiresSeconds) {
-		Date expiration = new Date(System.currentTimeMillis() + expiresSeconds * 1000L);
-		GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, objectKey);
-		request.setExpiration(expiration);
-		return ossClient.generatePresignedUrl(request).toString();
-	}
-
-	@PreDestroy
-	public void destroy() {
-		if (ossClient != null) {
-			ossClient.shutdown();
-			log.info("阿里云 OSS 客户端已关闭");
-		}
-	}
-
-}

+ 0 - 48
yyc-common-oss/src/main/java/net/yyc/common/oss/service/OssSigner.java

@@ -1,48 +0,0 @@
-/*
- *    Copyright (c) 2018-2025, hnqz All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * Neither the name of the pig4cloud.com developer nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * Author: hnqz
- */
-
-package net.yyc.common.oss.service;
-
-/**
- * OSS 签名 URL 生成器(生成长有效期访问链接)
- *
- * <p>V1 签名无 7 天有效期上限,可传入任意秒数(常见:一年 = 365*24*3600)
- *
- * @author hnqz
- */
-public interface OssSigner {
-
-	/**
-	 * 使用 oss2 默认 bucket + objectKeyPre 生成签名 URL
-	 *
-	 * @param objectKey      对象 key(不含 prefix,会自动拼接 oss2.object-key-pre)
-	 * @param expiresSeconds 过期秒数(任意正数)
-	 * @return 完整签名 URL
-	 */
-	String sign(String objectKey, long expiresSeconds);
-
-	/**
-	 * 指定 bucket 与 objectKey 生成签名 URL
-	 *
-	 * @param bucket         桶名
-	 * @param objectKey      对象 key(完整路径)
-	 * @param expiresSeconds 过期秒数(任意正数)
-	 * @return 完整签名 URL
-	 */
-	String sign(String bucket, String objectKey, long expiresSeconds);
-
-}