Skip to content

Commit 9c863db

Browse files
feat:support TSF certificate manager. (#644)
1 parent d36665b commit 9c863db

File tree

40 files changed

+2068
-12
lines changed

40 files changed

+2068
-12
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>polaris-certificate</artifactId>
7+
<groupId>com.tencent.polaris</groupId>
8+
<version>${revision}</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>polaris-certificate-api</artifactId>
14+
<name>Polaris Certificate API</name>
15+
<description>Polaris Certificate API JAR</description>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>com.tencent.polaris</groupId>
20+
<artifactId>polaris-client</artifactId>
21+
<version>${project.version}</version>
22+
</dependency>
23+
</dependencies>
24+
</project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Tencent is pleased to support the open source community by making polaris-java available.
3+
*
4+
* Copyright (C) 2021 Tencent. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
18+
package com.tencent.polaris.certificate.api.core;
19+
20+
import com.tencent.polaris.api.plugin.certificate.CertFile;
21+
import com.tencent.polaris.api.plugin.certificate.CertFileKey;
22+
23+
import java.io.Closeable;
24+
import java.util.Map;
25+
26+
public interface CertificateAPI extends AutoCloseable, Closeable {
27+
28+
/**
29+
* 获取证书文件Map
30+
*
31+
* @return
32+
*/
33+
Map<CertFileKey, CertFile> getPemFileMap();
34+
35+
/**
36+
* 清理并释放资源
37+
*/
38+
void destroy();
39+
40+
@Override
41+
default void close() {
42+
destroy();
43+
}
44+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Tencent is pleased to support the open source community by making polaris-java available.
3+
*
4+
* Copyright (C) 2021 Tencent. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
18+
package com.tencent.polaris.certificate.api.flow;
19+
20+
import com.tencent.polaris.api.plugin.certificate.CertFile;
21+
import com.tencent.polaris.api.plugin.certificate.CertFileKey;
22+
import com.tencent.polaris.client.flow.AbstractFlow;
23+
24+
import java.util.Map;
25+
26+
public interface CertificateFlow extends AbstractFlow {
27+
28+
/**
29+
* 获取证书文件Map
30+
*
31+
* @return
32+
*/
33+
Map<CertFileKey, CertFile> getPemFileMap();
34+
35+
/**
36+
* 清理并释放资源
37+
*/
38+
void destroy();
39+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Tencent is pleased to support the open source community by making polaris-java available.
3+
*
4+
* Copyright (C) 2021 Tencent. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
18+
package com.tencent.polaris.certificate.api.pojo;
19+
20+
import java.security.KeyPair;
21+
22+
/**
23+
* @author Haotian Zhang
24+
*/
25+
public class CsrRequest {
26+
27+
private final String commonName;
28+
29+
private final KeyPair keyPair;
30+
31+
public CsrRequest(String commonName, KeyPair keyPair) {
32+
this.commonName = commonName;
33+
this.keyPair = keyPair;
34+
}
35+
36+
public String getCommonName() {
37+
return commonName;
38+
}
39+
40+
public KeyPair getKeyPair() {
41+
return keyPair;
42+
}
43+
44+
@Override
45+
public String toString() {
46+
return "CsrRequest{" +
47+
"commonName='" + commonName + '\'' +
48+
'}';
49+
}
50+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>polaris-certificate</artifactId>
7+
<groupId>com.tencent.polaris</groupId>
8+
<version>${revision}</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>polaris-certificate-client</artifactId>
14+
<name>Polaris Certificate Client</name>
15+
<description>Polaris Certificate Client JAR</description>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>com.tencent.polaris</groupId>
20+
<artifactId>polaris-certificate-api</artifactId>
21+
<version>${project.version}</version>
22+
</dependency>
23+
</dependencies>
24+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Tencent is pleased to support the open source community by making polaris-java available.
3+
*
4+
* Copyright (C) 2021 Tencent. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
18+
package com.tencent.polaris.certificate.client.core;
19+
20+
import com.tencent.polaris.api.plugin.certificate.CertFile;
21+
import com.tencent.polaris.api.plugin.certificate.CertFileKey;
22+
import com.tencent.polaris.certificate.api.core.CertificateAPI;
23+
import com.tencent.polaris.certificate.api.flow.CertificateFlow;
24+
import com.tencent.polaris.client.api.BaseEngine;
25+
import com.tencent.polaris.client.api.SDKContext;
26+
27+
import java.util.Map;
28+
29+
public class DefaultCertificateAPI extends BaseEngine implements CertificateAPI {
30+
31+
private CertificateFlow certificateFlow;
32+
33+
public DefaultCertificateAPI(SDKContext sdkContext) {
34+
super(sdkContext);
35+
}
36+
37+
@Override
38+
protected void subInit() {
39+
certificateFlow = sdkContext.getOrInitFlow(CertificateFlow.class);
40+
}
41+
42+
@Override
43+
public Map<CertFileKey, CertFile> getPemFileMap() {
44+
checkAvailable("CertificateFlow");
45+
return certificateFlow.getPemFileMap();
46+
}
47+
48+
@Override
49+
public void close() {
50+
certificateFlow.destroy();
51+
}
52+
}

0 commit comments

Comments
 (0)