Java如何获取加密安全提供程序
package org.nhooo.example.security;
import java.security.Provider;
import java.security.Security;
import java.util.Set;
import java.util.HashSet;
public class SecurityProvider {
public static void main(String[] args) {
//创建一个集合,以便我们获得独特的结果。
Set result = new HashSet();
//返回包含所有已安装的提供程序的数组。
Provider[] providers = Security.getProviders();
for (Provider provider : providers) {
//获取提供者的属性密钥
Set keys = provider.keySet();
for (Object key : keys) {
String data = (String) key;
data = data.split(" ")[0];
//服务类型以“Alg.Alias”字符串开头"Alg.Alias" string
if (data.startsWith("Alg.Alias")) {
data = data.substring(10);
}
data = data.substring(0, data.indexOf('.'));
result.add(data);
}
}
for (Object o : result) {
System.out.println("Service Type = " + o);
}
}
}我们的代码的示例结果:
Service Type = KeyFactoryService Type = TransformServiceService Type = CertPathBuilderService Type = CipherService Type = SecureRandomService Type = SignatureService Type = AlgorithmParameterGeneratorService Type = KeyPairGeneratorService Type = XMLSignatureFactoryService Type = CertificateFactoryService Type = MessageDigestService Type = KeyInfoFactoryService Type = KeyAgreementService Type = CertStoreService Type = ConfigurationService Type = SSLContextService Type = SaslServerFactoryService Type = AlgorithmParametersService Type = TrustManagerFactoryService Type = GssApiMechanismService Type = TerminalFactoryService Type = MacService Type = KeyGeneratorService Type = PolicyService Type = CertPathValidatorService Type = SaslClientFactoryService Type = SecretKeyFactoryService Type = KeyManagerFactoryService Type = KeyStoreService Type = Provider
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短