Class SimpleEncryptionTest
- java.lang.Object
-
- org.opensaml.core.OpenSAMLInitBaseTestCase
-
- org.opensaml.core.xml.XMLObjectBaseTestCase
-
- org.opensaml.xmlsec.encryption.support.SimpleEncryptionTest
-
public class SimpleEncryptionTest extends XMLObjectBaseTestCase
Simple tests for encryption.
-
-
Field Summary
Fields Modifier and Type Field Description private StringalgoURIprivate DataEncryptionParametersencParamsprivate Encrypterencrypterprivate StringexpectedKEKKeyNameAESprivate StringexpectedKEKKeyNameRSAprivate StringexpectedKeyNameprivate StringexpectedRecipientAESprivate StringexpectedRecipientRSAprivate KeyInfokekKeyInfoAESprivate KeyInfokekKeyInfoRSAprivate KeyEncryptionParameterskekParamsAESprivate List<KeyEncryptionParameters>kekParamsListprivate KeyEncryptionParameterskekParamsRSAprivate StringkekURIAESprivate StringkekURIRSAprivate KeyInfokeyInfoprivate SecurityProviderTestSupportproviderSupportprivate StringtargetFile-
Fields inherited from class org.opensaml.core.xml.XMLObjectBaseTestCase
builderFactory, marshallerFactory, parserPool, simpleXMLObjectQName, unmarshallerFactory
-
-
Constructor Summary
Constructors Constructor Description SimpleEncryptionTest()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckKEKAES(EncryptedKey encKey, boolean hasKeyInfo)Helper method to test AES KEK.private voidcheckKEKRSA(EncryptedKey encKey, boolean hasKeyInfo)Helper method to test RSA KEK.private StringgetDigestMethod(EncryptedKey encryptedKey)private StringgetMGF(EncryptedKey encryptedKey)private StringgetOAEPParams(EncryptedKey encryptedKey)protected voidsetUp()voidtestAutoKeyGen()Test basic encryption with auto-generated symmetric key.voidtestAutoKeyGenNoKEK()Test failure with auto-generated symmetric key and no KEK(s).voidtestEncryptContentMultipleKEK()Test basic encryption with symmetric key, one KEK.voidtestEncryptContentSingleKEK()Test basic content encryption with symmetric key, one KEK.voidtestEncryptContentWithKeyNameNoKEK()Test basic content encryption with symmetric key, no key wrap, set key name in passed KeyInfo object.voidtestEncryptDataBadKEKDSA()Test proper error handling of attempt to encrypt with a DSA key.voidtestEncryptDataMultipleKEK()Test basic data encryption with symmetric key, one KEK.voidtestEncryptDataSingleKEK()Test data basic encryption with symmetric key, one KEK.voidtestEncryptDataWithKeyNameNoKEK()Test data basic encryption with symmetric key, no key wrap, set key name in passed KeyInfo object.voidtestEncryptKeyDigestMethodsRSAOAEP()Test code for the Apache XML-Security issue workaround that requires we expliclty express SHA-1 DigestMethod on EncryptionMethod, only when key transport algorithm is RSA-OAEP.voidtestEncryptKeyDigestMethodsRSAv15()Test code for the Apache XML-Security issue workaround that requires we expliclty express SHA-1 DigestMethod on EncryptionMethod, only when key transport algorithm is RSA-OAEP.voidtestEncryptKeyMultipleKEK()Test basic encryption of a symmetric key into an EncryptedKey, set key encrypting key name in passed KeyInfo object.voidtestEncryptKeySingleKEK()Test basic encryption of a symmetric key into an EncryptedKey, set key encrypting key name in passed KeyInfo object.voidtestRSAOAEPParameters()Test encryption of a symmetric key into an EncryptedKey, using various RSAOAEPParameters options.-
Methods inherited from class org.opensaml.core.xml.XMLObjectBaseTestCase
assertXMLEquals, assertXMLEquals, buildXMLObject, getBuilder, getMarshaller, getMarshaller, getUnmarshaller, getUnmarshaller, getUnmarshaller, initXMLObjectSupport, parseXMLDocument, printXML, printXML, unmarshallElement, unmarshallElement
-
Methods inherited from class org.opensaml.core.OpenSAMLInitBaseTestCase
initOpenSAML
-
-
-
-
Field Detail
-
encrypter
private Encrypter encrypter
-
encParams
private DataEncryptionParameters encParams
-
algoURI
private String algoURI
-
kekParamsList
private List<KeyEncryptionParameters> kekParamsList
-
kekParamsAES
private KeyEncryptionParameters kekParamsAES
-
kekURIAES
private String kekURIAES
-
kekParamsRSA
private KeyEncryptionParameters kekParamsRSA
-
kekURIRSA
private String kekURIRSA
-
keyInfo
private KeyInfo keyInfo
-
kekKeyInfoAES
private KeyInfo kekKeyInfoAES
-
kekKeyInfoRSA
private KeyInfo kekKeyInfoRSA
-
expectedKeyName
private String expectedKeyName
-
expectedKEKKeyNameAES
private String expectedKEKKeyNameAES
-
expectedKEKKeyNameRSA
private String expectedKEKKeyNameRSA
-
expectedRecipientRSA
private String expectedRecipientRSA
-
expectedRecipientAES
private String expectedRecipientAES
-
targetFile
private String targetFile
-
providerSupport
private SecurityProviderTestSupport providerSupport
-
-
Method Detail
-
setUp
@BeforeMethod protected void setUp() throws Exception
- Throws:
Exception
-
testEncryptDataWithKeyNameNoKEK
public void testEncryptDataWithKeyNameNoKEK()
Test data basic encryption with symmetric key, no key wrap, set key name in passed KeyInfo object.
-
testEncryptDataSingleKEK
public void testEncryptDataSingleKEK()
Test data basic encryption with symmetric key, one KEK.
-
testEncryptDataMultipleKEK
public void testEncryptDataMultipleKEK()
Test basic data encryption with symmetric key, one KEK.
-
testEncryptContentWithKeyNameNoKEK
public void testEncryptContentWithKeyNameNoKEK()
Test basic content encryption with symmetric key, no key wrap, set key name in passed KeyInfo object.
-
testEncryptContentSingleKEK
public void testEncryptContentSingleKEK()
Test basic content encryption with symmetric key, one KEK.
-
testEncryptContentMultipleKEK
public void testEncryptContentMultipleKEK()
Test basic encryption with symmetric key, one KEK.
-
testEncryptKeySingleKEK
public void testEncryptKeySingleKEK() throws NoSuchAlgorithmException, NoSuchProviderException, XMLParserException, KeyExceptionTest basic encryption of a symmetric key into an EncryptedKey, set key encrypting key name in passed KeyInfo object.- Throws:
NoSuchProviderException- bad JCA providerNoSuchAlgorithmException- bad JCA algorithmXMLParserException- error creating new Document from poolKeyException- ...
-
testEncryptKeyMultipleKEK
public void testEncryptKeyMultipleKEK() throws NoSuchAlgorithmException, NoSuchProviderException, XMLParserException, KeyExceptionTest basic encryption of a symmetric key into an EncryptedKey, set key encrypting key name in passed KeyInfo object.- Throws:
NoSuchProviderException- bad JCA providerNoSuchAlgorithmException- bad JCA algorithmXMLParserException- error creating new Document from poolKeyException- ...
-
testAutoKeyGen
public void testAutoKeyGen()
Test basic encryption with auto-generated symmetric key.
-
testAutoKeyGenNoKEK
public void testAutoKeyGenNoKEK()
Test failure with auto-generated symmetric key and no KEK(s).
-
testEncryptKeyDigestMethodsRSAOAEP
public void testEncryptKeyDigestMethodsRSAOAEP() throws NoSuchAlgorithmException, NoSuchProviderException, XMLParserException, KeyExceptionTest code for the Apache XML-Security issue workaround that requires we expliclty express SHA-1 DigestMethod on EncryptionMethod, only when key transport algorithm is RSA-OAEP.- Throws:
NoSuchProviderException- bad JCA providerNoSuchAlgorithmException- bad JCA algorithmXMLParserException- error creating new Document from poolKeyException- ...
-
testEncryptKeyDigestMethodsRSAv15
public void testEncryptKeyDigestMethodsRSAv15() throws NoSuchAlgorithmException, NoSuchProviderException, XMLParserException, KeyExceptionTest code for the Apache XML-Security issue workaround that requires we expliclty express SHA-1 DigestMethod on EncryptionMethod, only when key transport algorithm is RSA-OAEP.- Throws:
NoSuchProviderException- bad JCA providerNoSuchAlgorithmException- bad JCA algorithmXMLParserException- error creating new Document from poolKeyException- ...
-
testEncryptDataBadKEKDSA
public void testEncryptDataBadKEKDSA() throws NoSuchAlgorithmException, NoSuchProviderExceptionTest proper error handling of attempt to encrypt with a DSA key.- Throws:
NoSuchProviderException- ...NoSuchAlgorithmException- ...
-
testRSAOAEPParameters
public void testRSAOAEPParameters() throws NoSuchAlgorithmException, NoSuchProviderException, XMLParserException, KeyException, EncryptionExceptionTest encryption of a symmetric key into an EncryptedKey, using various RSAOAEPParameters options.- Throws:
NoSuchProviderException- bad JCA providerNoSuchAlgorithmException- bad JCA algorithmXMLParserException- error creating new Document from poolKeyException- ...EncryptionException- ...
-
checkKEKAES
private void checkKEKAES(EncryptedKey encKey, boolean hasKeyInfo)
Helper method to test AES KEK.- Parameters:
encKey- EncryptedKey to testhasKeyInfo- flag indicating expectation of KeyInfo presence
-
checkKEKRSA
private void checkKEKRSA(EncryptedKey encKey, boolean hasKeyInfo)
Helper method to test RSA KEK.- Parameters:
encKey- EncryptedKey to testhasKeyInfo- flag indicating expectation of KeyInfo presence
-
getDigestMethod
private String getDigestMethod(EncryptedKey encryptedKey)
-
getMGF
private String getMGF(EncryptedKey encryptedKey)
-
getOAEPParams
private String getOAEPParams(EncryptedKey encryptedKey)
-
-