use of org.bouncycastle.cms.RecipientInformation in project nhin-d by DirectProject.
the class DefaultDirectRecipientInformationFactory_createInstanceTest method testInstanceTest_emptyProvider_assertDefaultProvider.
public void testInstanceTest_emptyProvider_assertDefaultProvider() throws Exception {
final SMIMEEnveloped env = createSMIMEEnv();
final RecipientInformation recipient = (RecipientInformation) env.getRecipientInfos().getRecipients().iterator().next();
final DefaultDirectRecipientInformationFactory factory = new DefaultDirectRecipientInformationFactory();
final DefaultDirectRecipientInformation recInfo = (DefaultDirectRecipientInformation) factory.createInstance(recipient, env);
assertEquals(CryptoExtensions.getJCEProviderName(), recInfo.encProvider);
}
use of org.bouncycastle.cms.RecipientInformation in project nhin-d by DirectProject.
the class DefaultDirectRecipientInformationFactory_createInstanceTest method testInstanceTest_configedProvider_assertConfigedProvider.
public void testInstanceTest_configedProvider_assertConfigedProvider() throws Exception {
final SMIMEEnveloped env = createSMIMEEnv();
final RecipientInformation recipient = (RecipientInformation) env.getRecipientInfos().getRecipients().iterator().next();
final DefaultDirectRecipientInformationFactory factory = new DefaultDirectRecipientInformationFactory("Hello");
final DefaultDirectRecipientInformation recInfo = (DefaultDirectRecipientInformation) factory.createInstance(recipient, env);
assertEquals("Hello", recInfo.encProvider);
}
use of org.bouncycastle.cms.RecipientInformation in project nhin-d by DirectProject.
the class DefaultDirectRecipientInformation_getDecryptedContentTest method testDecryptedContent_defaultConfig_assertDecrypted.
public void testDecryptedContent_defaultConfig_assertDecrypted() throws Exception {
final SMIMEEnveloped env = createSMIMEEnv();
final RecipientInformation recipient = (RecipientInformation) env.getRecipientInfos().getRecipients().iterator().next();
final SplitDirectRecipientInformationFactory factory = new SplitDirectRecipientInformationFactory();
final SplitDirectRecipientInformation recInfo = (SplitDirectRecipientInformation) factory.createInstance(recipient, env);
// this won't work unless the data is successfully decrypted
assertNotNull(recInfo.getDecryptedContent(encCert.getPrivateKey()));
}
use of org.bouncycastle.cms.RecipientInformation in project nhin-d by DirectProject.
the class SplitDirectRecipientInformationFactory_createInstanceTest method testInstanceTest_emptyProvider_assertDefaultProvider.
public void testInstanceTest_emptyProvider_assertDefaultProvider() throws Exception {
final SMIMEEnveloped env = createSMIMEEnv();
final RecipientInformation recipient = (RecipientInformation) env.getRecipientInfos().getRecipients().iterator().next();
final SplitDirectRecipientInformationFactory factory = new SplitDirectRecipientInformationFactory();
final SplitDirectRecipientInformation recInfo = (SplitDirectRecipientInformation) factory.createInstance(recipient, env);
assertEquals(CryptoExtensions.getJCEProviderName(), recInfo.encProvider);
assertEquals(CryptoExtensions.getJCESensitiveProviderName(), recInfo.keyEncProvider);
}
use of org.bouncycastle.cms.RecipientInformation in project nhin-d by DirectProject.
the class SplitDirectRecipientInformation_getDecryptedContentTest method testGetDecryptedContent_sameDefaultEncAndKeyEncProvider_assertDecrypted.
public void testGetDecryptedContent_sameDefaultEncAndKeyEncProvider_assertDecrypted() throws Exception {
final SMIMEEnveloped env = createSMIMEEnv();
final RecipientInformation recipient = (RecipientInformation) env.getRecipientInfos().getRecipients().iterator().next();
final SplitDirectRecipientInformationFactory factory = new SplitDirectRecipientInformationFactory();
final SplitDirectRecipientInformation recInfo = (SplitDirectRecipientInformation) factory.createInstance(recipient, env);
// this will be non-null if it works correctly
assertNotNull(recInfo.getDecryptedContent(((X509CertificateEx) encCert).getPrivateKey()));
}
Aggregations