我认为 JCA 替代 JCE 很简单。然而,编写一些测试代码来获取我系统上的所有提供程序表明情况并非如此。
我注意到以下几点:
MD5withRSA 在 SunRsaSign 以及 SunJSSE 中)类型 的算法,这些算法超出了 JCE 的范围第 1 项很有意义,因为 JCA(对我而言)是一个可供选择的 JCE 提供程序库/数组。
第 2 项有点令人困惑,因为它表明 JCA 并不是一组“相同”的 JCE 提供者;对于任何“种类”的提供者,无论是否连接 JCE,它都是某种形式的水坑。
那么,JCA、它的提供者和 JCE 之间的工作关系是什么?这些提供商是否也存在于独立的孤岛中,或者它们是否相互“构建”/相互依赖?
对于那些对代码和提示这个问题的结果感兴趣的人,下面列出了它
import java.security.Provider;
import java.security.Security;
import java.util.ArrayList;
public class ConsoleListJca
{
public static void main(String[] args)
{
for (Provider provider : Security.getProviders())
{
System.out.println("Provider: " + provider.getName() + " (ver " + provider.getVersion() + ")");
System.out.print(" Algorithms: ");
ArrayList<String> algos = new ArrayList<String>();
for (Provider.Service service : provider.getServices())
{
algos.add(String.format( "%s (%s)", service.getAlgorithm(), service.getType()));
}
java.util.Collections.sort(algos);
String algorsStr = algos.toString();
// remove [ and ] from ArrayList's toString()
algorsStr = algorsStr.substring(1, algorsStr.length()-1);
System.out.println(algorsStr);
System.out.println();
}
}
}
结果(针对 SO 格式化)是
Provider: SUN (ver 1.7)
Algorithms: CaseExactJKS (KeyStore), Collection (CertStore), DSA (AlgorithmParameterGenerator),
DSA (AlgorithmParameters), DSA (KeyFactory), DSA (KeyPairGenerator),
JKS (KeyStore), JavaLoginConfig (Configuration), JavaPolicy (Policy),
LDAP (CertStore), MD2 (MessageDigest), MD5 (MessageDigest), NONEwithDSA (Signature),
NativePRNG (SecureRandom), PKIX (CertPathBuilder), PKIX (CertPathValidator),
SHA (MessageDigest), SHA-256 (MessageDigest), SHA-384 (MessageDigest),
SHA-512 (MessageDigest), SHA1PRNG (SecureRandom), SHA1withDSA (Signature),
X.509 (CertificateFactory), com.sun.security.IndexedCollection (CertStore)
Provider: SunRsaSign (ver 1.7)
Algorithms: MD2withRSA (Signature), MD5withRSA (Signature), RSA (KeyFactory), RSA (KeyPairGenerator),
SHA1withRSA (Signature), SHA256withRSA (Signature), SHA384withRSA (Signature),
SHA512withRSA (Signature)
Provider: SunEC (ver 1.7)
Algorithms: EC (AlgorithmParameters), EC (KeyFactory), EC (KeyPairGenerator), ECDH (KeyAgreement),
NONEwithECDSA (Signature), SHA1withECDSA (Signature), SHA256withECDSA (Signature),
SHA384withECDSA (Signature), SHA512withECDSA (Signature)
Provider: SunJSSE (ver 1.7)
Algorithms: Default (SSLContext), MD2withRSA (Signature), MD5andSHA1withRSA (Signature),
MD5withRSA (Signature), NewSunX509 (KeyManagerFactory), PKCS12 (KeyStore),
PKIX (TrustManagerFactory), RSA (KeyFactory), RSA (KeyPairGenerator),
SHA1withRSA (Signature), SunX509 (KeyManagerFactory), SunX509 (TrustManagerFactory),
TLSv1 (SSLContext), TLSv1.1 (SSLContext), TLSv1.2 (SSLContext)
Provider: SunJCE (ver 1.7)
Algorithms: AES (AlgorithmParameters), AES (Cipher), AES (KeyGenerator), AESWrap (Cipher),
ARCFOUR (Cipher), ARCFOUR (KeyGenerator), Blowfish (AlgorithmParameters),
Blowfish (Cipher), Blowfish (KeyGenerator), DES (AlgorithmParameters),
DES (Cipher), DES (KeyGenerator), DES (SecretKeyFactory), DESede (AlgorithmParameters),
DESede (Cipher), DESede (KeyGenerator), DESede (SecretKeyFactory), DESedeWrap (Cipher),
DiffieHellman (AlgorithmParameterGenerator), DiffieHellman (AlgorithmParameters),
DiffieHellman (KeyAgreement), DiffieHellman (KeyFactory),
DiffieHellman (KeyPairGenerator), HmacMD5 (KeyGenerator), HmacMD5 (Mac),
HmacPBESHA1 (Mac), HmacSHA1 (KeyGenerator), HmacSHA1 (Mac), HmacSHA256 (KeyGenerator),
HmacSHA256 (Mac), HmacSHA384 (KeyGenerator), HmacSHA384 (Mac), HmacSHA512 (KeyGenerator),
HmacSHA512 (Mac), JCEKS (KeyStore), OAEP (AlgorithmParameters), PBE (AlgorithmParameters),
PBEWithMD5AndDES (AlgorithmParameters), PBEWithMD5AndDES (Cipher),
PBEWithMD5AndDES (SecretKeyFactory), PBEWithMD5AndTripleDES (AlgorithmParameters),
PBEWithMD5AndTripleDES (Cipher), PBEWithMD5AndTripleDES (SecretKeyFactory),
PBEWithSHA1AndDESede (AlgorithmParameters), PBEWithSHA1AndDESede (Cipher),
PBEWithSHA1AndDESede (SecretKeyFactory), PBEWithSHA1AndRC2_40 (AlgorithmParameters),
PBEWithSHA1AndRC2_40 (Cipher), PBEWithSHA1AndRC2_40 (SecretKeyFactory),
PBKDF2WithHmacSHA1 (SecretKeyFactory), RC2 (AlgorithmParameters), RC2 (Cipher),
RC2 (KeyGenerator), RSA (Cipher), SslMacMD5 (Mac), SslMacSHA1 (Mac),
SunTls12Prf (KeyGenerator), SunTlsKeyMaterial (KeyGenerator), SunTlsMasterSecret (KeyGenerator),
SunTlsPrf (KeyGenerator), SunTlsRsaPremasterSecret (KeyGenerator)
Provider: SunJGSS (ver 1.7)
Algorithms: 1.2.840.113554.1.2.2 (GssApiMechanism), 1.3.6.1.5.5.2 (GssApiMechanism)
Provider: SunSASL (ver 1.7)
Algorithms: CRAM-MD5 (SaslClientFactory), CRAM-MD5 (SaslServerFactory), DIGEST-MD5 (SaslClientFactory),
DIGEST-MD5 (SaslServerFactory), EXTERNAL (SaslClientFactory), GSSAPI (SaslClientFactory),
GSSAPI (SaslServerFactory), NTLM (SaslClientFactory), NTLM (SaslServerFactory), PLAIN (SaslClientFactory)
Provider: XMLDSig (ver 1.0)
Algorithms: DOM (KeyInfoFactory), DOM (XMLSignatureFactory),
http://www.w3.org/2000/09/xmldsig#base64 (TransformService),
http://www.w3.org/2000/09/xmldsig#enveloped-signature (TransformService),
http://www.w3.org/2001/10/xml-exc-c14n# (TransformService),
http://www.w3.org/2001/10/xml-exc-c14n#WithComments (TransformService),
http://www.w3.org/2002/06/xmldsig-filter2 (TransformService),
http://www.w3.org/2006/12/xml-c14n11 (TransformService),
http://www.w3.org/2006/12/xml-c14n11#WithComments (TransformService),
http://www.w3.org/TR/1999/REC-xpath-19991116 (TransformService),
http://www.w3.org/TR/1999/REC-xslt-19991116 (TransformService),
http://www.w3.org/TR/2001/REC-xml-c14n-20010315 (TransformService),
http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments (TransformService)
Provider: SunPCSC (ver 1.7)
Algorithms: PC/SC (TerminalFactory)
Provider: Apple (ver 1.1)
Algorithms: KeychainStore (KeyStore)
最佳答案
JCA 和 JCE 的基本区别在于 JCE 是 JCA 的扩展,而不是替代品。 JCA 包括类似 MessageDigest 的类, SecureRandom , KeyFactory , Signature和 KeyStore . JCE添加更多的密码学类别,例如 Cipher , KeyGeneration , Mac和 KeyGeneration . JCA 和 JCE 之间的区别在很大程度上已经消失,因为 JCE 随标准运行时一起提供已有一段时间了。
JCA/JCE旨在将加密实现与抽象分开。它是一个基于提供商的架构,您可以在其中插入您选择的提供商,例如 BouncyCastle ,它比标准 Java 运行时中包含的提供程序提供的加密算法支持更多。
关于java - JCA、它的提供者和 JCE 之间的关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21029527/
我构建了两个需要相互通信和发送文件的Rails应用程序。例如,一个Rails应用程序会发送请求以查看其他应用程序数据库中的表。然后另一个应用程序将呈现该表的json并将其发回。我还希望一个应用程序将存储在其公共(public)目录中的文本文件发送到另一个应用程序的公共(public)目录。我从来没有做过这样的事情,所以我什至不知道从哪里开始。任何帮助,将不胜感激。谢谢! 最佳答案 无论Rails是什么,几乎所有Web应用程序都有您的要求,大多数现代Web应用程序都需要相互通信。但是有一个小小的理解需要你坚持下去,网站不应直接访问彼此
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
在Cooper的书BeginningRuby中,第166页有一个我无法重现的示例。classSongincludeComparableattr_accessor:lengthdef(other)@lengthother.lengthenddefinitialize(song_name,length)@song_name=song_name@length=lengthendenda=Song.new('Rockaroundtheclock',143)b=Song.new('BohemianRhapsody',544)c=Song.new('MinuteWaltz',60)a.betwee
我正在检查一个Rails项目。在ERubyHTML模板页面上,我看到了这样几行:我不明白为什么不这样写:在这种情况下,||=和ifnil?有什么区别? 最佳答案 在这种特殊情况下没有区别,但可能是出于习惯。每当我看到nil?被使用时,它几乎总是使用不当。在Ruby中,很少有东西在逻辑上是假的,只有文字false和nil是。这意味着像if(!x.nil?)这样的代码几乎总是更好地表示为if(x)除非期望x可能是文字false。我会将其切换为||=false,因为它具有相同的结果,但这在很大程度上取决于偏好。唯一的缺点是赋值会在每次运行
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我的问题的一个例子是体育游戏。一场体育比赛有两支球队,一支主队和一支客队。我的事件记录模型如下:classTeam"Team"has_one:away_team,:class_name=>"Team"end我希望能够通过游戏访问一个团队,例如:Game.find(1).home_team但我收到一个单元化常量错误:Game::team。谁能告诉我我做错了什么?谢谢, 最佳答案 如果Gamehas_one:team那么Rails假设您的teams表有一个game_id列。不过,您想要的是games表有一个team_id列,在这种情况下
我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我
什么是ruby的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht
这篇文章是继上一篇文章“Observability:从零开始创建Java微服务并监控它(一)”的续篇。在上一篇文章中,我们讲述了如何创建一个Javaweb应用,并使用Filebeat来收集应用所生成的日志。在今天的文章中,我来详述如何收集应用的指标,使用APM来监控应用并监督web服务的在线情况。源码可以在地址 https://github.com/liu-xiao-guo/java_observability 进行下载。摄入指标指标被视为可以随时更改的时间点值。当前请求的数量可以改变任何毫秒。你可能有1000个请求的峰值,然后一切都回到一个请求。这也意味着这些指标可能不准确,你还想提取最小/
HashMap中为什么引入红黑树,而不是AVL树呢1.概述开始学习这个知识点之前我们需要知道,在JDK1.8以及之前,针对HashMap有什么不同。JDK1.7的时候,HashMap的底层实现是数组+链表JDK1.8的时候,HashMap的底层实现是数组+链表+红黑树我们要思考一个问题,为什么要从链表转为红黑树呢。首先先让我们了解下链表有什么不好???2.链表上述的截图其实就是链表的结构,我们来看下链表的增删改查的时间复杂度增:因为链表不是线性结构,所以每次添加的时候,只需要移动一个节点,所以可以理解为复杂度是N(1)删:算法时间复杂度跟增保持一致查:既然是非线性结构,所以查询某一个节点的时候