|
@@ -4,13 +4,13 @@ import lombok.Getter;
|
|
|
import org.jetlinks.community.network.manager.entity.CertificateEntity;
|
|
|
import org.jetlinks.community.network.security.DefaultCertificate;
|
|
|
|
|
|
-import java.util.Base64;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import static org.apache.commons.codec.binary.Base64.decodeBase64;
|
|
|
+
|
|
|
/**
|
|
|
* @author wangzheng
|
|
|
- * @see
|
|
|
* @since 1.0
|
|
|
*/
|
|
|
@Getter
|
|
@@ -19,26 +19,26 @@ public enum CertificateType {
|
|
|
@Override
|
|
|
public DefaultCertificate init(DefaultCertificate certificate, CertificateEntity.CertificateConfig config) {
|
|
|
return certificate
|
|
|
- .initPfxKey(Base64.getDecoder().decode(config.getKeystoreBase64()), config.getKeystorePwd())
|
|
|
- .initPfxTrust(Base64.getDecoder().decode(config.getTrustKeyStoreBase64()), config.getTrustKeyStorePwd());
|
|
|
+ .initPfxKey(decodeBase64(config.getKeystoreBase64()), config.getKeystorePwd())
|
|
|
+ .initPfxTrust(decodeBase64(config.getTrustKeyStoreBase64()), config.getTrustKeyStorePwd());
|
|
|
}
|
|
|
},
|
|
|
JKS {
|
|
|
@Override
|
|
|
public DefaultCertificate init(DefaultCertificate certificate, CertificateEntity.CertificateConfig config) {
|
|
|
return certificate
|
|
|
- .initJksKey(Base64.getDecoder().decode(config.getKeystoreBase64()), config.getKeystorePwd())
|
|
|
- .initJksTrust(Base64.getDecoder().decode(config.getTrustKeyStoreBase64()), config.getTrustKeyStorePwd());
|
|
|
+ .initJksKey(decodeBase64(config.getKeystoreBase64()), config.getKeystorePwd())
|
|
|
+ .initJksTrust(decodeBase64(config.getTrustKeyStoreBase64()), config.getTrustKeyStorePwd());
|
|
|
}
|
|
|
},
|
|
|
PEM {
|
|
|
@Override
|
|
|
public DefaultCertificate init(DefaultCertificate certificate, CertificateEntity.CertificateConfig config) {
|
|
|
- List<byte[]> keyCert = Collections.singletonList(Base64.getDecoder().decode(config.getKeystoreBase64()));
|
|
|
+ List<byte[]> keyCert = Collections.singletonList(decodeBase64(config.getKeystoreBase64()));
|
|
|
|
|
|
return certificate
|
|
|
.initPemKey(keyCert, keyCert)
|
|
|
- .initPemTrust(Collections.singletonList(Base64.getDecoder().decode(config.getTrustKeyStoreBase64())));
|
|
|
+ .initPemTrust(Collections.singletonList(decodeBase64(config.getTrustKeyStoreBase64())));
|
|
|
|
|
|
}
|
|
|
};
|