summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Vartanian <flooey@google.com>2017-03-23 10:57:55 +0000
committerAdam Vartanian <flooey@google.com>2017-03-23 13:14:30 +0000
commita23aa31f7112ca408cd81ea457f42435ee36da38 (patch)
tree164c33c43092596e32c0803600d145ad840b80ed
parent90b7ee105631e6e1feabd08c9baaf29afde06b20 (diff)
downloadapache-harmony-a23aa31f7112ca408cd81ea457f42435ee36da38.tar.gz
Remove tests from external/apache-harmony
These tests are already replicated (sometimes in modified form) in the libcore tree in various places. I compared their contents and couldn't find any significant missing pieces from these, so just get rid of these instead of including them. Bug: 4483710 Test: cts -m CtsLibcoreTestCases Change-Id: Id1cc89685e2a3cfd2f69e832beb214487ba53b3d
-rw-r--r--Android.mk10
-rw-r--r--crypto/src/test/api/java.injected/javax/crypto/CipherInputStreamTest.java243
-rw-r--r--crypto/src/test/api/java.injected/javax/crypto/CipherOutputStreamTest.java176
-rw-r--r--crypto/src/test/api/java.injected/javax/crypto/CipherSpiTest.java328
-rw-r--r--crypto/src/test/api/java.injected/javax/crypto/ExemptionMechanismSpiTest.java106
-rw-r--r--crypto/src/test/api/java.injected/javax/crypto/KeyAgreementSpiTest.java88
-rw-r--r--crypto/src/test/api/java.injected/javax/crypto/KeyGeneratorSpiTest.java79
-rw-r--r--crypto/src/test/api/java.injected/javax/crypto/MacSpiTest.java151
-rw-r--r--crypto/src/test/api/java.injected/javax/crypto/SealedObjectTest.java235
-rw-r--r--crypto/src/test/api/java.injected/javax/crypto/SecretKeyFactorySpiTest.java63
-rw-r--r--crypto/src/test/api/java.injected/javax/crypto/spec/PSourceTest.java109
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/BadPaddingExceptionTest.java88
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java67
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java49
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java475
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfoTest.java1926
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismExceptionTest.java111
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismTest.java164
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/IllegalBlockSizeExceptionTest.java90
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementTest.java547
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorTest.java444
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java813
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/NoSuchPaddingExceptionTest.java90
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/NullCipherTest.java266
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactoryTest.java424
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyTest.java70
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ShortBufferExceptionTest.java89
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPrivateKeyTest.java81
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPublicKeyTest.java84
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/PBEKeyTest.java89
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.java44
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.java44
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.java44
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.java44
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.java44
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java290
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESedeKeySpecTest.java197
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHGenParameterSpecTest.java61
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHParameterSpecTest.java76
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPrivateKeySpecTest.java66
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPublicKeySpecTest.java66
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/IvParameterSpecTest.java139
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/OAEPParameterSpecTest.java161
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEKeySpecTest.java305
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEParameterSpecTest.java97
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC2ParameterSpecTest.java200
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java282
-rw-r--r--crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java274
-rw-r--r--crypto/src/test/impl/java.injected/org/apache/harmony/crypto/internal/NullCipherSpiTest.java230
-rw-r--r--crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_Impl1Test.java103
-rw-r--r--crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_ImplTest.java300
-rw-r--r--crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfo_ImplTest.java123
-rw-r--r--crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanism_ImplTest.java299
-rw-r--r--crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_Impl1Test.java100
-rw-r--r--crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_ImplTest.java264
-rw-r--r--crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGenerator_ImplTest.java270
-rw-r--r--crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Mac_ImplTest.java285
-rw-r--r--crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_Impl1Test.java120
-rw-r--r--crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_ImplTest.java233
-rw-r--r--crypto/src/test/resources/hyts_des-ede3-cbc.test1.ciphertext1
-rw-r--r--crypto/src/test/resources/hyts_des-ede3-cbc.test1.iv1
-rw-r--r--crypto/src/test/resources/hyts_des-ede3-cbc.test1.key1
-rw-r--r--crypto/src/test/resources/hyts_des-ede3-cbc.test1.plaintext1
-rw-r--r--crypto/src/test/resources/hyts_des-ede3-cbc.test2.ciphertextbin128 -> 0 bytes
-rw-r--r--crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv1
-rw-r--r--crypto/src/test/resources/hyts_des-ede3-cbc.test2.key1
-rw-r--r--crypto/src/test/resources/hyts_des-ede3-cbc.test2.plaintextbin126 -> 0 bytes
-rw-r--r--crypto/src/test/resources/hyts_des-ede3-cbc.test3.ciphertextbin10008 -> 0 bytes
-rw-r--r--crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv1
-rw-r--r--crypto/src/test/resources/hyts_des-ede3-cbc.test3.key1
-rw-r--r--crypto/src/test/resources/hyts_des-ede3-cbc.test3.plaintextbin10000 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.0.serbin1388 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.1.serbin1388 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.2.serbin1473 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.0.serbin1412 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.1.serbin1412 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.2.serbin1497 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.0.serbin1406 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.1.serbin1406 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.2.serbin1491 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.0.serbin1397 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.1.serbin1397 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.2.serbin1482 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.0.serbin1391 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.1.serbin1391 -> 0 bytes
-rw-r--r--crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.2.serbin1476 -> 0 bytes
-rw-r--r--crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/EncryptedPrivateKeyInfoData.java1228
-rw-r--r--crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyCipher.java120
-rw-r--r--crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyExemptionMechanismSpi.java142
-rw-r--r--crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyKeyAgreementSpi.java84
-rw-r--r--crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyKeyGeneratorSpi.java62
-rw-r--r--crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyMacSpi.java75
-rw-r--r--crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MySecretKeyFactorySpi.java55
-rw-r--r--security/src/test/api/java.injected/java/security/AlgorithmParameterGeneratorSpiTest.java78
-rw-r--r--security/src/test/api/java.injected/java/security/IdentityTest.java331
-rw-r--r--security/src/test/api/java.injected/java/security/ProviderTest.java208
-rw-r--r--security/src/test/api/java.injected/java/security/SecureClassLoaderTest.java207
-rw-r--r--security/src/test/api/java.injected/java/security/SecureRandomTest.java178
-rw-r--r--security/src/test/api/java.injected/java/security/SignatureTest.java316
-rw-r--r--security/src/test/api/java.injected/java/security/cert/myCertPath.java60
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlException2Test.java82
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlExceptionTest.java59
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator1Test.java385
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator2Test.java266
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator3Test.java192
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java647
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSignerTest.java111
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestExceptionTest.java185
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestInputStream2Test.java168
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestInputStreamTest.java583
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java604
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/GeneralSecurityExceptionTest.java189
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/GuardedObjectTest.java70
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/Identity2Test.java325
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScope2Test.java266
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java101
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidAlgorithmParameterExceptionTest.java199
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidKeyExceptionTest.java187
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidParameterExceptionTest.java90
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSCallbackHandlerProtectionTest.java71
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSPasswordProtectionTest.java72
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSPrivateKeyEntryTest.java210
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSSecretKeyEntryTest.java90
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSTrustedCertificateEntryTest.java72
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyExceptionTest.java185
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java406
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyManagementExceptionTest.java189
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator1Test.java502
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator2Test.java426
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator3Test.java134
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator4Test.java140
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator5Test.java44
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGeneratorSpiTest.java78
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairTest.java142
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyRepTest.java187
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java732
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore3Test.java278
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreExceptionTest.java186
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStorePrivateKeyEntryTest.java79
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java203
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java391
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyTest.java73
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest1Test.java257
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java455
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java165
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmExceptionTest.java189
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderExceptionTest.java90
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivateKeyTest.java71
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java49
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionExceptionTest.java59
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProtectionDomainTest.java260
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/Provider2Test.java168
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderExceptionTest.java186
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java125
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderTest.java307
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/PublicKeyTest.java71
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java72
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java212
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java337
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java376
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signature2Test.java250
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignatureExceptionTest.java187
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java58
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignerTest.java127
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/TimestampTest.java95
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnrecoverableEntryExceptionTest.java70
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnrecoverableKeyExceptionTest.java91
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java43
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java39
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java39
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLExceptionTest.java184
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLTest.java88
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java386
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java252
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderExceptionTest.java189
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderSpiTest.java65
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathTest.java175
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator1Test.java413
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator2Test.java251
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator3Test.java125
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorExceptionTest.java375
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorSpiTest.java73
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStore1Test.java427
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreExceptionTest.java186
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreSpiTest.java104
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingExceptionTest.java193
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExceptionTest.java188
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExpiredExceptionTest.java89
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory1Test.java693
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory2Test.java348
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory3Test.java191
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory4Test.java611
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactorySpiTest.java288
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateNotYetValidExceptionTest.java91
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateParsingExceptionTest.java191
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateTest.java202
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CollectionCertStoreParametersTest.java239
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/LDAPCertStoreParametersTest.java191
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParametersTest.java189
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java264
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathCheckerTest.java85
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java348
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXParametersTest.java1359
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PolicyQualifierInfoTest.java322
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchorTest.java557
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRL2Test.java66
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntry2Test.java66
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntryTest.java168
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLSelectorTest.java131
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLTest.java258
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CertSelectorTest.java135
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509Certificate2Test.java79
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.java49
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.java113
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.java76
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.java49
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.java49
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.java46
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.java45
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java103
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPrivateKeyTest.java80
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPublicKeyTest.java80
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPrivateKeyTest.java80
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPublicKeyTest.java80
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAMultiPrimePrivateCrtKeyTest.java108
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateCrtKeyTest.java104
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateKeyTest.java79
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPublicKeyTest.java79
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.java62
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.java48
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.java59
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.java47
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyPairTest.java98
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.java45
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.java64
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignedObjectTest.java102
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/TimestampTest.java45
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.java45
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.java45
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAParameterSpecTest.java91
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPrivateKeySpecTest.java109
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPublicKeySpecTest.java108
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2mTest.java539
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldFpTest.java197
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECGenParameterSpecTest.java81
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECPointTest.java243
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurveTest.java666
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpec2Test.java83
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpecTest.java110
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidKeySpecExceptionTest.java188
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidParameterSpecExceptionTest.java91
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/MGF1ParameterSpecTest.java93
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PKCS8EncodedKeySpecTest.java137
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PSSParameterSpecTest.java265
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAKeyGenParameterSpecTest.java91
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java708
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAOtherPrimeInfoTest.java148
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateCrtKeySpecTest.java238
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateKeySpecTest.java77
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPublicKeySpecTest.java92
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/X509EncodedKeySpecTest.java137
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.java50
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.java45
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateEncodingExceptionTest.java88
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExceptionTest.java89
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExpiredExceptionTest.java89
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateNotYetValidExceptionTest.java91
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateParsingExceptionTest.java89
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateTest.java152
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/X509CertificateTest.java339
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.java46
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.java45
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.java46
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.java45
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.java46
-rw-r--r--security/src/test/api/java/tests/api/java/security/AccessControlContextTest.java83
-rw-r--r--security/src/test/api/java/tests/api/java/security/DomainCombinerTest.java86
-rw-r--r--security/src/test/impl/java.injected/java/security/Provider_ImplTest.java98
-rw-r--r--security/src/test/impl/java.injected/java/security/Security_ImplTest.java130
-rw-r--r--security/src/test/impl/java.injected/java/security/Signature_Impl1Test.java88
-rw-r--r--security/src/test/impl/java.injected/java/security/Signature_Impl2Test.java254
-rw-r--r--security/src/test/impl/java.injected/java/security/URIParameterTest.java72
-rw-r--r--security/src/test/impl/java.injected/java/security/cert/X509CRLSelectorTest.java602
-rw-r--r--security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java2920
-rw-r--r--security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java282
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/SystemScopeTest.java194
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/AnyTest.java55
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BerInputStreamTest.java218
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BitStringTest.java246
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BooleanTest.java87
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ChoiceTest.java333
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/DerGeneralizedTimeEDTest.java179
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/DerUTCTimeEDTest.java166
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ExplicitTest.java193
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/GeneralizedTimeTest.java152
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ImplicitTest.java230
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/IntegerTest.java150
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/OidTest.java188
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceOfTest.java132
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceTest.java273
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/UTCTimeTest.java124
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/fortress/EngineTest.java131
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/fortress/MyProvider.java38
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/fortress/ServicesTest.java86
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/fortress/SomeClass.java26
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator_ImplTest.java126
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/CodeSigner_ImplTest.java52
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KSBuilder_ImplTest.java549
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KeyStore_Impl1Test.java982
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KeyStore_Impl2Test.java429
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KeyStore_Impl3Test.java200
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/MessageDigest_Impl2Test.java180
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/ProviderService_ImplTest.java64
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/SecureRandom_ImplTest.java140
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/Timestamp_ImplTest.java50
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertStore_ImplTest.java310
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory_ImplTest.java798
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParameters_ImplTest.java248
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXParameters_ImplTest.java297
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchor_ImplTest.java760
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2m_ImplTest.java217
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECParameterSpec_ImplTest.java263
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPrivateKeySpec_ImplTest.java157
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPublicKeySpec_ImplTest.java180
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurve_ImplTest.java110
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/pkcs7/AuthenticatedAttributesTest.java55
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/pkcs7/SignerInfoTest.java52
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/utils/AlgNameMapperTest.java71
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x501/NameTest.java89
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateListTest.java234
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java68
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateTest.java227
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/DistributionPointTest.java30
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java205
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNameTest.java200
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNamesTest.java54
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java79
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/PolicyQualifierInfoTest.java217
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/PrivateKeyUsagePeriodTest.java48
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/TimeTest.java50
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/PKIStatusInfoTest.java54
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/TSTInfoTest.java86
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/TimeStampReqTest.java69
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/TimeStampRespTest.java112
-rw-r--r--security/src/test/resources/AuthenticatedAttributesTest.datbin2230 -> 0 bytes
-rw-r--r--security/src/test/resources/PermissionCollection/keystore.bksbin2481 -> 0 bytes
-rw-r--r--security/src/test/resources/PermissionCollection/mypermissionBKS.jarbin3396 -> 0 bytes
-rw-r--r--security/src/test/resources/PermissionCollection/signedBKS.jarbin2453 -> 0 bytes
-rw-r--r--security/src/test/resources/PolicyTest.txt3
-rw-r--r--security/src/test/resources/hyts_badpem.cer31
-rw-r--r--security/src/test/resources/hyts_certificate_PEM.txt16
-rw-r--r--security/src/test/resources/hyts_ks.bksbin1295 -> 0 bytes
-rw-r--r--security/src/test/resources/java/security/Provider.prop.dat8
-rw-r--r--security/src/test/resources/java/security/cert/CertPath.PkiPathbin805 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.0.serbin1473 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.1.serbin1473 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.2.serbin1558 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.3.serbin2532 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.4.serbin1469 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.5.serbin3651 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.0.serbin1509 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.1.serbin1509 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.2.serbin1594 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.3.serbin2592 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.4.serbin1505 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.5.serbin3735 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.golden.serbin936 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.0.serbin1571 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.1.serbin1571 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.2.serbin1656 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.3.serbin2658 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.4.serbin1567 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.5.serbin3810 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.6.serbin3810 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.0.serbin1491 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.1.serbin1491 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.2.serbin1576 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.3.serbin2562 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.4.serbin1487 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.5.serbin3693 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.0.serbin1575 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.1.serbin1575 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.2.serbin1660 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.3.serbin2666 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.4.serbin1571 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.5.serbin3817 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.0.serbin1497 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.1.serbin1497 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.2.serbin1582 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.3.serbin2572 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.4.serbin1493 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.5.serbin3707 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.golden.0.serbin1572 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.golden.1.serbin1572 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.golden.2.serbin1657 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.0.serbin1584 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.1.serbin1584 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.2.serbin1669 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.0.serbin1572 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.1.serbin1572 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.2.serbin1657 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.3.serbin2661 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.4.serbin1568 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.5.serbin3810 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.golden.serbin938 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.0.serbin1560 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.1.serbin1569 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.2.serbin1560 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.3.serbin1683 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.golden.0.serbin752 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.golden.1.serbin613 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.0.serbin1472 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.1.serbin1472 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.2.serbin1557 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.3.serbin2532 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.4.serbin1468 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.5.serbin3652 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.0.serbin1446 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.1.serbin1446 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.2.serbin1531 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.3.serbin2524 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.4.serbin1442 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.5.serbin3662 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.golden.0.serbin113 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.golden.1.serbin121 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.golden.2.serbin265 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.0.serbin1529 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.1.serbin1529 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.2.serbin1614 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.3.serbin2627 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.4.serbin1525 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.5.serbin3785 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.0.serbin1525 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.1.serbin1525 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.2.serbin1610 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.3.serbin2593 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.4.serbin1521 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.5.serbin3721 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.golden.0.serbin1539 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.golden.1.serbin1539 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.golden.2.serbin1624 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.0.serbin1463 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.1.serbin1463 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.2.serbin1548 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.3.serbin2517 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.4.serbin1459 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.5.serbin3631 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.0.serbin1534 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.1.serbin1534 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.2.serbin1619 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.3.serbin2608 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.4.serbin1530 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.5.serbin3742 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyPairTest.golden.serbin532 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.0.serbin1478 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.1.serbin1478 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.2.serbin1563 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.3.serbin2542 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.4.serbin1474 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.5.serbin3666 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.0.serbin1499 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.1.serbin1499 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.2.serbin1584 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.3.serbin2577 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.4.serbin1495 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.5.serbin3715 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.golden.0.serbin1496 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.golden.1.serbin1496 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.golden.2.serbin1581 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.golden.0.serbin1482 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.golden.1.serbin2570 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.golden.2.serbin3696 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.0.serbin1466 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.1.serbin1466 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.2.serbin1551 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.3.serbin2530 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.4.serbin1462 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.5.serbin3654 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.0.serbin1481 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.1.serbin1481 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.2.serbin1566 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.3.serbin2547 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.4.serbin1477 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.5.serbin3673 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignedObjectTest.golden.0.serbin377 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/TimestampTest.golden.0.serbin644 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.golden.0.serbin1508 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.golden.1.serbin1508 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.golden.2.serbin1593 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.golden.0.serbin1502 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.golden.1.serbin1502 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.golden.2.serbin1587 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.0.serbin1506 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.1.serbin1506 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.2.serbin1591 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.3.serbin2587 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.4.serbin1502 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.5.serbin3728 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.golden.0.serbin1524 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.golden.1.serbin1524 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.golden.2.serbin1609 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.0.serbin1525 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.1.serbin1525 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.2.serbin1538 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.3.serbin1610 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.0.serbin1446 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.1.serbin1446 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.2.serbin1459 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.3.serbin1531 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.golden.0.serbin1522 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.golden.1.serbin1522 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.golden.2.serbin1607 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.0.serbin1534 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.1.serbin1534 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.2.serbin1619 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.0.serbin1522 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.1.serbin1522 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.2.serbin1607 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.3.serbin1607 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.0.serbin1607 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.1.serbin1607 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.2.serbin1611 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.3.serbin1711 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.4.serbin1730 -> 0 bytes
-rw-r--r--security/src/test/resources/test.BKS.ks1bin1276 -> 0 bytes
-rw-r--r--security/src/test/resources/test.BKS.ks2bin1026 -> 0 bytes
-rw-r--r--security/src/test/resources/test.BKS.ks3bin2198 -> 0 bytes
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/CertificateStub.java111
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/IdentityScopeStub.java133
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/IdentityStub.java76
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/KeyStoreTestSupport.java176
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MDGoldenData.java197
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyAlgorithmParameterGeneratorSpi.java53
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyBasicPermission.java29
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyGuard.java38
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator1.java144
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator2.java66
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator3.java49
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGeneratorSpi.java58
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyStore.java236
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyStoreSpi.java123
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyLoadStoreParams.java41
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java76
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java71
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyPermission.java52
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyPermissionCollection.java54
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature1.java102
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature2.java83
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/PrivateKeyStub.java79
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/PublicKeyStub.java73
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/RandomImpl.java55
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/SignerStub.java62
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/SpiEngUtils.java69
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/TestCertUtils.java828
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/TestKeyPair.java602
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/TestUtils.java79
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCRL.java58
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPath.java104
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathBuilderSpi.java46
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathValidatorSpi.java55
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreParameters.java42
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreSpi.java62
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertificate.java104
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertificateFactorySpi.java136
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java538
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/provider/cert/CertFactoryTestData.java330
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/spec/MyEncodedKeySpec.java50
-rw-r--r--security/src/test/support/common/java/org/apache/harmony/security/tests/support/tmpCallbackHandler.java44
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/CertPathTrustManagerParametersTest.java46
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/HandshakeCompletedEventTest.java152
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/HttpsURLConnectionTest.java159
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/KeyManagerFactory1Test.java439
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/KeyManagerFactory2Test.java268
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/KeyStoreBuilderParametersTest.java107
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext1Test.java505
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext2Test.java302
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineResultTest.java214
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java553
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLExceptionTest.java185
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLHandshakeExceptionTest.java76
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLKeyExceptionTest.java74
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLPeerUnverifiedExceptionTest.java76
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLProtocolExceptionTest.java75
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLServerSocketTest.java162
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSessionBindingEventTest.java196
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSocketTest.java223
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/TrustManagerFactory1Test.java446
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/TrustManagerFactory2Test.java257
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/X509ExtendedKeyManagerTest.java101
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/HandshakeCompletedEventTest.java54
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.java48
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.java45
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.java45
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.java45
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.java45
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLSessionBindingEventTest.java53
-rw-r--r--x-net/src/test/impl/java.injected/javax/net/ServerSocketFactoryTest.java95
-rw-r--r--x-net/src/test/impl/java.injected/javax/net/SocketFactoryTest.java107
-rw-r--r--x-net/src/test/impl/java.injected/javax/net/ssl/DefaultSSLServerSocketFactoryTest.java91
-rw-r--r--x-net/src/test/impl/java.injected/javax/net/ssl/DefaultSSLSocketFactoryTest.java123
-rw-r--r--x-net/src/test/impl/java.injected/javax/net/ssl/HttpsURLConnection_ImplTest.java107
-rw-r--r--x-net/src/test/impl/java.injected/javax/net/ssl/SSLServerSocketFactoryTest.java96
-rw-r--r--x-net/src/test/impl/java.injected/javax/net/ssl/SSLSocketFactoryTest.java96
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateMessageTest.java123
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateRequestTest.java103
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateVerifyTest.java87
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CipherSuiteTest.java554
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientHelloTest.java82
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientKeyExchangeTest.java191
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/DelegatedTaskTest.java40
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/DigitalSignatureTest.java104
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/HandshakeProtocolTest.java220
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/KeyManagerImplTest.java82
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLEngineImplTest.java1388
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLServerSocketImplTest.java682
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSessionContextImplTest.java86
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSessionImplTest.java150
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFactoriesTest.java474
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFunctionalTest.java368
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketImplTest.java1234
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLStreamedInputTest.java54
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHandshakeImplTest.java139
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHelloTest.java82
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerKeyExchangeTest.java186
-rw-r--r--x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/TrustManagerImplTest.java127
-rw-r--r--x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/DigitalSignatureTest.java142
-rw-r--r--x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/FinishedTest.java69
-rw-r--r--x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/HelloRequestTest.java65
-rw-r--r--x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/KeyManagerFactoryImplTest.java91
-rw-r--r--x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ProtocolVersionTest.java82
-rw-r--r--x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ServerHelloDoneTest.java71
-rw-r--r--x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/TrustManagerFactoryImplTest.java90
-rw-r--r--x-net/src/test/java/javax/net/ssl/KeyManagerFactorySpiTests.java99
-rw-r--r--x-net/src/test/java/javax/net/ssl/MyKeyManagerFactorySpi.java89
-rw-r--r--x-net/src/test/java/javax/net/ssl/MySSLContextSpi.java246
-rw-r--r--x-net/src/test/java/javax/net/ssl/MyTrustManagerFactorySpi.java75
-rw-r--r--x-net/src/test/java/javax/net/ssl/SSLContextSpiTests.java96
-rw-r--r--x-net/src/test/java/javax/net/ssl/TrustManagerFactorySpiTests.java88
-rw-r--r--x-net/src/test/resources/key_store.bksbin1212 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/HandshakeCompletedEventTest.golden.0.serbin94 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.0.serbin1508 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.1.serbin1593 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.2.serbin2611 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.3.serbin2748 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.4.serbin2646 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.golden.0.serbin1576 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.golden.1.serbin1589 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.golden.2.serbin1661 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.golden.0.serbin1558 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.golden.1.serbin1571 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.golden.2.serbin1643 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.golden.0.serbin1591 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.golden.1.serbin1604 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.golden.2.serbin1676 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.golden.0.serbin1573 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.golden.1.serbin1586 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.golden.2.serbin1658 -> 0 bytes
-rw-r--r--x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLSessionBindingEventTest.golden.0.serbin132 -> 0 bytes
-rw-r--r--x-net/src/test/support/common/java/org/apache/harmony/xnet/provider/jsse/JSSETestData.java92
-rw-r--r--x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MyKeyManagerFactorySpi.java89
-rw-r--r--x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MySSLContextSpi.java269
-rw-r--r--x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MyTrustManagerFactorySpi.java75
-rw-r--r--x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/SpiEngUtils.java69
676 files changed, 1 insertions, 84120 deletions
diff --git a/Android.mk b/Android.mk
index 019c4e2..335f205 100644
--- a/Android.mk
+++ b/Android.mk
@@ -8,26 +8,18 @@ endef
harmony_test_dirs := \
beans \
- crypto \
logging \
luni \
sql \
support \
-# TODO: get these working too!
-# security \
-# x-net
-
harmony_test_src_files := \
$(call all-harmony-test-java-files-under,$(harmony_test_dirs),src/test/java) \
- $(call all-harmony-test-java-files-under,$(harmony_test_dirs),src/test/api/java) \
$(call all-harmony-test-java-files-under,$(harmony_test_dirs),src/test/support/java) \
- $(call all-harmony-test-java-files-under,$(harmony_test_dirs),src/test/support/common/java) \
$(call all-harmony-test-java-files-under,luni,src/test/api/common) \
$(call all-harmony-test-java-files-under,luni,src/test/api/unix) \
$(call all-harmony-test-java-files-under,luni,src/test/impl/common) \
- $(call all-harmony-test-java-files-under,luni,src/test/impl/unix) \
- $(call all-harmony-test-java-files-under,security,src/test/support/common/java)
+ $(call all-harmony-test-java-files-under,luni,src/test/impl/unix)
# We need to use -maxdepth 4 because there's a non-resource directory called "resources" deeper in the tree.
define harmony-test-resource-dirs
diff --git a/crypto/src/test/api/java.injected/javax/crypto/CipherInputStreamTest.java b/crypto/src/test/api/java.injected/javax/crypto/CipherInputStreamTest.java
deleted file mode 100644
index 6385e32..0000000
--- a/crypto/src/test/api/java.injected/javax/crypto/CipherInputStreamTest.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package javax.crypto;
-
-import java.io.ByteArrayInputStream;
-import javax.crypto.NullCipher;
-
-import junit.framework.TestCase;
-
-/**
- */
-
-public class CipherInputStreamTest extends TestCase {
-
- private static class TestInputStream extends ByteArrayInputStream {
- private boolean closed = false;
-
- public TestInputStream(byte[] data) {
- super(data);
- }
-
- public void close() {
- closed = true;
- }
-
- public boolean wasClosed() {
- return closed;
- }
- }
-
- /**
- * CipherInputStream(InputStream is) method testing. Tests that
- * CipherInputStream uses NullCipher if Cipher is not specified
- * in the constructor.
- */
- public void testCipherInputStream() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestInputStream tis = new TestInputStream(data);
- CipherInputStream cis = new CipherInputStream(tis);
-
- for (int i = 0; i < data.length; i++) {
- if ((byte) cis.read() != data[i]) {
- fail("NullCipher should be used "
- + "if Cipher is not specified.");
- }
- }
- if (cis.read() != -1) {
- fail("NullCipher should be used if Cipher is not specified.");
- }
- }
-
- /**
- * read() method testing. Tests that method returns the correct value
- * (related to the InputStream) and that it returns -1 at the end of stream.
- */
- public void testRead1() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestInputStream tis = new TestInputStream(data);
- CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
- byte res;
- for (int i = 0; i < data.length; i++) {
- if ((res = (byte) cis.read()) != data[i]) {
- fail("read() returned the incorrect value. " + "Expected: "
- + data[i] + ", Got: " + res + ".");
- }
- }
- if (cis.read() != -1) {
- fail("read() should return -1 at the end of the stream.");
- }
- }
-
- /**
- * read(byte[] b) method testing. Tests that method returns the correct
- * value (related to the InputStream) and that it returns -1 at the end of
- * stream.
- */
- public void testRead2() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestInputStream tis = new TestInputStream(data);
- CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
-
- int expected = data.length;
- byte[] result = new byte[expected];
-
- int ind = 0; // index into the data array (to check the got data)
- int got = cis.read(result); // the number of got bytes
- while (true) {
- for (int j = 0; j < got - ind; j++) {
- if (result[j] != data[ind + j]) {
- fail("read(byte[] b) returned incorrect data.");
- }
- }
- if (got == expected) {
- break;
- } else if (got > expected) {
- fail("The data returned by read(byte[] b) "
- + "is larger than expected.");
- } else {
- ind = got;
- got += cis.read(result);
- }
- }
- if (cis.read(result) != -1) {
- fail("read(byte[] b) should return -1 "
- + "at the end of the stream.");
- }
- }
-
- /**
- * read(byte[] b, int off, int len) method testing. Tests that method
- * returns the correct value (related to the InputStream), that it discards
- * bytes in the case of null buffer, and that it returns -1 at the end of
- * stream.
- */
- public void testRead3() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestInputStream tis = new TestInputStream(data);
- CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
-
- int expected = data.length;
- byte[] result = new byte[expected];
-
- int skip = 2;
- int ind = skip; // index into the data array (to check the got data)
- // should read and discard bytes;
- cis.read(null, 0, skip);
- int got = skip + cis.read(result, 0, 1); // the number of got bytes
- while (true) {
- for (int j = 0; j < got - ind; j++) {
- assertEquals("read(byte[] b, int off, int len) "
- + "returned incorrect data.", result[j], data[ind + j]);
- }
- if (got == expected) {
- break;
- } else if (got > expected) {
- fail("The data returned by "
- + "read(byte[] b, int off, int len) "
- + "is larger than expected.");
- } else {
- ind = got;
- got += cis.read(result, 0, 3);
- }
- }
- if (cis.read(result, 0, 1) != -1) {
- fail("read() should return -1 at the end of the stream.");
- }
- }
-
- /**
- * skip(long n) method testing. Tests that the method correctly skips the
- * bytes.
- */
- public void testSkip() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestInputStream tis = new TestInputStream(data);
- CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
- int expected = data.length;
- byte[] result = new byte[expected];
-
- int skipped = (int) cis.skip(2);
- int ind = skipped;
- int got = skipped + cis.read(result, 0, 1); // the number of got bytes
- while (true) {
- for (int j = 0; j < got - ind; j++) {
- if (result[j] != data[ind + j]) {
- fail("read(byte[] b, int off, int len) "
- + "returned incorrect data: Expected "
- + data[ind + j] + ", got: " + result[j]);
- }
- }
- if (got == expected) {
- break;
- } else if (got > expected) {
- fail("The data returned by "
- + "read(byte[] b, int off, int len) "
- + "is larger than expected.");
- } else {
- ind = got;
- got += cis.read(result, 0, 1);
- }
- }
- if ((got = cis.read(result, 0, 1)) != -1) {
- fail("read() should return -1 at the end of the stream. "
- + "Output is: " + got + ".");
- }
- }
-
- /**
- * available() method testing. Tests that the method always return 0.
- */
- public void testAvailable() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestInputStream tis = new TestInputStream(data);
- CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
- assertEquals("The returned by available() method value "
- + "should be 0.", cis.available(), 0);
- }
-
- /**
- * close() method testing. Tests that the method calls the close()
- * method of the underlying input stream.
- */
- public void testClose() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestInputStream tis = new TestInputStream(data);
- CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
- cis.close();
- assertTrue("The close() method should call the close() method "
- + "of its underlying input stream.", tis.wasClosed());
- }
-
- /**
- * markSupported() method testing. Tests that mark is not supported.
- */
- public void testMarkSupported() {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestInputStream tis = new TestInputStream(data);
- CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
- assertFalse("The returned by markSupported() method value "
- + "should be false.", cis.markSupported());
- }
-
-}
-
diff --git a/crypto/src/test/api/java.injected/javax/crypto/CipherOutputStreamTest.java b/crypto/src/test/api/java.injected/javax/crypto/CipherOutputStreamTest.java
deleted file mode 100644
index acc64aa..0000000
--- a/crypto/src/test/api/java.injected/javax/crypto/CipherOutputStreamTest.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package javax.crypto;
-
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-import javax.crypto.NullCipher;
-
-import junit.framework.TestCase;
-
-/**
- */
-
-public class CipherOutputStreamTest extends TestCase {
-
- private static class TestOutputStream extends ByteArrayOutputStream {
- private boolean closed = false;
-
- public void close() {
- closed = true;
- }
-
- public boolean wasClosed() {
- return closed;
- }
- }
-
- /**
- * CipherOutputStream(OutputStream os) method testing. Tests that
- * CipherOutputStream uses NullCipher if Cipher is not specified
- * in the constructor.
- */
- public void testCipherOutputStream() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestOutputStream tos = new TestOutputStream();
- CipherOutputStream cos = new CipherOutputStream(tos);
- cos.write(data);
- cos.flush();
- byte[] result = tos.toByteArray();
- if (!Arrays.equals(result, data)) {
- fail("NullCipher should be used " + "if Cipher is not specified.");
- }
- }
-
- /**
- * write(int b) method testing. Tests that method writes correct values to
- * the underlying output stream.
- */
- public void testWrite1() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestOutputStream tos = new TestOutputStream();
- CipherOutputStream cos = new CipherOutputStream(tos, new NullCipher());
- for (int i = 0; i < data.length; i++) {
- cos.write(data[i]);
- }
- cos.flush();
- byte[] result = tos.toByteArray();
- if (!Arrays.equals(result, data)) {
- fail("CipherOutputStream wrote incorrect data.");
- }
- }
-
- /**
- * write(byte[] b) method testing. Tests that method writes correct values
- * to the underlying output stream.
- */
- public void testWrite2() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestOutputStream tos = new TestOutputStream();
- CipherOutputStream cos = new CipherOutputStream(tos, new NullCipher());
- cos.write(data);
- cos.flush();
- byte[] result = tos.toByteArray();
- if (!Arrays.equals(result, data)) {
- fail("CipherOutputStream wrote incorrect data.");
- }
- }
-
- /**
- * write(byte[] b, int off, int len) method testing.
- */
- public void testWrite3() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestOutputStream tos = new TestOutputStream();
- CipherOutputStream cos = new CipherOutputStream(tos, new NullCipher());
- for (int i = 0; i < data.length; i++) {
- cos.write(data, i, 1);
- }
- cos.flush();
- byte[] result = tos.toByteArray();
- if (!Arrays.equals(result, data)) {
- fail("CipherOutputStream wrote incorrect data.");
- }
- }
-
- /**
- * @tests write(byte[] b, int off, int len)
- */
- public void testWrite4() throws Exception {
- //Regression for HARMONY-758
- try {
- new CipherOutputStream(new BufferedOutputStream((OutputStream) null), new NullCipher()).write(new byte[] { 0 }, 1, Integer.MAX_VALUE);
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * @tests write(byte[] b, int off, int len)
- */
- public void testWrite5() throws Exception {
- //Regression for HARMONY-758
- Cipher cf = Cipher.getInstance("DES/CBC/PKCS5Padding");
- NullCipher nc = new NullCipher();
- CipherOutputStream stream1 = new CipherOutputStream(new BufferedOutputStream((OutputStream) null), nc);
- CipherOutputStream stream2 = new CipherOutputStream(stream1, cf);
- CipherOutputStream stream3 = new CipherOutputStream(stream2, nc);
- stream3.write(new byte[] { 0 }, 0, 0);
- //no exception expected
- }
-
- /**
- * flush() method testing. Tests that method flushes the data to the
- * underlying output stream.
- */
- public void testFlush() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestOutputStream tos = new TestOutputStream();
- CipherOutputStream cos = new CipherOutputStream(tos);
- cos.write(data);
- cos.flush();
- byte[] result = tos.toByteArray();
- if (!Arrays.equals(result, data)) {
- fail("CipherOutputStream did not flush the data.");
- }
- }
-
- /**
- * close() method testing. Tests that the method calls the close() method of
- * the underlying input stream.
- */
- public void testClose() throws Exception {
- byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
- TestOutputStream tos = new TestOutputStream();
- CipherOutputStream cos = new CipherOutputStream(tos);
- cos.write(data);
- cos.close();
- byte[] result = tos.toByteArray();
- if (!Arrays.equals(result, data)) {
- fail("CipherOutputStream did not flush the data.");
- }
- assertTrue("The close() method should call the close() method "
- + "of its underlying output stream.", tos.wasClosed());
- }
-}
-
diff --git a/crypto/src/test/api/java.injected/javax/crypto/CipherSpiTest.java b/crypto/src/test/api/java.injected/javax/crypto/CipherSpiTest.java
deleted file mode 100644
index c741004..0000000
--- a/crypto/src/test/api/java.injected/javax/crypto/CipherSpiTest.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package javax.crypto;
-
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-import java.security.AlgorithmParameters;
-import java.nio.ByteBuffer;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>CipherSpi</code> class constructors and methods.
- */
-
-public class CipherSpiTest extends TestCase {
-
- /**
- * Constructor for CipherSpiTests.
- *
- * @param arg0
- */
- public CipherSpiTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>CipherSpi</code> constructor
- * Assertion: constructs CipherSpi
- */
- public void testCipherSpiTests01() throws IllegalBlockSizeException,
- BadPaddingException, ShortBufferException {
-
- CipherSpi cSpi = new myCipherSpi();
- assertEquals("BlockSize is not 0", cSpi.engineGetBlockSize(), 0);
- assertEquals("OutputSize is not 0", cSpi.engineGetOutputSize(1), 0);
- byte[] bb = cSpi.engineGetIV();
- assertEquals("Length of result byte array is not 0", bb.length, 0);
- assertNull("Not null result", cSpi.engineGetParameters());
- byte[] bb1 = new byte[10];
- byte[] bb2 = new byte[10];
- bb = cSpi.engineUpdate(bb1, 1, 2);
- assertEquals("Incorrect result of engineUpdate(byte, int, int)",
- bb.length, 2);
- bb = cSpi.engineDoFinal(bb1, 1, 2);
- assertEquals("Incorrect result of engineDoFinal(byte, int, int)", 2,
- bb.length);
- assertEquals(
- "Incorrect result of engineUpdate(byte, int, int, byte, int)",
- cSpi.engineUpdate(bb1, 1, 2, bb2, 7), 2);
- assertEquals(
- "Incorrect result of engineDoFinal(byte, int, int, byte, int)",
- 2, cSpi.engineDoFinal(bb1, 1, 2, bb2, 0));
- }
-
- /**
- * Test for <code>engineGetKeySize(Key)</code> method
- * Assertion: It throws UnsupportedOperationException if it is not overridden
- */
- public void testCipherSpi02() throws Exception {
- CipherSpi cSpi = new myCipherSpi();
- try {
- cSpi.engineGetKeySize(null);
- fail("UnsupportedOperationException must be thrown");
- } catch (UnsupportedOperationException e) {
- }
- }
-
- /**
- * Test for <code>engineWrap(Key)</code> method
- * Assertion: It throws UnsupportedOperationException if it is not overridden
- */
- public void testCipherSpi03() throws Exception {
- CipherSpi cSpi = new myCipherSpi();
- try {
- cSpi.engineWrap(null);
- fail("UnsupportedOperationException must be thrown");
- } catch (UnsupportedOperationException e) {
- }
- }
-
- /**
- * Test for <code>engineUnwrap(byte[], String, int)</code> method
- * Assertion: It throws UnsupportedOperationException if it is not overridden
- */
- public void testCipherSpi04() throws Exception {
- CipherSpi cSpi = new myCipherSpi();
- try {
- cSpi.engineUnwrap(new byte[0], "", 0);
- fail("UnsupportedOperationException must be thrown");
- } catch (UnsupportedOperationException e) {
- }
- }
-
- /**
- * Test for <code>engineUpdate(ByteBuffer, ByteBuffer)</code> method
- * Assertions:
- * throws NullPointerException if one of these buffers is null;
- * throws ShortBufferException is there is no space in output to hold result
- */
- public void testCipherSpi05() throws ShortBufferException {
- CipherSpi cSpi = new myCipherSpi();
- byte[] bb = { (byte) 0, (byte) 1, (byte) 2, (byte) 3, (byte) 4,
- (byte) 5, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) 10 };
- int pos = 5;
- int len = bb.length;
- ByteBuffer bbNull = null;
- ByteBuffer bb1 = ByteBuffer.allocate(len);
- bb1.put(bb);
- bb1.position(0);
- try {
- cSpi.engineUpdate(bbNull, bb1);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- try {
- cSpi.engineUpdate(bb1, bbNull);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- ByteBuffer bb2 = ByteBuffer.allocate(bb.length);
- bb1.position(len);
- assertEquals("Incorrect number of stored bytes", 0, cSpi.engineUpdate(
- bb1, bb2));
-
- bb1.position(0);
- bb2.position(len - 2);
- try {
- cSpi.engineUpdate(bb1, bb2);
- fail("ShortBufferException bust be thrown. Output buffer remaining: "
- .concat(Integer.toString(bb2.remaining())));
- } catch (ShortBufferException e) {
- }
- bb1.position(10);
- bb2.position(0);
- assertTrue("Incorrect number of stored bytes", cSpi.engineUpdate(bb1,
- bb2) > 0);
- bb1.position(bb.length);
- cSpi.engineUpdate(bb1, bb2);
-
- bb1.position(pos);
- bb2.position(0);
- int res = cSpi.engineUpdate(bb1, bb2);
- assertTrue("Incorrect result", res > 0);
- }
-
- /**
- * Test for <code>engineDoFinal(ByteBuffer, ByteBuffer)</code> method
- * Assertions:
- * throws NullPointerException if one of these buffers is null;
- * throws ShortBufferException is there is no space in output to hold result
- */
- public void testCipherSpi06() throws BadPaddingException,
- ShortBufferException, IllegalBlockSizeException {
- CipherSpi cSpi = new myCipherSpi();
- int len = 10;
- byte[] bbuf = new byte[len];
- for (int i = 0; i < bbuf.length; i++) {
- bbuf[i] = (byte) i;
- }
- ByteBuffer bb1 = ByteBuffer.wrap(bbuf);
- ByteBuffer bbNull = null;
- try {
- cSpi.engineDoFinal(bbNull, bb1);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- try {
- cSpi.engineDoFinal(bb1, bbNull);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- ByteBuffer bb2 = ByteBuffer.allocate(len);
- bb1.position(bb1.limit());
- assertEquals("Incorrect result", 0, cSpi.engineDoFinal(bb1, bb2));
-
- bb1.position(0);
- bb2.position(len - 2);
- try {
- cSpi.engineDoFinal(bb1, bb2);
- fail("ShortBufferException must be thrown. Output buffer remaining: "
- .concat(Integer.toString(bb2.remaining())));
- } catch (ShortBufferException e) {
- }
- int pos = 5;
- bb1.position(pos);
- bb2.position(0);
- assertTrue("Incorrect result", cSpi.engineDoFinal(bb1, bb2) > 0);
- }
-}
-
-/**
- * Additional class for CipherGeneratorSpi constructor verification
- */
-
-class myCipherSpi extends CipherSpi {
- private byte[] initV;
-
- private static byte[] resV = { (byte) 7, (byte) 6, (byte) 5, (byte) 4,
- (byte) 3, (byte) 2, (byte) 1, (byte) 0 };
-
- public myCipherSpi() {
- this.initV = new byte[0];
- }
-
- protected void engineSetMode(String mode) throws NoSuchAlgorithmException {
- }
-
- protected void engineSetPadding(String padding)
- throws NoSuchPaddingException {
- }
-
- protected int engineGetBlockSize() {
- return 0;
- }
-
- protected int engineGetOutputSize(int inputLen) {
- return 0;
- }
-
- protected byte[] engineGetIV() {
- return new byte[0];
- }
-
- protected AlgorithmParameters engineGetParameters() {
- return null;
- }
-
- protected void engineInit(int opmode, Key key, SecureRandom random)
- throws InvalidKeyException {
- }
-
- protected void engineInit(int opmode, Key key,
- AlgorithmParameterSpec params, SecureRandom random)
- throws InvalidKeyException, InvalidAlgorithmParameterException {
- }
-
- protected void engineInit(int opmode, Key key, AlgorithmParameters params,
- SecureRandom random) throws InvalidKeyException,
- InvalidAlgorithmParameterException {
- }
-
- protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) {
- if (initV.length < inputLen) {
- initV = new byte[inputLen];
- }
- for (int i = 0; i < inputLen; i++) {
- initV[i] = input[inputOffset + i];
- }
- return initV;
- }
-
- protected int engineUpdate(byte[] input, int inputOffset, int inputLen,
- byte[] output, int outputOffset) throws ShortBufferException {
- byte[] res = engineUpdate(input, inputOffset, inputLen);
- int t = res.length;
- if ((output.length - outputOffset) < t) {
- throw new ShortBufferException("Update");
- }
- for (int i = 0; i < t; i++) {
- output[i + outputOffset] = initV[i];
- }
- return t;
- }
-
- protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen)
- throws IllegalBlockSizeException, BadPaddingException {
- if (resV.length > inputLen) {
- byte[] bb = new byte[inputLen];
- for (int i = 0; i < inputLen; i++) {
- bb[i] = resV[i];
- }
- return bb;
- }
- return resV;
- }
-
- protected int engineDoFinal(byte[] input, int inputOffset, int inputLen,
- byte[] output, int outputOffset) throws ShortBufferException,
- IllegalBlockSizeException, BadPaddingException {
- byte[] res = engineDoFinal(input, inputOffset, inputLen);
-
- int t = res.length;
- if ((output.length - outputOffset) < t) {
- throw new ShortBufferException("DoFinal");
- }
- for (int i = 0; i < t; i++) {
- output[i + outputOffset] = res[i];
- }
- return t;
- }
-
-
- protected int engineUpdate(ByteBuffer input, ByteBuffer output)
- throws ShortBufferException {
- return super.engineUpdate(input, output);
- }
-
- protected int engineDoFinal(ByteBuffer input, ByteBuffer output)
- throws ShortBufferException, IllegalBlockSizeException,
- BadPaddingException {
- return super.engineDoFinal(input, output);
- }
-}
diff --git a/crypto/src/test/api/java.injected/javax/crypto/ExemptionMechanismSpiTest.java b/crypto/src/test/api/java.injected/javax/crypto/ExemptionMechanismSpiTest.java
deleted file mode 100644
index 3e52034..0000000
--- a/crypto/src/test/api/java.injected/javax/crypto/ExemptionMechanismSpiTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package javax.crypto;
-
-import java.security.AlgorithmParameters;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>ExemptionMechanismSpi</code> class constructors and
- * methods.
- */
-
-public class ExemptionMechanismSpiTest extends TestCase {
- /**
- * Constructor for ExemptionMechanismSpiTests.
- *
- * @param arg0
- */
- public ExemptionMechanismSpiTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>ExemptionMechanismSpi</code> constructor Assertion:
- * constructs ExemptionMechanismSpi
- */
- public void testExemptionMechanismSpi01()
- throws ExemptionMechanismException,
- ShortBufferException, InvalidKeyException,
- InvalidAlgorithmParameterException {
- ExemptionMechanismSpi emSpi = new MyExemptionMechanismSpi();
- int len = MyExemptionMechanismSpi.getLength();
- byte[] bbRes = emSpi.engineGenExemptionBlob();
- assertEquals("Incorrect length", bbRes.length, len);
- assertEquals("Incorrect result",
- emSpi.engineGenExemptionBlob(new byte[1], len), len);
- assertEquals("Incorrect output size", 10, emSpi.engineGetOutputSize(100));
- Key key = null;
- AlgorithmParameters params = null;
- AlgorithmParameterSpec parSpec = null;
- try {
- emSpi.engineInit(key);
- fail("InvalidKeyException must be thrown");
- } catch (InvalidKeyException e) {
- }
- try {
- emSpi.engineInit(key, params);
- fail("InvalidKeyException must be thrown");
- } catch (InvalidKeyException e) {
- }
- try {
- emSpi.engineInit(key, parSpec);
- fail("InvalidKeyException must be thrown");
- } catch (InvalidKeyException e) {
- }
- key = ((MyExemptionMechanismSpi) emSpi).new tmp1Key("Proba", new byte[0]);
- try {
- emSpi.engineInit(key);
- fail("ExemptionMechanismException must be thrown");
- } catch (ExemptionMechanismException e) {
- }
- try {
- emSpi.engineInit(key, params);
- fail("ExemptionMechanismException must be thrown");
- } catch (ExemptionMechanismException e) {
- }
- try {
- emSpi.engineInit(key, parSpec);
- fail("ExemptionMechanismException must be thrown");
- } catch (ExemptionMechanismException e) {
- }
- key = ((MyExemptionMechanismSpi) emSpi).new tmpKey("Proba", new byte[0]);
- emSpi.engineInit(key);
- emSpi.engineInit(key, params);
- emSpi.engineInit(key, parSpec);
-
- assertEquals("Incorrect result", 10, emSpi.engineGetOutputSize(100));
- }
-}
diff --git a/crypto/src/test/api/java.injected/javax/crypto/KeyAgreementSpiTest.java b/crypto/src/test/api/java.injected/javax/crypto/KeyAgreementSpiTest.java
deleted file mode 100644
index c86a1f0..0000000
--- a/crypto/src/test/api/java.injected/javax/crypto/KeyAgreementSpiTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package javax.crypto;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.apache.harmony.crypto.tests.support.MyKeyAgreementSpi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyAgreementSpi</code> class constructors and methods.
- */
-
-public class KeyAgreementSpiTest extends TestCase {
- /**
- * Constructor for KeyAgreementSpiTests.
- *
- * @param arg0
- */
- public KeyAgreementSpiTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>KeyAgreementSpi</code> constructor Assertion: constructs
- * KeyAgreementSpi
- */
- public void testKeyAgreementSpi01() throws InvalidKeyException,
- ShortBufferException, NoSuchAlgorithmException,
- InvalidAlgorithmParameterException {
- KeyAgreementSpi kaSpi = new MyKeyAgreementSpi();
-
- assertNull("Not null result", kaSpi.engineDoPhase(null, true));
- try {
- kaSpi.engineDoPhase(null, false);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- byte[] bb = kaSpi.engineGenerateSecret();
- assertEquals("Length is not 0", bb.length, 0);
- assertEquals("Returned integer is not 0",
- kaSpi.engineGenerateSecret(new byte[1], 10),
- -1);
- assertNull("Not null result", kaSpi.engineGenerateSecret("aaa"));
- try {
- kaSpi.engineGenerateSecret("");
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- Key key = null;
- try {
- kaSpi.engineInit(key, new SecureRandom());
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- AlgorithmParameterSpec params = null;
- try {
- kaSpi.engineInit(key, params, new SecureRandom());
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-} \ No newline at end of file
diff --git a/crypto/src/test/api/java.injected/javax/crypto/KeyGeneratorSpiTest.java b/crypto/src/test/api/java.injected/javax/crypto/KeyGeneratorSpiTest.java
deleted file mode 100644
index ce3ddcd..0000000
--- a/crypto/src/test/api/java.injected/javax/crypto/KeyGeneratorSpiTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package javax.crypto;
-
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.SecureRandom;
-
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.apache.harmony.crypto.tests.support.MyKeyGeneratorSpi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyGeneratorSpi</code> class constructors and methods.
- */
-
-public class KeyGeneratorSpiTest extends TestCase {
-
- /**
- * Constructor for KeyGeneratorSpiTests.
- *
- * @param arg0
- */
- public KeyGeneratorSpiTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>KeyGeneratorSpi</code> constructor Assertion: constructs
- * KeyGeneratorSpi
- */
- public void testKeyGeneratorSpi01() throws InvalidAlgorithmParameterException {
- KeyGeneratorSpi kgSpi = new MyKeyGeneratorSpi();
- assertNull("Not null result", kgSpi.engineGenerateKey());
- try {
- kgSpi.engineInit(77, new SecureRandom());
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- try {
- kgSpi.engineInit(new SecureRandom());
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- AlgorithmParameterSpec aps = null;
- try {
- kgSpi.engineInit(aps, new SecureRandom());
- fail("InvalidAlgorithmParameterException must be thrown when parameter is null");
- } catch (InvalidAlgorithmParameterException e) {
- }
- aps = new APSpecSpi();
- kgSpi.engineInit(aps, new SecureRandom());
- }
-}
-
-class APSpecSpi implements AlgorithmParameterSpec {
-
-}
diff --git a/crypto/src/test/api/java.injected/javax/crypto/MacSpiTest.java b/crypto/src/test/api/java.injected/javax/crypto/MacSpiTest.java
deleted file mode 100644
index e2b8a63..0000000
--- a/crypto/src/test/api/java.injected/javax/crypto/MacSpiTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package javax.crypto;
-
-
-import java.nio.ByteBuffer;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.spec.AlgorithmParameterSpec;
-
-import javax.crypto.spec.SecretKeySpec;
-
-import org.apache.harmony.crypto.tests.support.MyMacSpi;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>MacSpi</code> class constructors and methods.
- */
-
-public class MacSpiTest extends TestCase {
-
- /**
- * Constructor for MacSpiTests.
- *
- * @param arg0
- */
- public MacSpiTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>MacSpi</code> constructor
- * Assertion: constructs MacSpi
- */
- public void testMacSpiTests01() throws Exception {
- MacSpi mSpi = new MyMacSpi();
-
- byte[] bb1 = { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5 };
- SecretKeySpec sks = new SecretKeySpec(bb1, "SHA1");
-
- assertEquals("Incorrect MacLength", mSpi.engineGetMacLength(), 0);
-
- try {
- mSpi.engineInit(null, null);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
-
- mSpi.engineInit(sks, null);
-
- byte[] bb = mSpi.engineDoFinal();
- assertEquals(bb.length, 0);
- try {
- mSpi.clone();
- fail("CloneNotSupportedException was not thrown as expected");
- } catch (CloneNotSupportedException e) {
- }
-
- MacSpi mSpi1 = new MyMacSpi1();
- mSpi1.clone();
-
- byte[] bbb = new byte[10];
- for (int i = 0; i < bbb.length; i++) {
- bbb[i] = (byte) i;
- }
- try {
- mSpi1.engineInit(null, null);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- mSpi1.engineInit(sks, null);
-
- ByteBuffer byteBuf = ByteBuffer.allocate(10);
- byteBuf.put(bbb);
- byteBuf.position(5);
- int beforeUp = byteBuf.remaining();
- mSpi1.engineUpdate(byteBuf);
- bb = mSpi1.engineDoFinal();
- assertEquals("Incorrect result of engineDoFinal", bb.length, beforeUp);
-
- MacSpi mSpi2 = new MyMacSpi2();
-
- mSpi2.engineInit(null, null);
- mSpi2.engineInit(sks, null);
-
- try {
- mSpi2.clone();
- } catch (CloneNotSupportedException e) {
- }
-
- byte[] bbuf = { (byte) 5, (byte) 4, (byte) 3, (byte) 2, (byte) 1 };
- byteBuf = ByteBuffer.allocate(5);
- byteBuf.put(bbuf);
- byteBuf.position(5);
- if (!byteBuf.hasRemaining()) {
- mSpi2.engineUpdate(byteBuf);
- }
- }
-}
-
-
-class MyMacSpi1 extends MyMacSpi {
- public Object clone() throws CloneNotSupportedException {
- return new MyMacSpi1();
- }
-}
-
-class MyMacSpi2 extends MacSpi {
- protected int engineGetMacLength() {
- return 0;
- }
-
- protected void engineInit(Key key, AlgorithmParameterSpec params)
- throws InvalidKeyException, InvalidAlgorithmParameterException {
- }
-
- protected void engineUpdate(byte input) {
- }
-
- protected void engineUpdate(byte[] input, int offset, int len) {
- }
-
- protected byte[] engineDoFinal() {
- return new byte[0];
- }
-
- protected void engineReset() {
- }
-}
diff --git a/crypto/src/test/api/java.injected/javax/crypto/SealedObjectTest.java b/crypto/src/test/api/java.injected/javax/crypto/SealedObjectTest.java
deleted file mode 100644
index 56c4c35..0000000
--- a/crypto/src/test/api/java.injected/javax/crypto/SealedObjectTest.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package javax.crypto;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.security.Key;
-import java.security.InvalidKeyException;
-import java.util.Arrays;
-import javax.crypto.Cipher;
-import javax.crypto.KeyGenerator;
-import javax.crypto.NullCipher;
-import javax.crypto.spec.IvParameterSpec;
-import javax.crypto.spec.SecretKeySpec;
-
-import junit.framework.TestCase;
-
-/**
- */
-
-public class SealedObjectTest extends TestCase {
-
- /**
- * readObject(ObjectInputStream s) method testing. Tests if the
- * serialization/deserialization works correctly: object is serialized,
- * deserialized, the content od deserialized object equals to the
- * content of initial object.
- */
- public void testReadObject() throws Exception {
- String secret = "secret string";
- SealedObject so = new SealedObject(secret, new NullCipher());
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
- oos.writeObject(so);
-
- ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
- bos.toByteArray()));
-
- SealedObject so_des = (SealedObject) ois.readObject();
- assertEquals("The secret content of deserialized object "
- + "should be equal to the secret content of initial object",
- secret, so_des.getObject(new NullCipher()));
- assertEquals("The value returned by getAlgorithm() method of "
- + "deserialized object should be equal to the value returned "
- + "by getAlgorithm() method of initial object", so
- .getAlgorithm(), so_des.getAlgorithm());
- }
-
- /**
- * SealedObject(Serializable object, Cipher c) method testing. Tests if the
- * NullPointerException is thrown in the case of null cipher.
- */
- public void testSealedObject1() throws Exception {
- String secret = "secret string";
- try {
- new SealedObject(secret, null);
- fail("NullPointerException should be thrown in the case "
- + "of null cipher.");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * SealedObject(SealedObject so) method testing. Tests if the
- * NullPointerException is thrown in the case of null SealedObject.
- */
- public void testSealedObject2() throws Exception {
- try {
- new SealedObject(null);
- fail("NullPointerException should be thrown in the case "
- + "of null SealedObject.");
- } catch (NullPointerException e) {
- }
-
- String secret = "secret string";
- Cipher cipher = new NullCipher();
- SealedObject so1 = new SealedObject(secret, cipher);
- SealedObject so2 = new SealedObject(so1);
-
- assertEquals("The secret content of the object should equals "
- + "to the secret content of initial object.", secret, so2
- .getObject(cipher));
- assertEquals("The algorithm which was used to seal the object "
- + "should be the same as the algorithm used to seal the "
- + "initial object", so1.getAlgorithm(), so2.getAlgorithm());
- }
-
- /**
- * getAlgorithm() method testing. Tests if the returned value equals to the
- * corresponding value of Cipher object.
- */
- public void testGetAlgorithm() throws Exception {
- String secret = "secret string";
- String algorithm = "DES";
- KeyGenerator kg = KeyGenerator.getInstance(algorithm);
- Key key = kg.generateKey();
-
- Cipher cipher = Cipher.getInstance(algorithm);
- cipher.init(Cipher.ENCRYPT_MODE, key);
- SealedObject so = new SealedObject(secret, cipher);
-
- assertEquals("The algorithm name should be the same as used "
- + "in cipher.", algorithm, so.getAlgorithm());
- }
-
- /**
- * getObject(Key key) method testing. Tests if the object sealed with
- * encryption algorithm and specified parameters can be retrieved by
- * specifying the cryptographic key.
- */
- public void testGetObject1() throws Exception {
- KeyGenerator kg = KeyGenerator.getInstance("DES");
- Key key = kg.generateKey();
-
- IvParameterSpec ips = new IvParameterSpec(new byte[] { 1, 2, 3, 4, 5,
- 6, 7, 8 });
-
- Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
- cipher.init(Cipher.ENCRYPT_MODE, key, ips);
-
- String secret = "secret string";
- SealedObject so = new SealedObject(secret, cipher);
-
- assertEquals("The returned object does not equals to the "
- + "original object.", secret, so.getObject(key));
-
- assertTrue("The encodedParams field of SealedObject object "
- + "should contain the encoded algorithm parameters.", Arrays
- .equals(so.encodedParams, cipher.getParameters().getEncoded()));
- }
-
- /**
- * getObject(Cipher c) method testing. Tests if the proper exception is
- * thrown in the case of incorrect input parameters and if the object sealed
- * with encryption algorithm and specified parameters can be retrieved by
- * specifying the initialized Cipher object.
- */
- public void testGetObject2() throws Exception {
- try {
- new SealedObject("secret string", new NullCipher())
- .getObject((Cipher) null);
- fail("NullPointerException should be thrown in the case of "
- + "null cipher.");
- } catch (NullPointerException e) {
- }
-
- KeyGenerator kg = KeyGenerator.getInstance("DES");
- Key key = kg.generateKey();
-
- IvParameterSpec ips = new IvParameterSpec(new byte[] { 1, 2, 3, 4, 5,
- 6, 7, 8 });
-
- Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
- cipher.init(Cipher.ENCRYPT_MODE, key, ips);
-
- String secret = "secret string";
- SealedObject so = new SealedObject(secret, cipher);
-
- cipher.init(Cipher.DECRYPT_MODE, key, ips);
- assertEquals("The returned object does not equals to the "
- + "original object.", secret, so.getObject(cipher));
- }
-
- /**
- * getObject(Key key, String provider) method testing. Tests if the proper
- * exception is thrown in the case of incorrect input parameters and if the
- * object sealed with encryption algorithm can be retrieved by specifying
- * the cryptographic key and provider name.
- */
- public void testGetObject3() throws Exception {
- try {
- new SealedObject("secret string", new NullCipher()).getObject(
- new SecretKeySpec(new byte[] { 0, 0, 0 }, "algorithm"),
- null);
- fail("IllegalArgumentException should be thrown in the case of "
- + "null provider.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new SealedObject("secret string", new NullCipher()).getObject(
- new SecretKeySpec(new byte[] { 0, 0, 0 }, "algorithm"), "");
- fail("IllegalArgumentException should be thrown in the case of "
- + "empty provider.");
- } catch (IllegalArgumentException e) {
- }
-
- KeyGenerator kg = KeyGenerator.getInstance("DES");
- Key key = kg.generateKey();
-
- Cipher cipher = Cipher.getInstance("DES");
- String provider = cipher.getProvider().getName();
- cipher.init(Cipher.ENCRYPT_MODE, key);
-
- String secret = "secret string";
- SealedObject so = new SealedObject(secret, cipher);
-
- cipher.init(Cipher.DECRYPT_MODE, key);
- assertEquals("The returned object does not equals to the "
- + "original object.", secret, so.getObject(key, provider));
- }
-
- // Regression test for HARMONY-6347
- public void testGetObject4() throws Exception {
- try {
- new SealedObject("secret string",
- new NullCipher()).getObject((Key) null);
- fail("NullPointerException should be thrown when key is null");
- } catch (NullPointerException e) {
- }
- }
-
-}
-
diff --git a/crypto/src/test/api/java.injected/javax/crypto/SecretKeyFactorySpiTest.java b/crypto/src/test/api/java.injected/javax/crypto/SecretKeyFactorySpiTest.java
deleted file mode 100644
index 814e7f4..0000000
--- a/crypto/src/test/api/java.injected/javax/crypto/SecretKeyFactorySpiTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package javax.crypto;
-
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.KeySpec;
-
-import org.apache.harmony.crypto.tests.support.MySecretKeyFactorySpi;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SecretKeyFactorySpi</code> class constructors and methods.
- */
-
-public class SecretKeyFactorySpiTest extends TestCase {
-
- /**
- * Constructor for SecretKeyfactorySpiTests.
- *
- * @param arg0
- */
- public SecretKeyFactorySpiTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>SecretKeyFactorySpi</code> constructor Assertion:
- * constructs SecretKeyFactorySpi
- */
- public void testSecretKeyFactorySpi01() throws InvalidKeyException,
- InvalidKeySpecException {
- SecretKeyFactorySpi skfSpi = new MySecretKeyFactorySpi();
- SecretKey sk = null;
- assertNull("Not null result", skfSpi.engineTranslateKey(sk));
-
- KeySpec kspec = null;
- assertNull("Not null result", skfSpi.engineGenerateSecret(kspec));
-
- assertNull("Not null result", skfSpi.engineGetKeySpec(sk, null));
- }
-}
diff --git a/crypto/src/test/api/java.injected/javax/crypto/spec/PSourceTest.java b/crypto/src/test/api/java.injected/javax/crypto/spec/PSourceTest.java
deleted file mode 100644
index 9274f74..0000000
--- a/crypto/src/test/api/java.injected/javax/crypto/spec/PSourceTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package javax.crypto.spec;
-
-import java.util.Arrays;
-import javax.crypto.spec.PSource;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class PSourceTest extends TestCase {
-
- /**
- * PSpecified(byte[] p) method testing. Tests that NullPointerException
- * is thrown in the case of null p array. Also it checks the value of
- * DEFAULT field, and that input p array is copied to protect against
- * subsequent modification.
- */
- public void testPSpecified() {
- try {
- new PSource.PSpecified(null);
- fail("NullPointerException should be thrown in the case of "
- + "null p array.");
- } catch (NullPointerException e) {
- }
-
- assertEquals("The PSource.PSpecified DEFAULT value should be byte[0]",
- 0, PSource.PSpecified.DEFAULT.getValue().length);
-
- byte[] p = new byte[] { 1, 2, 3, 4, 5 };
- PSource.PSpecified ps = new PSource.PSpecified(p);
- p[0]++;
- assertFalse("The change of p specified in the constructor "
- + "should not cause the change of internal array.",
- p[0] == ps.getValue()[0]);
- }
-
- /**
- * getValue() method testing. Tests that returned array is equal to the
- * array specified in the constructor. Checks that modification
- * of returned array does not affect the internal array.
- */
- public void testGetValue() {
- byte[] p = new byte[] { 1, 2, 3, 4, 5 };
-
- PSource.PSpecified ps = new PSource.PSpecified(p);
- byte[] result = ps.getValue();
- if (!Arrays.equals(p, result)) {
- fail("The returned array does not equal to the specified "
- + "in the constructor.");
- }
- result[0]++;
- assertFalse("The change of returned by getValue() array "
- + "should not cause the change of internal array.",
- result[0] == ps.getValue()[0]);
- }
-
- /**
- * PSource(String pSrcName) method testing. Tests that returned value is
- * equal to the value specified in the constructor.
- */
- public void testPSource() {
- try {
- new PSource(null);
- fail("NullPointerException should be thrown in the case of "
- + "null pSrcName.");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * getAlgorithm() method testing. Tests that returned value is
- * equal to the value specified in the constructor.
- */
- public void testGetAlgorithm() {
- String pSrcName = "pSrcName";
- PSource ps = new PSource(pSrcName);
- assertTrue("The returned value is not equal to the value specified "
- + "in constructor", pSrcName.equals(ps.getAlgorithm()));
- }
-
- public static Test suite() {
- return new TestSuite(PSourceTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/BadPaddingExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/BadPaddingExceptionTest.java
deleted file mode 100644
index c4f2ddb..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/BadPaddingExceptionTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import javax.crypto.BadPaddingException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>BadPaddingException</code> class constructors and methods.
- */
-public class BadPaddingExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for BadPaddingExceptionTests.
- *
- * @param arg0
- */
- public BadPaddingExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>BadPaddingException()</code> constructor Assertion:
- * constructs BadPaddingException with no detail message
- */
- public void testBadPaddingException01() {
- BadPaddingException tE = new BadPaddingException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>BadPaddingException(String)</code> constructor
- * Assertion: constructs BadPaddingException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testBadPaddingException02() {
- BadPaddingException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new BadPaddingException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>BadPaddingException(String)</code> constructor
- * Assertion: constructs BadPaddingException when <code>msg</code> is null
- */
- public void testBadPaddingException03() {
- String msg = null;
- BadPaddingException tE = new BadPaddingException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java
deleted file mode 100644
index 84f74ca..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import junit.framework.TestCase;
-
-import javax.crypto.Cipher;
-import javax.crypto.CipherInputStream;
-import javax.crypto.NullCipher;
-
-public class CipherInputStreamTest extends TestCase {
-
- /**
- * @tests javax.crypto.CipherInputStream#read(byte[] b, int off, int len)
- */
- public void testReadBII() throws Exception {
- // Regression for HARMONY-1080
- CipherInputStream stream = new CipherInputStream(null, new NullCipher());
- try {
- stream.read(new byte[1], 1, 0);
- fail("NullPointerException expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- /**
- * @tests javax.crypto.CipherInputStream#close()
- */
- public void testClose() throws Exception {
- // Regression for HARMONY-1087
- try {
- new CipherInputStream(new ByteArrayInputStream(new byte[] { 1 }),
- Cipher.getInstance("DES/CBC/PKCS5Padding")).close();
- fail("IllegalStateException expected!");
- } catch (IllegalStateException e) {
- // expected
- }
- try {
- new CipherInputStream(new BufferedInputStream((InputStream) null),
- Cipher.getInstance("DES/CBC/PKCS5Padding")).close();
- fail("IllegalStateException expected!");
- } catch (IllegalStateException e) {
- // expected
- }
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java
deleted file mode 100644
index d941ab8..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.io.OutputStream;
-import javax.crypto.Cipher;
-import javax.crypto.CipherOutputStream;
-
-public class CipherOutputStreamTest extends junit.framework.TestCase {
-
- /**
- * @tests javax.crypto.CipherOutputStream#close()
- */
- public void test_close() throws Exception {
- // regression test for HARMONY-1139
- try {
- new CipherOutputStream((OutputStream) null, Cipher
- .getInstance("DES/CBC/PKCS5Padding")).close();
- fail("IllegalStateException expected");
- } catch (IllegalStateException e) {
- // expected
- }
-
- CipherOutputStream ch = new CipherOutputStream((OutputStream) null) {
- };
- try {
- new CipherOutputStream(ch, Cipher
- .getInstance("DES/CBC/PKCS5Padding")).close();
- fail("IllegalStateException expected");
- } catch (IllegalStateException e) {
- // expected
- }
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java
deleted file mode 100644
index aaa27db..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.AlgorithmParameters;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.Security;
-import java.security.spec.AlgorithmParameterSpec;
-import java.util.Arrays;
-
-import javax.crypto.Cipher;
-import javax.crypto.CipherSpi;
-import javax.crypto.KeyGenerator;
-import javax.crypto.SecretKeyFactory;
-import javax.crypto.ShortBufferException;
-import javax.crypto.spec.DESedeKeySpec;
-import javax.crypto.spec.IvParameterSpec;
-
-import tests.support.resource.Support_Resources;
-import org.apache.harmony.crypto.tests.support.MyCipher;
-
-public class CipherTest extends junit.framework.TestCase {
-
- static Key cipherKey;
- static final String algorithm = "DESede";
- static final int keyLen = 168;
-
- static {
- try {
- KeyGenerator kg = KeyGenerator.getInstance(algorithm);
- kg.init(keyLen, new SecureRandom());
- cipherKey = kg.generateKey();
- } catch (Exception e) {
- fail("No key " + e);
- }
- }
-
-
- /**
- * @tests javax.crypto.Cipher#getInstance(java.lang.String)
- */
- public void test_getInstanceLjava_lang_String() throws Exception {
- Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
- assertNotNull("Received a null Cipher instance", cipher);
- }
-
- /**
- * @tests javax.crypto.Cipher#getInstance(java.lang.String,
- *java.lang.String)
- */
- public void test_getInstanceLjava_lang_StringLjava_lang_String()
- throws Exception {
-
- Provider[] providers = Security.getProviders("Cipher.DES");
-
- assertNotNull("No installed providers support Cipher.DES", providers);
-
- for (int i = 0; i < providers.length; i++) {
- Cipher cipher = Cipher.getInstance("DES", providers[i].getName());
- assertNotNull("Cipher.getInstance() returned a null value", cipher);
-
- // Exception case
- try {
- cipher = Cipher.getInstance("DoBeDoBeDo", providers[i]);
- fail("Should have thrown an NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- // Expected
- }
- }
-
- // Exception case
- try {
- Cipher.getInstance("DES", (String) null);
- fail("Should have thrown an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // Expected
- }
-
- // Exception case
- try {
- Cipher.getInstance("DES", "IHaveNotBeenConfigured");
- fail("Should have thrown an NoSuchProviderException");
- } catch (NoSuchProviderException e) {
- // Expected
- }
- }
-
- /**
- * @tests javax.crypto.Cipher#getInstance(java.lang.String,
- *java.security.Provider)
- */
- public void test_getInstanceLjava_lang_StringLjava_security_Provider()
- throws Exception {
-
- Provider[] providers = Security.getProviders("Cipher.DES");
-
- assertNotNull("No installed providers support Cipher.DES", providers);
-
- for (int i = 0; i < providers.length; i++) {
- Cipher cipher = Cipher.getInstance("DES", providers[i]);
- assertNotNull("Cipher.getInstance() returned a null value", cipher);
- }
- }
-
- /**
- * @tests javax.crypto.Cipher#getProvider()
- */
- public void test_getProvider() throws Exception {
-
- Provider[] providers = Security.getProviders("Cipher.AES");
-
- assertNotNull("No providers support Cipher.AES", providers);
-
- for (int i = 0; i < providers.length; i++) {
- Provider provider = providers[i];
- Cipher cipher = Cipher.getInstance("AES", provider.getName());
- Provider cipherProvider = cipher.getProvider();
- assertTrue("Cipher provider is not the same as that "
- + "provided as parameter to getInstance()", cipherProvider
- .equals(provider));
- }
- }
-
- /**
- * @tests javax.crypto.Cipher#getAlgorithm()
- */
- public void test_getAlgorithm() throws Exception {
- final String algorithm = "DESede/CBC/PKCS5Padding";
-
- Cipher cipher = Cipher.getInstance(algorithm);
- assertTrue("Cipher algorithm does not match", cipher.getAlgorithm()
- .equals(algorithm));
- }
-
- /**
- * @tests javax.crypto.Cipher#getBlockSize()
- */
- public void test_getBlockSize() throws Exception {
- final String algorithm = "DESede/CBC/PKCS5Padding";
-
- Cipher cipher = Cipher.getInstance(algorithm);
- assertEquals("Block size does not match", 8, cipher.getBlockSize());
- }
-
- /**
- * @tests javax.crypto.Cipher#getOutputSize(int)
- */
- public void test_getOutputSizeI() throws Exception {
-
- SecureRandom sr = new SecureRandom();
- Cipher cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding");
- cipher.init(Cipher.ENCRYPT_MODE, cipherKey, sr);
-
- // A 25-byte input could result in at least 4 8-byte blocks
- int result = cipher.getOutputSize(25);
- assertTrue("Output size too small", result > 31);
-
- // A 8-byte input should result in 2 8-byte blocks
- result = cipher.getOutputSize(8);
- assertTrue("Output size too small", result > 15);
- }
-
- /**
- * @tests javax.crypto.Cipher#init(int, java.security.Key)
- */
- public void test_initILjava_security_Key() throws Exception {
- Cipher cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding");
- cipher.init(Cipher.ENCRYPT_MODE, cipherKey);
- }
-
- /**
- * @tests javax.crypto.Cipher#init(int, java.security.Key,
- *java.security.SecureRandom)
- */
- public void test_initILjava_security_KeyLjava_security_SecureRandom()
- throws Exception {
- SecureRandom sr = new SecureRandom();
- Cipher cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding");
- cipher.init(Cipher.ENCRYPT_MODE, cipherKey, sr);
- }
-
- /**
- * @tests javax.crypto.Cipher#init(int, java.security.Key,
- *java.security.spec.AlgorithmParameterSpec)
- */
- public void test_initILjava_security_KeyLjava_security_spec_AlgorithmParameterSpec()
- throws Exception {
- SecureRandom sr = new SecureRandom();
- Cipher cipher = null;
-
- byte[] iv = null;
- AlgorithmParameterSpec ivAVP = null;
-
- iv = new byte[8];
- sr.nextBytes(iv);
- ivAVP = new IvParameterSpec(iv);
-
- cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding");
-
- cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ivAVP);
-
- byte[] cipherIV = cipher.getIV();
-
- assertTrue("IVs differ", Arrays.equals(cipherIV, iv));
- }
-
- /**
- * @tests javax.crypto.Cipher#init(int, java.security.Key,
- *java.security.spec.AlgorithmParameterSpec,
- *java.security.SecureRandom)
- */
- public void test_initILjava_security_KeyLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom()
- throws Exception {
- SecureRandom sr = new SecureRandom();
- Cipher cipher = null;
-
- byte[] iv = null;
- AlgorithmParameterSpec ivAVP = null;
-
- iv = new byte[8];
- sr.nextBytes(iv);
- ivAVP = new IvParameterSpec(iv);
-
- cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding");
-
- cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ivAVP, sr);
-
- byte[] cipherIV = cipher.getIV();
-
- assertTrue("IVs differ", Arrays.equals(cipherIV, iv));
- }
-
- /**
- * @tests javax.crypto.Cipher#update(byte[], int, int)
- */
- public void test_update$BII() throws Exception {
- for (int index = 1; index < 4; index++) {
- Cipher c = Cipher.getInstance("DESEDE/CBC/PKCS5Padding");
-
- byte[] keyMaterial = loadBytes("hyts_" + "des-ede3-cbc.test"
- + index + ".key");
- DESedeKeySpec keySpec = new DESedeKeySpec(keyMaterial);
- SecretKeyFactory skf = SecretKeyFactory.getInstance("DESEDE");
- Key k = skf.generateSecret(keySpec);
-
- byte[] ivMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" + index
- + ".iv");
- IvParameterSpec iv = new IvParameterSpec(ivMaterial);
-
- c.init(Cipher.DECRYPT_MODE, k, iv);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] input = new byte[256];
- String resPath = "hyts_" + "des-ede3-cbc.test" + index
- + ".ciphertext";
- InputStream is = Support_Resources.getResourceStream(resPath);
-
- int bytesRead = is.read(input, 0, 256);
- while (bytesRead > 0) {
- byte[] output = c.update(input, 0, bytesRead);
- if (output != null) {
- baos.write(output);
- }
- bytesRead = is.read(input, 0, 256);
- }
-
- byte[] output = c.doFinal();
- if (output != null) {
- baos.write(output);
- }
-
- byte[] decipheredCipherText = baos.toByteArray();
- is.close();
-
- byte[] plaintextBytes = loadBytes("hyts_" + "des-ede3-cbc.test"
- + index + ".plaintext");
- assertTrue("Operation produced incorrect results", Arrays.equals(
- plaintextBytes, decipheredCipherText));
- }// end for
- }
-
- /**
- * @tests javax.crypto.Cipher#doFinal()
- */
- public void test_doFinal() throws Exception {
- for (int index = 1; index < 4; index++) {
- Cipher c = Cipher.getInstance("DESEDE/CBC/PKCS5Padding");
-
- byte[] keyMaterial = loadBytes("hyts_" + "des-ede3-cbc.test"
- + index + ".key");
- DESedeKeySpec keySpec = new DESedeKeySpec(keyMaterial);
- SecretKeyFactory skf = SecretKeyFactory.getInstance("DESEDE");
- Key k = skf.generateSecret(keySpec);
-
- byte[] ivMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" + index
- + ".iv");
- IvParameterSpec iv = new IvParameterSpec(ivMaterial);
-
- c.init(Cipher.ENCRYPT_MODE, k, iv);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] input = new byte[256];
- String resPath = "hyts_" + "des-ede3-cbc.test" + index
- + ".plaintext";
- InputStream is = Support_Resources.getResourceStream(resPath);
-
- int bytesRead = is.read(input, 0, 256);
- while (bytesRead > 0) {
- byte[] output = c.update(input, 0, bytesRead);
- if (output != null) {
- baos.write(output);
- }
- bytesRead = is.read(input, 0, 256);
- }
- byte[] output = c.doFinal();
- if (output != null) {
- baos.write(output);
- }
- byte[] encryptedPlaintext = baos.toByteArray();
- is.close();
-
- byte[] cipherText = loadBytes("hyts_" + "des-ede3-cbc.test" + index
- + ".ciphertext");
- assertTrue("Operation produced incorrect results", Arrays.equals(
- encryptedPlaintext, cipherText));
- }// end for
- }
-
- private byte[] loadBytes(String resPath) {
- try {
- InputStream is = Support_Resources.getResourceStream(resPath);
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] buff = new byte[1024];
- int readlen;
- while ((readlen = is.read(buff)) > 0) {
- out.write(buff, 0, readlen);
- }
- is.close();
- return out.toByteArray();
- } catch (IOException e) {
- return null;
- }
- }
-
- public void testGetParameters() throws Exception {
- Cipher c = Cipher.getInstance("DES");
- assertNull(c.getParameters());
- }
-
- /*
- * Class under test for int update(byte[], int, int, byte[], int)
- */
- public void testUpdatebyteArrayintintbyteArrayint() throws Exception {
- Cipher c = Cipher.getInstance("DESede");
- c.init(Cipher.ENCRYPT_MODE, cipherKey);
- byte[] b = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- byte[] b1 = new byte[6];
- try {
- c.update(b, 0, 10, b1, 5);
- fail("No expected ShortBufferException");
- } catch (ShortBufferException e) {
- }
- }
-
- /*
- * Class under test for int doFinal(byte[], int, int, byte[], int)
- */
- public void testDoFinalbyteArrayintintbyteArrayint() throws Exception {
- Cipher c = Cipher.getInstance("DESede");
- c.init(Cipher.ENCRYPT_MODE, cipherKey);
- byte[] b = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- byte[] b1 = new byte[6];
- // FIXME Failed on BC provider
- // try {
- // c.doFinal(b, 3, 6, b1, 5);
- // fail("No expected ShortBufferException");
- // } catch (ShortBufferException e) {
- // }
- }
-
- public void testGetMaxAllowedKeyLength() throws NoSuchAlgorithmException {
- try {
- Cipher.getMaxAllowedKeyLength(null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- try {
- Cipher.getMaxAllowedKeyLength("//CBC/PKCS5Paddin");
- fail("No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
- try {
- Cipher.getMaxAllowedKeyLength("/DES/CBC/PKCS5Paddin/1");
- fail("No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
- }
-
- public void testGetMaxAllowedParameterSpec()
- throws NoSuchAlgorithmException {
- try {
- Cipher.getMaxAllowedParameterSpec(null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- try {
- Cipher.getMaxAllowedParameterSpec("/DES//PKCS5Paddin");
- fail("No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
- try {
- Cipher.getMaxAllowedParameterSpec("/DES/CBC/ /1");
- fail("No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
- }
-
- /**
- * @tests javax.crypto.Cipher#Cipher(CipherSpi cipherSpi, Provider provider,
- *String transformation)
- */
- public void test_Ctor() throws Exception {
- // Regression for Harmony-1184
- try {
- new testCipher(null, null, "s");
- fail("NullPointerException expected");
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- new testCipher(new MyCipher(), null, "s");
- fail("NullPointerException expected for 'null' provider");
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- new testCipher(null, new Provider("qwerty", 1.0, "qwerty") {
- }, "s");
- fail("NullPointerException expected for 'null' cipherSpi");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- class testCipher extends Cipher {
- testCipher(CipherSpi c, Provider p, String s) {
- super(c, p, s);
- }
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfoTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfoTest.java
deleted file mode 100644
index 4e94377..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfoTest.java
+++ /dev/null
@@ -1,1926 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.io.IOException;
-import java.security.AlgorithmParameters;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.NoSuchAlgorithmException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.InvalidParameterSpecException;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.util.Arrays;
-
-import javax.crypto.BadPaddingException;
-import javax.crypto.Cipher;
-import javax.crypto.EncryptedPrivateKeyInfo;
-import javax.crypto.IllegalBlockSizeException;
-import javax.crypto.KeyGenerator;
-import javax.crypto.NoSuchPaddingException;
-import javax.crypto.SecretKeyFactory;
-import javax.crypto.spec.PBEKeySpec;
-import javax.crypto.spec.PBEParameterSpec;
-
-import org.apache.harmony.crypto.tests.support.EncryptedPrivateKeyInfoData;
-
-import junit.framework.TestCase;
-
-/**
- * Test for EncryptedPrivateKeyInfo class.
- * <p/>
- * All binary data for this test were generated using BEA JRockit j2sdk1.4.2_04
- * (http://www.bea.com) with security providers list extended by Bouncy Castle's
- * one (http://www.bouncycastle.org)
- */
-public class EncryptedPrivateKeyInfoTest extends TestCase {
-
- private static final Provider[] provider = Security.getProviders();
-
- /**
- * Algorithm names/transformations used in roundtrip tests of
- * getKeySpec(...) methods
- */
- private static final String[][] algName = {
- // AES
- { "AES", null },
- // {"AES", "AES/ECB/PKCS5Padding"},
- // {"AES", "AES/CBC/PKCS5Padding"},
- // {"AES", "AES/OFB/PKCS5Padding"},
- // {"AES", "AES/CFB/PKCS5Padding"},
- // {"2.16.840.1.101.3.4.1.1", null},
- // {"2.16.840.1.101.3.4.1.2", null},
- // {"2.16.840.1.101.3.4.1.3", null},
- // {"2.16.840.1.101.3.4.1.4", null},
- // {"2.16.840.1.101.3.4.1.5", null},
- // {"2.16.840.1.101.3.4.1.21", null},
- // {"2.16.840.1.101.3.4.1.22", null},
- // {"2.16.840.1.101.3.4.1.23", null},
- // {"2.16.840.1.101.3.4.1.24", null},
- // {"2.16.840.1.101.3.4.1.25", null},
- // {"2.16.840.1.101.3.4.1.41", null},
- // {"2.16.840.1.101.3.4.1.42", null},
- // {"2.16.840.1.101.3.4.1.43", null},
- // {"2.16.840.1.101.3.4.1.44", null},
- // {"2.16.840.1.101.3.4.1.45", null},
-
- // Blowfish
- // NO OIDs for Blowfish defined (?)
- { "Blowfish", null },
- // {"Blowfish","Blowfish/CBC/PKCS5Padding"},
- // {"Blowfish","Blowfish/CFB/PKCS5Padding"},
- // {"Blowfish","Blowfish/OFB/PKCS5Padding"},
- // {"Blowfish","Blowfish/PCBC/PKCS5Padding"},
-
- // DES: OIW OIDs only
- // {iso(1) identified-organization(3) oiw(14) secsig(3)
- // algorithms(2) desECB(6)}
- // 1.3.14.3.2.6
- // 1.3.14.3.2.7
- // 1.3.14.3.2.8
- // 1.3.14.3.2.9
- { "DES", null },
- // {"DES", "DES/CBC/PKCS5Padding"},
- // {"DES","DES/CFB/PKCS5Padding"},
- // {"DES","DES/OFB/PKCS5Padding"},
- // {"DES","DES/PCBC/PKCS5Padding"},
-
- // DESede (=TripleDes)
- //{iso(1) identified-organization(3) oiw(14) secsig(3)
- // algorithms(2) desEDE(17)}
- // 1.3.14.3.2.17
- // {"DESede",null},
- // {"DESede","DESede/CBC/PKCS5Padding"},
- // {"DESede","DESede/CFB/PKCS5Padding"},
- // {"DESede","DESede/OFB/PKCS5Padding"},
- // {"DESede","DESede/PCBC/PKCS5Padding"},
- { "TripleDES", null },
- // {"TripleDES","TripleDES/CBC/PKCS5Padding"},
- // {"TripleDES","TripleDES/CFB/PKCS5Padding"},
- // {"TripleDES","TripleDES/OFB/PKCS5Padding"},
- // {"TripleDES","TripleDES/PCBC/PKCS5Padding"},
-
- // PBEWith<digest>And<encryption>
- { "PBEWithMD5AndTripleDES", null },
- // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-5(5)
- // pbeWithMD5AndDES-CBC(3)}
- { "PBEWithMD5AndDES", "PBEWithMD5AndDES/CBC/PKCS5Padding" },
- { "PBEWithMD5AndDES", null }, { "PBEWithHmacSHA1AndDESede", null },
- // more oids:
- // {iso(1) member-body(2) us(840) nortelnetworks(113533) entrust(7)
- // algorithms(66) pbeWithMD5AndCAST5-CBC(12)}
- //
- // also named pbeWithSHAAnd128BitRC4, pbeWithSHA1And128BitRC4:
- // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-12(12)
- // pkcs-12-PbeIds(1) pkcs-12-OfflineTransportMode(1)}
- //
- // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-12(12)
- // pkcs-12-PbeIds(1)} +
- // pbeWithSHAAnd40BitRC4(2) pbeWithSHAAnd3-KeyTripleDES-CBC(3)
- // pbeWithSHAAnd2-KeyTripleDES-CBC(4) pbeWithSHAAnd128BitRC2-CBC(5)
- // pbeWithSHAAnd40BitRC2-CBC(6)
-
- // DiffieHellman
- { "DiffieHellman", null }, // 1.2.840.10046.2.1
- // {"DH",null}, // 1.2.840.10046.2.1
- // {"1.2.840.113549.1.3.1", null},
-
- { "DSA", null }, // 1.2.840.10040.4.1
-
- { "RC2", null },
-
- { "RC4", null },
-
- { "RC5", null },
-
- // {"1.2.840.113549.1.12.1.1",null},
- // {"1.2.840.113549.1.12.1.2",null},
- { "1.2.840.113549.1.12.1.3", null },
- { "PBEWithSHA1AndDESede", null },
- // {"1.2.840.113549.1.12.1.4",null},
- // {"1.2.840.113549.1.12.1.5",null},
- // {"1.2.840.113549.1.12.1.6",null},
- // {"ELGAMAL/PKCS1", "ELGAMAL/ECB/PKCS1PADDING"},
- // {"ELGAMAL/PKCS1","ELGAMAL/NONE/PKCS1PADDING"},
- // {"PBEWITHSHAAND3-KEYTRIPLEDES-CBC", null},
- // {"PBEWITHSHA1ANDDESEDE", null},
- // {"PBEWithSHAAnd3KeyTripleDES",null},
- // {"PBEWITHSHAAND3-KEYTRIPLEDES-CBC",null},
- //
- // {"RC5-32",null},
- //
- // {"RSA/1", "RSA/1/PKCS1PADDING"},
- // {"RSA/2", "RSA/2/PKCS1PADDING"},
- // {"RSA/ISO9796-1", "RSA/ECB/ISO9796-1PADDING"},
- // {"RSA", "RSA/ECB/NOPADDING"},
- // {"RSA/OAEP", "RSA/ECB/OAEPPADDING"},
- // {"RSA/PKCS1", "RSA/ECB/PKCS1PADDING"},
- // {"RSA/ISO9796-1", "RSA/NONE/ISO9796-1PADDING"},
- // {"RSA", "RSA/NONE/NOPADDING"},
- // {"RSA/OAEP", "RSA/NONE/OAEPPADDING"},
- // {"RSA/PKCS1", "RSA/NONE/PKCS1PADDING"},
- // {"RSA",null}, // 1.2.840.113549.1.1.1
- // {"1.2.840.113549.1.1.1", null},
- };
-
- /**
- * Test #1 for <code>EncryptedPrivateKeyInfo(byte[])</code> constructor
- * <br>
- * Assertion: creates <code>EncryptedPrivateKeyInfo</code> instance <br>
- * Test preconditions: valid parameters passed <br>
- * Expected: must pass without any exceptions
- *
- * @throws IOException
- * @throws NoSuchAlgorithmException
- */
- public final void testEncryptedPrivateKeyInfobyteArray1() throws Exception {
- new EncryptedPrivateKeyInfo(EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding("DH"));
- }
-
- /**
- * Test #2 for <code>EncryptedPrivateKeyInfo(byte[])</code> constructor
- * <br>
- * Assertion: <code>NullPointerException</code> if encoding is
- * <code>null</code><br>
- * Test preconditions: <code>null</code> passed as a parameter <br>
- * Expected: <code>NullPointerException</code>
- *
- * @throws IOException
- */
- public final void testEncryptedPrivateKeyInfobyteArray2()
- throws IOException {
- try {
- new EncryptedPrivateKeyInfo(null);
- fail(getName() + ": NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test #3 for <code>EncryptedPrivateKeyInfo(byte[])</code> constructor
- * <br>
- * Assertion: <code>IOException</code> if encoding is wrong <br>
- * Test preconditions: wrong encoding passed as a parameter <br>
- * Expected: <code>IOException</code>
- */
- public final void testEncryptedPrivateKeyInfobyteArray3() {
- try {
- new EncryptedPrivateKeyInfo(new byte[0]);
- fail(getName() + ": IOException has not been thrown");
- } catch (IOException ok) {
- }
- }
-
- /**
- * Test #4 for <code>EncryptedPrivateKeyInfo(byte[])</code> constructor
- * <br>
- * Assertion: <code>IOException</code> if encoding is wrong <br>
- * Test preconditions: wrong encoding passed as a parameter <br>
- * Expected: <code>IOException</code>
- */
- public final void testEncryptedPrivateKeyInfobyteArray4() {
- try {
- new EncryptedPrivateKeyInfo(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9,
- 10 });
- fail(getName() + ": IOException has not been thrown");
- } catch (IOException ok) {
- }
- }
-
- /**
- * Test #5 for <code>EncryptedPrivateKeyInfo(byte[])</code> constructor
- * <br>
- * Assertion: <code>IOException</code> if encoding is wrong <br>
- * Test preconditions: wrong encoding passed as a parameter <br>
- * Expected: <code>IOException</code>
- */
- public final void testEncryptedPrivateKeyInfobyteArray5() throws Exception {
- byte[] enc = null;
- try {
- // 1: get valid encoding
- enc = EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding("DSA");
-
- // ... and corrupt it (set wrong alg OID length)
- enc[9] = (byte) 6;
-
- new EncryptedPrivateKeyInfo(enc);
- fail(getName() + "(1): IOException has not been thrown");
- } catch (IOException ok) {
- }
-
- try {
- // 2: get valid encoding
- enc = EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding("DSA");
- // ... and corrupt it (set wrong encrypted data tag)
- enc[307] = (byte) 6;
- new EncryptedPrivateKeyInfo(enc);
- fail(getName() + "(2): IOException has not been thrown");
- } catch (IOException ok) {
- }
-
- try {
- // 3: get valid encoding
- enc = EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding("DSA");
- // ... and corrupt it (set wrong encrypted data length)
- enc[310] = (byte) 1;
- new EncryptedPrivateKeyInfo(enc);
- fail(getName() + "(3): IOException has not been thrown");
- } catch (IOException ok) {
- }
-
- try {
- // 4: get valid encoding
- enc = EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding("DSA");
- // ... and corrupt it (set wrong tag for alg params sequence)
- enc[17] = (byte) 0x29;
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc);
-
- if (epki.getAlgParameters() == null) {
- // This kind of encoding corruption can
- // be only determined while AlgorithmParameters
- // initialization BUT No AlgorithmParameters instance
- // available for algName0[i][0].
- // So just skip this sub test
- } else {
- fail(getName() + "(4): IOException has not been thrown");
- }
-
- } catch (IOException ok) {
- }
-
- try {
- // 5: get valid encoding
- enc = EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding("DSA");
- // ... and corrupt it (set wrong length for alg params sequence)
- enc[20] = (byte) 0x1d;
- new EncryptedPrivateKeyInfo(enc);
- fail(getName() + "(5): IOException has not been thrown");
- } catch (IOException ok) {
- }
-
- try {
- // 6: get valid encoding
- enc = EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding("DSA");
- // ... and corrupt it (set wrong length for alg params sequence)
- enc[20] = (byte) 0x1f;
- new EncryptedPrivateKeyInfo(enc);
- fail(getName() + "(6): IOException has not been thrown");
- } catch (IOException ok) {
- }
- }
-
- /**
- * Test #6 for <code>EncryptedPrivateKeyInfo(byte[])</code> constructor
- * <br>
- * Assertion: byte array is copied to prevent subsequent modification <br>
- * Test preconditions: valid array passed then modified <br>
- * Expected: getEncoded(), invoked after above modification, must return
- * array as it was before the modification
- *
- * @throws IOException
- */
- public final void testEncryptedPrivateKeyInfobyteArray6() throws Exception {
- byte[] encoded = EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding("DSA");
- byte[] encodedCopy = encoded.clone();
- // pass valid array
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(encodedCopy);
- // modify array passed
- encodedCopy[9] = (byte) 6;
- // check that internal state has not been affected
- assertTrue(Arrays.equals(encoded, epki.getEncoded()));
- }
-
- /**
- * Test #1 for <code>EncryptedPrivateKeyInfo(String, byte[])</code>
- * constructor <br>
- * Assertion: creates <code>EncryptedPrivateKeyInfo</code> instance <br>
- * Test preconditions: valid parameters passed <br>
- * Expected: must pass without any exceptions
- */
- public final void testEncryptedPrivateKeyInfoStringbyteArray1() {
- boolean performed = false;
-
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- EncryptedPrivateKeyInfoData.encryptedData);
- performed = true;
- } catch (NoSuchAlgorithmException allowed) {
- }
- }
-
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #2 for <code>EncryptedPrivateKeyInfo(String, byte[])</code>
- * constructor <br>
- * Assertion: <code>NoSuchAlgorithmException</code>- if the specified
- * algorithm is not supported <br>
- * Test preconditions: pass nonexistent algorithm name <br>
- * Expected: <code>NoSuchAlgorithmException</code>
- */
- public final void testEncryptedPrivateKeyInfoStringbyteArray2() {
- try {
- new EncryptedPrivateKeyInfo("bla-bla",
- EncryptedPrivateKeyInfoData.encryptedData);
- fail(getName() + ": NoSuchAlgorithmException has not been thrown");
- } catch (NoSuchAlgorithmException ok) {
- }
-
- try {
- new EncryptedPrivateKeyInfo("",
- EncryptedPrivateKeyInfoData.encryptedData);
- fail(getName() + ": NoSuchAlgorithmException has not been thrown");
- } catch (NoSuchAlgorithmException ok) {
- }
- }
-
- /**
- * Test #3 for <code>EncryptedPrivateKeyInfo(String, byte[])</code>
- * constructor <br>
- * Assertion: <code>NullPointerException</code>- if the specified
- * algorithm or encrypted data is <code>null</code><br>
- * Test preconditions: pass <code>null</code> as algorithm name then as
- * encrypted data <br>
- * Expected: <code>NullPointerException</code> in both cases
- *
- * @throws NoSuchAlgorithmException
- */
- public final void testEncryptedPrivateKeyInfoStringbyteArray3()
- throws NoSuchAlgorithmException {
- // pass null as name
- try {
- new EncryptedPrivateKeyInfo((String) null,
- EncryptedPrivateKeyInfoData.encryptedData);
- fail(getName() + ": NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
-
- // pass null as encrypted data
- try {
- new EncryptedPrivateKeyInfo("DSA", null);
- fail(getName() + ": NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test #4 for <code>EncryptedPrivateKeyInfo(String, byte[])</code>
- * constructor <br>
- * Assertion: <code>IllegalArgumentException</code>- if encrypted data is
- * empty, i.e. 0-length <br>
- * Test preconditions: pass empty encrypted data <br>
- * Expected: <code>IllegalArgumentException</code>
- */
- public final void testEncryptedPrivateKeyInfoStringbyteArray4()
- throws Exception {
- try {
- new EncryptedPrivateKeyInfo("DSA", new byte[] { });
- fail(getName() + ": IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test #5 for <code>EncryptedPrivateKeyInfo(String, byte[])</code>
- * constructor <br>
- * Assertion: byte array is copied to prevent subsequent modification <br>
- * Test preconditions: valid array passed then modified <br>
- * Expected: getEncryptedData(), invoked after above modification, must
- * return array as it was before the modification
- *
- * @throws IOException
- */
- public final void testEncryptedPrivateKeyInfoStringbyteArray5()
- throws Exception {
- byte[] encryptedDataCopy = EncryptedPrivateKeyInfoData.encryptedData
- .clone();
- // pass valid array
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo("DSA",
- encryptedDataCopy);
- // modify array passed
- encryptedDataCopy[0] = (byte) 6;
- // check that internal state has not been affected
- assertTrue(Arrays.equals(EncryptedPrivateKeyInfoData.encryptedData,
- epki.getEncryptedData()));
- }
-
- /**
- * @tests javax/crypto/EncryptedPrivateKeyInfo(String, byte[])
- * Checks exception order
- */
- public final void testEncryptedPrivateKeyInfoStringbyteArray6() {
- //Regression for HARMONY-768
- try {
- new EncryptedPrivateKeyInfo("0", new byte[] { });
- fail("NoSuchAlgorithmException expected");
- } catch (NoSuchAlgorithmException e) {
- //expected
- }
- }
-
- /**
- * Test #1 for
- * <code>EncryptedPrivateKeyInfo(java.security.AlgorithmParameters, byte[])
- * </code>
- * constructor <br>
- * Assertion: creates <code>EncryptedPrivateKeyInfo</code> instance <br>
- * Test preconditions: valid parameters passed <br>
- * Expected: must pass without any exceptions
- *
- * @throws IOException
- */
- public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray1()
- throws IOException {
-
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- AlgorithmParameters ap = AlgorithmParameters
- .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]);
- // use pregenerated AlgorithmParameters encodings
- ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding(
- EncryptedPrivateKeyInfoData.algName0[i][0]));
-
- new EncryptedPrivateKeyInfo(ap,
- EncryptedPrivateKeyInfoData.encryptedData);
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #2 for
- * <code>EncryptedPrivateKeyInfo(java.security.AlgorithmParameters, byte[])
- * </code>
- * constructor <br>
- * Assertion: <code>NullPointerException</code>- if the specified
- * algorithm parameters or encrypted data is <code>null</code><br>
- * Test preconditions: pass <code>null</code> as algorithm parameters then
- * as encrypted data <br>
- * Expected: <code>NullPointerException</code> in both cases
- *
- * @throws NoSuchAlgorithmException
- * @throws IOException
- */
- public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray2()
- throws NoSuchAlgorithmException, IOException {
- // 1: pass null as AlgorithmParameters
- try {
- new EncryptedPrivateKeyInfo((AlgorithmParameters) null,
- EncryptedPrivateKeyInfoData.encryptedData);
- fail(getName() + ": NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
-
- // 2: pass null as encrypted data
- try {
- AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA");
- // use pregenerated AlgorithmParameters encodings
- ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA"));
- new EncryptedPrivateKeyInfo(ap, null);
- fail(getName() + ": NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test #3 for
- * <code>EncryptedPrivateKeyInfo(java.security.AlgorithmParameters, byte[])
- * </code>
- * constructor <br>
- * Assertion: <code>IllegalArgumentException</code>- if encrypted data is
- * empty, i.e. 0-length <br>
- * Test preconditions: pass empty encrypted data <br>
- * Expected: <code>IllegalArgumentException</code>
- *
- * @throws NoSuchAlgorithmException
- * @throws IOException
- */
- public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray3()
- throws Exception {
- try {
- AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA");
- // use pregenerated AlgorithmParameters encodings
- ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA"));
-
- new EncryptedPrivateKeyInfo(ap, new byte[] { });
- fail(getName() + ": IllegalArgumentException has not been thrown");
-
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test #4 for
- * <code>EncryptedPrivateKeyInfo(java.security.AlgorithmParameters, byte[])
- * </code>
- * constructor <br>
- * Assertion: byte array is copied to prevent subsequent modification <br>
- * Test preconditions: valid array passed then modified <br>
- * Expected: getEncryptedData(), invoked after above modification, must
- * return array as it was before the modification
- *
- * @throws IOException
- */
- public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray4()
- throws Exception {
- AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA");
- // use pregenerated AlgorithmParameters encodings
- ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA"));
-
- byte[] encryptedDataCopy = EncryptedPrivateKeyInfoData.encryptedData.clone();
- // pass valid array
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap,
- encryptedDataCopy);
-
- // modify array passed
- encryptedDataCopy[0] = (byte) 6;
-
- // check that internal state has not been affected
- assertTrue(Arrays.equals(EncryptedPrivateKeyInfoData.encryptedData,
- epki.getEncryptedData()));
- }
-
- /**
- * Test #1 for <code>getAlgParameters()</code> method <br>
- * Assertion: returns the algorithm parameters <br>
- * Test preconditions: test object created using ctor which takes encoded
- * form as the only parameter; encoded form passed contains algorithm
- * parameters encoding <br>
- * Expected: corresponding algorithm parameters must be returned
- *
- * @throws IOException
- */
- public final void testGetAlgParameters01() throws IOException {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding(
- EncryptedPrivateKeyInfoData.algName0[i][0]));
-
- AlgorithmParameters apar = epki.getAlgParameters();
- if (apar == null) {
- continue;
- }
-
- // check that method under test returns
- // parameters with the same encoded form
- assertTrue(Arrays
- .equals(
- EncryptedPrivateKeyInfoData
- .getParametersEncoding(EncryptedPrivateKeyInfoData.algName0[i][0]),
- apar.getEncoded()));
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- public final void testGetAlgParameters01_01() throws Exception {
- byte[] validEncodingWithUnknownAlgOID = EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding("DH");
- // correct oid value
- validEncodingWithUnknownAlgOID[18] = 0;
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- validEncodingWithUnknownAlgOID);
-
- assertNull(epki.getAlgParameters());
- }
-
- /**
- * Test #2 for <code>getAlgParameters()</code> method <br>
- * Assertion: returns the algorithm parameters <br>
- * Test preconditions: test object created using ctor which takes encoded
- * form as the only parameter; encoded form passed does not contain
- * algorithm parameters encoding <br>
- * Expected: <code>null</code> must be returned
- *
- * @throws IOException
- */
- public final void testGetAlgParameters02() throws IOException {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- false));
-
- // check that method under test returns null
- assertNull(epki.getAlgParameters());
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #3 for <code>getAlgParameters()</code> method <br>
- * Assertion: returns the algorithm parameters <br>
- * Test #6 for <code>EncryptedPrivateKeyInfo(String, byte[])</code>
- * constructor <br>
- * Assertion: ...This constructor will use null as the value of the
- * algorithm parameters. <br>
- * Test preconditions: test object created using ctor which takes algorithm
- * name and encrypted data as a parameters <br>
- * Expected: <code>null</code> must be returned
- *
- * @throws IOException
- */
- public final void testGetAlgParameters03() throws IOException {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- EncryptedPrivateKeyInfoData.encryptedData);
-
- // check that method under test returns null
- // for object constructed in such a way
- assertNull(epki.getAlgParameters());
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #4 for <code>getAlgParameters()</code> method <br>
- * Assertion: returns the algorithm parameters <br>
- * Test preconditions: test object created using ctor which takes
- * AlgorithmParameters and encrypted data as a parameters; <br>
- * Expected: the same algorithm parameters as ones passed to the ctor must be
- * returned
- *
- * @throws IOException
- */
- public final void testGetAlgParameters04() throws IOException {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- AlgorithmParameters ap = AlgorithmParameters
- .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]);
- // use pregenerated AlgorithmParameters encodings
- ap
- .init(EncryptedPrivateKeyInfoData
- .getParametersEncoding(
- EncryptedPrivateKeyInfoData.algName0[i][0]));
-
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap,
- EncryptedPrivateKeyInfoData.encryptedData);
-
- // check that method under test returns
- // the same parameters instance
- assertSame(ap, epki.getAlgParameters());
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #1 for <code>getEncryptedData()</code> method <br>
- * Assertion: returns the encrypted data <br>
- * Test preconditions: test object created using ctor which takes encoded
- * form as the only parameter; encoded form passed contains encrypted data
- * <br>
- * Expected: the equivalent encrypted data must be returned
- *
- * @throws IOException
- */
- public final void testGetEncryptedData01() throws IOException {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding(
- EncryptedPrivateKeyInfoData.algName0[i][0]));
-
- // check that method under test returns
- // valid encrypted data
- assertTrue(Arrays.equals(
- EncryptedPrivateKeyInfoData.encryptedData, epki
- .getEncryptedData()));
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #2 for <code>getEncryptedData()</code> method <br>
- * Assertion: returns the encrypted data <br>
- * Test preconditions: test object created using ctor which takes algorithm
- * name and encrypted data as a parameters <br>
- * Expected: the equivalent encrypted data must be returned
- */
- public final void testGetEncryptedData02() {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- EncryptedPrivateKeyInfoData.encryptedData);
-
- // check that method under test returns
- // valid encrypted data
- assertTrue(Arrays.equals(
- EncryptedPrivateKeyInfoData.encryptedData, epki
- .getEncryptedData()));
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #3 for <code>getEncryptedData()</code> method <br>
- * Assertion: returns the encrypted data <br>
- * Test preconditions: test object created using ctor which takes algorithm
- * parameters and encrypted data as a parameters <br>
- * Expected: the equivalent encrypted data must be returned
- *
- * @throws IOException
- */
- public final void testGetEncryptedData03() throws IOException {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- AlgorithmParameters ap = AlgorithmParameters
- .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]);
- // use pregenerated AlgorithmParameters encodings
- ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding(
- EncryptedPrivateKeyInfoData.algName0[i][0]));
-
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap,
- EncryptedPrivateKeyInfoData.encryptedData);
-
- // check that method under test returns
- // valid encrypted data
- assertTrue(Arrays.equals(
- EncryptedPrivateKeyInfoData.encryptedData, epki
- .getEncryptedData()));
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #4 for <code>getEncryptedData()</code> method <br>
- * Assertion: returns a new array each time this method is called <br>
- * Test preconditions: test object created using ctor which takes algorithm
- * name and encrypted data as a parameters <br>
- * Expected: refs to encrypted data byte array passed to the ctor and
- * returned by the method under test must be different
- */
- public final void testGetEncryptedData04() {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- EncryptedPrivateKeyInfoData.encryptedData);
-
- // check that method under test returns
- // new array each time
- byte[] ecd1 = epki.getEncryptedData();
- byte[] ecd2 = epki.getEncryptedData();
- assertNotSame(EncryptedPrivateKeyInfoData.encryptedData, ecd1);
- assertNotSame(EncryptedPrivateKeyInfoData.encryptedData, ecd2);
- assertNotSame(ecd1, ecd2);
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #1 for <code>getEncoded()</code> method <br>
- * Assertion: returns the ASN.1 encoding of this object <br>
- * Test preconditions: test object created using ctor which takes encoded
- * form as the only parameter <br>
- * Expected: equivalent encoded form must be returned
- *
- * @throws IOException
- */
- public final void testGetEncoded01() throws IOException {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- byte[] enc = EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding(
- EncryptedPrivateKeyInfoData.algName0[i][0]);
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc);
-
- // check that method under test returns
- // valid encoded form
- assertTrue(Arrays.equals(enc, epki.getEncoded()));
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #2 for <code>getEncoded()</code> method <br>
- * Assertion: returns the ASN.1 encoding of this object <br>
- * Test preconditions: test object created using ctor which takes algorithm
- * name and encrypted data as a parameters <br>
- * Expected: equivalent encoded form (without alg params) must be returned
- *
- * @throws IOException
- */
- public final void testGetEncoded02() throws IOException {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- EncryptedPrivateKeyInfoData.encryptedData);
-
- // check that method under test returns
- // valid encoded form
- byte[] refEnc = EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- false);
- // System.out.println(Array.toString(refEnc, " "));
- byte[] actEnc = epki.getEncoded();
- // System.out.println(Array.toString(actEnc, " "));
- assertTrue(Arrays.equals(refEnc, actEnc));
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #3 for <code>getEncoded()</code> method <br>
- * Assertion: returns the ASN.1 encoding of this object <br>
- * Test preconditions: test object created using ctor which takes algorithm
- * name and encrypted data as a parameters <br>
- * Expected: equivalent encoded form (without alg params) must be returned
- *
- * @throws IOException
- */
- public final void testGetEncoded03() throws IOException {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- AlgorithmParameters ap = AlgorithmParameters
- .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]);
- // use pregenerated AlgorithmParameters encodings
- ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding(
- EncryptedPrivateKeyInfoData.algName0[i][0]));
-
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap,
- EncryptedPrivateKeyInfoData.encryptedData);
-
- // check that method under test returns
- // valid encoded form
- assertTrue(Arrays.equals(
- EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding(
- EncryptedPrivateKeyInfoData.algName0[i][0]),
- epki.getEncoded()));
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #4 for <code>getEncoded()</code> method <br>
- * Assertion: returns a new array each time this method is called <br>
- * Test preconditions: test object created using ctor which takes algorithm
- * name and encrypted data as a parameters <br>
- * Expected: several refs to byte array returned by the method under test
- * must be different
- *
- * @throws IOException
- */
- public final void testGetEncoded04() throws IOException {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- EncryptedPrivateKeyInfoData.encryptedData);
-
- // check that method under test returns
- // new array each time
- byte[] ec1 = epki.getEncoded();
- byte[] ec2 = epki.getEncoded();
- byte[] ec3 = epki.getEncoded();
- assertNotSame(ec1, ec2);
- assertNotSame(ec2, ec3);
- assertNotSame(ec1, ec3);
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- public final void testGetKeySpecCipher01() {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- EncryptedPrivateKeyInfoData.encryptedData);
-
- try {
-
- // check that method under test throws NPE
- epki.getKeySpec((Cipher) null);
- fail(getName() + "NullPointerException has not been thrown");
-
- } catch (NullPointerException ok) {
- } catch (InvalidKeySpecException e) {
- fail(getName() + "Unexpected exception: " + e);
- }
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Encrypted data contains valid PKCS8 key info encoding
- */
- public final void test_ROUNDTRIP_GetKeySpecCipher01() {
- boolean performed = false;
-
- for (int i = 0; i < algName.length; i++) {
- try {
- // generate test data
- TestDataGenerator g = new TestDataGenerator(algName[i][0],
- algName[i][1], privateKeyInfo, null);
-
- // create test object
- EncryptedPrivateKeyInfo epki;
- if (g.ap() == null) {
- epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct());
- } else {
- epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
- }
-
- // call methods under test
- try {
-
- PKCS8EncodedKeySpec eks = epki.getKeySpec(g.c());
-
- if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) {
- fail(algName[i][0] + " != " + algName[i][1]);
- }
- } catch (InvalidKeySpecException e) {
- fail(algName[i][0] + ", " + algName[i][1] + e + "\n");
- }
- performed = true;
-
- } catch (TestDataGenerator.AllowedFailure allowedFailure) {
- } catch (NoSuchAlgorithmException allowed) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Encrypted data contains invalid PKCS8 key info encoding
- */
- public final void test_ROUNDTRIP_GetKeySpecCipher02() {
- boolean performed = false;
- for (int i = 0; i < algName.length; i++) {
- try {
- // generate test data
- TestDataGenerator g = new TestDataGenerator(algName[i][0],
- algName[i][1], privateKeyInfoDamaged, null);
-
- // create test object
- EncryptedPrivateKeyInfo epki;
- if (g.ap() == null) {
- epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct());
- } else {
- epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
- }
-
- // call methods under test
- try {
- epki.getKeySpec(g.c());
-
- // must not get here because decrypted data does
- // not represent valid PKCS8 encoding
- fail(algName[i][0] + ", " + algName[i][1]);
- } catch (InvalidKeySpecException ok) {
- }
-
- performed = true;
- } catch (TestDataGenerator.AllowedFailure allowedFailure) {
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- public final void testGetKeySpecKey01() {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- EncryptedPrivateKeyInfoData.encryptedData);
-
- try {
-
- // check that method under test throws NPE
- epki.getKeySpec((Key) null);
- fail(getName() + "NullPointerException has not been thrown");
-
- } catch (NullPointerException ok) {
- } catch (InvalidKeyException e) {
- fail(getName() + "Unexpected exception: " + e);
- }
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Encrypted data contains valid PKCS8 key info encoding
- */
- public final void test_ROUNDTRIP_GetKeySpecKey01() {
- boolean performed = false;
- for (int i = 0; i < algName.length; i++) {
- try {
- // generate test data
- TestDataGenerator g = new TestDataGenerator(algName[i][0],
- algName[i][1], privateKeyInfo, null);
-
- // create test object
- EncryptedPrivateKeyInfo epki;
- if (g.ap() == null) {
- epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct());
- } else {
- epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
- }
-
- try {
- PKCS8EncodedKeySpec eks = epki
- .getKeySpec(g.pubK() == null ? g.k() : g.pubK());
-
- if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) {
- fail(algName[i][0] + " != " + algName[i][1]);
- }
- } catch (InvalidKeyException e) {
- fail(algName[i][0] + ", " + algName[i][1] + ": " + e);
- }
-
- performed = true;
- } catch (TestDataGenerator.AllowedFailure allowedFailure) {
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Encrypted data contains invalid PKCS8 key info encoding
- */
- public final void test_ROUNDTRIP_GetKeySpecKey02() {
- boolean performed = false;
- for (int i = 0; i < algName.length; i++) {
- try {
- // generate test data
- TestDataGenerator g = new TestDataGenerator(algName[i][0],
- algName[i][1], privateKeyInfoDamaged, null);
-
- // create test object
- EncryptedPrivateKeyInfo epki;
- if (g.ap() == null) {
- epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct());
- } else {
- epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
- }
-
- try {
- epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK());
- fail(algName[i][0] + ", " + algName[i][1]);
- } catch (InvalidKeyException e) {
- }
-
- performed = true;
- } catch (TestDataGenerator.AllowedFailure allowedFailure) {
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- public final void testGetKeySpecKeyString01() throws Exception {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- EncryptedPrivateKeyInfoData.encryptedData);
-
- try {
-
- // check that method under test throws NPE
- epki.getKeySpec((Key) null, "SomeProviderName");
- fail(getName() + "NullPointerException has not been thrown");
-
- } catch (NullPointerException ok) {
- }
-
- try {
-
- // check that method under test throws NPE
- epki.getKeySpec(new Key() {
- public String getAlgorithm() {
- return "alg";
- }
-
- public String getFormat() {
- return "fmt";
- }
-
- public byte[] getEncoded() {
- return new byte[] { };
- }
- }, (String) null);
-
- fail(getName() + "NullPointerException has not been thrown");
-
- } catch (NullPointerException ok) {
- }
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Encrypted data contains valid PKCS8 key info encoding
- */
- public final void test_ROUNDTRIP_GetKeySpecKeyString01() throws Exception {
- boolean performed = false;
- for (int i = 0; i < algName.length; i++) {
- for (int l = 0; l < provider.length; l++) {
- if (provider[l] == null) {
- continue;
- }
- TestDataGenerator g;
- try {
- // generate test data
- g = new TestDataGenerator(algName[i][0], algName[i][1],
- privateKeyInfo, provider[l]);
- } catch (TestDataGenerator.AllowedFailure allowedFailure) {
- continue;
- }
-
- try {
- // create test object
- EncryptedPrivateKeyInfo epki;
- if (g.ap() == null) {
- epki = new EncryptedPrivateKeyInfo(algName[i][0], g
- .ct());
- } else {
- epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
- }
- try {
-
- PKCS8EncodedKeySpec eks = epki.getKeySpec(
- g.pubK() == null ? g.k() : g.pubK(),
- provider[l].getName());
-
- if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) {
- fail(algName[i][0] + " != " + algName[i][1]);
- }
- } catch (InvalidKeyException e) {
- fail(algName[i][0] + ", " + algName[i][1] + ": " + e);
- }
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Encrypted data contains invalid PKCS8 key info encoding
- */
- public final void test_ROUNDTRIP_GetKeySpecKeyString02() throws Exception {
- boolean performed = false;
- for (int i = 0; i < algName.length; i++) {
- for (int l = 0; l < provider.length; l++) {
- if (provider[l] == null) {
- continue;
- }
- TestDataGenerator g;
- try {
- // generate test data
- g = new TestDataGenerator(algName[i][0], algName[i][1],
- privateKeyInfoDamaged, provider[l]);
- } catch (TestDataGenerator.AllowedFailure allowedFailure) {
- continue;
- }
-
- try {
- // create test object
- EncryptedPrivateKeyInfo epki;
- if (g.ap() == null) {
- epki = new EncryptedPrivateKeyInfo(algName[i][0], g
- .ct());
- } else {
- epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
- }
-
- try {
-
- epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK(),
- provider[l].getName());
-
- fail(algName[i][0] + ", " + algName[i][1]);
-
- } catch (InvalidKeyException e) {
- }
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- public final void testGetKeySpecKeyProvider01() throws Exception {
- boolean performed = false;
-
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- EncryptedPrivateKeyInfoData.encryptedData);
-
- try {
-
- // check that method under test throws NPE
- epki.getKeySpec((Key) null, (Provider) null);
- fail(getName() + "NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
-
- try {
-
- // check that method under test throws NPE
- epki.getKeySpec(new Key() {
- public String getAlgorithm() {
- return "alg";
- }
-
- public String getFormat() {
- return "fmt";
- }
-
- public byte[] getEncoded() {
- return new byte[] { };
- }
- }, (Provider) null);
-
- fail(getName() + "NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
-
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Encrypted data contains valid PKCS8 key info encoding
- */
- public final void test_ROUNDTRIP_GetKeySpecKeyProvider01() {
- boolean performed = false;
-
- for (int i = 0; i < algName.length; i++) {
- for (int l = 0; l < provider.length; l++) {
- if (provider[l] == null) {
- continue;
- }
- TestDataGenerator g;
- try {
- // generate test data
- g = new TestDataGenerator(algName[i][0], algName[i][1],
- privateKeyInfo, provider[l]);
- } catch (TestDataGenerator.AllowedFailure allowedFailure) {
- continue;
- }
- try {
- // create test object
- EncryptedPrivateKeyInfo epki;
- if (g.ap() == null) {
- epki = new EncryptedPrivateKeyInfo(algName[i][0], g
- .ct());
- } else {
- epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
- }
- try {
-
- PKCS8EncodedKeySpec eks = epki.getKeySpec(
- g.pubK() == null ? g.k() : g.pubK(),
- provider[l]);
-
- if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) {
- fail(algName[i][0] + " != " + algName[i][1]);
- }
- } catch (InvalidKeyException e) {
- fail(algName[i][0] + ", " + algName[i][1] + ": " + e);
- }
- performed = true;
-
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Encrypted data contains invalid PKCS8 key info encoding
- */
- public final void test_ROUNDTRIP_GetKeySpecKeyProvider02() {
- boolean performed = false;
-
- for (int i = 0; i < algName.length; i++) {
- for (int l = 0; l < provider.length; l++) {
- if (provider[l] == null) {
- continue;
- }
- TestDataGenerator g;
- try {
- // generate test data
- g = new TestDataGenerator(algName[i][0], algName[i][1],
- privateKeyInfoDamaged, provider[l]);
- } catch (TestDataGenerator.AllowedFailure allowedFailure) {
- continue;
- }
-
- try {
- // create test object
- EncryptedPrivateKeyInfo epki;
- if (g.ap() == null) {
- epki = new EncryptedPrivateKeyInfo(algName[i][0], g
- .ct());
- } else {
- epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
- }
- try {
-
- epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK(),
- provider[l]);
-
- fail(algName[i][0] + ", " + algName[i][1]);
-
- } catch (InvalidKeyException e) {
- }
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- public static class TestDataGenerator {
-
- public static class AllowedFailure extends Exception {
- AllowedFailure(String msg) {
- super(msg);
- }
- }
-
- private Cipher c = null;
-
- private Key k = null, pubK = null;
-
- private AlgorithmParameters ap = null;
-
- byte[] ct;
-
- public TestDataGenerator(String algName, String transformation,
- byte[] privateKeyInfo, Provider provider) throws AllowedFailure {
- try {
- c = (provider == null) ? Cipher
- .getInstance(transformation != null ? transformation
- : algName) : Cipher.getInstance(
- transformation != null ? transformation : algName,
- provider);
- } catch (NoSuchAlgorithmException e) {
- throw new AllowedFailure(e.getMessage());
- } catch (NoSuchPaddingException e) {
- throw new AllowedFailure(e.getMessage());
- }
-
- try {
- KeyGenerator kg = (provider == null) ? KeyGenerator
- .getInstance(algName) : KeyGenerator.getInstance(
- algName, provider);
- k = kg.generateKey();
- } catch (NoSuchAlgorithmException e) {
- }
-
- if (k == null) {
- try {
- KeyPairGenerator kpg = (provider == null) ? KeyPairGenerator
- .getInstance(algName)
- : KeyPairGenerator.getInstance(algName, provider);
- KeyPair kp = kpg.genKeyPair();
- k = kp.getPrivate();
- pubK = kp.getPublic();
- } catch (NoSuchAlgorithmException e) {
- }
- }
-
- PBEParameterSpec pbeParamSpec = null;
- if (k == null) {
- try {
- pbeParamSpec = new PBEParameterSpec(new byte[] { 1, 2, 3,
- 4, 5, 6, 7, 8 }, 10);
- SecretKeyFactory skf = (provider == null) ? SecretKeyFactory
- .getInstance(algName)
- : SecretKeyFactory.getInstance(algName, provider);
- PBEKeySpec ks = new PBEKeySpec("12345678".toCharArray());
- try {
- k = skf.generateSecret(ks);
- } catch (InvalidKeySpecException e) {
- throw new AllowedFailure(e.getMessage());
- }
-
- } catch (NoSuchAlgorithmException e) {
- throw new AllowedFailure(e.getMessage());
- }
- }
-
- try {
- if (pbeParamSpec == null) {
- c.init(Cipher.ENCRYPT_MODE, k);
- } else {
- c.init(Cipher.ENCRYPT_MODE, k, pbeParamSpec);
- }
- } catch (InvalidKeyException e) {
- throw new AllowedFailure(e.getMessage());
- } catch (SecurityException e) {
- throw new AllowedFailure(e.getMessage());
- } catch (InvalidAlgorithmParameterException e) {
- throw new AllowedFailure(e.getMessage());
- }
-
- ap = c.getParameters();
-
- try {
- ct = c.doFinal(privateKeyInfo);
- } catch (IllegalStateException e) {
- throw new AllowedFailure(e.getMessage());
- } catch (IllegalBlockSizeException e) {
- throw new AllowedFailure(e.getMessage());
- } catch (BadPaddingException e) {
- throw new AllowedFailure(e.getMessage());
- } catch (RuntimeException e) {
- throw new AllowedFailure(e.getMessage());
- }
-
- try {
- // try to convert pbeParamSpec->ap
- if (pbeParamSpec != null) {
- try {
- ap = (provider == null) ? AlgorithmParameters
- .getInstance(algName) : AlgorithmParameters
- .getInstance(algName, provider);
- ap.init(pbeParamSpec);
- pbeParamSpec = null;
- } catch (NoSuchAlgorithmException e) {
- // couldn't convert
- throw new AllowedFailure(e.getMessage());
- } catch (InvalidParameterSpecException e) {
- // couldn't convert
- throw new AllowedFailure(e.getMessage());
- }
- }
-
- if (ap == null) {
- c.init(Cipher.DECRYPT_MODE, pubK == null ? k : pubK);
- } else {
- c.init(Cipher.DECRYPT_MODE, pubK == null ? k : pubK, ap);
- }
-
- } catch (InvalidKeyException e) {
- throw new AllowedFailure(e.getMessage());
- } catch (SecurityException e) {
- throw new AllowedFailure(e.getMessage());
- } catch (InvalidAlgorithmParameterException e) {
- throw new AllowedFailure(e.getMessage());
- }
- }
-
- public Key k() {
- return k;
- }
-
- public Key pubK() {
- return pubK;
- }
-
- public Cipher c() {
- return c;
- }
-
- public byte[] ct() {
- return ct;
- }
-
- public AlgorithmParameters ap() {
- return ap;
- }
- }
-
- // valid PrivateKeyInfo encoding
- private static final byte[] privateKeyInfo = { (byte) 0x30, (byte) 0x82,
- (byte) 0x02, (byte) 0x77, (byte) 0x02, (byte) 0x01, (byte) 0x00,
- (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a,
- (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d,
- (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00,
- (byte) 0x04, (byte) 0x82, (byte) 0x02, (byte) 0x61, (byte) 0x30,
- (byte) 0x82, (byte) 0x02, (byte) 0x5d, (byte) 0x02, (byte) 0x01,
- (byte) 0x00, (byte) 0x02, (byte) 0x81, (byte) 0x81, (byte) 0x00,
- (byte) 0xb2, (byte) 0x4a, (byte) 0x9b, (byte) 0x5b, (byte) 0xba,
- (byte) 0x01, (byte) 0xc0, (byte) 0xcd, (byte) 0x65, (byte) 0x09,
- (byte) 0x63, (byte) 0x70, (byte) 0x0b, (byte) 0x5a, (byte) 0x1b,
- (byte) 0x92, (byte) 0x08, (byte) 0xf8, (byte) 0x55, (byte) 0x5e,
- (byte) 0x7c, (byte) 0x1b, (byte) 0x50, (byte) 0x17, (byte) 0xec,
- (byte) 0x44, (byte) 0x4c, (byte) 0x58, (byte) 0x42, (byte) 0x2b,
- (byte) 0x41, (byte) 0x09, (byte) 0x59, (byte) 0xf2, (byte) 0xe1,
- (byte) 0x5d, (byte) 0x43, (byte) 0x71, (byte) 0x4d, (byte) 0x92,
- (byte) 0x03, (byte) 0x1d, (byte) 0xb6, (byte) 0x6c, (byte) 0x7f,
- (byte) 0x5d, (byte) 0x48, (byte) 0xcd, (byte) 0x17, (byte) 0xec,
- (byte) 0xd7, (byte) 0x4c, (byte) 0x39, (byte) 0xb1, (byte) 0x7b,
- (byte) 0xe2, (byte) 0xbf, (byte) 0x96, (byte) 0x77, (byte) 0xbe,
- (byte) 0xd0, (byte) 0xa0, (byte) 0xf0, (byte) 0x2d, (byte) 0x6b,
- (byte) 0x24, (byte) 0xaa, (byte) 0x14, (byte) 0xba, (byte) 0x82,
- (byte) 0x79, (byte) 0x10, (byte) 0x9b, (byte) 0x16, (byte) 0x68,
- (byte) 0x47, (byte) 0x81, (byte) 0x54, (byte) 0xa2, (byte) 0xfa,
- (byte) 0x91, (byte) 0x9e, (byte) 0x0a, (byte) 0x2a, (byte) 0x53,
- (byte) 0xa6, (byte) 0xe7, (byte) 0x9e, (byte) 0x7d, (byte) 0x29,
- (byte) 0x33, (byte) 0xd8, (byte) 0x05, (byte) 0xfc, (byte) 0x02,
- (byte) 0x3f, (byte) 0xbd, (byte) 0xc7, (byte) 0x6e, (byte) 0xed,
- (byte) 0xaa, (byte) 0x30, (byte) 0x6c, (byte) 0x5f, (byte) 0x52,
- (byte) 0xed, (byte) 0x35, (byte) 0x65, (byte) 0x4b, (byte) 0x0e,
- (byte) 0xc8, (byte) 0xa7, (byte) 0x12, (byte) 0x10, (byte) 0x56,
- (byte) 0x37, (byte) 0xaf, (byte) 0x11, (byte) 0xfa, (byte) 0x21,
- (byte) 0x0e, (byte) 0x99, (byte) 0xff, (byte) 0xfa, (byte) 0x8c,
- (byte) 0x65, (byte) 0x8e, (byte) 0x6d, (byte) 0x02, (byte) 0x03,
- (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x81,
- (byte) 0x80, (byte) 0x78, (byte) 0x41, (byte) 0x72, (byte) 0x40,
- (byte) 0x90, (byte) 0x59, (byte) 0x96, (byte) 0x5d, (byte) 0xf3,
- (byte) 0x84, (byte) 0x3d, (byte) 0x99, (byte) 0xd9, (byte) 0x4e,
- (byte) 0x51, (byte) 0xc2, (byte) 0x52, (byte) 0x62, (byte) 0x8d,
- (byte) 0xd2, (byte) 0x49, (byte) 0x0b, (byte) 0x73, (byte) 0x1e,
- (byte) 0x6f, (byte) 0xb2, (byte) 0x31, (byte) 0x7c, (byte) 0x66,
- (byte) 0x45, (byte) 0x1e, (byte) 0x7c, (byte) 0xdc, (byte) 0x3a,
- (byte) 0xc2, (byte) 0x5f, (byte) 0x51, (byte) 0x9a, (byte) 0x1e,
- (byte) 0xa4, (byte) 0x19, (byte) 0x8d, (byte) 0xf4, (byte) 0xf9,
- (byte) 0x81, (byte) 0x7e, (byte) 0xbe, (byte) 0x17, (byte) 0xf7,
- (byte) 0xc7, (byte) 0x3c, (byte) 0x00, (byte) 0xa1, (byte) 0xf9,
- (byte) 0x60, (byte) 0x82, (byte) 0x34, (byte) 0x8f, (byte) 0x9c,
- (byte) 0xfd, (byte) 0x0b, (byte) 0x63, (byte) 0x42, (byte) 0x1b,
- (byte) 0x7f, (byte) 0x45, (byte) 0xf1, (byte) 0x31, (byte) 0xc3,
- (byte) 0x63, (byte) 0x47, (byte) 0x5c, (byte) 0xc1, (byte) 0xb2,
- (byte) 0x5f, (byte) 0x57, (byte) 0xee, (byte) 0x02, (byte) 0x9f,
- (byte) 0x5e, (byte) 0x08, (byte) 0x48, (byte) 0xba, (byte) 0x74,
- (byte) 0xba, (byte) 0x81, (byte) 0xb7, (byte) 0x30, (byte) 0xac,
- (byte) 0x4c, (byte) 0x01, (byte) 0x35, (byte) 0xce, (byte) 0x46,
- (byte) 0x47, (byte) 0x8c, (byte) 0xe4, (byte) 0x62, (byte) 0x36,
- (byte) 0x1a, (byte) 0x65, (byte) 0x0e, (byte) 0x33, (byte) 0x56,
- (byte) 0xf9, (byte) 0xb7, (byte) 0xa0, (byte) 0xc4, (byte) 0xb6,
- (byte) 0x82, (byte) 0x55, (byte) 0x7d, (byte) 0x36, (byte) 0x55,
- (byte) 0xc0, (byte) 0x52, (byte) 0x5e, (byte) 0x35, (byte) 0x54,
- (byte) 0xbd, (byte) 0x97, (byte) 0x01, (byte) 0x00, (byte) 0xbf,
- (byte) 0x10, (byte) 0xdc, (byte) 0x1b, (byte) 0x51, (byte) 0x02,
- (byte) 0x41, (byte) 0x00, (byte) 0xe7, (byte) 0x68, (byte) 0x03,
- (byte) 0x3e, (byte) 0x21, (byte) 0x64, (byte) 0x68, (byte) 0x24,
- (byte) 0x7b, (byte) 0xd0, (byte) 0x31, (byte) 0xa0, (byte) 0xa2,
- (byte) 0xd9, (byte) 0x87, (byte) 0x6d, (byte) 0x79, (byte) 0x81,
- (byte) 0x8f, (byte) 0x8f, (byte) 0x2d, (byte) 0x7a, (byte) 0x95,
- (byte) 0x2e, (byte) 0x55, (byte) 0x9f, (byte) 0xd7, (byte) 0x86,
- (byte) 0x29, (byte) 0x93, (byte) 0xbd, (byte) 0x04, (byte) 0x7e,
- (byte) 0x4f, (byte) 0xdb, (byte) 0x56, (byte) 0xf1, (byte) 0x75,
- (byte) 0xd0, (byte) 0x4b, (byte) 0x00, (byte) 0x3a, (byte) 0xe0,
- (byte) 0x26, (byte) 0xf6, (byte) 0xab, (byte) 0x9e, (byte) 0x0b,
- (byte) 0x2a, (byte) 0xf4, (byte) 0xa8, (byte) 0xd7, (byte) 0xff,
- (byte) 0xbe, (byte) 0x01, (byte) 0xeb, (byte) 0x9b, (byte) 0x81,
- (byte) 0xc7, (byte) 0x5f, (byte) 0x02, (byte) 0x73, (byte) 0xe1,
- (byte) 0x2b, (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xc5,
- (byte) 0x3d, (byte) 0x78, (byte) 0xab, (byte) 0xe6, (byte) 0xab,
- (byte) 0x3e, (byte) 0x29, (byte) 0xfd, (byte) 0x98, (byte) 0xd0,
- (byte) 0xa4, (byte) 0x3e, (byte) 0x58, (byte) 0xee, (byte) 0x48,
- (byte) 0x45, (byte) 0xa3, (byte) 0x66, (byte) 0xac, (byte) 0xe9,
- (byte) 0x4d, (byte) 0xbd, (byte) 0x60, (byte) 0xea, (byte) 0x24,
- (byte) 0xff, (byte) 0xed, (byte) 0x0c, (byte) 0x67, (byte) 0xc5,
- (byte) 0xfd, (byte) 0x36, (byte) 0x28, (byte) 0xea, (byte) 0x74,
- (byte) 0x88, (byte) 0xd1, (byte) 0xd1, (byte) 0xad, (byte) 0x58,
- (byte) 0xd7, (byte) 0xf0, (byte) 0x67, (byte) 0x20, (byte) 0xc1,
- (byte) 0xe3, (byte) 0xb3, (byte) 0xdb, (byte) 0x52, (byte) 0xad,
- (byte) 0xf3, (byte) 0xc4, (byte) 0x21, (byte) 0xd8, (byte) 0x8c,
- (byte) 0x4c, (byte) 0x41, (byte) 0x27, (byte) 0xdb, (byte) 0xd0,
- (byte) 0x35, (byte) 0x92, (byte) 0xc7, (byte) 0x02, (byte) 0x41,
- (byte) 0x00, (byte) 0xe0, (byte) 0x99, (byte) 0x42, (byte) 0xb4,
- (byte) 0x76, (byte) 0x02, (byte) 0x97, (byte) 0x55, (byte) 0xf9,
- (byte) 0xda, (byte) 0x3b, (byte) 0xa0, (byte) 0xd7, (byte) 0x0e,
- (byte) 0xdc, (byte) 0xf4, (byte) 0x33, (byte) 0x7f, (byte) 0xbd,
- (byte) 0xcf, (byte) 0xd0, (byte) 0xeb, (byte) 0x6e, (byte) 0x89,
- (byte) 0xf7, (byte) 0x4f, (byte) 0x5a, (byte) 0x07, (byte) 0x7c,
- (byte) 0xa9, (byte) 0x49, (byte) 0x47, (byte) 0x68, (byte) 0x35,
- (byte) 0xa8, (byte) 0x05, (byte) 0x3d, (byte) 0xfd, (byte) 0x04,
- (byte) 0x7b, (byte) 0x17, (byte) 0x31, (byte) 0x0d, (byte) 0xc8,
- (byte) 0xa3, (byte) 0x98, (byte) 0x34, (byte) 0xa0, (byte) 0x50,
- (byte) 0x44, (byte) 0x00, (byte) 0xf1, (byte) 0x0c, (byte) 0xe6,
- (byte) 0xe5, (byte) 0xc4, (byte) 0x41, (byte) 0x3d, (byte) 0xf8,
- (byte) 0x3d, (byte) 0x4e, (byte) 0x0b, (byte) 0x1c, (byte) 0xdb,
- (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0x82, (byte) 0x9b,
- (byte) 0x8a, (byte) 0xfd, (byte) 0xa1, (byte) 0x98, (byte) 0x41,
- (byte) 0x68, (byte) 0xc2, (byte) 0xd1, (byte) 0xdf, (byte) 0x4e,
- (byte) 0xf3, (byte) 0x2e, (byte) 0x26, (byte) 0x53, (byte) 0x5b,
- (byte) 0x31, (byte) 0xb1, (byte) 0x7a, (byte) 0xcc, (byte) 0x5e,
- (byte) 0xbb, (byte) 0x09, (byte) 0xa2, (byte) 0xe2, (byte) 0x6f,
- (byte) 0x4a, (byte) 0x04, (byte) 0x0d, (byte) 0xef, (byte) 0x90,
- (byte) 0x15, (byte) 0xbe, (byte) 0x10, (byte) 0x4a, (byte) 0xac,
- (byte) 0x92, (byte) 0xeb, (byte) 0xda, (byte) 0x72, (byte) 0xdb,
- (byte) 0x43, (byte) 0x08, (byte) 0xb7, (byte) 0x2b, (byte) 0x4c,
- (byte) 0xe1, (byte) 0xbb, (byte) 0x58, (byte) 0xcb, (byte) 0x71,
- (byte) 0x80, (byte) 0xad, (byte) 0xbc, (byte) 0xdc, (byte) 0x62,
- (byte) 0x5e, (byte) 0x3e, (byte) 0xcb, (byte) 0x92, (byte) 0xda,
- (byte) 0xf6, (byte) 0xdf, (byte) 0x02, (byte) 0x40, (byte) 0x4d,
- (byte) 0x81, (byte) 0x90, (byte) 0xc5, (byte) 0x77, (byte) 0x30,
- (byte) 0xb7, (byte) 0x29, (byte) 0x00, (byte) 0xa8, (byte) 0xf1,
- (byte) 0xb4, (byte) 0xae, (byte) 0x52, (byte) 0x63, (byte) 0x00,
- (byte) 0xb2, (byte) 0x2d, (byte) 0x3e, (byte) 0x7d, (byte) 0xd6,
- (byte) 0x4d, (byte) 0xf9, (byte) 0x8a, (byte) 0xc1, (byte) 0xb1,
- (byte) 0x98, (byte) 0x89, (byte) 0x52, (byte) 0x40, (byte) 0x14,
- (byte) 0x1b, (byte) 0x0e, (byte) 0x61, (byte) 0x8f, (byte) 0xf4,
- (byte) 0xbe, (byte) 0x59, (byte) 0x79, (byte) 0x79, (byte) 0x95,
- (byte) 0x19, (byte) 0x5c, (byte) 0x51, (byte) 0x08, (byte) 0x66,
- (byte) 0xc1, (byte) 0x42, (byte) 0x30, (byte) 0xb3, (byte) 0x7a,
- (byte) 0x86, (byte) 0x9f, (byte) 0x3e, (byte) 0xf5, (byte) 0x19,
- (byte) 0xa3, (byte) 0xae, (byte) 0x64, (byte) 0x69, (byte) 0x14,
- (byte) 0x07, (byte) 0x50, (byte) 0x97, };
-
- // valid PrivateKeyInfo encoding (Damaged)
- private static final byte[] privateKeyInfoDamaged = { (byte) 0x30,
- (byte) 0x82, (byte) 0x02, (byte) 0x77, (byte) 0x02, (byte) 0x01,
- (byte) 0x00, (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09,
- (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7,
- (byte) 0x0d, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x05,
- (byte) 0x00, (byte) 0x04, // private key octet str
- (byte) 0x82, (byte) 0x02, (byte) 0x62, // Damage: l=460->461
- // (0x61->0x62)
- (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0x5d, (byte) 0x02,
- (byte) 0x01, (byte) 0x00, (byte) 0x02, (byte) 0x81, (byte) 0x81,
- (byte) 0x00, (byte) 0xb2, (byte) 0x4a, (byte) 0x9b, (byte) 0x5b,
- (byte) 0xba, (byte) 0x01, (byte) 0xc0, (byte) 0xcd, (byte) 0x65,
- (byte) 0x09, (byte) 0x63, (byte) 0x70, (byte) 0x0b, (byte) 0x5a,
- (byte) 0x1b, (byte) 0x92, (byte) 0x08, (byte) 0xf8, (byte) 0x55,
- (byte) 0x5e, (byte) 0x7c, (byte) 0x1b, (byte) 0x50, (byte) 0x17,
- (byte) 0xec, (byte) 0x44, (byte) 0x4c, (byte) 0x58, (byte) 0x42,
- (byte) 0x2b, (byte) 0x41, (byte) 0x09, (byte) 0x59, (byte) 0xf2,
- (byte) 0xe1, (byte) 0x5d, (byte) 0x43, (byte) 0x71, (byte) 0x4d,
- (byte) 0x92, (byte) 0x03, (byte) 0x1d, (byte) 0xb6, (byte) 0x6c,
- (byte) 0x7f, (byte) 0x5d, (byte) 0x48, (byte) 0xcd, (byte) 0x17,
- (byte) 0xec, (byte) 0xd7, (byte) 0x4c, (byte) 0x39, (byte) 0xb1,
- (byte) 0x7b, (byte) 0xe2, (byte) 0xbf, (byte) 0x96, (byte) 0x77,
- (byte) 0xbe, (byte) 0xd0, (byte) 0xa0, (byte) 0xf0, (byte) 0x2d,
- (byte) 0x6b, (byte) 0x24, (byte) 0xaa, (byte) 0x14, (byte) 0xba,
- (byte) 0x82, (byte) 0x79, (byte) 0x10, (byte) 0x9b, (byte) 0x16,
- (byte) 0x68, (byte) 0x47, (byte) 0x81, (byte) 0x54, (byte) 0xa2,
- (byte) 0xfa, (byte) 0x91, (byte) 0x9e, (byte) 0x0a, (byte) 0x2a,
- (byte) 0x53, (byte) 0xa6, (byte) 0xe7, (byte) 0x9e, (byte) 0x7d,
- (byte) 0x29, (byte) 0x33, (byte) 0xd8, (byte) 0x05, (byte) 0xfc,
- (byte) 0x02, (byte) 0x3f, (byte) 0xbd, (byte) 0xc7, (byte) 0x6e,
- (byte) 0xed, (byte) 0xaa, (byte) 0x30, (byte) 0x6c, (byte) 0x5f,
- (byte) 0x52, (byte) 0xed, (byte) 0x35, (byte) 0x65, (byte) 0x4b,
- (byte) 0x0e, (byte) 0xc8, (byte) 0xa7, (byte) 0x12, (byte) 0x10,
- (byte) 0x56, (byte) 0x37, (byte) 0xaf, (byte) 0x11, (byte) 0xfa,
- (byte) 0x21, (byte) 0x0e, (byte) 0x99, (byte) 0xff, (byte) 0xfa,
- (byte) 0x8c, (byte) 0x65, (byte) 0x8e, (byte) 0x6d, (byte) 0x02,
- (byte) 0x03, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02,
- (byte) 0x81, (byte) 0x80, (byte) 0x78, (byte) 0x41, (byte) 0x72,
- (byte) 0x40, (byte) 0x90, (byte) 0x59, (byte) 0x96, (byte) 0x5d,
- (byte) 0xf3, (byte) 0x84, (byte) 0x3d, (byte) 0x99, (byte) 0xd9,
- (byte) 0x4e, (byte) 0x51, (byte) 0xc2, (byte) 0x52, (byte) 0x62,
- (byte) 0x8d, (byte) 0xd2, (byte) 0x49, (byte) 0x0b, (byte) 0x73,
- (byte) 0x1e, (byte) 0x6f, (byte) 0xb2, (byte) 0x31, (byte) 0x7c,
- (byte) 0x66, (byte) 0x45, (byte) 0x1e, (byte) 0x7c, (byte) 0xdc,
- (byte) 0x3a, (byte) 0xc2, (byte) 0x5f, (byte) 0x51, (byte) 0x9a,
- (byte) 0x1e, (byte) 0xa4, (byte) 0x19, (byte) 0x8d, (byte) 0xf4,
- (byte) 0xf9, (byte) 0x81, (byte) 0x7e, (byte) 0xbe, (byte) 0x17,
- (byte) 0xf7, (byte) 0xc7, (byte) 0x3c, (byte) 0x00, (byte) 0xa1,
- (byte) 0xf9, (byte) 0x60, (byte) 0x82, (byte) 0x34, (byte) 0x8f,
- (byte) 0x9c, (byte) 0xfd, (byte) 0x0b, (byte) 0x63, (byte) 0x42,
- (byte) 0x1b, (byte) 0x7f, (byte) 0x45, (byte) 0xf1, (byte) 0x31,
- (byte) 0xc3, (byte) 0x63, (byte) 0x47, (byte) 0x5c, (byte) 0xc1,
- (byte) 0xb2, (byte) 0x5f, (byte) 0x57, (byte) 0xee, (byte) 0x02,
- (byte) 0x9f, (byte) 0x5e, (byte) 0x08, (byte) 0x48, (byte) 0xba,
- (byte) 0x74, (byte) 0xba, (byte) 0x81, (byte) 0xb7, (byte) 0x30,
- (byte) 0xac, (byte) 0x4c, (byte) 0x01, (byte) 0x35, (byte) 0xce,
- (byte) 0x46, (byte) 0x47, (byte) 0x8c, (byte) 0xe4, (byte) 0x62,
- (byte) 0x36, (byte) 0x1a, (byte) 0x65, (byte) 0x0e, (byte) 0x33,
- (byte) 0x56, (byte) 0xf9, (byte) 0xb7, (byte) 0xa0, (byte) 0xc4,
- (byte) 0xb6, (byte) 0x82, (byte) 0x55, (byte) 0x7d, (byte) 0x36,
- (byte) 0x55, (byte) 0xc0, (byte) 0x52, (byte) 0x5e, (byte) 0x35,
- (byte) 0x54, (byte) 0xbd, (byte) 0x97, (byte) 0x01, (byte) 0x00,
- (byte) 0xbf, (byte) 0x10, (byte) 0xdc, (byte) 0x1b, (byte) 0x51,
- (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xe7, (byte) 0x68,
- (byte) 0x03, (byte) 0x3e, (byte) 0x21, (byte) 0x64, (byte) 0x68,
- (byte) 0x24, (byte) 0x7b, (byte) 0xd0, (byte) 0x31, (byte) 0xa0,
- (byte) 0xa2, (byte) 0xd9, (byte) 0x87, (byte) 0x6d, (byte) 0x79,
- (byte) 0x81, (byte) 0x8f, (byte) 0x8f, (byte) 0x2d, (byte) 0x7a,
- (byte) 0x95, (byte) 0x2e, (byte) 0x55, (byte) 0x9f, (byte) 0xd7,
- (byte) 0x86, (byte) 0x29, (byte) 0x93, (byte) 0xbd, (byte) 0x04,
- (byte) 0x7e, (byte) 0x4f, (byte) 0xdb, (byte) 0x56, (byte) 0xf1,
- (byte) 0x75, (byte) 0xd0, (byte) 0x4b, (byte) 0x00, (byte) 0x3a,
- (byte) 0xe0, (byte) 0x26, (byte) 0xf6, (byte) 0xab, (byte) 0x9e,
- (byte) 0x0b, (byte) 0x2a, (byte) 0xf4, (byte) 0xa8, (byte) 0xd7,
- (byte) 0xff, (byte) 0xbe, (byte) 0x01, (byte) 0xeb, (byte) 0x9b,
- (byte) 0x81, (byte) 0xc7, (byte) 0x5f, (byte) 0x02, (byte) 0x73,
- (byte) 0xe1, (byte) 0x2b, (byte) 0x02, (byte) 0x41, (byte) 0x00,
- (byte) 0xc5, (byte) 0x3d, (byte) 0x78, (byte) 0xab, (byte) 0xe6,
- (byte) 0xab, (byte) 0x3e, (byte) 0x29, (byte) 0xfd, // 88
- (byte) 0x98, (byte) 0xd0, (byte) 0xa4, (byte) 0x3e, (byte) 0x58,
- (byte) 0xee, (byte) 0x48, (byte) 0x45, (byte) 0xa3, (byte) 0x66,
- (byte) 0xac, (byte) 0xe9, (byte) 0x4d, (byte) 0xbd, (byte) 0x60,
- (byte) 0xea, (byte) 0x24, (byte) 0xff, (byte) 0xed, (byte) 0x0c,
- (byte) 0x67, (byte) 0xc5, (byte) 0xfd, (byte) 0x36, (byte) 0x28,
- (byte) 0xea, (byte) 0x74, (byte) 0x88, (byte) 0xd1, (byte) 0xd1,
- (byte) 0xad, (byte) 0x58, (byte) 0xd7, (byte) 0xf0, (byte) 0x67,
- (byte) 0x20, (byte) 0xc1, (byte) 0xe3, (byte) 0xb3, (byte) 0xdb,
- (byte) 0x52, (byte) 0xad, (byte) 0xf3, (byte) 0xc4, (byte) 0x21,
- (byte) 0xd8, (byte) 0x8c, (byte) 0x4c, (byte) 0x41, (byte) 0x27,
- (byte) 0xdb, (byte) 0xd0, (byte) 0x35, (byte) 0x92, (byte) 0xc7,
- (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xe0, (byte) 0x99,
- (byte) 0x42, (byte) 0xb4, (byte) 0x76, (byte) 0x02, (byte) 0x97,
- (byte) 0x55, (byte) 0xf9, (byte) 0xda, (byte) 0x3b, (byte) 0xa0,
- (byte) 0xd7, (byte) 0x0e, (byte) 0xdc, (byte) 0xf4, (byte) 0x33,
- (byte) 0x7f, (byte) 0xbd, (byte) 0xcf, (byte) 0xd0, (byte) 0xeb,
- (byte) 0x6e, (byte) 0x89, (byte) 0xf7, (byte) 0x4f, (byte) 0x5a,
- (byte) 0x07, (byte) 0x7c, (byte) 0xa9, (byte) 0x49, (byte) 0x47,
- (byte) 0x68, (byte) 0x35, (byte) 0xa8, (byte) 0x05, (byte) 0x3d,
- (byte) 0xfd, (byte) 0x04, (byte) 0x7b, (byte) 0x17, (byte) 0x31,
- (byte) 0x0d, (byte) 0xc8, (byte) 0xa3, (byte) 0x98, (byte) 0x34,
- (byte) 0xa0, (byte) 0x50, (byte) 0x44, (byte) 0x00, (byte) 0xf1,
- (byte) 0x0c, (byte) 0xe6, (byte) 0xe5, (byte) 0xc4, (byte) 0x41,
- (byte) 0x3d, (byte) 0xf8, (byte) 0x3d, (byte) 0x4e, (byte) 0x0b, // 118
- (byte) 0x1c, (byte) 0xdb, (byte) 0x02, (byte) 0x41, (byte) 0x00,
- (byte) 0x82, (byte) 0x9b, (byte) 0x8a, (byte) 0xfd, (byte) 0xa1,
- (byte) 0x98, (byte) 0x41, (byte) 0x68, (byte) 0xc2, (byte) 0xd1,
- (byte) 0xdf, (byte) 0x4e, (byte) 0xf3, (byte) 0x2e, (byte) 0x26,
- (byte) 0x53, (byte) 0x5b, (byte) 0x31, (byte) 0xb1, (byte) 0x7a,
- (byte) 0xcc, (byte) 0x5e, (byte) 0xbb, (byte) 0x09, (byte) 0xa2,
- (byte) 0xe2, (byte) 0x6f, (byte) 0x4a, (byte) 0x04, (byte) 0x0d,
- (byte) 0xef, (byte) 0x90, (byte) 0x15, (byte) 0xbe, (byte) 0x10,
- (byte) 0x4a, (byte) 0xac, (byte) 0x92, (byte) 0xeb, (byte) 0xda,
- (byte) 0x72, (byte) 0xdb, (byte) 0x43, (byte) 0x08, (byte) 0xb7,
- (byte) 0x2b, (byte) 0x4c, (byte) 0xe1, (byte) 0xbb, (byte) 0x58,
- (byte) 0xcb, (byte) 0x71, (byte) 0x80, (byte) 0xad, (byte) 0xbc,
- (byte) 0xdc, (byte) 0x62, (byte) 0x5e, (byte) 0x3e, (byte) 0xcb,
- (byte) 0x92, (byte) 0xda, (byte) 0xf6, (byte) 0xdf, (byte) 0x02,
- (byte) 0x40, (byte) 0x4d, (byte) 0x81, (byte) 0x90, (byte) 0xc5,
- (byte) 0x77, (byte) 0x30, (byte) 0xb7, (byte) 0x29, (byte) 0x00,
- (byte) 0xa8, (byte) 0xf1, (byte) 0xb4, (byte) 0xae, (byte) 0x52,
- (byte) 0x63, (byte) 0x00, (byte) 0xb2, // 140
- (byte) 0x2d, (byte) 0x3e, (byte) 0x7d, (byte) 0xd6, (byte) 0x4d,
- (byte) 0xf9, (byte) 0x8a, (byte) 0xc1, (byte) 0xb1, (byte) 0x98,
- (byte) 0x89, (byte) 0x52, (byte) 0x40, (byte) 0x14, (byte) 0x1b,
- (byte) 0x0e, (byte) 0x61, (byte) 0x8f, (byte) 0xf4, (byte) 0xbe,
- (byte) 0x59, (byte) 0x79, (byte) 0x79, (byte) 0x95, (byte) 0x19,
- (byte) 0x5c, (byte) 0x51, (byte) 0x08, (byte) 0x66, (byte) 0xc1,
- (byte) 0x42, (byte) 0x30, (byte) 0xb3, (byte) 0x7a, (byte) 0x86,
- (byte) 0x9f, (byte) 0x3e, (byte) 0xf5, (byte) 0x19, (byte) 0xa3, // 150
- (byte) 0xae, (byte) 0x64, (byte) 0x69, (byte) 0x14, (byte) 0x07,
- (byte) 0x50, (byte) 0x97, };
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismExceptionTest.java
deleted file mode 100644
index a4f0a79..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismExceptionTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import javax.crypto.ExemptionMechanismException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>ExemptionMechanismException</code> class constructors and
- * methods.
- */
-public class ExemptionMechanismExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for ExemptionMechanismExceptionTests.
- *
- * @param arg0
- */
- public ExemptionMechanismExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- static String createErr(Exception tE, Exception eE) {
- return "ExemptionMechanismException: ".concat(tE.toString()).concat(
- " is not equal to caught exception: ").concat(eE.toString());
- }
-
- /**
- * Test for <code>ExemptionMechanismException()</code> constructor
- * Assertion: constructs ExemptionMechanismException with no detail message
- */
- public void testExemptionMechanismException01() {
- ExemptionMechanismException tE = new ExemptionMechanismException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- try {
- throw tE;
- } catch (Exception e) {
- assertTrue(createErr(tE, e), tE.equals(e));
- }
- }
-
- /**
- * Test for <code>ExemptionMechanismException(String)</code> constructor
- * Assertion: constructs ExemptionMechanismException with detail message
- * msg. Parameter <code>msg</code> is not null.
- */
- public void testExemptionMechanismException02() {
- ExemptionMechanismException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new ExemptionMechanismException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- try {
- throw tE;
- } catch (Exception e) {
- assertTrue(createErr(tE, e), tE.equals(e));
- }
- }
- }
-
- /**
- * Test for <code>ExemptionMechanismException(String)</code> constructor
- * Assertion: constructs ExemptionMechanismException when <code>msg</code>
- * is null
- */
- public void testExemptionMechanismException03() {
- String msg = null;
- ExemptionMechanismException tE = new ExemptionMechanismException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- try {
- throw tE;
- } catch (Exception e) {
- assertTrue(createErr(tE, e), tE.equals(e));
- }
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismTest.java
deleted file mode 100644
index a78c1bf..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-
-import javax.crypto.ExemptionMechanism;
-import javax.crypto.ExemptionMechanismSpi;
-
-import org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi;
-import org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi.tmpKey;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ExemptionMechanism</code> class constructors and methods
- */
-
-public class ExemptionMechanismTest extends TestCase {
-
- private static final String srvExemptionMechanism = "ExemptionMechanism";
-
- private static final String defaultAlg = "EMech";
-
- private static final String ExemptionMechanismProviderClass = "org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi";
-
- /**
- * Test for <code>ExemptionMechanism</code> constructor
- * Assertion: creates new object using provider and mechanism name
- */
- public void testExemptionMechanism() throws Exception {
- Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider",
- "Provider for ExemptionMechanism testing",
- srvExemptionMechanism.concat(".").concat(defaultAlg),
- ExemptionMechanismProviderClass);
-
- ExemptionMechanismSpi spi = new MyExemptionMechanismSpi();
-
- ExemptionMechanism em = new ExemptionMechanism(spi, mProv, defaultAlg) {
- };
- assertEquals("Incorrect provider", em.getProvider(), mProv);
- assertEquals("Incorrect algorithm", em.getName(), defaultAlg);
- try {
- em.init(null);
- fail("InvalidKeyException must be thrown");
- } catch (InvalidKeyException e) {
- }
-
- try {
- em.getOutputSize(100);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
-
-
- em = new ExemptionMechanism(null, null, null) {
- };
- assertNull("Incorrect mechanism", em.getName());
- assertNull("Incorrect provider", em.getProvider());
- try {
- em.init(null);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- try {
- em.getOutputSize(100);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- }
-
- /**
- * @tests javax/crypto/ExemptionMechanism#getInstance(String algorithm, String provider)
- * Checks exception order
- */
- public void testGetInstance() throws Exception {
- //Regression for HARMONY-762
- try {
- ExemptionMechanism.getInstance((String) null, "aaa");
- fail("NoSuchProviderException must be thrown");
- } catch (NoSuchProviderException pe) {
- //expected
- }
- }
-
- /**
- * Test for <code>isCryptoAllowed(Key key)</code> method
- */
- public void testIsCryptoAllowed() throws Exception {
-
- //Regression for HARMONY-1029
- Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider",
- "Provider for ExemptionMechanism testing",
- srvExemptionMechanism.concat(".").concat(defaultAlg),
- ExemptionMechanismProviderClass);
-
- ExemptionMechanism em = new ExemptionMechanism(
- new MyExemptionMechanismSpi(), mProv, defaultAlg) {
- };
-
- Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]);
-
- assertFalse(em.isCryptoAllowed(key));
-
- em.init(key);
- assertFalse(em.isCryptoAllowed(key));
-
- em.genExemptionBlob();
- assertTrue(em.isCryptoAllowed(key));
-
- Key key1 = new MyExemptionMechanismSpi().new tmpKey("Proba",
- new byte[] { 1 });
- assertFalse(em.isCryptoAllowed(key1));
-
- em.init(key1);
- assertFalse(em.isCryptoAllowed(key));
- }
-
- /**
- * Test for <code>genExemptionBlob((byte[] output, int outputOffset)</code> method
- */
- public void testGenExemptionBlob() throws Exception {
-
- //Regression for HARMONY-1029
- Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider",
- "Provider for ExemptionMechanism testing",
- srvExemptionMechanism.concat(".").concat(defaultAlg),
- ExemptionMechanismProviderClass);
-
- ExemptionMechanism em = new ExemptionMechanism(
- new MyExemptionMechanismSpi(), mProv, defaultAlg) {
- };
-
- Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]);
-
- em.init(key);
- // ExemptionMechanism doesn't check parameters
- // it is a responsibility of ExemptionMechanismSpi
- em.genExemptionBlob(null, 0);
- em.genExemptionBlob(new byte[0], 0);
- em.genExemptionBlob(new byte[10], -5);
-
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/IllegalBlockSizeExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/IllegalBlockSizeExceptionTest.java
deleted file mode 100644
index 34988cf..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/IllegalBlockSizeExceptionTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import javax.crypto.IllegalBlockSizeException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>IllegalBlockSizeException</code> class constructors and
- * methods.
- */
-public class IllegalBlockSizeExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for IllegalBlockSizeExceptionTests.
- *
- * @param arg0
- */
- public IllegalBlockSizeExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>IllegalBlockSizeException()</code> constructor
- * Assertion: constructs IllegalBlockSizeException with no detail message
- */
- public void testIllegalBlockSizeException01() {
- IllegalBlockSizeException tE = new IllegalBlockSizeException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>IllegalBlockSizeException(String)</code> constructor
- * Assertion: constructs IllegalBlockSizeException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testIllegalBlockSizeException02() {
- IllegalBlockSizeException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new IllegalBlockSizeException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>IllegalBlockSizeException(String)</code> constructor
- * Assertion: constructs IllegalBlockSizeException when <code>msg</code>
- * is null
- */
- public void testIllegalBlockSizeException03() {
- String msg = null;
- IllegalBlockSizeException tE = new IllegalBlockSizeException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementTest.java
deleted file mode 100644
index aceb585..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementTest.java
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.math.BigInteger;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.PublicKey;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.DSAParameterSpec;
-
-import javax.crypto.KeyAgreement;
-import javax.crypto.KeyAgreementSpi;
-import javax.crypto.interfaces.DHPrivateKey;
-import javax.crypto.spec.DHParameterSpec;
-
-import org.apache.harmony.crypto.tests.support.MyKeyAgreementSpi;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.TestKeyPair;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for KeyAgreement constructor and methods
- */
-
-public class KeyAgreementTest extends TestCase {
-
- public static final String srvKeyAgreement = "KeyAgreement";
-
- private static String defaultAlgorithm = "DH";
-
- private static String defaultProviderName = null;
-
- private static Provider defaultProvider = null;
-
- private static boolean DEFSupported = false;
-
- private static final String NotSupportMsg = "There is no suitable provider for KeyAgreement";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static String[] validValues = { "DH", "dH",
- "Dh", "dh" };
-
- private static PrivateKey privKey = null;
-
- private static PublicKey publKey = null;
-
- private static boolean initKeys = false;
-
- static {
- defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm,
- srvKeyAgreement);
- DEFSupported = (defaultProvider != null);
- defaultProviderName = (DEFSupported ? defaultProvider.getName() : null);
- }
-
- private void createKeys() throws Exception {
- if (!initKeys) {
- TestKeyPair tkp = new TestKeyPair(defaultAlgorithm);
- privKey = tkp.getPrivate();
- publKey = tkp.getPublic();
- initKeys = true;
- }
-
- }
-
- private KeyAgreement[] createKAs() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- }
-
- KeyAgreement[] ka = new KeyAgreement[3];
- ka[0] = KeyAgreement.getInstance(defaultAlgorithm);
- ka[1] = KeyAgreement.getInstance(defaultAlgorithm, defaultProvider);
- ka[2] = KeyAgreement.getInstance(defaultAlgorithm,
- defaultProviderName);
- return ka;
- }
-
- public static String getDefAlg() {
- return defaultAlgorithm;
- }
-
- /**
- * Test for <code> getInstance(String algorithm) </code> method Assertions:
- * throws NullPointerException when algorithm is null throws
- * NoSuchAlgorithmException when algorithm isnot available
- */
- public void testGetInstanceString01() throws NoSuchAlgorithmException {
- try {
- KeyAgreement.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyAgreement.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code> getInstance(String algorithm) </code> method Assertions:
- * returns KeyAgreement object
- */
- public void testGetInstanceString02() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyAgreement keyA;
- for (int i = 0; i < validValues.length; i++) {
- keyA = KeyAgreement.getInstance(validValues[i]);
- assertEquals("Incorrect algorithm", keyA.getAlgorithm(),
- validValues[i]);
- }
- }
-
- /**
- * Test for <code> getInstance(String algorithm, String provider)</code>
- * method Assertions: throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not available
- */
- public void testGetInstanceStringString01()
- throws NoSuchAlgorithmException, IllegalArgumentException,
- NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- try {
- KeyAgreement.getInstance(null, defaultProviderName);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyAgreement.getInstance(invalidValues[i], defaultProviderName);
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code> getInstance(String algorithm, String provider)</code>
- * method Assertions: throws IllegalArgumentException when provider is null
- * or empty throws NoSuchProviderException when provider has not be
- * configured
- */
- public void testGetInstanceStringString02()
- throws IllegalArgumentException, NoSuchAlgorithmException,
- NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- String provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyAgreement.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- try {
- KeyAgreement.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty");
- } catch (IllegalArgumentException e) {
- }
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- KeyAgreement.getInstance(validValues[i], invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(validValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- }
-
- /**
- * Test for <code> getInstance(String algorithm, String provider)</code>
- * method Assertions: returns KeyAgreement object
- */
- public void testGetInstanceStringString03()
- throws IllegalArgumentException, NoSuchAlgorithmException,
- NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyAgreement keyA;
- for (int i = 0; i < validValues.length; i++) {
- keyA = KeyAgreement
- .getInstance(validValues[i], defaultProviderName);
- assertEquals("Incorrect algorithm", keyA.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyA.getProvider().getName(),
- defaultProviderName);
- }
- }
-
- /**
- * Test for <code> getInstance(String algorithm, Provider provider)</code>
- * method Assertions: throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm isnot available
- */
- public void testGetInstanceStringProvider01()
- throws NoSuchAlgorithmException, IllegalArgumentException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- try {
- KeyAgreement.getInstance(null, defaultProvider);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyAgreement.getInstance(invalidValues[i], defaultProvider);
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code> getInstance(String algorithm, Provider provider)</code>
- * method Assertions: throws IllegalArgumentException when provider is null
- */
- public void testGetInstanceStringProvider02()
- throws NoSuchAlgorithmException, IllegalArgumentException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- Provider provider = null;
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyAgreement.getInstance(invalidValues[i], provider);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code> getInstance(String algorithm, Provider provider)</code>
- * method Assertions: returns KeyAgreement object
- */
- public void testGetInstanceStringProvider03()
- throws IllegalArgumentException, NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyAgreement keyA;
- for (int i = 0; i < validValues.length; i++) {
- keyA = KeyAgreement.getInstance(validValues[i], defaultProvider);
- assertEquals("Incorrect algorithm", keyA.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyA.getProvider(),
- defaultProvider);
- }
- }
-
- /**
- * Test for the methods: <code>init(Key key)</code>
- * <code>generateSecret()</code>
- * <code>generateSecret(byte[] sharedsecret, int offset)</code>
- * <code>generateSecret(String algorithm)</code>
- * Assertions: initializes KeyAgreement; returns sharedSecret; puts
- * sharedsecret in buffer and return numbers of bytes; returns SecretKey
- * object
- */
- public void testGenerateSecret03() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- createKeys();
- KeyAgreement[] kAgs = createKAs();
-
- byte[] bb;
- byte[] bb1 = new byte[10];
- for (int i = 0; i < kAgs.length; i++) {
- kAgs[i].init(privKey);
- kAgs[i].doPhase(publKey, true);
- bb = kAgs[i].generateSecret();
- kAgs[i].init(privKey);
- kAgs[i].doPhase(publKey, true);
- bb1 = new byte[bb.length + 10];
- kAgs[i].generateSecret(bb1, 9);
- kAgs[i].init(privKey);
- kAgs[i].doPhase(publKey, true);
- kAgs[i].generateSecret("DES");
- }
- }
-
- /**
- * Test for <code>doPhase(Key key, boolean lastPhase)</code> method
- * Assertion: throws InvalidKeyException if key is not appropriate
- */
- public void testDoPhase() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- createKeys();
- KeyAgreement[] kAgs = createKAs();
-
- for (int i = 0; i < kAgs.length; i++) {
- kAgs[i].init(privKey);
- try {
- kAgs[i].doPhase(privKey, false);
- fail("InvalidKeyException must be throw");
- } catch (InvalidKeyException e) {
- }
-
- try {
- kAgs[i].doPhase(privKey, true);
- fail("InvalidKeyException must be throw");
- } catch (InvalidKeyException e) {
- }
- }
- }
-
- /**
- * Test for the methods <code>init(Key key)</code>
- * <code>init(Key key, SecureRandom random)</code>
- * <code>init(Key key, AlgorithmParameterSpec params)</code>
- * <code>init(Key key, AlgorithmParameterSpec params, SecureRandom random)</code>
- * Assertion: throws InvalidKeyException when key is inappropriate
- */
- public void testInit01() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- createKeys();
- KeyAgreement[] kAgs = createKAs();
-
- SecureRandom random = null;
- AlgorithmParameterSpec aps = null;
- DHParameterSpec dhPs = new DHParameterSpec(new BigInteger("56"),
- new BigInteger("56"));
- for (int i = 0; i < kAgs.length; i++) {
- try {
- kAgs[i].init(publKey);
- fail("InvalidKeyException must be throw");
- } catch (InvalidKeyException e) {
- }
- try {
- kAgs[i].init(publKey, new SecureRandom());
- fail("InvalidKeyException must be throw");
- } catch (InvalidKeyException e) {
- }
- try {
- kAgs[i].init(publKey, random);
- fail("InvalidKeyException must be throw");
- } catch (InvalidKeyException e) {
- }
- try {
- kAgs[i].init(publKey, dhPs);
- fail("InvalidKeyException must be throw");
- } catch (InvalidKeyException e) {
- }
- try {
- kAgs[i].init(publKey, aps);
- fail("InvalidKeyException must be throw");
- } catch (InvalidKeyException e) {
- }
- try {
- kAgs[i].init(publKey, dhPs, new SecureRandom());
- fail("InvalidKeyException must be throw");
- } catch (InvalidKeyException e) {
- }
- }
- }
-
- /**
- * Test for the methods
- * <code>init(Key key, AlgorithmParameterSpec params)</code>
- * <code>init(Key key, AlgorithmParameterSpec params, SecureRandom random)</code>
- * Assertion: throws AlgorithmParameterException when params are
- * inappropriate
- */
- public void testInit02() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- createKeys();
- KeyAgreement[] kAgs = createKAs();
-
- SecureRandom random = null;
- DSAParameterSpec dsa = new DSAParameterSpec(new BigInteger("56"),
- new BigInteger("56"), new BigInteger("56"));
- for (int i = 0; i < kAgs.length; i++) {
- try {
- kAgs[i].init(privKey, dsa);
- fail("InvalidAlgorithmParameterException or InvalidKeyException must be throw");
- } catch (InvalidAlgorithmParameterException e) {
- } catch (InvalidKeyException e) {
- }
- try {
- kAgs[i].init(privKey, dsa, new SecureRandom());
- fail("InvalidAlgorithmParameterException or InvalidKeyException must be throw");
- } catch (InvalidAlgorithmParameterException e) {
- } catch (InvalidKeyException e) {
- }
- try {
- kAgs[i].init(privKey, dsa, random);
- fail("InvalidAlgorithmParameterException or InvalidKeyException must be throw");
- } catch (InvalidAlgorithmParameterException e) {
- } catch (InvalidKeyException e) {
- }
- }
- }
-
- /**
- * Test for the methods: <code>init(Key key)</code>
- * <code>init(Key key, SecureRandom random)</code>
- * <code>generateSecret()</code>
- * Assertions: initializes KeyAgreement and returns byte array
- */
- public void testInit03() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- createKeys();
- KeyAgreement[] kAgs = createKAs();
-
- byte[] bbRes1;
- byte[] bbRes2;
- byte[] bbRes3;
- SecureRandom randomNull = null;
- SecureRandom random = new SecureRandom();
- for (int i = 0; i < kAgs.length; i++) {
- kAgs[i].init(privKey);
- kAgs[i].doPhase(publKey, true);
- bbRes1 = kAgs[i].generateSecret();
- kAgs[i].init(privKey, random);
- kAgs[i].doPhase(publKey, true);
- bbRes2 = kAgs[i].generateSecret();
- assertEquals("Incorrect byte array length", bbRes1.length,
- bbRes2.length);
- for (int j = 0; j < bbRes1.length; j++) {
- assertEquals("Incorrect byte (index: ".concat(
- Integer.toString(i)).concat(")"), bbRes1[j], bbRes2[j]);
- }
- kAgs[i].init(privKey, randomNull);
- kAgs[i].doPhase(publKey, true);
- bbRes3 = kAgs[i].generateSecret();
- assertEquals("Incorrect byte array length", bbRes1.length,
- bbRes3.length);
- for (int j = 0; j < bbRes1.length; j++) {
- assertEquals("Incorrect byte (index: ".concat(
- Integer.toString(i)).concat(")"), bbRes1[j], bbRes3[j]);
- }
- }
- }
-
- /**
- * Test for the methods:
- * <code>init(Key key, AlgorithmParameterSpec params)</code>
- * <code>init(Key key, AlgorithmParameterSpec params, SecureRandom random)</code>
- * <code>generateSecret()</code>
- * Assertions: initializes KeyAgreement and returns byte array
- */
- public void testInit04() throws Exception,
- InvalidAlgorithmParameterException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- createKeys();
- KeyAgreement[] kAgs = createKAs();
-
- DHParameterSpec dhPs = ((DHPrivateKey) privKey).getParams();
-
- byte[] bbRes1;
- byte[] bbRes2;
- byte[] bbRes3;
- SecureRandom randomNull = null;
- SecureRandom random = new SecureRandom();
- for (int i = 0; i < kAgs.length; i++) {
- kAgs[i].init(privKey, dhPs);
- kAgs[i].doPhase(publKey, true);
- bbRes1 = kAgs[i].generateSecret();
- kAgs[i].init(privKey, dhPs, random);
- kAgs[i].doPhase(publKey, true);
- bbRes2 = kAgs[i].generateSecret();
- assertEquals("Incorrect byte array length", bbRes1.length,
- bbRes2.length);
- for (int j = 0; j < bbRes1.length; j++) {
- assertEquals("Incorrect byte (index: ".concat(
- Integer.toString(i)).concat(")"), bbRes1[j], bbRes2[j]);
- }
- kAgs[i].init(privKey, dhPs, randomNull);
- kAgs[i].doPhase(publKey, true);
- bbRes3 = kAgs[i].generateSecret();
- assertEquals("Incorrect byte array length", bbRes1.length,
- bbRes3.length);
- for (int j = 0; j < bbRes1.length; j++) {
- assertEquals("Incorrect byte (index: ".concat(
- Integer.toString(i)).concat(")"), bbRes1[j], bbRes3[j]);
- }
- }
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorTest.java
deleted file mode 100644
index cedf55b..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorTest.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-
-import javax.crypto.KeyGenerator;
-import javax.crypto.KeyGeneratorSpi;
-import javax.crypto.SecretKey;
-
-import org.apache.harmony.crypto.tests.support.MyKeyGeneratorSpi;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for KeyGenerator constructor and methods
- */
-
-public class KeyGeneratorTest extends TestCase {
-
- public static final String srvKeyGenerator = "KeyGenerator";
-
- public static final String validAlgorithmsKeyGenerator[] =
- { "DESede", "DES", "Blowfish", "AES", "HmacMD5" };
-
- private static final int[] validKeySizes = { 168, 56, 56, 256, 56 };
-
- private static int defaultKeySize = -1;
-
- private static String defaultAlgorithm = null;
-
- private static String defaultProviderName = null;
-
- private static Provider defaultProvider = null;
-
- private static boolean DEFSupported = false;
-
- private static final String NotSupportMsg = "There is no suitable provider for KeyGenerator";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static String[] validValues = new String[3];
-
- static {
- for (int i = 0; i < validAlgorithmsKeyGenerator.length; i++) {
- defaultProvider = SpiEngUtils.isSupport(validAlgorithmsKeyGenerator[i],
- srvKeyGenerator);
- DEFSupported = (defaultProvider != null);
- if (DEFSupported) {
- defaultAlgorithm = validAlgorithmsKeyGenerator[i];
- defaultKeySize = validKeySizes[i];
- defaultProviderName = defaultProvider.getName();
- validValues[0] = defaultAlgorithm;
- validValues[1] = defaultAlgorithm.toUpperCase();
- validValues[2] = defaultAlgorithm.toLowerCase();
- break;
- }
- }
- }
-
- private KeyGenerator[] createKGs() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- }
-
- KeyGenerator[] kg = new KeyGenerator[3];
- kg[0] = KeyGenerator.getInstance(defaultAlgorithm);
- kg[1] = KeyGenerator.getInstance(defaultAlgorithm, defaultProvider);
- kg[2] = KeyGenerator.getInstance(defaultAlgorithm, defaultProviderName);
- return kg;
- }
-
-
- /**
- * Test for <code>KeyGenerator</code> constructor Assertion: returns
- * KeyGenerator object
- */
- public void testKeyGenerator() throws NoSuchAlgorithmException,
- InvalidAlgorithmParameterException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyGeneratorSpi spi = new MyKeyGeneratorSpi();
- KeyGenerator keyG = new myKeyGenerator(spi, defaultProvider,
- defaultAlgorithm);
- assertEquals("Incorrect algorithm", keyG.getAlgorithm(),
- defaultAlgorithm);
- assertEquals("Incorrect provider", keyG.getProvider(), defaultProvider);
- AlgorithmParameterSpec params = null;
- int keysize = 0;
- try {
- keyG.init(params, null);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- try {
- keyG.init(keysize, null);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- keyG = new myKeyGenerator(null, null, null);
- assertNull("Algorithm must be null", keyG.getAlgorithm());
- assertNull("Provider must be null", keyG.getProvider());
-
- try {
- keyG.init(params, null);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- try {
- keyG.init(keysize, null);
- fail("NullPointerException or InvalidParameterException must be thrown");
- } catch (InvalidParameterException e) {
- } catch (NullPointerException e) {
- }
- }
-
- /*
- * Test for <code> getInstance(String algorithm) </code> method Assertions:
- * throws NullPointerException when algorithm is null throws
- * NoSuchAlgorithmException when algorithm isnot available
- */
- public void testGetInstanceString01() throws NoSuchAlgorithmException {
- try {
- KeyGenerator.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyGenerator.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException should be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /*
- * Test for <code> getInstance(String algorithm) </code> method
- * Assertions: returns KeyGenerator object
- */
- public void testGetInstanceString02() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyGenerator keyG;
- for (int i = 0; i < validValues.length; i++) {
- keyG = KeyGenerator.getInstance(validValues[i]);
- assertEquals("Incorrect algorithm", keyG.getAlgorithm(), validValues[i]);
- }
- }
-
- /*
- * Test for <code> getInstance(String algorithm, String provider)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm isnot available
- */
- public void testGetInstanceStringString01() throws
- NoSuchAlgorithmException, IllegalArgumentException,
- NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- try {
- KeyGenerator.getInstance(null, defaultProviderName);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyGenerator.getInstance(invalidValues[i], defaultProviderName);
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /*
- * Test for <code> getInstance(String algorithm, String provider)</code> method
- * Assertions:
- * throws IllegalArgumentException when provider is null or empty
- * throws NoSuchProviderException when provider has not be configured
- */
- public void testGetInstanceStringString02() throws IllegalArgumentException,
- NoSuchAlgorithmException, NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- String provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyGenerator.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- try {
- KeyGenerator.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty");
- } catch (IllegalArgumentException e) {
- }
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- KeyGenerator.getInstance(validValues[i], invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(validValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- }
-
- /*
- * Test for <code> getInstance(String algorithm, String provider)</code> method
- * Assertions: returns KeyGenerator object
- */
- public void testGetInstanceStringString03() throws IllegalArgumentException,
- NoSuchAlgorithmException, NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyGenerator keyG;
- for (int i = 0; i < validValues.length; i++) {
- keyG = KeyGenerator.getInstance(validValues[i], defaultProviderName);
- assertEquals("Incorrect algorithm", keyG.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider", keyG.getProvider().getName(), defaultProviderName);
- }
- }
-
- /*
- * Test for <code> getInstance(String algorithm, Provider provider)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm isnot available
- */
- public void testGetInstanceStringProvider01() throws NoSuchAlgorithmException,
- IllegalArgumentException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- try {
- KeyGenerator.getInstance(null, defaultProvider);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyGenerator.getInstance(invalidValues[i], defaultProvider);
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /*
- * Test for <code> getInstance(String algorithm, Provider provider)</code> method
- * Assertions:
- * throws IllegalArgumentException when provider is null
- */
- public void testGetInstanceStringProvider02() throws NoSuchAlgorithmException,
- IllegalArgumentException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- Provider provider = null;
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyGenerator.getInstance(invalidValues[i], provider);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /*
- * Test for <code> getInstance(String algorithm, Provider provider)</code> method
- * Assertions: returns KeyGenerator object
- */
- public void testGetInstanceStringProvider03() throws IllegalArgumentException,
- NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyGenerator keyA;
- for (int i = 0; i < validValues.length; i++) {
- keyA = KeyGenerator.getInstance(validValues[i], defaultProvider);
- assertEquals("Incorrect algorithm", keyA.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider", keyA.getProvider(), defaultProvider);
- }
- }
-
- /*
- * Test for <code>init(int keysize)</code> and
- * <code>init(int keysize, SecureRandom random)</code> methods
- * Assertion: throws InvalidParameterException if keysize is wrong
- *
- */
- public void testInitKey() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- if (defaultAlgorithm
- .equals(validAlgorithmsKeyGenerator[validAlgorithmsKeyGenerator.length - 1])) {
- return;
- }
- int[] size = { Integer.MIN_VALUE, -1, 0, Integer.MAX_VALUE };
- KeyGenerator[] kgs = createKGs();
- SecureRandom random = new SecureRandom();
-
- for (int i = 0; i < kgs.length; i++) {
- for (int j = 0; j < size.length; j++) {
- try {
- kgs[i].init(size[j]);
- } catch (InvalidParameterException ignore) {
- }
-
- try {
- kgs[i].init(size[j], random);
- } catch (InvalidParameterException ignore) {
- }
- }
- }
- }
-
- /*
- * Test for <code>init(AlgorithmParameterSpec params)</code> and
- * <code>init(AlgorithmParameterSpec params, SecureRandom random)</code> methods
- * Assertion: throws InvalidAlgorithmParameterException when params is null
- */
- public void testInitParams() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyGenerator[] kgs = createKGs();
- AlgorithmParameterSpec aps = null;
-
- for (int i = 0; i < kgs.length; i++) {
- try {
- kgs[i].init(aps);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- try {
- kgs[i].init(aps, new SecureRandom());
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
- }
-
- /*
- * Test for <code>generateKey()</code> and
- * <code>init(SecureRandom random)</code> methods
- * <code>init(int keysize, SecureRandom random)</code> methods
- * <code>init(int keysize)</code> methods
- * <code>init(AlgorithmParameterSpec params, SecureRandom random)</code> methods
- * <code>init(AlgorithmParameterSpec params)</code> methods
- * Assertions:
- * initializes KeyGenerator;
- * returns SecretKey object
- *
- */
- public void testGenerateKey() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- SecretKey sKey;
- String dAl = defaultAlgorithm.toUpperCase();
-
- KeyGenerator[] kgs = createKGs();
-
- for (int i = 0; i < kgs.length; i++) {
- sKey = kgs[i].generateKey();
- assertEquals("Incorrect algorithm", sKey.getAlgorithm()
- .toUpperCase(), dAl);
- kgs[i].init(new SecureRandom());
- sKey = kgs[i].generateKey();
- assertEquals("Incorrect algorithm", sKey.getAlgorithm()
- .toUpperCase(), dAl);
- kgs[i].init(defaultKeySize);
- sKey = kgs[i].generateKey();
- assertEquals("Incorrect algorithm", sKey.getAlgorithm()
- .toUpperCase(), dAl);
- kgs[i].init(defaultKeySize, new SecureRandom());
- sKey = kgs[i].generateKey();
- assertEquals("Incorrect algorithm", sKey.getAlgorithm()
- .toUpperCase(), dAl);
- }
- }
-
-}
-
-/**
- * Additional class for KeyGenerator constructor verification
- */
-class myKeyGenerator extends KeyGenerator {
-
- public myKeyGenerator(KeyGeneratorSpi keyAgreeSpi, Provider provider,
- String algorithm) {
- super(keyAgreeSpi, provider, algorithm);
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java
deleted file mode 100644
index a665b64..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java
+++ /dev/null
@@ -1,813 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.nio.ByteBuffer;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-
-import javax.crypto.Mac;
-import javax.crypto.MacSpi;
-import javax.crypto.ShortBufferException;
-import javax.crypto.spec.DHGenParameterSpec;
-
-import javax.crypto.spec.SecretKeySpec;
-
-import org.apache.harmony.crypto.tests.support.MyMacSpi;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Tests for Mac class constructors and methods
- */
-
-public class MacTest extends TestCase {
-
- public static final String srvMac = "Mac";
-
- private static String defaultAlgorithm = null;
-
- private static String defaultProviderName = null;
-
- private static Provider defaultProvider = null;
-
- private static boolean DEFSupported = false;
-
- private static final String NotSupportedMsg = "There is no suitable provider for Mac";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static String[] validValues = new String[3];
-
- public static final String validAlgorithmsMac[] =
- { "HmacSHA1", "HmacMD5", "HmacSHA256", "HmacSHA384", "HmacSHA512" };
-
-
- static {
- for (int i = 0; i < validAlgorithmsMac.length; i++) {
- defaultProvider = SpiEngUtils.isSupport(validAlgorithmsMac[i],
- srvMac);
- DEFSupported = (defaultProvider != null);
- if (DEFSupported) {
- defaultAlgorithm = validAlgorithmsMac[i];
- defaultProviderName = defaultProvider.getName();
- validValues[0] = defaultAlgorithm;
- validValues[1] = defaultAlgorithm.toUpperCase();
- validValues[2] = defaultAlgorithm.toLowerCase();
- break;
- }
- }
- }
-
- private Mac[] createMacs() {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return null;
- }
- try {
- Mac m[] = new Mac[3];
- m[0] = Mac.getInstance(defaultAlgorithm);
- m[1] = Mac.getInstance(defaultAlgorithm, defaultProvider);
- m[2] = Mac.getInstance(defaultAlgorithm, defaultProviderName);
- return m;
- } catch (Exception e) {
- return null;
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not available
- */
- public void testMac01() {
- try {
- Mac.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- Mac.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown when algorithm is not available: "
- .concat(invalidValues[i]));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion: returns Mac object
- */
- public void testMac02() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac mac;
- for (int i = 0; i < validValues.length; i++) {
- mac = Mac.getInstance(validValues[i]);
- assertEquals("Incorrect algorithm", mac.getAlgorithm(), validValues[i]);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
- * throws IllegalArgumentException when provider is null or empty
- * throws NoSuchProviderException when provider is not available
- */
- public void testMac03() throws NoSuchAlgorithmException, NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- String provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- Mac.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- try {
- Mac.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty");
- } catch (IllegalArgumentException e) {
- }
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- Mac.getInstance(validValues[i], invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(validValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not available
- */
- public void testMac04() throws NoSuchAlgorithmException,
- IllegalArgumentException, NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- try {
- Mac.getInstance(null, defaultProviderName);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- Mac.getInstance(invalidValues[i], defaultProviderName);
- fail("NoSuchAlgorithmException must be throws when algorithm is not available: "
- .concat(invalidValues[i]));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion: returns Mac object
- */
- public void testMac05() throws NoSuchAlgorithmException, NoSuchProviderException,
- IllegalArgumentException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac mac;
- for (int i = 0; i < validValues.length; i++) {
- mac = Mac.getInstance(validValues[i], defaultProviderName);
- assertEquals("Incorrect algorithm", mac.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider", mac.getProvider().getName(),
- defaultProviderName);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code> method
- * Assertion: throws IllegalArgumentException when provider is null
- */
- public void testMac06() throws NoSuchAlgorithmException, NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Provider provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- Mac.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not available
- */
- public void testMac07() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- try {
- Mac.getInstance(null, defaultProvider);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- Mac.getInstance(invalidValues[i], defaultProvider);
- fail("NoSuchAlgorithmException must be thrown when algorithm is not available: "
- .concat(invalidValues[i]));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code> method
- * Assertion: returns Mac object
- */
- public void testMac08() throws NoSuchAlgorithmException, NoSuchProviderException,
- IllegalArgumentException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac mac;
- for (int i = 0; i < validValues.length; i++) {
- mac = Mac.getInstance(validValues[i], defaultProvider);
- assertEquals("Incorrect algorithm", mac.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider", mac.getProvider(), defaultProvider);
- }
- }
-
- /**
- * Test for <code>update</code> and <code>doFinal</code> methods
- * Assertion: throws IllegalStateException when Mac is not initialized
- */
- public void testMac09() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException, ShortBufferException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- byte[] buf = new byte[10];
- ByteBuffer bBuf = ByteBuffer.wrap(buf, 0, 10);
- for (int i = 0; i < macs.length; i++) {
- try {
- macs[i].update((byte) 0);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- try {
- macs[i].update(buf);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- try {
- macs[i].update(buf, 0, 3);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- try {
- macs[i].update(bBuf);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- try {
- macs[i].doFinal();
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- try {
- macs[i].doFinal(new byte[10]);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- try {
- macs[i].doFinal(new byte[10], 0);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- }
- }
-
- /**
- * Test for <code>doFinal(byte[] output, int outOffset)</code> method
- * Assertion:
- * throws ShotBufferException when outOffset is negative or
- * outOffset >= output.length or when given buffer is small
- */
- public void testMac10() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- IllegalStateException, InvalidKeyException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- byte[] b = { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 };
- byte[] byteA = new byte[b.length];
- SecretKeySpec sks = new SecretKeySpec(b, "SHA1");
- for (int i = 0; i < macs.length; i++) {
- macs[i].init(sks);
- try {
- macs[i].doFinal(null, 10);
- fail("ShortBufferException must be thrown");
- } catch (ShortBufferException e) {
- }
- try {
- macs[i].doFinal(byteA, -4);
- fail("ShortBufferException must be thrown");
- } catch (ShortBufferException e) {
- }
- try {
- macs[i].doFinal(byteA, 10);
- fail("ShortBufferException must be thrown");
- } catch (ShortBufferException e) {
- }
- try {
- macs[i].doFinal(new byte[1], 0);
- fail("ShortBufferException must be thrown");
- } catch (ShortBufferException e) {
- }
- byte[] res = macs[i].doFinal();
- try {
- macs[i].doFinal(new byte[res.length - 1], 0);
- fail("ShortBufferException must be thrown");
- } catch (ShortBufferException e) {
- }
- }
- }
-
- /**
- * Test for <code>doFinal(byte[] output, int outOffset)</code> and
- * <code>doFinal()</code> methods Assertion: Mac result is stored in
- * output buffer
- */
- public void testMac11() throws NoSuchAlgorithmException, NoSuchProviderException,
- IllegalArgumentException, IllegalStateException,
- InvalidKeyException, ShortBufferException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- byte[] b = { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 };
- SecretKeySpec scs = new SecretKeySpec(b, "SHA1");
- for (int i = 0; i < macs.length; i++) {
- macs[i].init(scs);
- byte[] res1 = macs[i].doFinal();
- byte[] res2 = new byte[res1.length + 10];
- macs[i].doFinal(res2, 0);
- for (int j = 0; j < res1.length; j++) {
- assertEquals("Not equals byte number: "
- .concat(Integer.toString(j)), res1[j], res2[j]);
- }
- }
- }
-
- /**
- * Test for <code>doFinal(byte[] input)</code> method
- * Assertion: update Mac and returns result
- */
- public void testMac12() throws NoSuchAlgorithmException, NoSuchProviderException,
- IllegalArgumentException, IllegalStateException,
- InvalidKeyException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- byte[] b = { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 };
- byte[] upd = { (byte) 5, (byte) 4, (byte) 3, (byte) 2, (byte) 1, (byte) 0 };
- SecretKeySpec scs = new SecretKeySpec(b, "SHA1");
- for (int i = 0; i < macs.length; i++) {
- macs[i].init(scs);
- byte[] res1 = macs[i].doFinal();
- byte[] res2 = macs[i].doFinal();
- assertEquals("Results are not the same", res1.length, res2.length);
- for (int t = 0; t < res1.length; t++) {
- assertEquals("Results are not the same", res1[t], res2[t]);
- }
- res2 = macs[i].doFinal(upd);
- macs[i].update(upd);
- res1 = macs[i].doFinal();
- assertEquals("Results are not the same", res1.length, res2.length);
- for (int t = 0; t < res1.length; t++) {
- assertEquals("Results are not the same", res1[t], res2[t]);
- }
- }
- }
-
- /**
- * Test for <code>update(byte[] input, int outset, int len)</code> method
- * Assertion: throws IllegalArgumentException when offset or len is negative,
- * offset + len >= input.length
- */
- public void testMac13() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException, IllegalStateException,
- InvalidKeyException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- byte[] b = { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 };
- SecretKeySpec scs = new SecretKeySpec(b, "SHA1");
- for (int i = 0; i < macs.length; i++) {
- macs[i].init(scs);
- try {
- macs[i].update(b, -10, b.length);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- try {
- macs[i].update(b, 0, -10);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- try {
- macs[i].update(b, 0, b.length + 1);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- try {
- macs[i].update(b, b.length - 1, 2);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>update(byte[] input, int outset, int len)</code> and
- * <code>update(byte[] input</code>
- * methods
- * Assertion: updates Mac
- */
- public void testMac14() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException, IllegalStateException,
- InvalidKeyException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- byte[] b = { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 };
- byte[] upd1 = { (byte) 0, (byte) 1, (byte) 5, (byte) 4, (byte) 3, (byte) 2 };
- byte[] upd2 = { (byte) 5, (byte) 4, (byte) 3, (byte) 2 };
- byte[] res1;
- byte[] res2;
- SecretKeySpec scs = new SecretKeySpec(b, "SHA1");
- for (int i = 0; i < macs.length; i++) {
- macs[i].init(scs);
- macs[i].update(upd1, 2, 4);
- res1 = macs[i].doFinal();
- macs[i].init(scs);
- macs[i].update(upd2);
- res2 = macs[i].doFinal();
- assertEquals("Results are not the same", res1.length, res2.length);
- for (int t = 0; t < res1.length; t++) {
- assertEquals("Results are not the same", res1[t], res2[t]);
- }
- macs[i].init(scs);
- macs[i].update((byte) 5);
- res1 = macs[i].doFinal();
- macs[i].init(scs);
- macs[i].update(upd1, 2, 1);
- res2 = macs[i].doFinal();
- assertEquals("Results are not the same", res1.length, res2.length);
- for (int t = 0; t < res1.length; t++) {
- assertEquals("Results are not the same", res1[t], res2[t]);
- }
- }
- }
-
- /**
- * Test for <code>clone()</code> method
- * Assertion: returns Mac object or throws CloneNotSupportedException
- */
- public void testMacClone() throws NoSuchAlgorithmException, CloneNotSupportedException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- for (int i = 0; i < macs.length; i++) {
- try {
- Mac mac1 = (Mac) macs[i].clone();
- assertEquals(mac1.getAlgorithm(), macs[i].getAlgorithm());
- assertEquals(mac1.getProvider(), macs[i].getProvider());
- assertFalse(macs[i].equals(mac1));
- } catch (CloneNotSupportedException e) {
- }
- }
- }
-
- /**
- * Test for
- * <code>init(Key key, AlgorithmParameterSpec params)</code>
- * <code>init(Key key)</code>
- * methods
- * Assertion: throws InvalidKeyException and InvalidAlgorithmParameterException
- * when parameters are not appropriate
- */
- public void testInit() throws NoSuchAlgorithmException, NoSuchProviderException,
- IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException,
- InvalidKeyException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- byte[] b = { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5 };
- SecretKeySpec sks = new SecretKeySpec(b, "SHA1");
- DHGenParameterSpec algPS = new DHGenParameterSpec(1, 2);
-
- for (int i = 0; i < macs.length; i++) {
- try {
- macs[i].init(sks, algPS);
- fail("init(..) accepts incorrect AlgorithmParameterSpec parameter");
- } catch (InvalidAlgorithmParameterException e) {
- }
-
- try {
- macs[i].init(null, null);
- fail("InvalidKeyException must be thrown");
- } catch (InvalidKeyException e) {
- }
-
- try {
- macs[i].init(null);
- fail("InvalidKeyException must be thrown");
- } catch (InvalidKeyException e) {
- }
- }
- }
-
- /**
- * Test for <code>update(ByteBuffer input)</code>
- * <code>update(byte[] input, int offset, int len)</code>
- * methods
- * Assertion: processes Mac; if input is null then do nothing
- */
- public void testUpdateByteBuffer01() throws NoSuchAlgorithmException, NoSuchProviderException,
- IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException,
- InvalidKeyException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- byte[] bb = { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5 };
- SecretKeySpec sks = new SecretKeySpec(bb, "SHA1");
- ByteBuffer byteNull = null;
- ByteBuffer byteBuff = ByteBuffer.allocate(0);
- byte[] bb1;
- byte[] bb2;
- for (int i = 0; i < macs.length; i++) {
- macs[i].init(sks);
- bb1 = macs[i].doFinal();
- try {
- macs[i].update(byteNull);
- fail("IllegalArgumentException must be thrown because buffer is null");
- } catch (IllegalArgumentException e) {
- }
- macs[i].update(byteBuff);
- bb2 = macs[i].doFinal();
- for (int t = 0; t < bb1.length; t++) {
- assertEquals("Incorrect doFinal result", bb1[t], bb2[t]);
- }
- macs[i].init(sks);
- bb1 = macs[i].doFinal();
- macs[i].update(null, 0, 0);
- bb2 = macs[i].doFinal();
- for (int t = 0; t < bb1.length; t++) {
- assertEquals("Incorrect doFinal result", bb1[t], bb2[t]);
- }
- }
- }
-
- /**
- * Test for <code>update(ByteBuffer input)</code>
- * <code>update(byte[] input, int offset, int len)</code>
- * methods
- * Assertion: processes Mac
- */
- public void testUpdateByteBuffer02() throws NoSuchAlgorithmException, NoSuchProviderException,
- IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException,
- InvalidKeyException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- byte[] bb = { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5 };
- SecretKeySpec sks = new SecretKeySpec(bb, "SHA1");
- byte[] bbuf = { (byte) 5, (byte) 4, (byte) 3, (byte) 2, (byte) 1 };
- ByteBuffer byteBuf;
- byte[] bb1;
- byte[] bb2;
- for (int i = 0; i < macs.length; i++) {
- byteBuf = ByteBuffer.allocate(5);
- byteBuf.put(bbuf);
- byteBuf.position(2);
- macs[i].init(sks);
- macs[i].update(byteBuf);
- bb1 = macs[i].doFinal();
-
- macs[i].init(sks);
- macs[i].update(bbuf, 2, 3);
- bb2 = macs[i].doFinal();
- for (int t = 0; t < bb1.length; t++) {
- assertEquals("Incorrect doFinal result", bb1[t], bb2[t]);
- }
- }
- }
-
- /**
- * Test for <code>clone()</code> method
- * Assertion: clone if provider is clo
- */
- public void testClone() {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- Mac res;
- for (int i = 0; i < macs.length; i++) {
- try {
- res = (Mac) macs[i].clone();
- assertTrue("Object should not be equals", !macs[i].equals(res));
- assertEquals("Incorrect class", macs[i].getClass(), res.getClass());
- } catch (CloneNotSupportedException e) {
- }
- }
- }
-
- /**
- * Test for <code>getMacLength()</code> method
- * Assertion: return Mac length
- */
- public void testGetMacLength() {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- for (int i = 0; i < macs.length; i++) {
- assertTrue("Length should be positive", (macs[i].getMacLength() >= 0));
- }
- }
-
- /**
- * Test for <code>reset()</code> method
- * Assertion: return Mac length
- */
- public void testReset() throws InvalidKeyException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Mac[] macs = createMacs();
- assertNotNull("Mac objects were not created", macs);
- byte[] bb = { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5 };
- SecretKeySpec sks = new SecretKeySpec(bb, "SHA1");
- byte[] bbuf = { (byte) 5, (byte) 4, (byte) 3, (byte) 2, (byte) 1 };
- byte[] bb1;
- byte[] bb2;
- for (int i = 0; i < macs.length; i++) {
- macs[i].init(sks);
- bb1 = macs[i].doFinal();
- macs[i].reset();
- bb2 = macs[i].doFinal();
- assertEquals("incorrect result", bb1.length, bb2.length);
- for (int t = 0; t < bb1.length; t++) {
- assertEquals("Incorrect doFinal result", bb1[t], bb2[t]);
- }
- macs[i].reset();
- macs[i].update(bbuf);
- bb1 = macs[i].doFinal();
- macs[i].reset();
- macs[i].update(bbuf, 0, bbuf.length);
- bb2 = macs[i].doFinal();
- assertEquals("incorrect result", bb1.length, bb2.length);
- for (int t = 0; t < bb1.length; t++) {
- assertEquals("Incorrect doFinal result", bb1[t], bb2[t]);
- }
- }
- }
-
- /**
- * Test for <code>Mac</code> constructor
- * Assertion: returns Mac object
- */
- public void testMacConstructor() throws NoSuchAlgorithmException,
- InvalidKeyException, InvalidAlgorithmParameterException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- MacSpi spi = new MyMacSpi();
- Mac mac = new myMac(spi, defaultProvider, defaultAlgorithm);
- assertEquals("Incorrect algorithm", mac.getAlgorithm(),
- defaultAlgorithm);
- assertEquals("Incorrect provider", mac.getProvider(), defaultProvider);
- try {
- mac.init(null, null);
- fail("Exception should be thrown because init(..) uses incorrect parameters");
- } catch (Exception e) {
- }
- assertEquals("Invalid mac length", mac.getMacLength(), 0);
-
- mac = new myMac(null, null, null);
- assertNull("Algorithm must be null", mac.getAlgorithm());
- assertNull("Provider must be null", mac.getProvider());
- try {
- mac.init(null, null);
- fail("Exception should be thrown because init(..) uses incorrect parameters");
- } catch (Exception e) {
- }
- try {
- mac.getMacLength();
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- }
-
- public static Test suite() {
- return new TestSuite(MacTest.class);
- }
-
-}
-
-/**
- * Additional class for Mac constructor verification
- */
-class myMac extends Mac {
-
- public myMac(MacSpi macSpi, Provider provider,
- String algorithm) {
- super(macSpi, provider, algorithm);
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/NoSuchPaddingExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/NoSuchPaddingExceptionTest.java
deleted file mode 100644
index 23c6631..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/NoSuchPaddingExceptionTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import javax.crypto.NoSuchPaddingException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>NoSuchPaddingException</code> class constructors and
- * methods.
- */
-public class NoSuchPaddingExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for NoSuchPaddingExceptionTests.
- *
- * @param arg0
- */
- public NoSuchPaddingExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>NoSuchPaddingException()</code> constructor Assertion:
- * constructs NoSuchPaddingException with no detail message
- */
- public void testNoSuchPaddingException01() {
- NoSuchPaddingException tE = new NoSuchPaddingException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>NoSuchPaddingException(String)</code> constructor
- * Assertion: constructs NoSuchPaddingException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testNoSuchPaddingException02() {
- NoSuchPaddingException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new NoSuchPaddingException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>NoSuchPaddingException(String)</code> constructor
- * Assertion: constructs NoSuchPaddingException when <code>msg</code> is
- * null
- */
- public void testNoSuchPaddingException03() {
- String msg = null;
- NoSuchPaddingException tE = new NoSuchPaddingException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/NullCipherTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/NullCipherTest.java
deleted file mode 100644
index 2679dbe..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/NullCipherTest.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.SecureRandom;
-import java.util.Arrays;
-
-import javax.crypto.Cipher;
-import javax.crypto.NullCipher;
-import javax.crypto.spec.SecretKeySpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for NullCipher
- */
-public class NullCipherTest extends TestCase {
-
- private Cipher c;
-
- protected void setUp() throws Exception {
- super.setUp();
- c = new NullCipher();
- }
-
- public void testGetAlgorithm() {
- c.getAlgorithm();
- }
-
- public void testGetBlockSize() {
- assertEquals("Incorrect BlockSize", 1, c.getBlockSize());
- }
-
- public void testGetOutputSize() {
- assertEquals("Incorrect OutputSize", 111, c.getOutputSize(111));
- }
-
- public void testGetIV() {
- assertTrue("Incorrect IV", Arrays.equals(c.getIV(), new byte[8]));
- }
-
- public void testGetParameters() {
- assertNull("Incorrect Parameters", c.getParameters());
- }
-
- public void testGetExemptionMechanism() {
- assertNull("Incorrect ExemptionMechanism", c.getExemptionMechanism());
- }
-
- /*
- * Class under test for void init(int, Key)
- */
- public void testInitintKey() throws Exception {
- c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[1], "algorithm"));
-
- }
-
- /*
- * Class under test for void init(int, Key, SecureRandom)
- */
- public void testInitintKeySecureRandom() throws Exception {
- c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[1],
- "algorithm"), new SecureRandom());
- }
-
- /*
- * Class under test for void init(int, Key, AlgorithmParameterSpec)
- */
- public void testInitintKeyAlgorithmParameterSpec() throws Exception {
- class myAlgorithmParameterSpec implements java.security.spec.AlgorithmParameterSpec {
- }
- c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[1],
- "algorithm"), new myAlgorithmParameterSpec());
- }
-
- /*
- * Class under test for byte[] update(byte[])
- */
- public void testUpdatebyteArray() throws Exception {
- byte[] b = { 1, 2, 3, 4, 5 };
- byte[] r = c.update(b);
- assertEquals("different length", b.length, r.length);
- assertTrue("different content", Arrays.equals(b, r));
- }
-
- /*
- * Class under test for byte[] update(byte[], int, int)
- */
- public void testUpdatebyteArrayintint() throws Exception {
- byte[] b = { 1, 2, 3, 4, 5 };
- byte[] r = c.update(b, 0, 5);
- assertEquals("different length", b.length, r.length);
- assertTrue("different content", Arrays.equals(b, r));
-
- r = c.update(b, 1, 3);
- assertEquals("different length", 3, r.length);
- for (int i = 0; i < 3; i++) {
- assertEquals("different content", b[i + 1], r[i]);
- }
- }
-
- /*
- * Class under test for int update(byte[], int, int, byte[])
- */
- public void testUpdatebyteArrayintintbyteArray() throws Exception {
- byte[] b = { 1, 2, 3, 4, 5 };
- byte[] r = new byte[5];
- c.update(b, 0, 5, r);
- assertTrue("different content", Arrays.equals(b, r));
- }
-
- /*
- * Class under test for int update(byte[], int, int, byte[], int)
- */
- public void testUpdatebyteArrayintintbyteArrayint() throws Exception {
- byte[] b = { 1, 2, 3, 4, 5 };
- byte[] r = new byte[5];
- c.update(b, 0, 5, r, 0);
- assertTrue("different content", Arrays.equals(b, r));
- }
-
- /*
- * Class under test for byte[] doFinal()
- */
- public void testDoFinal() throws Exception {
- assertNull("doFinal failed", c.doFinal());
- }
-
- /*
- * Class under test for int doFinal(byte[], int)
- */
- public void testDoFinalbyteArrayint() throws Exception {
- byte[] r = new byte[5];
- assertEquals("doFinal failed", 0, c.doFinal(r, 0));
- }
-
- /*
- * Class under test for byte[] doFinal(byte[])
- */
- public void testDoFinalbyteArray() throws Exception {
- byte[] b = { 1, 2, 3, 4, 5 };
- byte[] r = null;
- r = c.doFinal(b);
- assertEquals("different length", b.length, r.length);
- assertTrue("different content", Arrays.equals(b, r));
- }
-
- /*
- * Class under test for byte[] doFinal(byte[], int, int)
- */
- public void testDoFinalbyteArrayintint() throws Exception {
- byte[] b = { 1, 2, 3, 4, 5 };
- byte[] r = null;
- r = c.doFinal(b, 0, 5);
- assertEquals("different length", b.length, r.length);
- assertTrue("different content", Arrays.equals(b, r));
-
- r = c.doFinal(b, 1, 3);
- assertEquals("different length", 3, r.length);
- for (int i = 0; i < 3; i++) {
- assertEquals("different content", b[i + 1], r[i]);
- }
- }
-
- /*
- * Class under test for byte[] update(byte[], int, int)
- */
- public void testUpdatebyteArrayintint2() {
- //Regression for HARMONY-758
- try {
- new NullCipher().update(new byte[1], 1, Integer.MAX_VALUE);
- fail("Expected IllegalArgumentException was not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /*
- * Class under test for int doFinal(byte[], int, int, byte[])
- */
- public void testDoFinalbyteArrayintintbyteArray() throws Exception {
- byte[] b = { 1, 2, 3, 4, 5 };
- byte[] r = new byte[5];
- c.doFinal(b, 0, 5, r);
- assertTrue("different content", Arrays.equals(b, r));
- }
-
- /*
- * Class under test for int doFinal(byte[], int, int, byte[])
- */
- public void testDoFinalbyteArrayintintbyteArray2() throws Exception {
- //Regression for HARMONY-758
- try {
- new NullCipher().update(new byte[1], 1, Integer.MAX_VALUE,
- new byte[1]);
- fail("Expected IllegalArgumentException was not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /*
- * Class under test for int doFinal(byte[], int, int, byte[])
- */
- public void testDoFinalbyteArrayintintbyteArray3() throws Exception {
- //Regression for HARMONY-758
- try {
- new NullCipher().update(new byte[1], 0, 1, new byte[0]);
- fail("Expected ArrayIndexOutOfBoundsException was not thrown");
- } catch (ArrayIndexOutOfBoundsException e) {
- }
- }
-
- /*
- * Class under test for int doFinal(byte[], int, int, byte[], int)
- */
- public void testDoFinalbyteArrayintintbyteArrayint() throws Exception {
- byte[] b = { 1, 2, 3, 4, 5 };
- byte[] r = new byte[5];
- c.doFinal(b, 0, 5, r, 0);
- assertTrue("different content", Arrays.equals(b, r));
- }
-
- /*
- * Class under test for int doFinal(byte[], int, int, byte[], int)
- */
- public void testDoFinalbyteArrayintintbyteArrayint2() throws Exception {
- //Regression for HARMONY-758
- try {
- new NullCipher().update(new byte[1], 1, Integer.MAX_VALUE,
- new byte[1], 0);
- fail("Expected IllegalArgumentException was not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /*
- * Class under test for int doFinal(byte[], int, int, byte[], int)
- */
- public void testDoFinalbyteArrayintintbyteArrayint3() throws Exception {
- //Regression for HARMONY-758
- try {
- new NullCipher().update(new byte[1], 0, 1,
- new byte[0], 0);
- fail("Expected ArrayIndexOutOfBoundsException was not thrown");
- } catch (ArrayIndexOutOfBoundsException e) {
- }
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactoryTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactoryTest.java
deleted file mode 100644
index f9f4657..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactoryTest.java
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.KeySpec;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactory;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.DESKeySpec;
-import javax.crypto.spec.DESedeKeySpec;
-import javax.crypto.spec.SecretKeySpec;
-
-import org.apache.harmony.crypto.tests.support.MySecretKeyFactorySpi;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SecretKeyFactory</code> class constructors and methods.
- */
-
-public class SecretKeyFactoryTest extends TestCase {
-
- public static final String srvSecretKeyFactory = "SecretKeyFactory";
-
- private static String defaultAlgorithm1 = "DESede";
- private static String defaultAlgorithm2 = "DES";
-
- public static String defaultAlgorithm = null;
-
- private static String defaultProviderName = null;
-
- private static Provider defaultProvider = null;
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- public static final String[] validValues = new String[2];
- private static boolean DEFSupported = false;
-
- private static final String NotSupportMsg = "Default algorithm is not supported";
-
- static {
- defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm1,
- srvSecretKeyFactory);
- DEFSupported = (defaultProvider != null);
- if (DEFSupported) {
- defaultAlgorithm = defaultAlgorithm1;
- validValues[0] = defaultAlgorithm.toUpperCase();
- validValues[1] = defaultAlgorithm.toLowerCase();
- defaultProviderName = defaultProvider.getName();
- } else {
- defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm2,
- srvSecretKeyFactory);
- DEFSupported = (defaultProvider != null);
- if (DEFSupported) {
- defaultAlgorithm = defaultAlgorithm2;
- validValues[0] = defaultAlgorithm.toUpperCase();
- validValues[2] = defaultAlgorithm.toLowerCase();
- defaultProviderName = defaultProvider.getName();
- } else {
- defaultAlgorithm = null;
- defaultProviderName = null;
- defaultProvider = null;
- }
- }
- }
-
- protected SecretKeyFactory[] createSKFac() {
- if (!DEFSupported) {
- fail(defaultAlgorithm + " algorithm is not supported");
- return null;
- }
- SecretKeyFactory[] skF = new SecretKeyFactory[3];
- try {
- skF[0] = SecretKeyFactory.getInstance(defaultAlgorithm);
- skF[1] = SecretKeyFactory.getInstance(defaultAlgorithm,
- defaultProvider);
- skF[2] = SecretKeyFactory.getInstance(defaultAlgorithm,
- defaultProviderName);
- return skF;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- /**
- * Test for <code>SecretKeyFactory</code> constructor
- * Assertion: returns SecretKeyFactory object
- */
- public void testSecretKeyFactory01() throws NoSuchAlgorithmException,
- InvalidKeySpecException, InvalidKeyException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- SecretKeyFactorySpi spi = new MySecretKeyFactorySpi();
- SecretKeyFactory secKF = new mySecretKeyFactory(spi, defaultProvider,
- defaultAlgorithm);
- assertEquals("Incorrect algorithm", secKF.getAlgorithm(),
- defaultAlgorithm);
- assertEquals("Incorrect provider", secKF.getProvider(), defaultProvider);
- assertNull("Incorrect result", secKF.generateSecret(null));
- assertNull("Incorrect result", secKF.getKeySpec(null, null));
- assertNull("Incorrect result", secKF.translateKey(null));
- secKF = new mySecretKeyFactory(null, null, null);
- assertNull("Algorithm must be null", secKF.getAlgorithm());
- assertNull("Provider must be null", secKF.getProvider());
- try {
- secKF.translateKey(null);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm has invalid value
- */
- public void testSecretKeyFactory02() throws NoSuchAlgorithmException {
- try {
- SecretKeyFactory.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- SecretKeyFactory.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException was not thrown as expected");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion: returns SecretKeyObject
- */
- public void testSecretKeyFactory03() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- for (int i = 0; i < validValues.length; i++) {
- SecretKeyFactory secKF = SecretKeyFactory
- .getInstance(validValues[i]);
- assertEquals("Incorrect algorithm", secKF.getAlgorithm(),
- validValues[i]);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is invalid
- */
- public void testSecretKeyFactory04() throws NoSuchAlgorithmException,
- NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- try {
- SecretKeyFactory.getInstance(null, defaultProviderName);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- SecretKeyFactory.getInstance(invalidValues[i],
- defaultProviderName);
- fail("NoSuchAlgorithmException was not thrown as expected (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion:
- * throws IllegalArgumentException when provider is null or empty;
- * throws NoSuchProviderException when provider has invalid value
- */
- public void testSecretKeyFactory05() throws NoSuchAlgorithmException,
- NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- SecretKeyFactory.getInstance(validValues[i], prov);
- fail("IllegalArgumentException was not thrown as expected (algorithm: "
- .concat(validValues[i]).concat(" provider: null"));
- } catch (IllegalArgumentException e) {
- }
- try {
- SecretKeyFactory.getInstance(validValues[i], "");
- fail("IllegalArgumentException was not thrown as expected (algorithm: "
- .concat(validValues[i]).concat(" provider: empty"));
- } catch (IllegalArgumentException e) {
- }
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- SecretKeyFactory.getInstance(validValues[i],
- invalidValues[j]);
- fail("NoSuchProviderException was not thrown as expected (algorithm: "
- .concat(validValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion: returns SecretKeyFactory object
- */
- public void testSecretKeyFactory06() throws NoSuchProviderException,
- NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- for (int i = 0; i < validValues.length; i++) {
- SecretKeyFactory secKF = SecretKeyFactory.getInstance(
- validValues[i], defaultProviderName);
- assertEquals("Incorrect algorithm", secKF.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", secKF.getProvider().getName(),
- defaultProviderName);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion: throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is invalid
- */
- public void testSecretKeyFactory07() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- try {
- SecretKeyFactory.getInstance(null, defaultProvider);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- SecretKeyFactory.getInstance(invalidValues[i], defaultProvider);
- fail("NoSuchAlgorithmException was not thrown as expected (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion: throws IllegalArgumentException when provider is null
- */
- public void testSecretKeyFactory08() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- SecretKeyFactory.getInstance(validValues[i], prov);
- fail("IllegalArgumentException was not thrown as expected (provider is null, algorithm: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion: returns SecretKeyFactory object
- */
- public void testSecretKeyFactory09() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- for (int i = 0; i < validValues.length; i++) {
- SecretKeyFactory secKF = SecretKeyFactory.getInstance(
- validValues[i], defaultProvider);
- assertEquals("Incorrect algorithm", secKF.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", secKF.getProvider(),
- defaultProvider);
- }
- }
-
- /**
- * Test for <code>generateSecret(KeySpec keySpec)</code> and
- * <code>getKeySpec(SecretKey key, Class keySpec)
- * methods
- * Assertion:
- * throw InvalidKeySpecException if parameter is inappropriate
- */
- public void testSecretKeyFactory10() throws InvalidKeyException,
- InvalidKeySpecException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- byte[] bb = new byte[24];
- KeySpec ks = (defaultAlgorithm.equals(defaultAlgorithm2) ? (KeySpec) new DESKeySpec(bb) :
- (KeySpec) new DESedeKeySpec(bb));
- KeySpec rks = null;
- SecretKeySpec secKeySpec = new SecretKeySpec(bb, defaultAlgorithm);
- SecretKey secKey = null;
- SecretKeyFactory[] skF = createSKFac();
- assertNotNull("SecretKeyFactory object were not created", skF);
- for (int i = 0; i < skF.length; i++) {
- try {
- skF[i].generateSecret(null);
- fail("generateSecret(null): InvalidKeySpecException must be thrown");
- } catch (InvalidKeySpecException e) {
- }
-
- secKey = skF[i].generateSecret(ks);
- try {
- skF[i].getKeySpec(null, null);
- fail("getKeySpec(null,null): InvalidKeySpecException must be thrown");
- } catch (InvalidKeySpecException e) {
- }
- try {
- skF[i].getKeySpec(null, ks.getClass());
- fail("getKeySpec(null, Class): InvalidKeySpecException must be thrown");
- } catch (InvalidKeySpecException e) {
- }
- try {
- skF[i].getKeySpec(secKey, null);
- fail("getKeySpec(secKey, null): NullPointerException or InvalidKeySpecException must be thrown");
- } catch (InvalidKeySpecException e) {
- // Expected
- } catch (NullPointerException e) {
- // Expected
- }
-
- try {
- Class c;
- if (defaultAlgorithm.equals(defaultAlgorithm2)) {
- c = DESedeKeySpec.class;
- } else {
- c = DESKeySpec.class;
- }
- skF[i].getKeySpec(secKeySpec, c);
- fail("getKeySpec(secKey, Class): InvalidKeySpecException must be thrown");
- } catch (InvalidKeySpecException e) {
- }
- rks = skF[i].getKeySpec(secKeySpec, ks.getClass());
- if (defaultAlgorithm.equals(defaultAlgorithm1)) {
- assertTrue("Incorrect getKeySpec() result 1",
- rks instanceof DESedeKeySpec);
- } else {
- assertTrue("Incorrect getKeySpec() result 1",
- rks instanceof DESKeySpec);
- }
-
- rks = skF[i].getKeySpec(secKey, ks.getClass());
- if (defaultAlgorithm.equals(defaultAlgorithm1)) {
- assertTrue("Incorrect getKeySpec() result 2",
- rks instanceof DESedeKeySpec);
- } else {
- assertTrue("Incorrect getKeySpec() result 2",
- rks instanceof DESKeySpec);
- }
- }
- }
-}
-
-class mySecretKeyFactory extends SecretKeyFactory {
- public mySecretKeyFactory(SecretKeyFactorySpi spi, Provider prov, String alg) {
- super(spi, prov, alg);
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyTest.java
deleted file mode 100644
index a68eb33..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import javax.crypto.SecretKey;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SecretKey</code> class field
- */
-public class SecretKeyTest extends TestCase {
-
- /**
- * Constructor for SecretKeyTest.
- *
- * @param arg0
- */
- public SecretKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkSecretKey sk = new checkSecretKey();
- assertEquals("Incorrect serialVersionUID",
- sk.getSerVerUID(), //SecretKey.serialVersionUID
- -4795878709595146952L);
- }
-
- public class checkSecretKey implements SecretKey {
- public String getAlgorithm() {
- return "SecretKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ShortBufferExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ShortBufferExceptionTest.java
deleted file mode 100644
index 27dafc4..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ShortBufferExceptionTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import javax.crypto.ShortBufferException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>ShortBufferException</code> class constructors and methods.
- */
-public class ShortBufferExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for ShortBufferExceptionTests.
- *
- * @param arg0
- */
- public ShortBufferExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>ShortBufferException()</code> constructor Assertion:
- * constructs ShortBufferException with no detail message
- */
- public void testShortBufferException01() {
- ShortBufferException tE = new ShortBufferException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>ShortBufferException(String)</code> constructor
- * Assertion: constructs ShortBufferException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testShortBufferException02() {
- ShortBufferException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new ShortBufferException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>ShortBufferException(String)</code> constructor
- * Assertion: constructs ShortBufferException when <code>msg</code> is
- * null
- */
- public void testShortBufferException03() {
- String msg = null;
- ShortBufferException tE = new ShortBufferException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPrivateKeyTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPrivateKeyTest.java
deleted file mode 100644
index a361f0a..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPrivateKeyTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.interfaces;
-
-import javax.crypto.interfaces.DHPrivateKey;
-import javax.crypto.spec.DHParameterSpec;
-
-import junit.framework.TestCase;
-
-import java.math.BigInteger;
-
-
-/**
- * Tests for <code>DHPrivateKey</code> class field
- */
-public class DHPrivateKeyTest extends TestCase {
-
- /**
- * Constructor for DHPrivateKey.
- *
- * @param arg0
- */
- public DHPrivateKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkDHPrivateKey key = new checkDHPrivateKey();
- assertEquals("Incorrect serialVersionUID",
- key.getSerVerUID(), //DHPrivateKey.serialVersionUID
- 2211791113380396553L);
- }
-
- public class checkDHPrivateKey implements DHPrivateKey {
- public String getAlgorithm() {
- return "SecretKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
-
- public BigInteger getX() {
- return null;
- }
-
- public DHParameterSpec getParams() {
- return null;
- }
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPublicKeyTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPublicKeyTest.java
deleted file mode 100644
index 9dee141..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPublicKeyTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.interfaces;
-
-import java.math.BigInteger;
-
-import javax.crypto.interfaces.DHPublicKey;
-import javax.crypto.spec.DHParameterSpec;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>DHPublicKey</code> class field
- */
-public class DHPublicKeyTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for DHPublicKey.
- *
- * @param arg0
- */
- public DHPublicKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkDHPublicKey key = new checkDHPublicKey();
- assertEquals("Incorrect serialVersionUID",
- key.getSerVerUID(), //DHPublicKey.serialVersionUID
- -6628103563352519193L);
- }
-
- public class checkDHPublicKey implements DHPublicKey {
- public String getAlgorithm() {
- return "SecretKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
-
- public BigInteger getY() {
- return null;
- }
-
- public DHParameterSpec getParams() {
- return null;
- }
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/PBEKeyTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/PBEKeyTest.java
deleted file mode 100644
index 7cf22a8..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/PBEKeyTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.interfaces;
-
-import java.math.BigInteger;
-
-import javax.crypto.interfaces.PBEKey;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>PBEKey</code> class field
- */
-public class PBEKeyTest extends TestCase {
-
-
- /**
- * Constructor for PBEKey.
- *
- * @param arg0
- */
- public PBEKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkPBEKey key = new checkPBEKey();
- assertEquals("Incorrect serialVersionUID",
- key.getSerVerUID(), //PBEKey.serialVersionUID
- -1430015993304333921L);
- }
-
- public class checkPBEKey implements PBEKey {
- public String getAlgorithm() {
- return "SecretKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
-
- public BigInteger getY() {
- return null;
- }
-
- public int getIterationCount() {
- return 0;
- }
-
- public byte[] getSalt() {
- return new byte[0];
- }
-
- public char[] getPassword() {
- return new char[0];
- }
- }
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.java
deleted file mode 100644
index ede0fb1..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.serialization;
-
-import javax.crypto.BadPaddingException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for BadPaddingException serialization
- */
-
-public class BadPaddingExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new BadPaddingException(),
- new BadPaddingException(null), new BadPaddingException(msgs[1]) };
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.java
deleted file mode 100644
index 55a8a1a..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.serialization;
-
-import javax.crypto.ExemptionMechanismException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for ExemptionMechanismException serialization
- */
-
-public class ExemptionMechanismExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new ExemptionMechanismException(),
- new ExemptionMechanismException(null), new ExemptionMechanismException(msgs[1]) };
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.java
deleted file mode 100644
index 0e2ce1b..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.serialization;
-
-import javax.crypto.IllegalBlockSizeException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for IllegalBlockSizeException serialization
- */
-
-public class IllegalBlockSizeExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new IllegalBlockSizeException(),
- new IllegalBlockSizeException(null), new IllegalBlockSizeException(msgs[1]) };
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.java
deleted file mode 100644
index 85d3d8b..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.serialization;
-
-import javax.crypto.NoSuchPaddingException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for NuSuchPaddingException serialization
- */
-
-public class NoSuchPaddingExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new NoSuchPaddingException(),
- new NoSuchPaddingException(null), new NoSuchPaddingException(msgs[1]) };
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.java
deleted file mode 100644
index 12061dc..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.serialization;
-
-import javax.crypto.ShortBufferException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for ShortBufferException serialization
- */
-
-public class ShortBufferExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new ShortBufferException(),
- new ShortBufferException(null), new ShortBufferException(msgs[1]) };
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java
deleted file mode 100644
index 6dc01ea..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.lang.NullPointerException;
-import java.security.InvalidKeyException;
-import java.util.Arrays;
-
-import javax.crypto.spec.DESKeySpec;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class DESKeySpecTest extends TestCase {
-
- // DES weak and semi-weak keys
- // Got from:
- // FIP PUB 74
- // FEDERAL INFORMATION PROCESSING STANDARDS PUBLICATION 1981
- // GUIDELINES FOR IMPLEMENTING AND USING THE NBS DATA ENCRYPTION STANDARD
- // http://www.dice.ucl.ac.be/crypto/standards/fips/fip74/fip74-1.pdf
- private static final byte[][] semiweaks = {
- { (byte) 0xE0, (byte) 0x01, (byte) 0xE0, (byte) 0x01,
- (byte) 0xF1, (byte) 0x01, (byte) 0xF1, (byte) 0x01 },
-
- { (byte) 0x01, (byte) 0xE0, (byte) 0x01, (byte) 0xE0,
- (byte) 0x01, (byte) 0xF1, (byte) 0x01, (byte) 0xF1 },
-
- { (byte) 0xFE, (byte) 0x1F, (byte) 0xFE, (byte) 0x1F,
- (byte) 0xFE, (byte) 0x0E, (byte) 0xFE, (byte) 0x0E },
-
- { (byte) 0x1F, (byte) 0xFE, (byte) 0x1F, (byte) 0xFE,
- (byte) 0x0E, (byte) 0xFE, (byte) 0x0E, (byte) 0xFE },
-
- { (byte) 0xE0, (byte) 0x1F, (byte) 0xE0, (byte) 0x1F,
- (byte) 0xF1, (byte) 0x0E, (byte) 0xF1, (byte) 0x0E },
-
- { (byte) 0x1F, (byte) 0xE0, (byte) 0x1F, (byte) 0xE0,
- (byte) 0x0E, (byte) 0xF1, (byte) 0x0E, (byte) 0xF1 },
-
- { (byte) 0x01, (byte) 0xFE, (byte) 0x01, (byte) 0xFE,
- (byte) 0x01, (byte) 0xFE, (byte) 0x01, (byte) 0xFE },
-
- { (byte) 0xFE, (byte) 0x01, (byte) 0xFE, (byte) 0x01,
- (byte) 0xFE, (byte) 0x01, (byte) 0xFE, (byte) 0x01 },
-
- { (byte) 0x01, (byte) 0x1F, (byte) 0x01, (byte) 0x1F,
- (byte) 0x01, (byte) 0x0E, (byte) 0x01, (byte) 0x0E },
-
- { (byte) 0x1F, (byte) 0x01, (byte) 0x1F, (byte) 0x01,
- (byte) 0x0E, (byte) 0x01, (byte) 0x0E, (byte) 0x01 },
-
- { (byte) 0xE0, (byte) 0xFE, (byte) 0xE0, (byte) 0xFE,
- (byte) 0xF1, (byte) 0xFE, (byte) 0xF1, (byte) 0xFE },
-
- { (byte) 0xFE, (byte) 0xE0, (byte) 0xFE, (byte) 0xE0,
- (byte) 0xFE, (byte) 0xF1, (byte) 0xFE, (byte) 0xF1 },
-
- { (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
- (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01 },
-
- { (byte) 0xFE, (byte) 0xFE, (byte) 0xFE, (byte) 0xFE,
- (byte) 0xFE, (byte) 0xFE, (byte) 0xFE, (byte) 0xFE },
-
- { (byte) 0xE0, (byte) 0xE0, (byte) 0xE0, (byte) 0xE0,
- (byte) 0xF1, (byte) 0xF1, (byte) 0xF1, (byte) 0xF1 },
-
- { (byte) 0x1F, (byte) 0x1F, (byte) 0x1F, (byte) 0x1F,
- (byte) 0x0E, (byte) 0x0E, (byte) 0x0E, (byte) 0x0E },
- };
-
- /* DES not weak or semi-weak keys */
- private static final byte[][] notsemiweaks = {
- { (byte) 0x1f, (byte) 0x1f, (byte) 0x1f, (byte) 0x1f,
- (byte) 0x1f, (byte) 0x1f, (byte) 0x1f, (byte) 0x1f },
-
- { (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0,
- (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0 }
- };
-
- /**
- * Constructors testing. Tests behavior of each of two constructors
- * in the cases of: null array, short array, normal array.
- */
- public void testDESKeySpec() {
- try {
- new DESKeySpec((byte[]) null);
- fail("Should raise an NullPointerException "
- + "in case of null byte array.");
- } catch (NullPointerException e) {
- } catch (InvalidKeyException e) {
- fail("Should raise an NullPointerException "
- + "in case of null byte array.");
- }
- try {
- new DESKeySpec(new byte[] { 1, 2, 3 });
- fail("Should raise an InvalidKeyException on a short byte array.");
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- }
- try {
- new DESKeySpec(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 });
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- fail("Unexpected InvalidKeyException was thrown.");
- }
- try {
- new DESKeySpec((byte[]) null, 1);
- fail("Should raise an NullPointerException "
- + "in case of null byte array.");
- } catch (NullPointerException e) {
- } catch (InvalidKeyException e) {
- fail("Should raise an NullPointerException "
- + "in case of null byte array.");
- }
- try {
- new DESKeySpec(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }, 1);
- fail("Should raise an InvalidKeyException on a short byte array.");
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- }
- try {
- new DESKeySpec(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 1);
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- fail("Unexpected InvalidKeyException was thrown.");
- }
- }
-
- /**
- * getKey() method testing. Checks that modification of returned key
- * does not affect the internal key. Also test check an equality of
- * the key with the key specified in the constructor. The object under
- * the test is created by different constructors.
- */
- public void testGetKey() {
- byte[] key = { 1, 2, 3, 4, 5, 6, 7, 8 };
- DESKeySpec ks;
- try {
- ks = new DESKeySpec(key);
- } catch (InvalidKeyException e) {
- fail("InvalidKeyException should not be thrown.");
- return;
- }
- byte[] res = ks.getKey();
- assertTrue("The returned array should be equal to the specified "
- + "in constructor.", Arrays.equals(key, res));
- res[0] += 1;
- assertFalse("The modification of returned key should not affect"
- + "the underlying key.", key[0] == res[0]);
-
- byte[] key1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
- try {
- ks = new DESKeySpec(key1, 2);
- } catch (InvalidKeyException e) {
- fail("InvalidKeyException should not be thrown.");
- return;
- }
- res = ks.getKey();
- assertNotSame("The returned array should not be the same object "
- + "as specified in a constructor.", key1, res);
- byte[] exp = new byte[8];
- System.arraycopy(key1, 2, exp, 0, 8);
- assertTrue("The returned array should be equal to the specified "
- + "in constructor.", Arrays.equals(exp, res));
- }
-
- /**
- * isParityAdjusted(byte[] key, offset) method testing. Tests if the
- * method throws appropriate exceptions on incorrect byte array, if
- * it returns false on the key which is not parity adjusted, and if
- * it returns true on parity adjusted key.
- */
- public void testIsParityAdjusted() {
- try {
- DESKeySpec.isParityAdjusted(null, 1);
- fail("Should raise an InvalidKeyException "
- + "in case of null byte array.");
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- }
-
- byte[] key = { 1, 2, 3, 4, 5, 6, 7, 8 };
- try {
- DESKeySpec.isParityAdjusted(key, 1);
- fail("Should raise an InvalidKeyException "
- + "in case of short byte array.");
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- }
-
- byte[] key_not_pa = { 1, 2, 3, 4, 5, 6, 7, 8 };
- try {
- assertFalse("Method returns true when false is expected.",
- DESKeySpec.isParityAdjusted(key_not_pa, 0));
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- fail("Unexpected InvalidKeyException was thrown.");
- }
-
- byte[] key_pa = { (byte) 128, (byte) 131, (byte) 133, (byte) 134,
- (byte) 137, (byte) 138, (byte) 140, (byte) 143 };
- try {
- assertTrue("Method returns false when true is expected.",
- DESKeySpec.isParityAdjusted(key_pa, 0));
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- fail("Unexpected InvalidKeyException was thrown.");
- }
- }
-
- /**
- * isWeak(byte[] key, int offset) method testing. Tests if the
- * method throws appropriate exceptions on incorrect byte array, if
- * it returns true on weak or semi-weak keys, and if it returns
- * false on other keys.
- */
- public void testIsWeak() {
- try {
- DESKeySpec.isWeak(null, 1);
- fail("Should raise an InvalidKeyException "
- + "in case of null byte array.");
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- }
-
- byte[] key = { 1, 2, 3, 4, 5, 6, 7, 8 };
- try {
- DESKeySpec.isWeak(key, 1);
- fail("Should raise an InvalidKeyException "
- + "in case of short byte array.");
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- }
-
- for (int i = 0; i < semiweaks.length; i++) {
- try {
- assertTrue("Method returns false when true is expected",
- DESKeySpec.isWeak(semiweaks[i], 0));
- } catch (InvalidKeyException e) {
- fail("Unexpected InvalidKeyException was thrown.");
- }
- }
- for (int i = 0; i < notsemiweaks.length; i++) {
- try {
- assertFalse("Method returns true when false is expected",
- DESKeySpec.isWeak(notsemiweaks[i], 0));
- } catch (InvalidKeyException e) {
- fail("Unexpected InvalidKeyException was thrown.");
- }
- }
- }
-
- public static Test suite() {
- return new TestSuite(DESKeySpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESedeKeySpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESedeKeySpecTest.java
deleted file mode 100644
index 0db1b6d..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESedeKeySpecTest.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.lang.NullPointerException;
-import java.security.InvalidKeyException;
-import java.util.Arrays;
-
-import javax.crypto.spec.DESedeKeySpec;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class DESedeKeySpecTest extends TestCase {
-
- /**
- * Constructors testing. Tests behavior of each of two constructors
- * in the cases of: null array, short array, normal array.
- */
- public void testDESedeKeySpec() {
- try {
- new DESedeKeySpec((byte[]) null);
- fail("Should raise an NullPointerException "
- + "in case of null byte array.");
- } catch (NullPointerException e) {
- } catch (InvalidKeyException e) {
- fail("Should raise an NullPointerException "
- + "in case of null byte array.");
- }
- try {
- new DESedeKeySpec(new byte[] { 1, 2, 3 });
- fail("Should raise an InvalidKeyException on a short byte array.");
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- }
- try {
- new DESedeKeySpec(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
- 1, 2, 3, 4 });
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- fail("Unexpected InvalidKeyException was thrown.");
- }
- try {
- new DESedeKeySpec((byte[]) null, 1);
- fail("Should raise an NullPointerException "
- + "in case of null byte array.");
- } catch (NullPointerException e) {
- } catch (InvalidKeyException e) {
- fail("Should raise an NullPointerException "
- + "in case of null byte array.");
- }
- try {
- new DESedeKeySpec(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
- 1, 2, 3, 4 }, 1);
- fail("Should raise an InvalidKeyException on a short byte array.");
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- }
- try {
- new DESedeKeySpec(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
- 1, 2, 3, 4, 5 }, 1);
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- fail("Unexpected InvalidKeyException was thrown.");
- }
- }
-
- /**
- * getKey() method testing. Checks that modification of returned key
- * does not affect the internal key. Also test check an equality of
- * the key with the key specified in the constructor. The object under
- * the test is created by different constructors.
- */
- public void testGetKey() {
- byte[] key = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2 };
- DESedeKeySpec ks;
- try {
- ks = new DESedeKeySpec(key);
- } catch (InvalidKeyException e) {
- fail("InvalidKeyException should not be thrown.");
- return;
- }
- byte[] res = ks.getKey();
- assertTrue("The returned array should be equal to the specified "
- + "in constructor.", Arrays.equals(key, res));
- res[0] += 1;
- assertFalse("The modification of returned key should not affect"
- + "the underlying key.", key[0] == res[0]);
-
- byte[] key1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3 };
- try {
- ks = new DESedeKeySpec(key1, 2);
- } catch (InvalidKeyException e) {
- fail("InvalidKeyException should not be thrown.");
- return;
- }
- res = ks.getKey();
- assertNotSame("The returned array should not be the same object "
- + "as specified in a constructor.", key1, res);
- byte[] exp = new byte[24];
- System.arraycopy(key1, 2, exp, 0, 24);
- assertTrue("The returned array should be equal to the specified "
- + "in constructor.", Arrays.equals(exp, res));
- }
-
- /**
- * isParityAdjusted(byte[] key, offset) method testing. Tests if the
- * method throws appropriate exceptions on incorrect byte array, if
- * it returns false on the key which is not parity adjusted, and if
- * it returns true on parity adjusted key.
- */
- public void testIsParityAdjusted() {
- try {
- DESedeKeySpec.isParityAdjusted(null, 1);
- fail("Should raise an NullPointerException "
- + "in case of null byte array.");
- } catch (NullPointerException e) {
- } catch (InvalidKeyException e) {
- fail("Should raise an NullPointerException "
- + "in case of null byte array.");
- }
-
- byte[] key = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
- try {
- DESedeKeySpec.isParityAdjusted(key, 1);
- fail("Should raise an InvalidKeyException "
- + "in case of short byte array.");
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- }
-
- byte[] key_not_pa = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2 };
- try {
- assertFalse("Method returns true when false is expected.",
- DESedeKeySpec.isParityAdjusted(key_not_pa, 0));
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- fail("Unexpected InvalidKeyException was thrown.");
- }
-
- byte[] key_pa = { (byte) 128, (byte) 131, (byte) 133, (byte) 134,
- (byte) 137, (byte) 138, (byte) 140, (byte) 143,
- (byte) 145, (byte) 146, (byte) 148, (byte) 151,
- (byte) 152, (byte) 155, (byte) 157, (byte) 158,
- (byte) 161, (byte) 162, (byte) 164, (byte) 167,
- (byte) 168, (byte) 171, (byte) 173, (byte) 174 };
- try {
- assertTrue("Method returns false when true is expected.",
- DESedeKeySpec.isParityAdjusted(key_pa, 0));
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- } catch (InvalidKeyException e) {
- fail("Unexpected InvalidKeyException was thrown.");
- }
- }
-
- public static Test suite() {
- return new TestSuite(DESedeKeySpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHGenParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHGenParameterSpecTest.java
deleted file mode 100644
index 79420cb..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHGenParameterSpecTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.lang.Integer;
-
-import javax.crypto.spec.DHGenParameterSpec;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class DHGenParameterSpecTest extends TestCase {
-
- /**
- * DHGenParameterSpec class testing. Tests the equivalence of
- * parameters specified in the constructor with the values returned
- * by getters.
- */
- public void testDHGenParameterSpec() {
- int[] primes = { Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE };
- int[] exponents = { Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE };
- for (int i = 0; i < primes.length; i++) {
- DHGenParameterSpec ps = new DHGenParameterSpec(primes[i],
- exponents[i]);
- assertEquals("The value returned by getPrimeSize() must be "
- + "equal to the value specified in the constructor",
- ps.getPrimeSize(), primes[i]);
- assertEquals("The value returned by getExponentSize() must be "
- + "equal to the value specified in the constructor",
- ps.getPrimeSize(), exponents[i]);
- }
- }
-
- public static Test suite() {
- return new TestSuite(DHGenParameterSpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHParameterSpecTest.java
deleted file mode 100644
index 3ee1afc..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHParameterSpecTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.lang.Integer;
-import java.math.BigInteger;
-
-import javax.crypto.spec.DHParameterSpec;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class DHParameterSpecTest extends TestCase {
-
- /**
- * DHParameterSpec class testing. Tests the equivalence of parameters
- * specified in the constructor with the values returned by getters.
- * The tested object is created by different constructors.
- */
- public void testDHParameterSpec() {
- BigInteger[] ps = { new BigInteger("-1000000000000"), BigInteger.ZERO,
- BigInteger.ONE, new BigInteger("1000000000000") };
- BigInteger[] gs = { new BigInteger("-1000000000000"), BigInteger.ZERO,
- BigInteger.ONE, new BigInteger("1000000000000") };
- int[] ls = { Integer.MIN_VALUE, 0, 1, Integer.MAX_VALUE };
- for (int i = 0; i < ps.length; i++) {
- DHParameterSpec dhps = new DHParameterSpec(ps[i], gs[i]);
- assertEquals("The value returned by getP() must be "
- + "equal to the value specified in the constructor",
- dhps.getP(), ps[i]);
- assertEquals("The value returned by getG() must be "
- + "equal to the value specified in the constructor",
- dhps.getG(), gs[i]);
- }
- for (int i = 0; i < ps.length; i++) {
- DHParameterSpec dhps = new DHParameterSpec(ps[i], gs[i], ls[i]);
- assertEquals("The value returned by getP() must be "
- + "equal to the value specified in the constructor",
- dhps.getP(), ps[i]);
- assertEquals("The value returned by getG() must be "
- + "equal to the value specified in the constructor",
- dhps.getG(), gs[i]);
- assertEquals("The value returned by getL() must be "
- + "equal to the value specified in the constructor",
- dhps.getL(), ls[i]);
- }
- }
-
- public static Test suite() {
- return new TestSuite(DHParameterSpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPrivateKeySpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPrivateKeySpecTest.java
deleted file mode 100644
index b4be8bd..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPrivateKeySpecTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.math.BigInteger;
-
-import javax.crypto.spec.DHPrivateKeySpec;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class DHPrivateKeySpecTest extends TestCase {
-
- /**
- * DHPrivateKeySpec class testing. Tests the equivalence of parameters
- * specified in the constructor with the values returned by getters.
- */
- public void testDHPrivateKeySpec() {
- BigInteger[] xs = { new BigInteger("-1000000000000"), BigInteger.ZERO,
- BigInteger.ONE, new BigInteger("1000000000000") };
- BigInteger[] ps = { new BigInteger("-1000000000000"), BigInteger.ZERO,
- BigInteger.ONE, new BigInteger("1000000000000") };
- BigInteger[] gs = { new BigInteger("-1000000000000"), BigInteger.ZERO,
- BigInteger.ONE, new BigInteger("1000000000000") };
- for (int i = 0; i < ps.length; i++) {
- DHPrivateKeySpec dhpks = new DHPrivateKeySpec(xs[i], ps[i], gs[i]);
- assertEquals("The value returned by getX() must be "
- + "equal to the value specified in the constructor",
- dhpks.getX(), xs[i]);
- assertEquals("The value returned by getP() must be "
- + "equal to the value specified in the constructor",
- dhpks.getP(), ps[i]);
- assertEquals("The value returned by getG() must be "
- + "equal to the value specified in the constructor",
- dhpks.getG(), gs[i]);
- }
- }
-
- public static Test suite() {
- return new TestSuite(DHPrivateKeySpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPublicKeySpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPublicKeySpecTest.java
deleted file mode 100644
index de9ea4e..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPublicKeySpecTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.math.BigInteger;
-
-import javax.crypto.spec.DHPublicKeySpec;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class DHPublicKeySpecTest extends TestCase {
-
- /**
- * DHPublicKeySpec class testing. Tests the equivalence of parameters
- * specified in the constructor with the values returned by getters.
- */
- public void testDHPrivateKeySpec() {
- BigInteger[] ys = { new BigInteger("-1000000000000"), BigInteger.ZERO,
- BigInteger.ONE, new BigInteger("1000000000000") };
- BigInteger[] ps = { new BigInteger("-1000000000000"), BigInteger.ZERO,
- BigInteger.ONE, new BigInteger("1000000000000") };
- BigInteger[] gs = { new BigInteger("-1000000000000"), BigInteger.ZERO,
- BigInteger.ONE, new BigInteger("1000000000000") };
- for (int i = 0; i < ps.length; i++) {
- DHPublicKeySpec dhpks = new DHPublicKeySpec(ys[i], ps[i], gs[i]);
- assertEquals("The value returned by getY() must be "
- + "equal to the value specified in the constructor",
- dhpks.getY(), ys[i]);
- assertEquals("The value returned by getP() must be "
- + "equal to the value specified in the constructor",
- dhpks.getP(), ps[i]);
- assertEquals("The value returned by getG() must be "
- + "equal to the value specified in the constructor",
- dhpks.getG(), gs[i]);
- }
- }
-
- public static Test suite() {
- return new TestSuite(DHPublicKeySpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/IvParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/IvParameterSpecTest.java
deleted file mode 100644
index f3f1bc2..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/IvParameterSpecTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.lang.NullPointerException;
-import java.lang.IllegalArgumentException;
-import java.lang.ArrayIndexOutOfBoundsException;
-
-import javax.crypto.spec.IvParameterSpec;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class IvParameterSpecTest extends TestCase {
-
- /**
- * IvParameterSpec(byte[] iv) constructor testing. Checks that
- * NullPointerException is thrown in the case of null input
- * array and that input array is copied during initialization.
- */
- public void testIvParameterSpec1() {
- try {
- new IvParameterSpec(null);
- fail("Should raise an NullPointerException "
- + "in the case of null byte array.");
- } catch (NullPointerException e) {
- }
-
- byte[] iv = new byte[] { 1, 2, 3, 4, 5 };
- IvParameterSpec ivps = new IvParameterSpec(iv);
- iv[0]++;
- assertFalse("The change of input array's content should not cause "
- + "the change of internal array", iv[0] == ivps.getIV()[0]);
- }
-
- /**
- * IvParameterSpec(byte[] iv) constructor testing. Checks that
- * NullPointerException is thrown in the case of null input
- * array and that input array is copied during initialization.
- */
- public void testIvParameterSpec2() {
- try {
- new IvParameterSpec(null, 1, 1);
- fail("Should raise an IllegalArgumentException "
- + "in the case of null byte array.");
- } catch (ArrayIndexOutOfBoundsException e) {
- fail("Unexpected ArrayIndexOutOfBoundsException was thrown");
- } catch (IllegalArgumentException e) {
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown");
- }
-
- try {
- new IvParameterSpec(new byte[] { 1, 2, 3 }, 2, 2);
- fail("Should raise an IllegalArgumentException "
- + "if (iv.length - offset < len).");
- } catch (ArrayIndexOutOfBoundsException e) {
- fail("Unexpected ArrayIndexOutOfBoundsException was thrown");
- } catch (IllegalArgumentException e) {
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown");
- }
-
- try {
- new IvParameterSpec(new byte[] { 1, 2, 3 }, -1, 1);
- fail("Should raise an ArrayIndexOutOfBoundsException "
- + "if offset index bytes outside the iv.");
- } catch (ArrayIndexOutOfBoundsException e) {
- } catch (IllegalArgumentException e) {
- fail("Unexpected IllegalArgumentException was thrown");
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown");
- }
-
- /* TODO: DRL fail with java.lang.NegativeArraySizeException
- try {
- new IvParameterSpec(new byte[] {1, 2, 3}, 1, -2);
- fail("Should raise an ArrayIndexOutOfBoundsException "
- + "if len index bytes outside the iv.");
- } catch(ArrayIndexOutOfBoundsException e) {
- } catch(IllegalArgumentException e) {
- fail("Unexpected IllegalArgumentException was thrown");
- } catch(NullPointerException e) {
- fail("Unexpected NullPointerException was thrown");
- }
- */
-
- byte[] iv = new byte[] { 1, 2, 3, 4, 5 };
- IvParameterSpec ivps = new IvParameterSpec(iv, 0, iv.length);
- iv[0]++;
- assertFalse("The change of input array's content should not cause "
- + "the change of internal array", iv[0] == ivps.getIV()[0]);
-
- //Regression for HARMONY-1089
- try {
- new IvParameterSpec(new byte[2], 2, -1);
- fail("ArrayIndexOutOfBoundsException expected");
- } catch (ArrayIndexOutOfBoundsException e) {
- //expected
- }
- }
-
- public void testGetIV() {
- byte[] iv = new byte[] { 1, 2, 3, 4, 5 };
- IvParameterSpec ivps = new IvParameterSpec(iv);
- iv = ivps.getIV();
- iv[0]++;
- assertFalse("The change of returned array should not cause "
- + "the change of internal array", iv[0] == ivps.getIV()[0]);
- }
-
- public static Test suite() {
- return new TestSuite(IvParameterSpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/OAEPParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/OAEPParameterSpecTest.java
deleted file mode 100644
index af29953..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/OAEPParameterSpecTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.security.spec.MGF1ParameterSpec;
-import java.security.spec.AlgorithmParameterSpec;
-
-import javax.crypto.spec.OAEPParameterSpec;
-import javax.crypto.spec.PSource;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class OAEPParameterSpecTest extends TestCase {
-
- /**
- * OAEPParameterSpec(String mdName, String mgfName, AlgorithmParameterSpec
- * mgfSpec, PSource pSrc) method testing. Tests that NullPointerException
- * is thrown in the case of inappropriate constructor parameters and checks
- * the value of DEFAULT field.
- */
- public void testOAEPParameterSpec() {
- // using init values for OAEPParameterSpec.DEFAULT
- String mdName = "SHA-1";
- String mgfName = "MGF1";
- AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1;
- PSource pSrc = PSource.PSpecified.DEFAULT;
-
- try {
- new OAEPParameterSpec(null, mgfName, mgfSpec, pSrc);
- fail("NullPointerException should be thrown in the case of "
- + "null mdName.");
- } catch (NullPointerException e) {
- }
-
- try {
- new OAEPParameterSpec(mdName, null, mgfSpec, pSrc);
- fail("NullPointerException should be thrown in the case of "
- + "null mgfName.");
- } catch (NullPointerException e) {
- }
-
- try {
- new OAEPParameterSpec(mdName, mgfName, mgfSpec, null);
- fail("NullPointerException should be thrown in the case of "
- + "null pSrc.");
- } catch (NullPointerException e) {
- }
-
- assertTrue("The message digest algorithm name of "
- + "OAEPParameterSpec.DEFAULT field should be " + mdName,
- OAEPParameterSpec.DEFAULT.getDigestAlgorithm().equals(mdName));
-
- assertTrue("The mask generation function algorithm name of "
- + "OAEPParameterSpec.DEFAULT field should be " + mgfName,
- OAEPParameterSpec.DEFAULT.getMGFAlgorithm().equals(mgfName));
-
- assertTrue("The mask generation function parameters of "
- + "OAEPParameterSpec.DEFAULT field should be the same object "
- + "as MGF1ParameterSpec.SHA1",
- OAEPParameterSpec.DEFAULT.getMGFParameters()
- == MGF1ParameterSpec.SHA1);
- assertTrue("The source of the encoding input P of "
- + "OAEPParameterSpec.DEFAULT field should be the same object "
- + "PSource.PSpecified.DEFAULT",
- OAEPParameterSpec.DEFAULT.getPSource()
- == PSource.PSpecified.DEFAULT);
- }
-
- /**
- * getDigestAlgorithm() method testing.
- */
- public void testGetDigestAlgorithm() {
- String mdName = "SHA-1";
- String mgfName = "MGF1";
- AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1;
- PSource pSrc = PSource.PSpecified.DEFAULT;
-
- OAEPParameterSpec ps = new OAEPParameterSpec(mdName, mgfName,
- mgfSpec, pSrc);
- assertTrue("The returned value does not equal to the "
- + "value specified in the constructor.",
- ps.getDigestAlgorithm().equals(mdName));
- }
-
- /**
- * getMGFAlgorithm() method testing.
- */
- public void testGetMGFAlgorithm() {
- String mdName = "SHA-1";
- String mgfName = "MGF1";
- AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1;
- PSource pSrc = PSource.PSpecified.DEFAULT;
-
- OAEPParameterSpec ps = new OAEPParameterSpec(mdName, mgfName,
- mgfSpec, pSrc);
- assertTrue("The returned value does not equal to the "
- + "value specified in the constructor.",
- ps.getMGFAlgorithm().equals(mgfName));
- }
-
- /**
- * getMGFParameters() method testing.
- */
- public void testGetMGFParameters() {
- String mdName = "SHA-1";
- String mgfName = "MGF1";
- AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1;
- PSource pSrc = PSource.PSpecified.DEFAULT;
-
- OAEPParameterSpec ps = new OAEPParameterSpec(mdName, mgfName,
- mgfSpec, pSrc);
- assertTrue("The returned value does not equal to the "
- + "value specified in the constructor.",
- ps.getMGFParameters() == mgfSpec);
- }
-
- /**
- * getPSource() method testing.
- */
- public void testGetPSource() {
- String mdName = "SHA-1";
- String mgfName = "MGF1";
- AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1;
- PSource pSrc = PSource.PSpecified.DEFAULT;
-
- OAEPParameterSpec ps = new OAEPParameterSpec(mdName, mgfName,
- mgfSpec, pSrc);
- assertTrue("The returned value does not equal to the "
- + "value specified in the constructor.",
- ps.getPSource() == pSrc);
- }
-
- public static Test suite() {
- return new TestSuite(OAEPParameterSpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEKeySpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEKeySpecTest.java
deleted file mode 100644
index 2e23668..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEKeySpecTest.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.util.Arrays;
-
-import javax.crypto.spec.PBEKeySpec;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class PBEKeySpecTest extends TestCase {
-
- /**
- * PBEKeySpec(char[] password) method testing. Tests the behavior of
- * the method in the case of null input char array and tests that input
- * array is copied during the object initialization.
- */
- public void testPBEKeySpec1() {
- try {
- PBEKeySpec pbeks = new PBEKeySpec(null);
- assertTrue("An empty char[] should be used in case of null "
- + "char array.", pbeks.getPassword().length == 0);
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- }
-
- char[] password = new char[] { '1', '2', '3', '4', '5' };
- PBEKeySpec pbeks = new PBEKeySpec(password);
- password[0]++;
- assertFalse("The change of password specified in the constructor "
- + "should not cause the change of internal array.",
- password[0] == pbeks.getPassword()[0]);
- }
-
- /**
- * PBEKeySpec(char[] password, byte[] salt, int iterationCount, int
- * keyLength) method testing. Tests the behavior of the method in the case
- * of inappropriate parameters and checks that array objects specified as
- * a parameters are copied during the object initialization.
- */
- public void testPBEKeySpec2() {
- char[] password = new char[] { '1', '2', '3', '4', '5' };
- byte[] salt = new byte[] { 1, 2, 3, 4, 5 };
- int iterationCount = 10;
- int keyLength = 10;
-
- try {
- PBEKeySpec pbeks = new PBEKeySpec(null, salt,
- iterationCount, keyLength);
- assertTrue("An empty char[] should be used in case of null input "
- + "char array.", pbeks.getPassword().length == 0);
- } catch (IllegalArgumentException e) {
- fail("Unexpected IllegalArgumentException was thrown.");
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- }
-
- try {
- new PBEKeySpec(password, null, iterationCount, keyLength);
- fail("A NullPointerException should be was thrown "
- + "in the case of null salt.");
- } catch (IllegalArgumentException e) {
- fail("Unexpected IllegalArgumentException was thrown.");
- } catch (NullPointerException e) {
- }
-
- try {
- new PBEKeySpec(password, new byte[0], iterationCount, keyLength);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of empty salt.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new PBEKeySpec(password, salt, -1, keyLength);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of negative iterationCount.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new PBEKeySpec(password, salt, iterationCount, -1);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of negative keyLength.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new PBEKeySpec(password, salt, 0, keyLength);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of zero iterationCount.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new PBEKeySpec(password, salt, iterationCount, 0);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of zero keyLength.");
- } catch (IllegalArgumentException e) {
- }
-
- PBEKeySpec pbeks = new PBEKeySpec(password, salt,
- iterationCount, keyLength);
- password[0]++;
- assertFalse("The change of password specified in the constructor "
- + "should not cause the change of internal array.",
- password[0] == pbeks.getPassword()[0]);
- salt[0]++;
- assertFalse("The change of salt specified in the constructor "
- + " should not cause the change of internal array.",
- salt[0] == pbeks.getSalt()[0]);
- }
-
- /**
- * PBEKeySpec(char[] password, byte[] salt, int iterationCount) method
- * testing. Tests the behavior of the method in the case
- * of inappropriate parameters and checks that array objects specified as
- * a parameters are copied during the object initialization.
- */
- public void testPBEKeySpec3() {
- char[] password = new char[] { '1', '2', '3', '4', '5' };
- byte[] salt = new byte[] { 1, 2, 3, 4, 5 };
- int iterationCount = 10;
-
- try {
- PBEKeySpec pbeks = new PBEKeySpec(null, salt, iterationCount);
- assertTrue("An empty char[] should be used in case of null input "
- + "char array.", pbeks.getPassword().length == 0);
- } catch (IllegalArgumentException e) {
- fail("Unexpected IllegalArgumentException was thrown.");
- } catch (NullPointerException e) {
- fail("Unexpected NullPointerException was thrown.");
- }
-
- try {
- new PBEKeySpec(password, null, iterationCount);
- fail("A NullPointerException should be was thrown "
- + "in the case of null salt.");
- } catch (IllegalArgumentException e) {
- fail("Unexpected IllegalArgumentException was thrown.");
- } catch (NullPointerException e) {
- }
-
- try {
- new PBEKeySpec(password, new byte[0],
- iterationCount);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of empty salt.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new PBEKeySpec(password, salt, -1);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of negative iterationCount.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new PBEKeySpec(password, salt, 0);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of zero iterationCount.");
- } catch (IllegalArgumentException e) {
- }
-
- PBEKeySpec pbeks = new PBEKeySpec(password, salt, iterationCount);
- password[0]++;
- assertFalse("The change of password specified in the constructor "
- + "should not cause the change of internal array.",
- password[0] == pbeks.getPassword()[0]);
- salt[0]++;
- assertFalse("The change of salt specified in the constructor "
- + " should not cause the change of internal array.",
- salt[0] == pbeks.getSalt()[0]);
- }
-
- /**
- * clearPassword() method testing. Tests that internal copy of password
- * is cleared after the method call.
- */
- public void testClearPassword() {
- char[] password = new char[] { '1', '2', '3', '4', '5' };
- PBEKeySpec pbeks = new PBEKeySpec(password);
- pbeks.clearPassword();
- try {
- pbeks.getPassword();
- fail("An IllegalStateException should be was thrown "
- + "after the clearing the password.");
- } catch (IllegalStateException e) {
- }
- }
-
- /**
- * getPassword() method testing. Tests that returned password is equal
- * to the password specified in the constructor and that the change of
- * returned array does not cause the change of internal array.
- */
- public void testGetPassword() {
- char[] password = new char[] { '1', '2', '3', '4', '5' };
- PBEKeySpec pbeks = new PBEKeySpec(password);
- char[] result = pbeks.getPassword();
- if (!Arrays.equals(password, result)) {
- fail("The returned password is not equal to the specified "
- + "in the constructor.");
- }
- result[0]++;
- assertFalse("The change of returned by getPassword() method password "
- + "should not cause the change of internal array.",
- result[0] == pbeks.getPassword()[0]);
- }
-
- /**
- * getSalt() method testing. Tests that returned salt is equal
- * to the salt specified in the constructor and that the change of
- * returned array does not cause the change of internal array.
- * Also it checks that the method returns null if salt is not
- * specified.
- */
- public void testGetSalt() {
- char[] password = new char[] { '1', '2', '3', '4', '5' };
- byte[] salt = new byte[] { 1, 2, 3, 4, 5 };
- int iterationCount = 10;
- PBEKeySpec pbeks = new PBEKeySpec(password, salt, iterationCount);
- byte[] result = pbeks.getSalt();
- if (!Arrays.equals(salt, result)) {
- fail("The returned salt is not equal to the specified "
- + "in the constructor.");
- }
- result[0]++;
- assertFalse("The change of returned by getSalt() method salt"
- + "should not cause the change of internal array.",
- result[0] == pbeks.getSalt()[0]);
- pbeks = new PBEKeySpec(password);
- assertNull("The getSalt() method should return null if the salt "
- + "is not specified.", pbeks.getSalt());
- }
-
- /**
- * getIterationCount() method testing. Tests that returned value is equal
- * to the value specified in the constructor.
- * Also it checks that the method returns 0 if iterationCount is not
- * specified.
- */
- public void testGetIterationCount() {
- char[] password = new char[] { '1', '2', '3', '4', '5' };
- byte[] salt = new byte[] { 1, 2, 3, 4, 5 };
- int iterationCount = 10;
- PBEKeySpec pbeks = new PBEKeySpec(password, salt, iterationCount);
- assertTrue("The returned iterationCount is not equal to the specified "
- + "in the constructor.",
- pbeks.getIterationCount() == iterationCount);
- pbeks = new PBEKeySpec(password);
- assertTrue("The getIterationCount() method should return 0 "
- + "if the iterationCount is not specified.",
- pbeks.getIterationCount() == 0);
- }
-
- /**
- * getKeyLength() method testing.
- */
- public void testGetKeyLength() {
- char[] password = new char[] { '1', '2', '3', '4', '5' };
- byte[] salt = new byte[] { 1, 2, 3, 4, 5 };
- int iterationCount = 10;
- int keyLength = 10;
- PBEKeySpec pbeks = new PBEKeySpec(password, salt,
- iterationCount, keyLength);
- assertTrue("The returned keyLength is not equal to the value specified "
- + "in the constructor.",
- pbeks.getKeyLength() == keyLength);
- pbeks = new PBEKeySpec(password);
- assertTrue("The getKeyLength() method should return 0 "
- + "if the keyLength is not specified.",
- pbeks.getKeyLength() == 0);
- }
-
- public static Test suite() {
- return new TestSuite(PBEKeySpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEParameterSpecTest.java
deleted file mode 100644
index f9c2230..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEParameterSpecTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.util.Arrays;
-
-import javax.crypto.spec.PBEParameterSpec;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class PBEParameterSpecTest extends TestCase {
-
- /**
- * PBEParameterSpec(byte[] salt, int iterationCount) method testing.
- * Tests the behavior of the method in the case of null input array
- * and tests that input array is copied during the object initialization.
- */
- public void testPBEParameterSpec() {
- byte[] salt = { 1, 2, 3, 4, 5 };
- int iterationCount = 10;
-
- try {
- new PBEParameterSpec(null, iterationCount);
- fail("A NullPointerException should be was thrown "
- + "in the case of null salt.");
- } catch (NullPointerException e) {
- }
-
- PBEParameterSpec pbeps = new PBEParameterSpec(salt, iterationCount);
- salt[0]++;
- assertFalse("The change of salt specified in the constructor "
- + "should not cause the change of internal array.",
- salt[0] == pbeps.getSalt()[0]);
- }
-
- /**
- * getSalt() method testing. Tests that returned salt is equal
- * to the salt specified in the constructor and that the change of
- * returned array does not cause the change of internal array.
- */
- public void testGetSalt() {
- byte[] salt = new byte[] { 1, 2, 3, 4, 5 };
- int iterationCount = 10;
- PBEParameterSpec pbeps = new PBEParameterSpec(salt, iterationCount);
- byte[] result = pbeps.getSalt();
- if (!Arrays.equals(salt, result)) {
- fail("The returned salt is not equal to the specified "
- + "in the constructor.");
- }
- result[0]++;
- assertFalse("The change of returned by getSalt() method salt"
- + "should not cause the change of internal array.",
- result[0] == pbeps.getSalt()[0]);
- }
-
- /**
- * getIterationCount() method testing. Tests that returned value is equal
- * to the value specified in the constructor.
- */
- public void testGetIterationCount() {
- byte[] salt = new byte[] { 1, 2, 3, 4, 5 };
- int iterationCount = 10;
- PBEParameterSpec pbeps = new PBEParameterSpec(salt, iterationCount);
- assertTrue("The returned iterationCount is not equal to the specified "
- + "in the constructor.",
- pbeps.getIterationCount() == iterationCount);
- }
-
- public static Test suite() {
- return new TestSuite(PBEParameterSpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC2ParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC2ParameterSpecTest.java
deleted file mode 100644
index d7d6c35..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC2ParameterSpecTest.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.lang.IllegalArgumentException;
-import java.util.Arrays;
-
-import javax.crypto.spec.RC2ParameterSpec;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class RC2ParameterSpecTest extends TestCase {
-
- /**
- * RC2ParameterSpec(int effectiveKeyBits, byte[] iv) method testing.
- * Tests that IllegalArgumentException is thrown in the case of
- * inappropriate constructor parameters and that input iv array is
- * copied to protect against subsequent modification.
- */
- public void testRC2ParameterSpec1() {
- int effectiveKeyBits = 10;
- byte[] iv = { 1, 2, 3, 4, 5, 6, 7, 8 };
-
- try {
- new RC2ParameterSpec(effectiveKeyBits, null);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of null iv.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new RC2ParameterSpec(effectiveKeyBits, new byte[] { 1, 2, 3, 4, 5 });
- fail("An IllegalArgumentException should be thrown "
- + "in the case of short iv.");
- } catch (IllegalArgumentException e) {
- }
-
- RC2ParameterSpec ps = new RC2ParameterSpec(effectiveKeyBits, iv);
- iv[0]++;
- assertFalse("The change of iv specified in the constructor "
- + "should not cause the change of internal array.",
- iv[0] == ps.getIV()[0]);
- }
-
- /**
- * RC2ParameterSpec(int effectiveKeyBits, byte[] iv, int offset) method
- * testing. Tests that IllegalArgumentException is thrown in the case of
- * inappropriate constructor parameters and that input iv array is
- * copied to protect against subsequent modification.
- */
- public void testRC2ParameterSpec2() {
- int effectiveKeyBits = 10;
- byte[] iv = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
- int offset = 2;
-
- try {
- new RC2ParameterSpec(effectiveKeyBits, null, offset);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of null iv.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new RC2ParameterSpec(effectiveKeyBits, iv, 4);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of short iv.");
- } catch (IllegalArgumentException e) {
- }
-
- RC2ParameterSpec ps = new RC2ParameterSpec(effectiveKeyBits, iv, offset);
- iv[offset]++;
- assertFalse("The change of iv specified in the constructor "
- + "should not cause the change of internal array.",
- iv[offset] == ps.getIV()[0]);
- }
-
- /**
- * getEffectiveKeyBits() method testing. Tests that returned value is
- * equal to the value specified in the constructor.
- */
- public void testGetEffectiveKeyBits() {
- int effectiveKeyBits = 10;
- byte[] iv = { 1, 2, 3, 4, 5, 6, 7, 8 };
-
- RC2ParameterSpec ps = new RC2ParameterSpec(effectiveKeyBits, iv);
- assertTrue("The returned effectiveKeyBits value is not equal to the "
- + "value specified in the constructor.",
- effectiveKeyBits == ps.getEffectiveKeyBits());
- }
-
- /**
- * getIV() method testing. Tests that returned array is equal to the
- * array specified in the constructor. Checks that modification
- * of returned array does not affect the internal array. Also it checks
- * that getIV() method returns null if iv is not specified.
- */
- public void testGetIV() {
- int effectiveKeyBits = 10;
- byte[] iv = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
-
- RC2ParameterSpec ps = new RC2ParameterSpec(effectiveKeyBits, iv);
- byte[] result = ps.getIV();
- if (!Arrays.equals(iv, result)) {
- fail("The returned iv is not equal to the specified "
- + "in the constructor.");
- }
- result[0]++;
- assertFalse("The change of returned by getIV() method iv "
- + "should not cause the change of internal array.",
- result[0] == ps.getIV()[0]);
- ps = new RC2ParameterSpec(effectiveKeyBits);
- assertNull("The getIV() method should return null if the parameter "
- + "set does not contain iv.", ps.getIV());
- }
-
- /**
- * equals(Object obj) method testing. Tests the correctness of equal
- * operation: it should be reflexive, symmetric, transitive, consistent
- * and should be false on null object.
- */
- public void testEquals() {
- int effectiveKeyBits = 10;
- byte[] iv = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
-
- RC2ParameterSpec ps1 = new RC2ParameterSpec(effectiveKeyBits, iv);
- RC2ParameterSpec ps2 = new RC2ParameterSpec(effectiveKeyBits, iv);
- RC2ParameterSpec ps3 = new RC2ParameterSpec(10,
- new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
-
- // checking for reflexive law:
- assertTrue("The equivalence relation should be reflexive.",
- ps1.equals(ps1));
-
- assertTrue("Objects built on the same parameters should be equal.",
- ps1.equals(ps2));
- // checking for symmetric law:
- assertTrue("The equivalence relation should be symmetric.",
- ps2.equals(ps1));
-
- assertTrue("Objects built on the equal parameters should be equal.",
- ps2.equals(ps3));
-
- // checking for transitive law:
- assertTrue("The equivalence relation should be transitive.",
- ps1.equals(ps3));
-
- assertFalse("Should return not be equal to null object.",
- ps1.equals(null));
-
- ps2 = new RC2ParameterSpec(11, iv);
- assertFalse("Objects should not be equal.", ps1.equals(ps2));
-
- ps2 = new RC2ParameterSpec(11, new byte[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 });
- assertFalse("Objects should not be equal.", ps1.equals(ps2));
- }
-
- /**
- * hashCode() method testing. Tests that for equal objects hash codes
- * are equal.
- */
- public void testHashCode() {
- int effectiveKeyBits = 0;
- byte[] iv = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
-
- RC2ParameterSpec ps1 = new RC2ParameterSpec(effectiveKeyBits, iv);
- RC2ParameterSpec ps2 = new RC2ParameterSpec(effectiveKeyBits, iv);
-
- assertTrue("Equal objects should have the same hash codes.",
- ps1.hashCode() == ps2.hashCode());
- }
-
- public static Test suite() {
- return new TestSuite(RC2ParameterSpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java
deleted file mode 100644
index c5c63a6..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.util.Arrays;
-
-import javax.crypto.spec.RC5ParameterSpec;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class RC5ParameterSpecTest extends TestCase {
-
- /**
- * RC5ParameterSpec(int version, int rounds, int wordSize, byte[] iv) method
- * testing. Tests that IllegalArgumentException is thrown in the case of
- * inappropriate constructor parameters and that input iv array is
- * copied to protect against subsequent modification.
- */
- public void testRC5ParameterSpec1() {
- int version = 1;
- int rounds = 5;
- int wordSize = 16;
- byte[] iv = { 1, 2, 3, 4 };
-
- try {
- new RC5ParameterSpec(version, rounds, wordSize, null);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of null iv.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new RC5ParameterSpec(version, rounds, wordSize + 8, iv);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of short iv.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new RC5ParameterSpec(version, rounds, wordSize, new byte[] { 1, 2, 3 });
- fail("An IllegalArgumentException should be thrown "
- + "in the case of short iv.");
- } catch (IllegalArgumentException e) {
- }
-
- RC5ParameterSpec ps = new RC5ParameterSpec(version, rounds,
- wordSize, iv);
- iv[0]++;
- assertFalse("The change of iv specified in the constructor "
- + "should not cause the change of internal array.",
- iv[0] == ps.getIV()[0]);
- }
-
- /**
- * RC5ParameterSpec(int version, int rounds, int wordSize, byte[] iv, int
- * offset) method testing. Tests that IllegalArgumentException is thrown in
- * the case of inappropriate constructor parameters and that input iv array
- * is copied to protect against subsequent modification.
- */
- public void testRC5ParameterSpec2() {
- int version = 1;
- int rounds = 5;
- int wordSize = 16;
- byte[] iv = { 1, 2, 3, 4, 5, 6 };
- int offset = 2;
-
- try {
- new RC5ParameterSpec(version, rounds, wordSize, null, offset);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of null iv.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new RC5ParameterSpec(version, rounds, wordSize + 8, iv, offset);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of short iv.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new RC5ParameterSpec(version, rounds, wordSize, iv, offset + 1);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of short iv.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new RC5ParameterSpec(version, rounds, wordSize, new byte[] { 1, 2,
- 3, 4 }, offset);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of short iv.");
- } catch (IllegalArgumentException e) {
- }
-
- RC5ParameterSpec ps = new RC5ParameterSpec(version, rounds, wordSize,
- iv, offset);
- iv[offset]++;
- assertFalse("The change of iv specified in the constructor "
- + "should not cause the change of internal array.",
- iv[offset] == ps.getIV()[0]);
-
- // Regression test for HARMONY-1077
- try {
- new RC5ParameterSpec(0, 9, 77, new byte[] { 2 }, -100);
- fail("ArrayIndexOutOfBoundsException expected");
- } catch (ArrayIndexOutOfBoundsException e) {
- // expected
- }
- }
-
- /**
- * getVersion() method testing. Tests that returned value is
- * equal to the value specified in the constructor.
- */
- public void testGetVersion() {
- int version = 1;
- int rounds = 5;
- int wordSize = 16;
-
- RC5ParameterSpec ps = new RC5ParameterSpec(version, rounds, wordSize);
- assertTrue("The returned version value should be equal to the "
- + "value specified in the constructor.",
- ps.getVersion() == version);
- }
-
- /**
- * getRounds() method testing. Tests that returned value is
- * equal to the value specified in the constructor.
- */
- public void testGetRounds() {
- int version = 1;
- int rounds = 5;
- int wordSize = 16;
-
- RC5ParameterSpec ps = new RC5ParameterSpec(version, rounds, wordSize);
- assertTrue("The returned rounds value should be equal to the "
- + "value specified in the constructor.",
- ps.getRounds() == rounds);
- }
-
- /**
- * getWordSize() method testing. Tests that returned value is
- * equal to the value specified in the constructor.
- */
- public void testGetWordSize() {
- int version = 1;
- int rounds = 5;
- int wordSize = 16;
-
- RC5ParameterSpec ps = new RC5ParameterSpec(version, rounds, wordSize);
- assertTrue("The returned wordSize value should be equal to the "
- + "value specified in the constructor.",
- ps.getWordSize() == wordSize);
- }
-
- /**
- * getIV() method testing. Tests that returned array is equal to the
- * array specified in the constructor. Checks that modification
- * of returned array does not affect the internal array. Also it checks
- * that getIV() method returns null if iv is not specified.
- */
- public void testGetIV() {
- int version = 1;
- int rounds = 5;
- int wordSize = 16;
- byte[] iv = { 1, 2, 3, 4 };
-
- RC5ParameterSpec ps = new RC5ParameterSpec(version, rounds,
- wordSize, iv);
- byte[] result = ps.getIV();
- if (!Arrays.equals(iv, result)) {
- fail("The returned iv is not equal to the specified "
- + "in the constructor.");
- }
- result[0]++;
- assertFalse("The change of returned by getIV() method iv "
- + "should not cause the change of internal array.",
- result[0] == ps.getIV()[0]);
- ps = new RC5ParameterSpec(version, rounds, wordSize);
- assertNull("The getIV() method should return null if the parameter "
- + "set does not contain IV.", ps.getIV());
- }
-
- /**
- * equals(Object obj) method testing. Tests the correctness of equal
- * operation: it should be reflexive, symmetric, transitive, consistent
- * and should be false on null object.
- */
- public void testEquals() {
- int version = 1;
- int rounds = 5;
- int wordSize = 16;
- byte[] iv = { 1, 2, 3, 4, 5, 6 };
-
- RC5ParameterSpec ps1 = new RC5ParameterSpec(version, rounds,
- wordSize, iv);
- RC5ParameterSpec ps2 = new RC5ParameterSpec(version, rounds,
- wordSize, iv);
- RC5ParameterSpec ps3 = new RC5ParameterSpec(version, rounds, wordSize,
- new byte[] { 1, 2, 3, 4 });
- // checking for reflexive law:
- assertTrue("The equivalence relation should be reflexive.",
- ps1.equals(ps1));
-
- assertTrue("Objects built on the same parameters should be equal.",
- ps1.equals(ps2));
- // checking for symmetric law:
- assertTrue("The equivalence relation should be symmetric.",
- ps2.equals(ps1));
-
- assertTrue("Objects built on the equal parameters should be equal.",
- ps2.equals(ps3));
-
- // checking for transitive law:
- assertTrue("The equivalence relation should be transitive.",
- ps1.equals(ps3));
-
- assertFalse("Should return not be equal to null object.",
- ps1.equals(null));
-
- ps2 = new RC5ParameterSpec(version + 1, rounds, wordSize, iv);
- assertFalse("Objects should not be equal.", ps1.equals(ps2));
-
- ps2 = new RC5ParameterSpec(version, rounds + 1, wordSize, iv);
- assertFalse("Objects should not be equal.", ps1.equals(ps2));
-
- ps2 = new RC5ParameterSpec(version, rounds, wordSize / 2, iv);
- assertFalse("Objects should not be equal.", ps1.equals(ps2));
-
- ps2 = new RC5ParameterSpec(version, rounds, wordSize,
- new byte[] { 4, 3, 2, 1 });
- assertFalse("Objects should not be equal.", ps1.equals(ps2));
- }
-
- /**
- * hashCode() method testing. Tests that for equal objects hash codes
- * are equal.
- */
- public void testHashCode() {
- int version = 1;
- int rounds = 5;
- int wordSize = 16;
- byte[] iv = { 1, 2, 3, 4, 5, 6 };
-
- RC5ParameterSpec ps1 = new RC5ParameterSpec(version, rounds,
- wordSize, iv);
- RC5ParameterSpec ps2 = new RC5ParameterSpec(version, rounds,
- wordSize, iv);
- assertTrue("Equal objects should have the same hash codes.",
- ps1.hashCode() == ps2.hashCode());
- }
-
- public static Test suite() {
- return new TestSuite(RC5ParameterSpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java
deleted file mode 100644
index 4b61174..0000000
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto.spec;
-
-import java.util.Arrays;
-
-import javax.crypto.spec.SecretKeySpec;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class SecretKeySpecTest extends TestCase {
-
- /**
- * SecretKeySpec(byte[] key, String algorithm) method testing. Tests that
- * IllegalArgumentException is thrown in the case of inappropriate
- * constructor parameters and that input iv array is
- * copied to protect against subsequent modification.
- */
- public void testSecretKeySpec1() {
- byte[] key = new byte[] { 1, 2, 3, 4, 5 };
- String algorithm = "Algorithm";
-
- try {
- new SecretKeySpec(new byte[] { }, algorithm);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of empty key.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new SecretKeySpec(null, algorithm);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of null key.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new SecretKeySpec(key, null);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of null algorithm.");
- } catch (IllegalArgumentException e) {
- }
-
- SecretKeySpec ks = new SecretKeySpec(key, algorithm);
- key[0]++;
- assertFalse("The change of key specified in the constructor "
- + "should not cause the change of internal array.",
- key[0] == ks.getEncoded()[0]);
- }
-
- /**
- * SecretKeySpec(byte[] key, int offset, int len, String algorithm) method
- * testing. Tests that IllegalArgumentException is thrown in
- * the case of inappropriate constructor parameters and that input iv array
- * is copied to protect against subsequent modification.
- */
- public void testSecretKeySpec2() {
- byte[] key = new byte[] { 1, 2, 3, 4, 5 };
- int offset = 1;
- int len = 4;
- String algorithm = "Algorithm";
-
- try {
- new SecretKeySpec(new byte[] { }, 0, 0, algorithm);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of empty key.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new SecretKeySpec(null, 0, 0, algorithm);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of null key.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new SecretKeySpec(key, offset, len, null);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of short key algorithm.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new SecretKeySpec(key, offset, key.length, algorithm);
- fail("An IllegalArgumentException should be thrown "
- + "when offset and len specify an invalid chunk of key.");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- new SecretKeySpec(key, -1, key.length, algorithm);
- fail("An ArrayIndexOutOfBoundsException should be thrown "
- + "in the case of negative offset.");
- } catch (IllegalArgumentException e) {
- fail("Not expected IllegalArgumentException was thrown.");
- } catch (ArrayIndexOutOfBoundsException e) {
- }
-
- // BEGIN Android-removed: Unnecessarily specific test
- // This is illegal for three reasons (key too short, invalid offset, invalid length),
- // and the spec doesn't specify which exception should be thrown if multiple are
- // valid. We happen to throw IllegalArgumentException, which is allowed behavior.
- /*
- // Regression test for HARMONY-6347
- try {
- new SecretKeySpec(key, -1, key.length + 2, algorithm);
- fail("An ArrayIndexOutOfBoundsException should be thrown "
- + "in the case of negative offset.");
- } catch (IllegalArgumentException e) {
- fail("Not expected IllegalArgumentException was thrown.");
- } catch (ArrayIndexOutOfBoundsException e) {
- }
- */
- // END Android-removed: Unnecessarily specific test
-
-
- try {
- new SecretKeySpec(key, offset, len, null);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of null algorithm.");
- } catch (IllegalArgumentException e) {
- }
-
- SecretKeySpec ks = new SecretKeySpec(key, algorithm);
- key[offset]++;
- assertFalse("The change of key specified in the constructor "
- + "should not cause the change of internal array.",
- key[offset] == ks.getEncoded()[0]);
-
- // Regression test for HARMONY-1077
- try {
- new SecretKeySpec(new byte[] { 2 }, 4, -100, "CCC");
- fail("ArrayIndexOutOfBoundsException expected");
- } catch (ArrayIndexOutOfBoundsException e) {
- //expected
- }
- }
-
- /**
- * getAlgorithm() method testing. Tests that returned value is
- * equal to the value specified in the constructor.
- */
- public void testGetAlgorithm() {
- byte[] key = new byte[] { 1, 2, 3, 4, 5 };
- String algorithm = "Algorithm";
-
- SecretKeySpec ks = new SecretKeySpec(key, algorithm);
- assertEquals("The returned value does not equal to the "
- + "value specified in the constructor.",
- algorithm, ks.getAlgorithm());
- }
-
- /**
- * getFormat() method testing. Tests that returned value is "RAW".
- */
- public void testGetFormat() {
- byte[] key = new byte[] { 1, 2, 3, 4, 5 };
- String algorithm = "Algorithm";
-
- SecretKeySpec ks = new SecretKeySpec(key, algorithm);
- assertTrue("The returned value is not \"RAW\".",
- ks.getFormat() == "RAW");
- }
-
- /**
- * getEncoded() method testing. Tests that returned array is equal to the
- * array specified in the constructor. Checks that modification
- * of returned array does not affect the internal array.
- */
- public void testGetEncoded() {
- byte[] key = new byte[] { 1, 2, 3, 4, 5 };
- String algorithm = "Algorithm";
-
- SecretKeySpec ks = new SecretKeySpec(key, algorithm);
- byte[] result = ks.getEncoded();
- if (!Arrays.equals(key, result)) {
- fail("The returned key does not equal to the specified "
- + "in the constructor.");
- }
- result[0]++;
- assertFalse("The change of returned by getEncoded() method key "
- + "should not cause the change of internal array.",
- result[0] == ks.getEncoded()[0]);
-
- // Regression for HARMONY-78
- int offset = 1;
- int len = 4;
- SecretKeySpec sks = new SecretKeySpec(key, offset, len, algorithm);
- assertEquals("Key length is incorrect", len, sks.getEncoded().length);
- }
-
- /**
- * hashCode() method testing. Tests that for equal objects hash codes
- * are equal.
- */
- public void testHashCode() {
- byte[] key = new byte[] { 1, 2, 3, 4, 5 };
- String algorithm = "Algorithm";
-
- SecretKeySpec ks1 = new SecretKeySpec(key, algorithm);
- SecretKeySpec ks2 = new SecretKeySpec(key, algorithm);
- assertTrue("Equal objects should have the same hash codes.",
- ks1.hashCode() == ks2.hashCode());
- }
-
- /**
- * equals(Object obj) method testing. Tests the correctness of equal
- * operation: it should be reflexive, symmetric, transitive, consistent
- * and should be false on null object.
- */
- public void testEquals() {
- byte[] key = new byte[] { 1, 2, 3, 4, 5 };
- String algorithm = "Algorithm";
-
- SecretKeySpec ks1 = new SecretKeySpec(key, algorithm);
- SecretKeySpec ks2 = new SecretKeySpec(key, algorithm);
- SecretKeySpec ks3 = new SecretKeySpec(key, algorithm);
-
- // checking for reflexive law:
- assertTrue("The equivalence relation should be reflexive.",
- ks1.equals(ks1));
-
- assertTrue("Objects built on the same parameters should be equal.",
- ks1.equals(ks2));
- // checking for symmetric law:
- assertTrue("The equivalence relation should be symmetric.",
- ks2.equals(ks1));
-
- assertTrue("Objects built on the equal parameters should be equal.",
- ks2.equals(ks3));
- // checking for transitive law:
- assertTrue("The equivalence relation should be transitive.",
- ks1.equals(ks3));
-
- assertFalse("Should not be equal to null object.",
- ks1.equals(null));
-
- ks2 = new SecretKeySpec(new byte[] { 1 }, algorithm);
- assertFalse("Objects should not be equal.", ks1.equals(ks2));
-
- ks2 = new SecretKeySpec(key, "Another Algorithm");
- assertFalse("Objects should not be equal.", ks1.equals(ks2));
- }
-
- public static Test suite() {
- return new TestSuite(SecretKeySpecTest.class);
- }
-
-}
diff --git a/crypto/src/test/impl/java.injected/org/apache/harmony/crypto/internal/NullCipherSpiTest.java b/crypto/src/test/impl/java.injected/org/apache/harmony/crypto/internal/NullCipherSpiTest.java
deleted file mode 100644
index 845b0d3..0000000
--- a/crypto/src/test/impl/java.injected/org/apache/harmony/crypto/internal/NullCipherSpiTest.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.crypto.internal;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
-import javax.crypto.ShortBufferException;
-
-import org.apache.harmony.crypto.internal.NullCipherSpi;
-import junit.framework.TestCase;
-
-/**
- * Tests for NullCipher implementation
- */
-public class NullCipherSpiTest extends TestCase {
-
- public void testEngineGetBlockSize() {
- NullCipherSpi spi = new NullCipherSpi();
- assertEquals("incorrect block size", 1, spi.engineGetBlockSize());
- }
-
- public void testEngineGetOutputSize() {
- NullCipherSpi spi = new NullCipherSpi();
- assertEquals("incorrect output size", 100, spi.engineGetOutputSize(100));
- }
-
- public void testEngineGetIV() {
- NullCipherSpi spi = new NullCipherSpi();
- assertTrue("Incorrect IV", Arrays.equals(spi.engineGetIV(), new byte[8]));
- }
-
- /*
- * Class under test for byte[] engineUpdate(byte[], int, int)
- */
- public void testEngineUpdatebyteArrayintint() {
- NullCipherSpi spi = new NullCipherSpi();
- byte[] b = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- byte[] b1 = spi.engineUpdate(b, 3, 4);
- for (int i = 0; i < 4; i++) {
- assertEquals("incorrect update result", b[3 + i], b1[i]);
- }
- }
-
- /*
- * Class under test for int engineUpdate(byte[], int, int, byte[], int)
- */
- public void testEngineUpdatebyteArrayintintbyteArrayint() throws Exception {
- NullCipherSpi spi = new NullCipherSpi();
- byte[] b = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- byte[] b1 = new byte[10];
- assertEquals("incorrect update result", 4, spi.engineUpdate(b, 3, 4, b1, 5));
- for (int i = 0; i < 4; i++) {
- assertEquals("incorrect update result", b[3 + i], b1[5 + i]);
- }
- }
-
- /*
- * Class under test for byte[] engineDoFinal(byte[], int, int)
- */
- public void testEngineDoFinalbyteArrayintint() throws Exception {
- NullCipherSpi spi = new NullCipherSpi();
- byte[] b = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- byte[] b1 = null;
- b1 = spi.engineDoFinal(b, 3, 4);
- for (int i = 0; i < 4; i++) {
- assertEquals("incorrect doFinal result", b[3 + i], b1[i]);
- }
- }
-
- /*
- * Class under test for int engineDoFinal(byte[], int, int, byte[], int)
- */
- public void testEngineDoFinalbyteArrayintintbyteArrayint() throws Exception {
- NullCipherSpi spi = new NullCipherSpi();
- byte[] b = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- byte[] b1 = new byte[10];
- assertEquals("incorrect doFinal result", 4, spi.engineDoFinal(b, 3, 4, b1, 5));
- for (int i = 0; i < 4; i++) {
- assertEquals("incorrect doFinal result", b[3 + i], b1[5 + i]);
- }
-
- }
-
- /*
- * Class under test for int engineUpdate(ByteBuffer, ByteBuffer)
- */
- public void testEngineUpdateByteBufferByteBuffer() throws Exception {
- NullCipherSpi spi = new NullCipherSpi();
- byte[] b = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
-
- ByteBuffer inbuf = ByteBuffer.wrap(b, 0, b.length);
- ByteBuffer outbuf = ByteBuffer.allocate(6);
-
- try {
- spi.engineUpdate(null, outbuf);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- try {
- spi.engineUpdate(inbuf, null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- inbuf.get();
- inbuf.get();
- inbuf.get();
- inbuf.get();
- int result = spi.engineUpdate(inbuf, outbuf);
- assertEquals("incorrect result", b.length - 4, result);
- for (int i = 0; i < result; i++) {
- assertEquals("incorrect outbuf", i + 4, outbuf.get(i));
- }
-
- inbuf = ByteBuffer.wrap(b, 0, b.length);
- outbuf = ByteBuffer.allocate(5);
- inbuf.get();
- inbuf.get();
- inbuf.get();
- inbuf.get();
- try {
- spi.engineUpdate(inbuf, outbuf);
- fail("No expected ShortBufferException");
- } catch (ShortBufferException e) {
- }
- }
-
- /*
- * Class under test for int engineDoFinal(ByteBuffer, ByteBuffer)
- */
- public void testEngineDoFinalByteBufferByteBuffer() throws Exception {
- NullCipherSpi spi = new NullCipherSpi();
- byte[] b = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
-
- ByteBuffer inbuf = ByteBuffer.wrap(b, 0, b.length);
- ByteBuffer outbuf = ByteBuffer.allocate(6);
-
- try {
- spi.engineDoFinal(null, outbuf);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- try {
- spi.engineDoFinal(inbuf, null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- inbuf.get();
- inbuf.get();
- inbuf.get();
- inbuf.get();
- int result = spi.engineDoFinal(inbuf, outbuf);
- assertEquals("incorrect result", b.length - 4, result);
- for (int i = 0; i < result; i++) {
- assertEquals("incorrect outbuf", i + 4, outbuf.get(i));
- }
-
- inbuf = ByteBuffer.wrap(b, 0, b.length);
- outbuf = ByteBuffer.allocate(5);
- inbuf.get();
- inbuf.get();
- inbuf.get();
- inbuf.get();
- try {
- spi.engineDoFinal(inbuf, outbuf);
- fail("No expected ShortBufferException");
- } catch (ShortBufferException e) {
- }
- }
-
- /*
- * Class under test for byte[] engineWrap(Key)
- */
- public void testEngineWrapKey() throws Exception {
- NullCipherSpi spi = new NullCipherSpi();
- try {
- spi.engineWrap(null);
- fail("No expected UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
- }
- }
-
- /*
- * Class under test for Key engineUnwrap(byte[], String, int)
- */
- public void testEngineUnwrapbyteArrayStringint() throws Exception {
- NullCipherSpi spi = new NullCipherSpi();
- try {
- spi.engineUnwrap(new byte[3], "", 10);
- fail("No expected UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
- }
- }
-
- /*
- * Class under test for int engineGetKeySize(Key)
- */
- public void testEngineGetKeySize() throws Exception {
- NullCipherSpi spi = new NullCipherSpi();
- try {
- spi.engineGetKeySize(null);
- fail("No expected UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
- }
- }
-
-}
diff --git a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_Impl1Test.java b/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_Impl1Test.java
deleted file mode 100644
index e761a6d..0000000
--- a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_Impl1Test.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.AlgorithmParameters;
-import java.security.Key;
-import java.security.SecureRandom;
-import java.util.Arrays;
-
-import javax.crypto.Cipher;
-import javax.crypto.KeyGenerator;
-
-public class Cipher_Impl1Test extends junit.framework.TestCase {
-
- static Key cipherKey;
- final static String algorithm = "DESede";
- final static int keyLen = 168;
-
- static {
- try {
- KeyGenerator kg = KeyGenerator.getInstance(algorithm);
- kg.init(keyLen, new SecureRandom());
- cipherKey = kg.generateKey();
- } catch (Exception e) {
- fail("No key " + e);
- }
- }
-
-
- /**
- * @tests javax.crypto.Cipher#getIV()
- * @tests javax.crypto.Cipher#init(int, java.security.Key,
- *java.security.AlgorithmParameters)
- */
- public void test_getIV() throws Exception {
- /*
- * If this test is changed, implement the following:
- * test_initILjava_security_KeyLjava_security_AlgorithmParameters()
- */
-
- SecureRandom sr = new SecureRandom();
- Cipher cipher = null;
-
- byte[] iv = new byte[8];
- sr.nextBytes(iv);
- AlgorithmParameters ap = AlgorithmParameters.getInstance(algorithm);
- ap.init(iv, "RAW");
-
- cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding");
- cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ap);
-
- byte[] cipherIV = cipher.getIV();
-
- assertTrue("IVs differ", Arrays.equals(cipherIV, iv));
- }
-
- /**
- * @tests javax.crypto.Cipher#getParameters()
- * @tests javax.crypto.Cipher#init(int, java.security.Key,
- *java.security.AlgorithmParameters, java.security.SecureRandom)
- */
- public void test_getParameters() throws Exception {
-
- /*
- * If this test is changed, implement the following:
- * test_initILjava_security_KeyLjava_security_AlgorithmParametersLjava_security_SecureRandom()
- */
-
- SecureRandom sr = new SecureRandom();
- Cipher cipher = null;
-
- byte[] apEncoding = null;
-
- byte[] iv = new byte[8];
- sr.nextBytes(iv);
-
- AlgorithmParameters ap = AlgorithmParameters.getInstance("DESede");
- ap.init(iv, "RAW");
- apEncoding = ap.getEncoded("ASN.1");
-
- cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding");
- cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ap, sr);
-
- byte[] cipherParmsEnc = cipher.getParameters().getEncoded("ASN.1");
- assertTrue("Parameters differ", Arrays.equals(apEncoding,
- cipherParmsEnc));
- }
-}
diff --git a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_ImplTest.java b/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_ImplTest.java
deleted file mode 100644
index daf2bfd..0000000
--- a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_ImplTest.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.Cipher;
-import javax.crypto.NoSuchPaddingException;
-
-import org.apache.harmony.security.tests.support.TestKeyPair;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>Cipher</code> class constructors and methods.
- */
-public class Cipher_ImplTest extends TestCase {
-
- private Provider p1;
- private Provider p2;
- private TestKeyPair tkp = null;
- private Key key = null;
-
- private boolean noKey = false;
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- p1 = new MyProvider1();
- p2 = new MyProvider2();
- Security.insertProviderAt(p1, 1);
- Security.insertProviderAt(p2, 1);
- try {
- tkp = new TestKeyPair("DSA");
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- noKey = true;
- return;
- }
-
- try {
- key = tkp.getPrivate();
- } catch (InvalidKeySpecException e) {
- e.printStackTrace();
- noKey = true;
- return;
- }
-
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider("MyProvider1");
- Security.removeProvider("MyProvider2");
- }
-
- /*
- * Class under test for Cipher getInstance(String)
- */
- public void testGetInstanceString1() throws NoSuchAlgorithmException,
- NoSuchPaddingException {
-
- Cipher c = Cipher.getInstance("DES");
- assertSame(p2, c.getProvider());
- }
-
- /*
- * Class under test for Cipher getInstance(String)
- */
- public void testGetInstanceString2() throws NoSuchAlgorithmException,
- NoSuchPaddingException {
-
- Cipher c = Cipher.getInstance("DES/CBC/PKCS5Padding");
- assertSame("Case1:", p1, c.getProvider());
-
- Security.removeProvider(p1.getName());
-
- c = Cipher.getInstance("DES/CBC/PKCS5Padding");
- assertSame("Case2:", p2, c.getProvider());
- }
-
- /*
- * Class under test for Cipher getInstance(String)
- */
- public void testGetInstanceString3() throws NoSuchAlgorithmException,
- NoSuchPaddingException {
-
- try {
- Cipher.getInstance("DES/CBC/");
- fail("Case1: No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
-
- try {
- Cipher.getInstance("DES//PKCS5Padding");
- fail("Case2: No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
-
- try {
- Cipher.getInstance("DES/CBC/IncorrectPadding");
- fail("No expected NoSuchPaddingException");
- } catch (NoSuchPaddingException e) {
- }
- }
-
-
- /*
- * Class under test for Cipher getInstance(String, String)
- */
- public void testGetInstanceStringString1() throws NoSuchAlgorithmException,
- NoSuchProviderException, NoSuchPaddingException {
-
- try {
- Cipher.getInstance("DES/CBC/", "MyProvider2");
- fail("Case1: No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
-
- try {
- Cipher.getInstance("DES//PKCS5Padding", "MyProvider2");
- fail("Case2: No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
-
- try {
- Cipher.getInstance("DES/CBC/IncorrectPadding", "MyProvider2");
- fail("No expected NoSuchPaddingException");
- } catch (NoSuchPaddingException e) {
- }
-
- try {
- Cipher.getInstance("DES/CBC/PKCS5Padding", "IncorrectProvider");
- fail("No expected NoSuchProviderException");
- } catch (NoSuchProviderException e) {
- }
- }
-
- /*
- * Class under test for Cipher getInstance(String, String)
- */
- public void testGetInstanceStringString2() throws NoSuchAlgorithmException,
- NoSuchProviderException, NoSuchPaddingException {
-
- Cipher c = Cipher.getInstance("DES", "MyProvider2");
- assertSame("Case1:", p2, c.getProvider());
-
- c = Cipher.getInstance("DES/CBC/PKCS5Padding", "MyProvider2");
- assertSame("Case2:", p2, c.getProvider());
- }
-
- /*
- * Class under test for Cipher getInstance(String, Provider)
- */
- public void testGetInstanceStringProvider1()
- throws NoSuchAlgorithmException, NoSuchPaddingException {
-
- try {
- Cipher.getInstance("DES/CBC/", p2);
- fail("Case1: No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
-
- try {
- Cipher.getInstance("DES//PKCS5Padding", p2);
- fail("Case2: No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
-
- try {
- Cipher.getInstance("DES/CBC/IncorrectPadding", p2);
- fail("No expected NoSuchProviderException");
- } catch (NoSuchPaddingException e) {
- }
-
- try {
- Cipher.getInstance("DES/CBC/PKCS5Padding", "IncorrectProvider");
- fail("No expected NoSuchProviderException");
- } catch (NoSuchProviderException e) {
- }
- }
-
- /*
- * Class under test for Cipher getInstance(String, Provider)
- */
- public void testGetInstanceStringProvider2()
- throws NoSuchAlgorithmException, NoSuchPaddingException {
-
- Cipher c = Cipher.getInstance("DES", p2);
- assertSame("Case1:", p2, c.getProvider());
-
- c = Cipher.getInstance("DES/CBC/PKCS5Padding", p2);
- assertSame("Case2:", p2, c.getProvider());
- assertFalse("getAlgorithm", "DES".equals(c.getAlgorithm()));
- }
-
- public void testGetBlockSize() throws NoSuchAlgorithmException,
- NoSuchPaddingException {
-
- Cipher c = Cipher.getInstance("DES");
- assertEquals("getBlockSize", 111, c.getBlockSize());
- }
-
- public void testGetOutputSize() throws NoSuchAlgorithmException,
- NoSuchPaddingException, InvalidKeyException {
-
- Cipher c = Cipher.getInstance("DES");
- try {
- c.getOutputSize(111);
- fail("No expected IllegalStateException");
- } catch (IllegalStateException e) {
- }
-
- if (noKey) {
- return;
- }
-
- c.init(Cipher.DECRYPT_MODE, key);
- assertEquals("getOutputSize", 121, c.getOutputSize(111));
- }
-
- public void testGetIV() throws NoSuchAlgorithmException,
- NoSuchPaddingException {
-
- Cipher c = Cipher.getInstance("DES");
- assertEquals(3, c.getIV().length);
- }
-
- /*
- * Class under test for byte[] update(byte[])
- */
- public void testUpdatebyteArray() throws NoSuchAlgorithmException,
- NoSuchPaddingException, InvalidKeyException {
-
- Cipher c = Cipher.getInstance("DES");
-
- byte[] b = { 1, 2, 3, 4 };
- try {
- c.update(b);
- fail("No expected IllegalStateException");
- } catch (IllegalStateException e) {
- }
- if (noKey) {
- return;
- }
-
- c.init(Cipher.DECRYPT_MODE, key);
- try {
- c.update(null);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- assertNull(c.update(new byte[0]));
- }
-
- private class MyProvider1 extends Provider {
- MyProvider1() {
- super("MyProvider1", 1.0, "Provider1 for testing");
- put("Cipher.DES/CBC/PKCS5Padding", "org.apache.harmony.crypto.tests.support.MyCipher");
- put("Cipher.DES/ECB/PKCS5Padding", "org.apache.harmony.crypto.tests.support.MyCipher");
- }
- }
-
- private class MyProvider2 extends Provider {
- MyProvider2() {
- super("MyProvider2", 1.0, "Provider2 for testing");
- put("Cipher.DES", "org.apache.harmony.crypto.tests.support.MyCipher");
- }
-
- }
-} \ No newline at end of file
diff --git a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfo_ImplTest.java b/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfo_ImplTest.java
deleted file mode 100644
index 283f3fc..0000000
--- a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfo_ImplTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.io.IOException;
-import java.security.AlgorithmParameters;
-import java.security.NoSuchAlgorithmException;
-
-import javax.crypto.EncryptedPrivateKeyInfo;
-
-import org.apache.harmony.crypto.tests.support.EncryptedPrivateKeyInfoData;
-
-import junit.framework.TestCase;
-
-/**
- * Test for EncryptedPrivateKeyInfo class.
- * <p/>
- * All binary data for this test were generated using
- * BEA JRockit j2sdk1.4.2_04 (http://www.bea.com) with
- * security providers list extended by Bouncy Castle's one
- * (http://www.bouncycastle.org)
- */
-public class EncryptedPrivateKeyInfo_ImplTest extends TestCase {
-
- /**
- * Test #1 for <code>getAlgName()</code> method <br>
- * Assertion: Returns the encryption algorithm name <br>
- * Test preconditions: test object created using ctor which takes encoded
- * form as the only parameter <br>
- * Expected: corresponding algorithm name must be returned
- *
- * @throws IOException
- */
- public final void testGetAlgName01() throws IOException {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData
- .getValidEncryptedPrivateKeyInfoEncoding(
- EncryptedPrivateKeyInfoData.algName0[i][0]));
- assertEquals(EncryptedPrivateKeyInfoData.algName0[i][1], epki
- .getAlgName());
- performed = true;
- } catch (NoSuchAlgorithmException allowed) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #2 for <code>getAlgName()</code> method <br>
- * Assertion: Returns the encryption algorithm name <br>
- * Test preconditions: test object created using ctor which takes algorithm
- * name and encrypted data as a parameters <br>
- * Expected: corresponding algorithm name must be returned
- *
- * @throws IOException
- */
- public final void testGetAlgName02() {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
- EncryptedPrivateKeyInfoData.algName0[i][0],
- EncryptedPrivateKeyInfoData.encryptedData);
- assertEquals(EncryptedPrivateKeyInfoData.algName0[i][1], epki
- .getAlgName());
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-
- /**
- * Test #3 for <code>getAlgName()</code> method <br>
- * Assertion: Returns the encryption algorithm name <br>
- * Test preconditions: test object created using ctor which takes
- * AlgorithmParameters and encrypted data as a parameters <br>
- * Expected: corresponding algorithm name must be returned
- *
- * @throws IOException
- */
- public final void testGetAlgName03() throws IOException {
- boolean performed = false;
- for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
- try {
- AlgorithmParameters ap = AlgorithmParameters
- .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]);
- // use pregenerated AlgorithmParameters encodings
- ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding(
- EncryptedPrivateKeyInfoData.algName0[i][0]));
- EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap,
- EncryptedPrivateKeyInfoData.encryptedData);
- assertEquals(EncryptedPrivateKeyInfoData.algName0[i][1], epki
- .getAlgName());
- performed = true;
- } catch (NoSuchAlgorithmException allowedFailure) {
- }
- }
- assertTrue("Test not performed", performed);
- }
-}
diff --git a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanism_ImplTest.java b/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanism_ImplTest.java
deleted file mode 100644
index 8f3a19c..0000000
--- a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanism_ImplTest.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.AlgorithmParameters;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.spec.AlgorithmParameterSpec;
-
-import javax.crypto.ExemptionMechanism;
-import javax.crypto.ExemptionMechanismException;
-import javax.crypto.ExemptionMechanismSpi;
-import javax.crypto.ShortBufferException;
-import javax.crypto.spec.SecretKeySpec;
-
-import org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ExemptionMechanism</code> class constructors and methods
- */
-
-public class ExemptionMechanism_ImplTest extends TestCase {
-
- public static final String srvExemptionMechanism = "ExemptionMechanism";
-
- private static final String defaultAlg = "EMech";
-
- private static final String ExemptionMechanismProviderClass = "org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "eMEch";
- validValues[3] = "emecH";
- }
-
- Provider mProv;
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider",
- "Provider for ExemptionMechanism testing",
- srvExemptionMechanism.concat(".").concat(defaultAlg),
- ExemptionMechanismProviderClass);
- Security.insertProviderAt(mProv, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- private void checkResult(ExemptionMechanism exMech)
- throws ExemptionMechanismException, ShortBufferException,
- InvalidKeyException, InvalidAlgorithmParameterException {
- Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]);
- byte[] emptyA = new byte[0];
- int len = MyExemptionMechanismSpi.getLength();
- byte[] byteA = new byte[len];
- try {
- exMech.genExemptionBlob();
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- try {
- exMech.genExemptionBlob(byteA);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- try {
- exMech.genExemptionBlob(byteA, 1);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- try {
- exMech.getOutputSize(0);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
-
- exMech.init(key);
- byte[] bbRes = exMech.genExemptionBlob();
- assertEquals("Incorrect length", bbRes.length, len);
- assertEquals("Incorrect result", exMech.genExemptionBlob(new byte[5]), 5);
- assertEquals("Incorrect result", exMech.genExemptionBlob(bbRes), len);
-
- AlgorithmParameters params = null;
- exMech.init(key, params);
- AlgorithmParameterSpec parSpec = null;
- exMech.init(key, parSpec);
- key = new SecretKeySpec(new byte[10], "DSA");
- try {
- exMech.init(key);
- fail("ExemptionMechanismException must be thrown");
- } catch (ExemptionMechanismException e) {
- assertTrue("Empty message", (e.getMessage().length() > 0));
- }
- try {
- exMech.init(key, params);
- fail("ExemptionMechanismException must be thrown");
- } catch (ExemptionMechanismException e) {
- assertTrue("Empty message", (e.getMessage().length() > 0));
- }
- try {
- exMech.init(key, parSpec);
- fail("ExemptionMechanismException must be thrown");
- } catch (ExemptionMechanismException e) {
- assertTrue("Empty message", (e.getMessage().length() > 0));
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is incorrect;
- * returns ExemptionMechanism object
- */
- public void testGetInstance01() throws NoSuchAlgorithmException,
- ExemptionMechanismException, InvalidAlgorithmParameterException,
- ShortBufferException, InvalidKeyException {
- try {
- ExemptionMechanism.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- ExemptionMechanism.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- ExemptionMechanism exMech;
- for (int i = 0; i < validValues.length; i++) {
- exMech = ExemptionMechanism.getInstance(validValues[i]);
- assertEquals("Incorrect algorithm", exMech.getName(),
- validValues[i]);
- assertEquals("Incorrect provider", exMech.getProvider(), mProv);
- checkResult(exMech);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is null or incorrect;
- * throws IllegalArgumentException when provider is null;
- * throws NoSuchProviderException when provider is available;
- * returns ExemptionMechanism object
- */
- public void testGetInstance02() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- ExemptionMechanismException, InvalidAlgorithmParameterException,
- ShortBufferException, InvalidKeyException {
- try {
- ExemptionMechanism.getInstance(null, mProv.getName());
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- ExemptionMechanism.getInstance(invalidValues[i], mProv
- .getName());
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- ExemptionMechanism.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- ExemptionMechanism.getInstance(validValues[i],
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- ExemptionMechanism exMech;
- for (int i = 0; i < validValues.length; i++) {
- exMech = ExemptionMechanism.getInstance(validValues[i], mProv
- .getName());
- assertEquals("Incorrect algorithm", exMech.getName(),
- validValues[i]);
- assertEquals("Incorrect provider", exMech.getProvider().getName(),
- mProv.getName());
- checkResult(exMech);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is null or incorrect;
- * throws IllegalArgumentException when provider is null;
- * returns ExemptionMechanism object
- */
- public void testGetInstance03() throws NoSuchAlgorithmException,
- IllegalArgumentException,
- ExemptionMechanismException, InvalidAlgorithmParameterException,
- ShortBufferException, InvalidKeyException {
- try {
- ExemptionMechanism.getInstance(null, mProv);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- ExemptionMechanism.getInstance(invalidValues[i], mProv);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- ExemptionMechanism.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- ExemptionMechanism exMech;
- for (int i = 0; i < validValues.length; i++) {
- exMech = ExemptionMechanism.getInstance(validValues[i], mProv);
- assertEquals("Incorrect algorithm", exMech.getName(),
- validValues[i]);
- assertEquals("Incorrect provider", exMech.getProvider(), mProv);
- checkResult(exMech);
- }
- }
-}
-
-class myEM extends ExemptionMechanism {
-
- public myEM(ExemptionMechanismSpi spi, Provider prov, String mechanism) {
- super(spi, prov, mechanism);
- }
-
- public void finalize() {
- try {
- super.finalize();
- } catch (Throwable e) {
- throw new RuntimeException("finalize was broken", e);
- }
- }
-}
diff --git a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_Impl1Test.java b/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_Impl1Test.java
deleted file mode 100644
index a21a5f7..0000000
--- a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_Impl1Test.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.Provider;
-
-import javax.crypto.KeyAgreement;
-import javax.crypto.KeyAgreementSpi;
-
-import org.apache.harmony.crypto.tests.support.MyKeyAgreementSpi;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for KeyAgreement constructor and methods
- */
-
-public class KeyAgreement_Impl1Test extends TestCase {
-
- public static final String srvKeyAgreement = "KeyAgreement";
-
- private static String defaultAlgorithm = "DH";
-
-
- private static Provider defaultProvider = null;
-
- private static boolean DEFSupported = false;
-
- private static final String NotSupportMsg = "There is no suitable provider for KeyAgreement";
-
-
- static {
- defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm,
- srvKeyAgreement);
- DEFSupported = (defaultProvider != null);
- }
-
- /**
- * Test for <code>KeyAgreement</code> constructor Assertion: returns
- * KeyAgreement object
- */
- public void testKeyAgreement() throws NoSuchAlgorithmException,
- InvalidKeyException, IllegalStateException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyAgreementSpi spi = new MyKeyAgreementSpi();
- KeyAgreement keyA = new myKeyAgreement(spi, defaultProvider,
- defaultAlgorithm);
- assertEquals("Incorrect algorithm", keyA.getAlgorithm(),
- defaultAlgorithm);
- assertEquals("Incorrect provider", keyA.getProvider(), defaultProvider);
- assertNull("Incorrect result", keyA.doPhase(null, true));
- assertEquals("Incorrect result", keyA.generateSecret().length, 0);
-
- keyA = new myKeyAgreement(null, null, null);
- assertNull("Algorithm must be null", keyA.getAlgorithm());
- assertNull("Provider must be null", keyA.getProvider());
- try {
- keyA.doPhase(null, true);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- }
-}
-
-/**
- * Additional class for KeyAgreement constructor verification
- */
-
-class myKeyAgreement extends KeyAgreement {
-
- public myKeyAgreement(KeyAgreementSpi keyAgreeSpi, Provider provider,
- String algorithm) {
- super(keyAgreeSpi, provider, algorithm);
- }
-}
diff --git a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_ImplTest.java b/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_ImplTest.java
deleted file mode 100644
index 6b527f6..0000000
--- a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_ImplTest.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.Security;
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.KeyAgreement;
-import javax.crypto.ShortBufferException;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import junit.framework.TestCase;
-
-
-/**
- * Tests for KeyAgreement class constructors and methods
- */
-
-public class KeyAgreement_ImplTest extends TestCase {
-
- private static final String srvKeyAgreement = "KeyAgreement";
-
- private static final String defaultAlg = "MyKeyAgr";
-
- private static final String KeyAgreementProviderClass = "org.apache.harmony.crypto.tests.support.MyKeyAgreementSpi";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "myKeyagr";
- validValues[3] = "mYkeYAGR";
- }
-
- Provider mProv;
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyKAProvider", "Testing provider",
- srvKeyAgreement.concat(".").concat(defaultAlg),
- KeyAgreementProviderClass);
- Security.insertProviderAt(mProv, 1);
- }
-
- /**
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- protected void checkResult(KeyAgreement keyAgr)
- throws InvalidKeyException, ShortBufferException,
- NoSuchAlgorithmException, IllegalStateException,
- InvalidAlgorithmParameterException {
- assertNull("Not null result", keyAgr.doPhase(null, true));
- try {
- keyAgr.doPhase(null, false);
- fail("IllegalStateException must be thrown");
- } catch (IllegalStateException e) {
- }
- byte[] bb = keyAgr.generateSecret();
- assertEquals("Length is not 0", bb.length, 0);
- assertEquals("Returned integer is not 0",
- keyAgr.generateSecret(new byte[1], 10),
- -1);
- assertNull("Not null result", keyAgr.generateSecret("aaa"));
- try {
- keyAgr.generateSecret("");
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- Key key = null;
- try {
- keyAgr.init(key, new SecureRandom());
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- AlgorithmParameterSpec params = null;
- try {
- keyAgr.init(key, params, new SecureRandom());
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is incorrect;
- * returns KeyAgreement object
- */
- public void testGetInstance01() throws NoSuchAlgorithmException,
- InvalidKeySpecException, InvalidKeyException,
- ShortBufferException, InvalidAlgorithmParameterException {
- try {
- KeyAgreement.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyAgreement.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- KeyAgreement keyAgr;
- for (int i = 0; i < validValues.length; i++) {
- keyAgr = KeyAgreement.getInstance(validValues[i]);
- assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyAgr.getProvider(), mProv);
- checkResult(keyAgr);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is null or incorrect;
- * throws IllegalArgumentException when provider is null or null;
- * throws NoSuchProviderException when provider is available;
- * returns KeyAgreement object
- */
- public void testGetInstance02() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidKeySpecException, InvalidKeyException,
- ShortBufferException, InvalidAlgorithmParameterException {
- try {
- KeyAgreement.getInstance(null, mProv.getName());
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyAgreement.getInstance(invalidValues[i], mProv
- .getName());
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyAgreement.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- try {
- KeyAgreement.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- KeyAgreement.getInstance(validValues[i],
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- KeyAgreement keyAgr;
- for (int i = 0; i < validValues.length; i++) {
- keyAgr = KeyAgreement.getInstance(validValues[i], mProv
- .getName());
- assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyAgr.getProvider().getName(),
- mProv.getName());
- checkResult(keyAgr);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is null or incorrect;
- * throws IllegalArgumentException when provider is null;
- * returns KeyAgreement object
- */
- public void testGetInstance03() throws NoSuchAlgorithmException,
- IllegalArgumentException,
- InvalidKeySpecException, InvalidKeyException,
- ShortBufferException, InvalidAlgorithmParameterException {
- try {
- KeyAgreement.getInstance(null, mProv);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyAgreement.getInstance(invalidValues[i], mProv);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyAgreement.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- KeyAgreement keyAgr;
- for (int i = 0; i < validValues.length; i++) {
- keyAgr = KeyAgreement.getInstance(validValues[i], mProv);
- assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyAgr.getProvider(), mProv);
- checkResult(keyAgr);
- }
- }
-}
diff --git a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGenerator_ImplTest.java b/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGenerator_ImplTest.java
deleted file mode 100644
index f977b15..0000000
--- a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGenerator_ImplTest.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.Security;
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.KeyGenerator;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>KeyGenerator</code> class constructors and methods
- */
-
-public class KeyGenerator_ImplTest extends TestCase {
-
- private static final String srvKeyGenerator = "KeyGenerator";
-
- private static final String defaultAlg = "MyKeyGen";
-
- private static final String KeyGeneratorProviderClass = "org.apache.harmony.crypto.tests.support.MyKeyGeneratorSpi";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "myKeyGen";
- validValues[3] = "mYkeYgeN";
- }
-
- Provider mProv;
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyKGProvider", "Testing provider",
- srvKeyGenerator.concat(".").concat(defaultAlg),
- KeyGeneratorProviderClass);
- Security.insertProviderAt(mProv, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- private void checkResult(KeyGenerator keyGen) {
- AlgorithmParameterSpec paramsNull = null;
- AlgorithmParameterSpec params = new APSpec();
- try {
- keyGen.init(0, new SecureRandom());
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- try {
- keyGen.init(77, new SecureRandom());
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- keyGen.init(78, new SecureRandom());
- try {
- keyGen.init(new SecureRandom());
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- assertNull("generateKey must return null", keyGen.generateKey());
- try {
- keyGen.init(paramsNull, new SecureRandom());
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- try {
- keyGen.init(params, new SecureRandom());
- } catch (Exception e) {
- fail("Unexpected: " + e.toString() + " was thrown");
- }
- try {
- keyGen.init(paramsNull);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- try {
- keyGen.init(params);
- } catch (Exception e) {
- fail("Unexpected: " + e.toString() + " was thrown");
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is incorrect;
- * returns KeyGenerator object
- */
- public void testGetInstance01() throws NoSuchAlgorithmException,
- InvalidKeySpecException, InvalidKeyException {
- try {
- KeyGenerator.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyGenerator.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- KeyGenerator keyGen;
- for (int i = 0; i < validValues.length; i++) {
- keyGen = KeyGenerator.getInstance(validValues[i]);
- assertEquals("Incorrect algorithm", keyGen.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyGen.getProvider(), mProv);
- checkResult(keyGen);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is null or incorrect;
- * throws IllegalArgumentException when provider is null or empty;
- * throws NoSuchProviderException when provider is available;
- * returns KeyGenerator object
- */
- public void testGetInstance02() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidKeySpecException, InvalidKeyException {
- try {
- KeyGenerator.getInstance(null, mProv.getName());
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyGenerator.getInstance(invalidValues[i], mProv
- .getName());
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyGenerator.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- try {
- KeyGenerator.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- KeyGenerator.getInstance(validValues[i],
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- KeyGenerator keyGen;
- for (int i = 0; i < validValues.length; i++) {
- keyGen = KeyGenerator.getInstance(validValues[i], mProv
- .getName());
- assertEquals("Incorrect algorithm", keyGen.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyGen.getProvider().getName(),
- mProv.getName());
- checkResult(keyGen);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is null or incorrect;
- * throws IllegalArgumentException when provider is null;
- * returns KeyGenerator object
- */
- public void testGetInstance03() throws NoSuchAlgorithmException,
- IllegalArgumentException,
- InvalidKeySpecException, InvalidKeyException {
- try {
- KeyGenerator.getInstance(null, mProv);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyGenerator.getInstance(invalidValues[i], mProv);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyGenerator.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- KeyGenerator keyGen;
- for (int i = 0; i < validValues.length; i++) {
- keyGen = KeyGenerator.getInstance(validValues[i], mProv);
- assertEquals("Incorrect algorithm", keyGen.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyGen.getProvider(), mProv);
- checkResult(keyGen);
- }
- }
-}
-
-class APSpec implements AlgorithmParameterSpec {
-
-}
diff --git a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Mac_ImplTest.java b/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Mac_ImplTest.java
deleted file mode 100644
index a002661..0000000
--- a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Mac_ImplTest.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.spec.AlgorithmParameterSpec;
-
-import javax.crypto.Mac;
-import javax.crypto.spec.SecretKeySpec;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import junit.framework.TestCase;
-
-
-/**
- * Tests for Mac class constructors and methods
- */
-
-public class Mac_ImplTest extends TestCase {
-
- private static final String srvMac = "Mac";
-
- private static final String defaultAlg = "MyMacProv";
-
- private static final String MacProviderClass = "org.apache.harmony.crypto.tests.support.MyMacSpi";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[5];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toUpperCase();
- validValues[2] = defaultAlg.toLowerCase();
- validValues[3] = "myMACprov";
- validValues[4] = "MyMaCpRoV";
- }
-
- Provider mProv;
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyMacProvider", "Testing provider",
- srvMac.concat(".").concat(defaultAlg),
- MacProviderClass);
- Security.insertProviderAt(mProv, 2);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- protected void checkResult(Mac mac) throws InvalidKeyException,
- InvalidAlgorithmParameterException {
- assertEquals("Incorrect MacLength", mac.getMacLength(), 0);
- byte[] b = { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 };
- SecretKeySpec scs = new SecretKeySpec(b, "SHA1");
- AlgParSpec parms = new AlgParSpec();
- tmpKey tKey = new tmpKey();
- mac.init(scs);
- byte[] bb = mac.doFinal();
- assertEquals(bb.length, 0);
- mac.reset();
- bb = mac.doFinal();
- assertEquals(bb.length, 1);
- try {
- mac.init(null);
- fail("InvalidKeyException should be thrown");
- } catch (InvalidKeyException e) {
- }
- try {
- mac.init(null, null);
- fail("InvalidKeyException should be thrown");
- } catch (InvalidKeyException e) {
- }
- mac.init(scs, null);
- mac.init(scs, parms);
- try {
- mac.init(tKey, null);
- fail("InvalidAlgorithmParameterException or IllegalArgumentException "
- + "should be thrown for incorrect parameter");
- } catch (IllegalArgumentException e) {
- } catch (InvalidAlgorithmParameterException e) {
- }
- try {
- mac.clone();
- fail("No expected CloneNotSupportedException");
- } catch (CloneNotSupportedException e) {
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- * returns Mac object
- */
- public void testGetInstance01() throws NoSuchAlgorithmException,
- InvalidKeyException,
- InvalidAlgorithmParameterException {
- try {
- Mac.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- Mac.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Mac keyAgr;
- for (int i = 0; i < validValues.length; i++) {
- keyAgr = Mac.getInstance(validValues[i]);
- assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyAgr.getProvider(), mProv);
- checkResult(keyAgr);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- * throws IllegalArgumentException when provider is null;
- * throws NoSuchProviderException when provider is available;
- * returns Mac object
- */
- public void testGetInstance02() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidKeyException,
- InvalidAlgorithmParameterException {
- try {
- Mac.getInstance(null, mProv.getName());
- fail("NullPointerException or NoSuchAlgorithmException should be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- Mac.getInstance(invalidValues[i], mProv
- .getName());
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- Mac.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- Mac.getInstance(validValues[i],
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- Mac keyAgr;
- for (int i = 0; i < validValues.length; i++) {
- keyAgr = Mac.getInstance(validValues[i], mProv
- .getName());
- assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyAgr.getProvider().getName(),
- mProv.getName());
- checkResult(keyAgr);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- * throws IllegalArgumentException when provider is null;
- * returns Mac object
- */
- public void testGetInstance03() throws NoSuchAlgorithmException,
- IllegalArgumentException,
- InvalidKeyException,
- InvalidAlgorithmParameterException {
- try {
- Mac.getInstance(null, mProv);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- Mac.getInstance(invalidValues[i], mProv);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- Mac.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- Mac keyAgr;
- for (int i = 0; i < validValues.length; i++) {
- keyAgr = Mac.getInstance(validValues[i], mProv);
- assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyAgr.getProvider(), mProv);
- checkResult(keyAgr);
- }
- }
-
- public static class AlgParSpec implements AlgorithmParameterSpec {
-
- }
-
- public static class tmpKey implements Key {
- public tmpKey() {
-
- }
-
- public String getAlgorithm() {
- return "Test";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return null;
- }
- }
-}
diff --git a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_Impl1Test.java b/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_Impl1Test.java
deleted file mode 100644
index 21e3a0f..0000000
--- a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_Impl1Test.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.InvalidKeyException;
-import java.security.Provider;
-
-import javax.crypto.SecretKeyFactory;
-import javax.crypto.spec.SecretKeySpec;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>SecretKeyFactory</code> class constructors and methods.
- */
-
-public class SecretKeyFactory_Impl1Test extends TestCase {
-
- public static final String srvSecretKeyFactory = "SecretKeyFactory";
-
- private static String defaultAlgorithm1 = "DESede";
- private static String defaultAlgorithm2 = "DES";
-
- public static String defaultAlgorithm = null;
-
- private static String defaultProviderName = null;
-
- private static Provider defaultProvider = null;
-
- private static boolean DEFSupported = false;
-
- private static final String NotSupportMsg = "Default algorithm is not supported";
-
- static {
- defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm1,
- srvSecretKeyFactory);
- DEFSupported = (defaultProvider != null);
- if (DEFSupported) {
- defaultAlgorithm = defaultAlgorithm1;
- defaultProviderName = defaultProvider.getName();
- } else {
- defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm2,
- srvSecretKeyFactory);
- DEFSupported = (defaultProvider != null);
- if (DEFSupported) {
- defaultAlgorithm = defaultAlgorithm2;
- defaultProviderName = defaultProvider.getName();
- } else {
- defaultAlgorithm = null;
- defaultProviderName = null;
- defaultProvider = null;
- }
- }
- }
-
- protected SecretKeyFactory[] createSKFac() {
- if (!DEFSupported) {
- fail(defaultAlgorithm + " algorithm is not supported");
- return null;
- }
- SecretKeyFactory[] skF = new SecretKeyFactory[3];
- try {
- skF[0] = SecretKeyFactory.getInstance(defaultAlgorithm);
- skF[1] = SecretKeyFactory.getInstance(defaultAlgorithm,
- defaultProvider);
- skF[2] = SecretKeyFactory.getInstance(defaultAlgorithm,
- defaultProviderName);
- return skF;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- /**
- * Test for <code>translateKey(SecretKey key)</code> method
- * Assertion:
- * throw InvalidKeyException if parameter is inappropriate
- */
- public void testSecretKeyFactory11() throws InvalidKeyException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- byte[] bb = new byte[10];
- SecretKeySpec secKeySpec = new SecretKeySpec(bb, defaultAlgorithm);
- SecretKeyFactory[] skF = createSKFac();
- assertNotNull("SecretKeyFactory object were not created", skF);
- for (int i = 0; i < skF.length; i++) {
- try {
- skF[i].translateKey(null);
- fail("InvalidKeyException must be thrown: " + i);
- } catch (InvalidKeyException e) {
- }
-
- skF[i].translateKey(secKeySpec);
- }
- }
-}
-
diff --git a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_ImplTest.java b/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_ImplTest.java
deleted file mode 100644
index 2075969..0000000
--- a/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_ImplTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.javax.crypto;
-
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.KeySpec;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactory;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SecretKeyFactory</code> class constructors and methods
- */
-
-public class SecretKeyFactory_ImplTest extends TestCase {
-
- private static final String srvSecretKeyFactory = "SecretKeyFactory";
- private static final String defaultAlg = "MySecretKey";
- private static final String SecretKeyFactoryProviderClass = "org.apache.harmony.crypto.tests.support.MySecretKeyFactorySpi";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "mySECRETkey";
- validValues[3] = "MYSECretkey";
- }
-
- Provider mProv;
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MySKFProvider", "Testing provider",
- srvSecretKeyFactory.concat(".").concat(defaultAlg),
- SecretKeyFactoryProviderClass);
- Security.insertProviderAt(mProv, 2);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- private void checkResult(SecretKeyFactory skf) throws InvalidKeyException,
- InvalidKeySpecException {
- SecretKey sk;
- KeySpec keySpec;
- sk = skf.generateSecret(null);
- assertNull("generateSecret method must return null", sk);
- sk = skf.translateKey(null);
- assertNull("translateKey method must return null", sk);
- keySpec = skf.getKeySpec(null, null);
- assertNull("getKeySpec method must return null", keySpec);
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is incorrect;
- * returns SecretKeyFactory object
- */
- public void testGetInstance01() throws NoSuchAlgorithmException,
- InvalidKeySpecException, InvalidKeyException {
- try {
- SecretKeyFactory.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- SecretKeyFactory.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- SecretKeyFactory skf;
- for (int i = 0; i < validValues.length; i++) {
- skf = SecretKeyFactory.getInstance(validValues[i]);
- assertEquals("Incorrect algorithm", skf.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", skf.getProvider(), mProv);
- checkResult(skf);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is null or incorrect;
- * throws IllegalArgumentException when provider is null or empty;
- * throws NoSuchProviderException when provider is available;
- * returns SecretKeyFactory object
- */
- public void testGetInstance02() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidKeySpecException, InvalidKeyException {
- try {
- SecretKeyFactory.getInstance(null, mProv.getName());
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- SecretKeyFactory.getInstance(invalidValues[i], mProv
- .getName());
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- SecretKeyFactory.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- try {
- SecretKeyFactory.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- SecretKeyFactory.getInstance(validValues[i],
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- SecretKeyFactory skf;
- for (int i = 0; i < validValues.length; i++) {
- skf = SecretKeyFactory.getInstance(validValues[i], mProv
- .getName());
- assertEquals("Incorrect algorithm", skf.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", skf.getProvider().getName(),
- mProv.getName());
- checkResult(skf);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is null or incorrect;
- * throws IllegalArgumentException when provider is null;
- * returns SecretKeyFactory object
- */
- public void testGetInstance03() throws NoSuchAlgorithmException,
- IllegalArgumentException,
- InvalidKeySpecException, InvalidKeyException {
- try {
- SecretKeyFactory.getInstance(null, mProv);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- SecretKeyFactory.getInstance(invalidValues[i], mProv);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- SecretKeyFactory.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- SecretKeyFactory skf;
- for (int i = 0; i < validValues.length; i++) {
- skf = SecretKeyFactory.getInstance(validValues[i], mProv);
- assertEquals("Incorrect algorithm", skf.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", skf.getProvider(), mProv);
- checkResult(skf);
- }
- }
-}
diff --git a/crypto/src/test/resources/hyts_des-ede3-cbc.test1.ciphertext b/crypto/src/test/resources/hyts_des-ede3-cbc.test1.ciphertext
deleted file mode 100644
index 2d7b94b..0000000
--- a/crypto/src/test/resources/hyts_des-ede3-cbc.test1.ciphertext
+++ /dev/null
@@ -1 +0,0 @@
-!#oN{¦@ \ No newline at end of file
diff --git a/crypto/src/test/resources/hyts_des-ede3-cbc.test1.iv b/crypto/src/test/resources/hyts_des-ede3-cbc.test1.iv
deleted file mode 100644
index 401f335..0000000
--- a/crypto/src/test/resources/hyts_des-ede3-cbc.test1.iv
+++ /dev/null
@@ -1 +0,0 @@
-žôQ2#P\ \ No newline at end of file
diff --git a/crypto/src/test/resources/hyts_des-ede3-cbc.test1.key b/crypto/src/test/resources/hyts_des-ede3-cbc.test1.key
deleted file mode 100644
index 2ffb5ea..0000000
--- a/crypto/src/test/resources/hyts_des-ede3-cbc.test1.key
+++ /dev/null
@@ -1 +0,0 @@
-igêŽkXŒÜ´têyA#˜{ †ôö$ \ No newline at end of file
diff --git a/crypto/src/test/resources/hyts_des-ede3-cbc.test1.plaintext b/crypto/src/test/resources/hyts_des-ede3-cbc.test1.plaintext
deleted file mode 100644
index 9787ee2..0000000
--- a/crypto/src/test/resources/hyts_des-ede3-cbc.test1.plaintext
+++ /dev/null
@@ -1 +0,0 @@
-߆ ÓC \ No newline at end of file
diff --git a/crypto/src/test/resources/hyts_des-ede3-cbc.test2.ciphertext b/crypto/src/test/resources/hyts_des-ede3-cbc.test2.ciphertext
deleted file mode 100644
index 1ae3f96..0000000
--- a/crypto/src/test/resources/hyts_des-ede3-cbc.test2.ciphertext
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv b/crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv
deleted file mode 100644
index 72660fc..0000000
--- a/crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv
+++ /dev/null
@@ -1 +0,0 @@
-@ö"З< \ No newline at end of file
diff --git a/crypto/src/test/resources/hyts_des-ede3-cbc.test2.key b/crypto/src/test/resources/hyts_des-ede3-cbc.test2.key
deleted file mode 100644
index 9876f3f..0000000
--- a/crypto/src/test/resources/hyts_des-ede3-cbc.test2.key
+++ /dev/null
@@ -1 +0,0 @@
-q’<»Å(GåâÁΡԑ€Iž:Æá¹' \ No newline at end of file
diff --git a/crypto/src/test/resources/hyts_des-ede3-cbc.test2.plaintext b/crypto/src/test/resources/hyts_des-ede3-cbc.test2.plaintext
deleted file mode 100644
index 1b5ef4a..0000000
--- a/crypto/src/test/resources/hyts_des-ede3-cbc.test2.plaintext
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/hyts_des-ede3-cbc.test3.ciphertext b/crypto/src/test/resources/hyts_des-ede3-cbc.test3.ciphertext
deleted file mode 100644
index b9dd600..0000000
--- a/crypto/src/test/resources/hyts_des-ede3-cbc.test3.ciphertext
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv b/crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv
deleted file mode 100644
index 7a6ded5..0000000
--- a/crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv
+++ /dev/null
@@ -1 +0,0 @@
-÷–~ÞSr[ \ No newline at end of file
diff --git a/crypto/src/test/resources/hyts_des-ede3-cbc.test3.key b/crypto/src/test/resources/hyts_des-ede3-cbc.test3.key
deleted file mode 100644
index e18fd89..0000000
--- a/crypto/src/test/resources/hyts_des-ede3-cbc.test3.key
+++ /dev/null
@@ -1 +0,0 @@
-ïÝ/]o³¨DÐεžPeɵ®à¸0?6 \ No newline at end of file
diff --git a/crypto/src/test/resources/hyts_des-ede3-cbc.test3.plaintext b/crypto/src/test/resources/hyts_des-ede3-cbc.test3.plaintext
deleted file mode 100644
index f45bd88..0000000
--- a/crypto/src/test/resources/hyts_des-ede3-cbc.test3.plaintext
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.0.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.0.ser
deleted file mode 100644
index a7d6333..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.1.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.1.ser
deleted file mode 100644
index 447c1f4..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.2.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.2.ser
deleted file mode 100644
index ae028bd..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.0.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.0.ser
deleted file mode 100644
index 60c67c0..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.1.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.1.ser
deleted file mode 100644
index 58b303f..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.2.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.2.ser
deleted file mode 100644
index ee41ad6..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.0.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.0.ser
deleted file mode 100644
index 98823fc..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.1.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.1.ser
deleted file mode 100644
index a69ae56..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.2.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.2.ser
deleted file mode 100644
index f23826c..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.0.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.0.ser
deleted file mode 100644
index 0cdc09d..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.1.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.1.ser
deleted file mode 100644
index 3a12187..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.2.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.2.ser
deleted file mode 100644
index 5818cd4..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.0.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.0.ser
deleted file mode 100644
index 1f8e55f..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.1.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.1.ser
deleted file mode 100644
index b0fadb2..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.2.ser b/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.2.ser
deleted file mode 100644
index 9edf260..0000000
--- a/crypto/src/test/resources/serialization/com/android/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/EncryptedPrivateKeyInfoData.java b/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/EncryptedPrivateKeyInfoData.java
deleted file mode 100644
index 12f4110..0000000
--- a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/EncryptedPrivateKeyInfoData.java
+++ /dev/null
@@ -1,1228 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.crypto.tests.support;
-
-import java.security.NoSuchAlgorithmException;
-import java.util.HashMap;
-
-/**
- * Support class for EncryptedPrivateKeyInfo_ImplTest and EncryptedPrivateKeyInfo_Test
- * <p/>
- * All binary data for these tests were generated using
- * BEA JRockit j2sdk1.4.2_04 (http://www.bea.com) with
- * security providers list extended by Bouncy Castle's one
- * (http://www.bouncycastle.org)
- */
-public class EncryptedPrivateKeyInfoData {
-
-
- /**
- * "valid" encoding for DSA with alg params
- */
- private static final byte[] dsaEncryptedPrivateKeyInfo = new byte[] {
- (byte) 0x30, (byte) 0x82, (byte) 0x05, (byte) 0x33, (byte) 0x30,
- (byte) 0x82, (byte) 0x01, (byte) 0x2b, (byte) 0x06, (byte) 0x07,
- (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0xce, (byte) 0x38,
- (byte) 0x04, (byte) 0x01, (byte) 0x30, (byte) 0x82, (byte) 0x01,
- (byte) 0x1e, (byte) 0x02, (byte) 0x81, (byte) 0x81, (byte) 0x00,
- (byte) 0x9f, (byte) 0x5e, (byte) 0x76, (byte) 0x19, (byte) 0x59,
- (byte) 0xd8, (byte) 0xf7, (byte) 0x6b, (byte) 0x91, (byte) 0x6d,
- (byte) 0x15, (byte) 0x7e, (byte) 0x14, (byte) 0x27, (byte) 0x25,
- (byte) 0x6e, (byte) 0x59, (byte) 0x2c, (byte) 0xec, (byte) 0x21,
- (byte) 0x7a, (byte) 0xb7, (byte) 0xd4, (byte) 0xf4, (byte) 0xa0,
- (byte) 0x26, (byte) 0x4e, (byte) 0x72, (byte) 0x29, (byte) 0x18,
- (byte) 0x4a, (byte) 0x1c, (byte) 0x9a, (byte) 0xc9, (byte) 0xcd,
- (byte) 0x85, (byte) 0x1b, (byte) 0x39, (byte) 0x41, (byte) 0x9e,
- (byte) 0x58, (byte) 0x16, (byte) 0xeb, (byte) 0x20, (byte) 0x84,
- (byte) 0x28, (byte) 0x2a, (byte) 0xb9, (byte) 0xce, (byte) 0xc7,
- (byte) 0x6d, (byte) 0x74, (byte) 0x99, (byte) 0xfe, (byte) 0xa5,
- (byte) 0xe8, (byte) 0x66, (byte) 0xe1, (byte) 0x48, (byte) 0xdd,
- (byte) 0x2e, (byte) 0xcf, (byte) 0xfe, (byte) 0xb9, (byte) 0x6a,
- (byte) 0x8e, (byte) 0x12, (byte) 0x4b, (byte) 0xa4, (byte) 0xa8,
- (byte) 0x87, (byte) 0xd7, (byte) 0xab, (byte) 0x26, (byte) 0xd6,
- (byte) 0xc3, (byte) 0xd1, (byte) 0x3b, (byte) 0x95, (byte) 0xc4,
- (byte) 0x97, (byte) 0x2c, (byte) 0xdc, (byte) 0xab, (byte) 0x5d,
- (byte) 0xf5, (byte) 0x55, (byte) 0xae, (byte) 0x58, (byte) 0x68,
- (byte) 0x84, (byte) 0x41, (byte) 0x99, (byte) 0x1b, (byte) 0xd3,
- (byte) 0xd0, (byte) 0xd9, (byte) 0xd3, (byte) 0xdd, (byte) 0xf5,
- (byte) 0x48, (byte) 0x04, (byte) 0xa2, (byte) 0x92, (byte) 0x61,
- (byte) 0xf8, (byte) 0xb1, (byte) 0xe6, (byte) 0x24, (byte) 0x65,
- (byte) 0x8f, (byte) 0xa4, (byte) 0x97, (byte) 0x40, (byte) 0x1d,
- (byte) 0x3f, (byte) 0x2b, (byte) 0x85, (byte) 0x00, (byte) 0xd5,
- (byte) 0xcb, (byte) 0x8d, (byte) 0x66, (byte) 0x9a, (byte) 0xac,
- (byte) 0x7b, (byte) 0x5f, (byte) 0xc7, (byte) 0x02, (byte) 0x15,
- (byte) 0x00, (byte) 0x9a, (byte) 0xfb, (byte) 0x6f, (byte) 0x72,
- (byte) 0x15, (byte) 0x01, (byte) 0x03, (byte) 0x16, (byte) 0x2a,
- (byte) 0xd6, (byte) 0xca, (byte) 0x60, (byte) 0x10, (byte) 0x47,
- (byte) 0xde, (byte) 0x4b, (byte) 0x0f, (byte) 0xd6, (byte) 0x73,
- (byte) 0x37, (byte) 0x02, (byte) 0x81, (byte) 0x80, (byte) 0x5d,
- (byte) 0x51, (byte) 0x28, (byte) 0x64, (byte) 0xb2, (byte) 0x2b,
- (byte) 0xeb, (byte) 0x85, (byte) 0xb4, (byte) 0x14, (byte) 0x0d,
- (byte) 0xad, (byte) 0xec, (byte) 0xc8, (byte) 0x1f, (byte) 0x96,
- (byte) 0x1e, (byte) 0x6a, (byte) 0x52, (byte) 0xd4, (byte) 0x0b,
- (byte) 0x69, (byte) 0xb0, (byte) 0x33, (byte) 0xa1, (byte) 0xd1,
- (byte) 0xbc, (byte) 0x64, (byte) 0xd6, (byte) 0x64, (byte) 0xef,
- (byte) 0x2c, (byte) 0x89, (byte) 0xc7, (byte) 0x39, (byte) 0x75,
- (byte) 0x87, (byte) 0x82, (byte) 0x61, (byte) 0xbe, (byte) 0xd1,
- (byte) 0xcd, (byte) 0x70, (byte) 0x41, (byte) 0x85, (byte) 0x99,
- (byte) 0x55, (byte) 0x75, (byte) 0x6f, (byte) 0x16, (byte) 0xc0,
- (byte) 0x40, (byte) 0xf1, (byte) 0x0c, (byte) 0x78, (byte) 0x1f,
- (byte) 0xe8, (byte) 0x63, (byte) 0x5d, (byte) 0xfa, (byte) 0x37,
- (byte) 0xc1, (byte) 0xce, (byte) 0x97, (byte) 0x76, (byte) 0xa5,
- (byte) 0x48, (byte) 0x5b, (byte) 0x88, (byte) 0xe4, (byte) 0xd5,
- (byte) 0xb8, (byte) 0x06, (byte) 0xf5, (byte) 0x7f, (byte) 0x92,
- (byte) 0xda, (byte) 0x99, (byte) 0xa5, (byte) 0x5a, (byte) 0x64,
- (byte) 0xc9, (byte) 0x30, (byte) 0x2c, (byte) 0x77, (byte) 0x58,
- (byte) 0x60, (byte) 0xa6, (byte) 0x35, (byte) 0x1d, (byte) 0x71,
- (byte) 0xfb, (byte) 0x49, (byte) 0x24, (byte) 0x6c, (byte) 0x34,
- (byte) 0x29, (byte) 0xa0, (byte) 0x47, (byte) 0xf1, (byte) 0x14,
- (byte) 0xad, (byte) 0xc2, (byte) 0x85, (byte) 0x41, (byte) 0xdd,
- (byte) 0x2c, (byte) 0x78, (byte) 0x2a, (byte) 0x5a, (byte) 0x24,
- (byte) 0x7f, (byte) 0x19, (byte) 0xf4, (byte) 0x0a, (byte) 0x2e,
- (byte) 0x1d, (byte) 0x92, (byte) 0x80, (byte) 0xe5, (byte) 0xe4,
- (byte) 0x05, (byte) 0x28, (byte) 0x48, (byte) 0x5c, // 38
- (byte) 0x34, (byte) 0xc8, (byte) 0x22, (byte) 0x04, (byte) 0x82,
- (byte) 0x04, (byte) 0x00, (byte) 0x00, //
- (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05,
- (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0a,
- (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f,
- (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14,
- (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19,
- (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, (byte) 0x1e,
- (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22, (byte) 0x23,
- (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28,
- (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d,
- (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31, (byte) 0x32,
- (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37,
- (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b, (byte) 0x3c,
- (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40, (byte) 0x41,
- (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46,
- (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x4b,
- (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, (byte) 0x50,
- (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54, (byte) 0x55,
- (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a,
- (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, (byte) 0x5f,
- (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x64,
- (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69,
- (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, (byte) 0x6e,
- (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72, (byte) 0x73,
- (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78,
- (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, (byte) 0x7d,
- (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0x82,
- (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87,
- (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b, (byte) 0x8c,
- (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90, (byte) 0x91,
- (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95, (byte) 0x96,
- (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0x9b,
- (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, (byte) 0xa0,
- (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, (byte) 0xa5,
- (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa,
- (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae, (byte) 0xaf,
- (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4,
- (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, (byte) 0xb9,
- (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, (byte) 0xbe,
- (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, (byte) 0xc3,
- (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, (byte) 0xc8,
- (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc, (byte) 0xcd,
- (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, (byte) 0xd2,
- (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7,
- (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb, (byte) 0xdc,
- (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0, (byte) 0xe1,
- (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6,
- (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea, (byte) 0xeb,
- (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef, (byte) 0xf0,
- (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5,
- (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa,
- (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, (byte) 0xff,
- (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04,
- (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09,
- (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e,
- (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13,
- (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18,
- (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d,
- (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22,
- (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27,
- (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c,
- (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31,
- (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36,
- (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b,
- (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40,
- (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45,
- (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a,
- (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f,
- (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54,
- (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59,
- (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e,
- (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63,
- (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68,
- (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d,
- (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72,
- (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77,
- (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c,
- (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81,
- (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86,
- (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b,
- (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90,
- (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95,
- (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a,
- (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f,
- (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4,
- (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9,
- (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae,
- (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3,
- (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8,
- (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd,
- (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2,
- (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7,
- (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc,
- (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1,
- (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6,
- (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb,
- (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0,
- (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5,
- (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea,
- (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef,
- (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4,
- (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9,
- (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe,
- (byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
- (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08,
- (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d,
- (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12,
- (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17,
- (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c,
- (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21,
- (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26,
- (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b,
- (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30,
- (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35,
- (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a,
- (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f,
- (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44,
- (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49,
- (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e,
- (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53,
- (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58,
- (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d,
- (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62,
- (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67,
- (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c,
- (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71,
- (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76,
- (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b,
- (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80,
- (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85,
- (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a,
- (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f,
- (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94,
- (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99,
- (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e,
- (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3,
- (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8,
- (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad,
- (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2,
- (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7,
- (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc,
- (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1,
- (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6,
- (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb,
- (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0,
- (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5,
- (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda,
- (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf,
- (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4,
- (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9,
- (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee,
- (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3,
- (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8,
- (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd,
- (byte) 0xfe, (byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x02,
- (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
- (byte) 0x08, (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c,
- (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11,
- (byte) 0x12, (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16,
- (byte) 0x17, (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b,
- (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20,
- (byte) 0x21, (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25,
- (byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a,
- (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f,
- (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34,
- (byte) 0x35, (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39,
- (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e,
- (byte) 0x3f, (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43,
- (byte) 0x44, (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48,
- (byte) 0x49, (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d,
- (byte) 0x4e, (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52,
- (byte) 0x53, (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57,
- (byte) 0x58, (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c,
- (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61,
- (byte) 0x62, (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66,
- (byte) 0x67, (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b,
- (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70,
- (byte) 0x71, (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75,
- (byte) 0x76, (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a,
- (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f,
- (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84,
- (byte) 0x85, (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89,
- (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e,
- (byte) 0x8f, (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93,
- (byte) 0x94, (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98,
- (byte) 0x99, (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d,
- (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2,
- (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7,
- (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac,
- (byte) 0xad, (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1,
- (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6,
- (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb,
- (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0,
- (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5,
- (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca,
- (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf,
- (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4,
- (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9,
- (byte) 0xda, (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde,
- (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3,
- (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8,
- (byte) 0xe9, (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed,
- (byte) 0xee, (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2,
- (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7,
- (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc,
- (byte) 0xfd, (byte) 0xfe, (byte) 0xff };
-
- /**
- * "valid" encoding for DSA - no alg params
- */
- private static final byte[] dsaEncryptedPrivateKeyInfoNP = new byte[] {
- (byte) 0x30, (byte) 0x82, (byte) 0x04, (byte) 0x11, (byte) 0x30,
- (byte) 0x0b, (byte) 0x06, (byte) 0x07, (byte) 0x2a, (byte) 0x86,
- (byte) 0x48, (byte) 0xce, (byte) 0x38, (byte) 0x04, (byte) 0x01,
- (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x82, (byte) 0x04,
- (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
- (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08,
- (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d,
- (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12,
- (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17,
- (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c,
- (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21,
- (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26,
- (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b,
- (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30,
- (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35,
- (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a,
- (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f,
- (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44,
- (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49,
- (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e,
- (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53,
- (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58,
- (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d,
- (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62,
- (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67,
- (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c,
- (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71,
- (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76,
- (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b,
- (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80,
- (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85,
- (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a,
- (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f,
- (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94,
- (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99,
- (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e,
- (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3,
- (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8,
- (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad,
- (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2,
- (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7,
- (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc,
- (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1,
- (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6,
- (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb,
- (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0,
- (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5,
- (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda,
- (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf,
- (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4,
- (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9,
- (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee,
- (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3,
- (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8,
- (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd,
- (byte) 0xfe, (byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x02,
- (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
- (byte) 0x08, (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c,
- (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11,
- (byte) 0x12, (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16,
- (byte) 0x17, (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b,
- (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20,
- (byte) 0x21, (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25,
- (byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a,
- (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f,
- (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34,
- (byte) 0x35, (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39,
- (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e,
- (byte) 0x3f, (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43,
- (byte) 0x44, (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48,
- (byte) 0x49, (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d,
- (byte) 0x4e, (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52,
- (byte) 0x53, (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57,
- (byte) 0x58, (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c,
- (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61,
- (byte) 0x62, (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66,
- (byte) 0x67, (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b,
- (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70,
- (byte) 0x71, (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75,
- (byte) 0x76, (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a,
- (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f,
- (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84,
- (byte) 0x85, (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89,
- (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e,
- (byte) 0x8f, (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93,
- (byte) 0x94, (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98,
- (byte) 0x99, (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d,
- (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2,
- (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7,
- (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac,
- (byte) 0xad, (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1,
- (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6,
- (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb,
- (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0,
- (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5,
- (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca,
- (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf,
- (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4,
- (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9,
- (byte) 0xda, (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde,
- (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3,
- (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8,
- (byte) 0xe9, (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed,
- (byte) 0xee, (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2,
- (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7,
- (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc,
- (byte) 0xfd, (byte) 0xfe, (byte) 0xff, (byte) 0x00, (byte) 0x01,
- (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06,
- (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0a, (byte) 0x0b,
- (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, (byte) 0x10,
- (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14, (byte) 0x15,
- (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19, (byte) 0x1a,
- (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, (byte) 0x1f,
- (byte) 0x20, (byte) 0x21, (byte) 0x22, (byte) 0x23, (byte) 0x24,
- (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29,
- (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, (byte) 0x2e,
- (byte) 0x2f, (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x33,
- (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37, (byte) 0x38,
- (byte) 0x39, (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, (byte) 0x3d,
- (byte) 0x3e, (byte) 0x3f, (byte) 0x40, (byte) 0x41, (byte) 0x42,
- (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46, (byte) 0x47,
- (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x4b, (byte) 0x4c,
- (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, (byte) 0x50, (byte) 0x51,
- (byte) 0x52, (byte) 0x53, (byte) 0x54, (byte) 0x55, (byte) 0x56,
- (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a, (byte) 0x5b,
- (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, (byte) 0x60,
- (byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x64, (byte) 0x65,
- (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69, (byte) 0x6a,
- (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, (byte) 0x6f,
- (byte) 0x70, (byte) 0x71, (byte) 0x72, (byte) 0x73, (byte) 0x74,
- (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78, (byte) 0x79,
- (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, (byte) 0x7e,
- (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83,
- (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87, (byte) 0x88,
- (byte) 0x89, (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, (byte) 0x8d,
- (byte) 0x8e, (byte) 0x8f, (byte) 0x90, (byte) 0x91, (byte) 0x92,
- (byte) 0x93, (byte) 0x94, (byte) 0x95, (byte) 0x96, (byte) 0x97,
- (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0x9b, (byte) 0x9c,
- (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, (byte) 0xa1,
- (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, (byte) 0xa6,
- (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, (byte) 0xab,
- (byte) 0xac, (byte) 0xad, (byte) 0xae, (byte) 0xaf, (byte) 0xb0,
- (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, (byte) 0xb5,
- (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, (byte) 0xba,
- (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, (byte) 0xbf,
- (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, (byte) 0xc4,
- (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, (byte) 0xc9,
- (byte) 0xca, (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, (byte) 0xce,
- (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, (byte) 0xd3,
- (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, (byte) 0xd8,
- (byte) 0xd9, (byte) 0xda, (byte) 0xdb, (byte) 0xdc, (byte) 0xdd,
- (byte) 0xde, (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, (byte) 0xe2,
- (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, (byte) 0xe7,
- (byte) 0xe8, (byte) 0xe9, (byte) 0xea, (byte) 0xeb, (byte) 0xec,
- (byte) 0xed, (byte) 0xee, (byte) 0xef, (byte) 0xf0, (byte) 0xf1,
- (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, (byte) 0xf6,
- (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xfb,
- (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, (byte) 0xff, (byte) 0x00,
- (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05,
- (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0a,
- (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f,
- (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14,
- (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19,
- (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, (byte) 0x1e,
- (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22, (byte) 0x23,
- (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28,
- (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d,
- (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31, (byte) 0x32,
- (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37,
- (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b, (byte) 0x3c,
- (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40, (byte) 0x41,
- (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46,
- (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x4b,
- (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, (byte) 0x50,
- (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54, (byte) 0x55,
- (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a,
- (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, (byte) 0x5f,
- (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x64,
- (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69,
- (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, (byte) 0x6e,
- (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72, (byte) 0x73,
- (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78,
- (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, (byte) 0x7d,
- (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0x82,
- (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87,
- (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b, (byte) 0x8c,
- (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90, (byte) 0x91,
- (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95, (byte) 0x96,
- (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0x9b,
- (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, (byte) 0xa0,
- (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, (byte) 0xa5,
- (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa,
- (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae, (byte) 0xaf,
- (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4,
- (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, (byte) 0xb9,
- (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, (byte) 0xbe,
- (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, (byte) 0xc3,
- (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, (byte) 0xc8,
- (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc, (byte) 0xcd,
- (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, (byte) 0xd2,
- (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7,
- (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb, (byte) 0xdc,
- (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0, (byte) 0xe1,
- (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6,
- (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea, (byte) 0xeb,
- (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef, (byte) 0xf0,
- (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5,
- (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa,
- (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, (byte) 0xff, };
-
- /**
- * "valid" encoding for DH with alg params
- */
- private static final byte[] dhEncryptedPrivateKeyInfo = new byte[] {
- (byte) 0x30, (byte) 0x82, (byte) 0x05, (byte) 0x22, (byte) 0x30,
- (byte) 0x82, (byte) 0x01, (byte) 0x1a, (byte) 0x06, (byte) 0x09,
- (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7,
- (byte) 0x0d, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x30,
- (byte) 0x82, (byte) 0x01, (byte) 0x0b, (byte) 0x02, (byte) 0x81,
- (byte) 0x81, (byte) 0x00, (byte) 0xce, (byte) 0x2c, (byte) 0x4f,
- (byte) 0xea, (byte) 0xf2, (byte) 0x83, (byte) 0xc5, (byte) 0x38,
- (byte) 0xc9, (byte) 0xb6, (byte) 0xd4, (byte) 0xf8, (byte) 0xb8,
- (byte) 0x17, (byte) 0xa1, (byte) 0x7d, (byte) 0x4c, (byte) 0xec,
- (byte) 0x6b, (byte) 0xd7, (byte) 0xc2, (byte) 0x1a, (byte) 0x35,
- (byte) 0x85, (byte) 0x54, (byte) 0x14, (byte) 0x6c, (byte) 0x52,
- (byte) 0x24, (byte) 0xbf, (byte) 0xe6, (byte) 0x32, (byte) 0xd8,
- (byte) 0x42, (byte) 0xac, (byte) 0xb3, (byte) 0x28, (byte) 0x4f,
- (byte) 0x77, (byte) 0xf6, (byte) 0xfc, (byte) 0xea, (byte) 0xea,
- (byte) 0x72, (byte) 0xcf, (byte) 0x1d, (byte) 0x7b, (byte) 0xe1,
- (byte) 0x72, (byte) 0xfa, (byte) 0x77, (byte) 0x12, (byte) 0xa9,
- (byte) 0x42, (byte) 0xba, (byte) 0xc4, (byte) 0xf4, (byte) 0xfb,
- (byte) 0xbd, (byte) 0x9f, (byte) 0x63, (byte) 0x9a, (byte) 0x58,
- (byte) 0x6b, (byte) 0xb6, (byte) 0xa2, (byte) 0x6e, (byte) 0x3a,
- (byte) 0x71, (byte) 0xf3, (byte) 0x43, (byte) 0x5e, (byte) 0x6f,
- (byte) 0x8a, (byte) 0xd0, (byte) 0xac, (byte) 0xe5, (byte) 0x60,
- (byte) 0x76, (byte) 0x57, (byte) 0x1f, (byte) 0x83, (byte) 0x4d,
- (byte) 0xbc, (byte) 0xaa, (byte) 0xb1, (byte) 0x18, (byte) 0x40,
- (byte) 0x19, (byte) 0xac, (byte) 0x31, (byte) 0xd4, (byte) 0xfc,
- (byte) 0x39, (byte) 0x01, (byte) 0x46, (byte) 0xab, (byte) 0xab,
- (byte) 0x53, (byte) 0x19, (byte) 0x2d, (byte) 0xf8, (byte) 0x4c,
- (byte) 0xd3, (byte) 0x9f, (byte) 0x4d, (byte) 0xa6, (byte) 0x71,
- (byte) 0x92, (byte) 0x06, (byte) 0xc7, (byte) 0x89, (byte) 0x70,
- (byte) 0xc4, (byte) 0xc6, (byte) 0xa2, (byte) 0x1f, (byte) 0x05,
- (byte) 0x4a, (byte) 0x5b, (byte) 0x84, (byte) 0xf9, (byte) 0xfb,
- (byte) 0x98, (byte) 0x63, (byte) 0xc9, (byte) 0x9c, (byte) 0x13,
- (byte) 0x02, (byte) 0x81, (byte) 0x80, (byte) 0x36, (byte) 0x55,
- (byte) 0x93, (byte) 0xb3, (byte) 0x22, (byte) 0x0c, (byte) 0xcd,
- (byte) 0x7c, (byte) 0xc3, (byte) 0xe3, (byte) 0xa3, (byte) 0x8a,
- (byte) 0xd7, (byte) 0xb4, (byte) 0xe9, (byte) 0xe0, (byte) 0xfa,
- (byte) 0xa9, (byte) 0xa8, (byte) 0x69, (byte) 0xd6, (byte) 0xa6,
- (byte) 0x20, (byte) 0xb8, (byte) 0xd4, (byte) 0xe7, (byte) 0x87,
- (byte) 0x4e, (byte) 0xf3, (byte) 0x90, (byte) 0x10, (byte) 0xdd,
- (byte) 0x75, (byte) 0x5d, (byte) 0xff, (byte) 0xee, (byte) 0xf0,
- (byte) 0xef, (byte) 0x6a, (byte) 0x0a, (byte) 0xb0, (byte) 0xf1,
- (byte) 0x8a, (byte) 0xb6, (byte) 0x7b, (byte) 0x39, (byte) 0x95,
- (byte) 0xd5, (byte) 0x24, (byte) 0x83, (byte) 0x10, (byte) 0x95,
- (byte) 0x34, (byte) 0x08, (byte) 0x77, (byte) 0x1d, (byte) 0xaf,
- (byte) 0x69, (byte) 0xf0, (byte) 0xb5, (byte) 0xdb, (byte) 0x24,
- (byte) 0x89, (byte) 0x72, (byte) 0xb2, (byte) 0x0d, (byte) 0x57,
- (byte) 0x94, (byte) 0xb0, (byte) 0xe8, (byte) 0xc2, (byte) 0x37,
- (byte) 0x45, (byte) 0x5a, (byte) 0xfc, (byte) 0xa1, (byte) 0xa0,
- (byte) 0x41, (byte) 0xe4, (byte) 0x0c, (byte) 0xa3, (byte) 0x40,
- (byte) 0x8b, (byte) 0x9c, (byte) 0x19, (byte) 0x63, (byte) 0x61,
- (byte) 0xd9, (byte) 0x05, (byte) 0xbf, (byte) 0xc5, (byte) 0xe8,
- (byte) 0xf7, (byte) 0xbd, (byte) 0x3a, (byte) 0xf5, (byte) 0x78,
- (byte) 0xc2, (byte) 0x92, (byte) 0xe8, (byte) 0x60, (byte) 0x07,
- (byte) 0x3e, (byte) 0x57, (byte) 0x12, (byte) 0xf6, (byte) 0x97,
- (byte) 0x1f, (byte) 0xea, (byte) 0x02, (byte) 0xa3, (byte) 0x19,
- (byte) 0xa7, (byte) 0x5a, (byte) 0x9b, (byte) 0xf6, (byte) 0xd2,
- (byte) 0x0f, (byte) 0xe9, (byte) 0x6b, (byte) 0xeb, (byte) 0xd7,
- (byte) 0x93, (byte) 0x9a, (byte) 0x7e, (byte) 0x4f, (byte) 0xd6,
- (byte) 0x29, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0xff,
- (byte) 0x04, (byte) 0x82, (byte) 0x04, (byte) 0x00, (byte) 0x00,
- (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05,
- (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0a,
- (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f,
- (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14,
- (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19,
- (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, (byte) 0x1e,
- (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22, (byte) 0x23,
- (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28,
- (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d,
- (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31, (byte) 0x32,
- (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37,
- (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b, (byte) 0x3c,
- (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40, (byte) 0x41,
- (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46,
- (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x4b,
- (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, (byte) 0x50,
- (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54, (byte) 0x55,
- (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a,
- (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, (byte) 0x5f,
- (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x64,
- (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69,
- (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, (byte) 0x6e,
- (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72, (byte) 0x73,
- (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78,
- (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, (byte) 0x7d,
- (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0x82,
- (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87,
- (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b, (byte) 0x8c,
- (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90, (byte) 0x91,
- (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95, (byte) 0x96,
- (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0x9b,
- (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, (byte) 0xa0,
- (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, (byte) 0xa5,
- (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa,
- (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae, (byte) 0xaf,
- (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4,
- (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, (byte) 0xb9,
- (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, (byte) 0xbe,
- (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, (byte) 0xc3,
- (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, (byte) 0xc8,
- (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc, (byte) 0xcd,
- (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, (byte) 0xd2,
- (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7,
- (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb, (byte) 0xdc,
- (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0, (byte) 0xe1,
- (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6,
- (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea, (byte) 0xeb,
- (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef, (byte) 0xf0,
- (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5,
- (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa,
- (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, (byte) 0xff,
- (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04,
- (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09,
- (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e,
- (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13,
- (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18,
- (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d,
- (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22,
- (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27,
- (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c,
- (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31,
- (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36,
- (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b,
- (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40,
- (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45,
- (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a,
- (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f,
- (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54,
- (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59,
- (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e,
- (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63,
- (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68,
- (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d,
- (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72,
- (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77,
- (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c,
- (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81,
- (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86,
- (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b,
- (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90,
- (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95,
- (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a,
- (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f,
- (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4,
- (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9,
- (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae,
- (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3,
- (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8,
- (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd,
- (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2,
- (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7,
- (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc,
- (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1,
- (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6,
- (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb,
- (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0,
- (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5,
- (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea,
- (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef,
- (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4,
- (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9,
- (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe,
- (byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
- (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08,
- (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d,
- (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12,
- (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17,
- (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c,
- (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21,
- (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26,
- (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b,
- (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30,
- (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35,
- (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a,
- (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f,
- (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44,
- (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49,
- (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e,
- (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53,
- (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58,
- (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d,
- (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62,
- (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67,
- (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c,
- (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71,
- (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76,
- (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b,
- (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80,
- (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85,
- (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a,
- (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f,
- (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94,
- (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99,
- (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e,
- (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3,
- (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8,
- (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad,
- (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2,
- (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7,
- (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc,
- (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1,
- (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6,
- (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb,
- (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0,
- (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5,
- (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda,
- (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf,
- (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4,
- (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9,
- (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee,
- (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3,
- (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8,
- (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd,
- (byte) 0xfe, (byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x02,
- (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
- (byte) 0x08, (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c,
- (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11,
- (byte) 0x12, (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16,
- (byte) 0x17, (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b,
- (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20,
- (byte) 0x21, (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25,
- (byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a,
- (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f,
- (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34,
- (byte) 0x35, (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39,
- (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e,
- (byte) 0x3f, (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43,
- (byte) 0x44, (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48,
- (byte) 0x49, (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d,
- (byte) 0x4e, (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52,
- (byte) 0x53, (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57,
- (byte) 0x58, (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c,
- (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61,
- (byte) 0x62, (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66,
- (byte) 0x67, (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b,
- (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70,
- (byte) 0x71, (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75,
- (byte) 0x76, (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a,
- (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f,
- (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84,
- (byte) 0x85, (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89,
- (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e,
- (byte) 0x8f, (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93,
- (byte) 0x94, (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98,
- (byte) 0x99, (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d,
- (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2,
- (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7,
- (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac,
- (byte) 0xad, (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1,
- (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6,
- (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb,
- (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0,
- (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5,
- (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca,
- (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf,
- (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4,
- (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9,
- (byte) 0xda, (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde,
- (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3,
- (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8,
- (byte) 0xe9, (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed,
- (byte) 0xee, (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2,
- (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7,
- (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc,
- (byte) 0xfd, (byte) 0xfe, (byte) 0xff };
-
- /**
- * "valid" encoding for DH - no alg params
- */
- private static final byte[] dhEncryptedPrivateKeyInfoNP = new byte[] {
- (byte) 0x30, (byte) 0x82, (byte) 0x04, (byte) 0x13, (byte) 0x30,
- (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a, (byte) 0x86,
- (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01,
- (byte) 0x03, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x04,
- (byte) 0x82, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x01,
- (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06,
- (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0a, (byte) 0x0b,
- (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, (byte) 0x10,
- (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14, (byte) 0x15,
- (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19, (byte) 0x1a,
- (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, (byte) 0x1f,
- (byte) 0x20, (byte) 0x21, (byte) 0x22, (byte) 0x23, (byte) 0x24,
- (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29,
- (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, (byte) 0x2e,
- (byte) 0x2f, (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x33,
- (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37, (byte) 0x38,
- (byte) 0x39, (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, (byte) 0x3d,
- (byte) 0x3e, (byte) 0x3f, (byte) 0x40, (byte) 0x41, (byte) 0x42,
- (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46, (byte) 0x47,
- (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x4b, (byte) 0x4c,
- (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, (byte) 0x50, (byte) 0x51,
- (byte) 0x52, (byte) 0x53, (byte) 0x54, (byte) 0x55, (byte) 0x56,
- (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a, (byte) 0x5b,
- (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, (byte) 0x60,
- (byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x64, (byte) 0x65,
- (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69, (byte) 0x6a,
- (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, (byte) 0x6f,
- (byte) 0x70, (byte) 0x71, (byte) 0x72, (byte) 0x73, (byte) 0x74,
- (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78, (byte) 0x79,
- (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, (byte) 0x7e,
- (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83,
- (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87, (byte) 0x88,
- (byte) 0x89, (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, (byte) 0x8d,
- (byte) 0x8e, (byte) 0x8f, (byte) 0x90, (byte) 0x91, (byte) 0x92,
- (byte) 0x93, (byte) 0x94, (byte) 0x95, (byte) 0x96, (byte) 0x97,
- (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0x9b, (byte) 0x9c,
- (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, (byte) 0xa1,
- (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, (byte) 0xa6,
- (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, (byte) 0xab,
- (byte) 0xac, (byte) 0xad, (byte) 0xae, (byte) 0xaf, (byte) 0xb0,
- (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, (byte) 0xb5,
- (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, (byte) 0xba,
- (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, (byte) 0xbf,
- (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, (byte) 0xc4,
- (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, (byte) 0xc9,
- (byte) 0xca, (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, (byte) 0xce,
- (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, (byte) 0xd3,
- (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, (byte) 0xd8,
- (byte) 0xd9, (byte) 0xda, (byte) 0xdb, (byte) 0xdc, (byte) 0xdd,
- (byte) 0xde, (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, (byte) 0xe2,
- (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, (byte) 0xe7,
- (byte) 0xe8, (byte) 0xe9, (byte) 0xea, (byte) 0xeb, (byte) 0xec,
- (byte) 0xed, (byte) 0xee, (byte) 0xef, (byte) 0xf0, (byte) 0xf1,
- (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, (byte) 0xf6,
- (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xfb,
- (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, (byte) 0xff, (byte) 0x00,
- (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05,
- (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0a,
- (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f,
- (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14,
- (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19,
- (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, (byte) 0x1e,
- (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22, (byte) 0x23,
- (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28,
- (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d,
- (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31, (byte) 0x32,
- (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37,
- (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b, (byte) 0x3c,
- (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40, (byte) 0x41,
- (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46,
- (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x4b,
- (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, (byte) 0x50,
- (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54, (byte) 0x55,
- (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a,
- (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, (byte) 0x5f,
- (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x64,
- (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69,
- (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, (byte) 0x6e,
- (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72, (byte) 0x73,
- (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78,
- (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, (byte) 0x7d,
- (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0x82,
- (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87,
- (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b, (byte) 0x8c,
- (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90, (byte) 0x91,
- (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95, (byte) 0x96,
- (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0x9b,
- (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, (byte) 0xa0,
- (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, (byte) 0xa5,
- (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa,
- (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae, (byte) 0xaf,
- (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4,
- (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, (byte) 0xb9,
- (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, (byte) 0xbe,
- (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, (byte) 0xc3,
- (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, (byte) 0xc8,
- (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc, (byte) 0xcd,
- (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, (byte) 0xd2,
- (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7,
- (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb, (byte) 0xdc,
- (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0, (byte) 0xe1,
- (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6,
- (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea, (byte) 0xeb,
- (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef, (byte) 0xf0,
- (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5,
- (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa,
- (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, (byte) 0xff,
- (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04,
- (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09,
- (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e,
- (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13,
- (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18,
- (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d,
- (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22,
- (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27,
- (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c,
- (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31,
- (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36,
- (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b,
- (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40,
- (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45,
- (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a,
- (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f,
- (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54,
- (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59,
- (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e,
- (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63,
- (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68,
- (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d,
- (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72,
- (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77,
- (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c,
- (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81,
- (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86,
- (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b,
- (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90,
- (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95,
- (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a,
- (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f,
- (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4,
- (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9,
- (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae,
- (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3,
- (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8,
- (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd,
- (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2,
- (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7,
- (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc,
- (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1,
- (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6,
- (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb,
- (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0,
- (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5,
- (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea,
- (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef,
- (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4,
- (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9,
- (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe,
- (byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
- (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08,
- (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d,
- (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12,
- (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17,
- (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c,
- (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21,
- (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26,
- (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b,
- (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30,
- (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35,
- (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a,
- (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f,
- (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44,
- (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49,
- (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e,
- (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53,
- (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58,
- (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d,
- (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62,
- (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67,
- (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c,
- (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71,
- (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76,
- (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b,
- (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80,
- (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85,
- (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a,
- (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f,
- (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94,
- (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99,
- (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e,
- (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3,
- (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8,
- (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad,
- (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2,
- (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7,
- (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc,
- (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1,
- (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6,
- (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb,
- (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0,
- (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5,
- (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda,
- (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf,
- (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4,
- (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9,
- (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee,
- (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3,
- (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8,
- (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd,
- (byte) 0xfe, (byte) 0xff, };
-
- /**
- * Valid DSA parameters encoding
- */
- private static final byte[] dsaParamsEncoded = { (byte) 0x30, (byte) 0x82,
- (byte) 0x01, (byte) 0x1e, (byte) 0x02, (byte) 0x81, (byte) 0x81,
- (byte) 0x00, (byte) 0x9f, (byte) 0x5e, (byte) 0x76, (byte) 0x19,
- (byte) 0x59, (byte) 0xd8, (byte) 0xf7, (byte) 0x6b, (byte) 0x91,
- (byte) 0x6d, (byte) 0x15, (byte) 0x7e, (byte) 0x14, (byte) 0x27,
- (byte) 0x25, (byte) 0x6e, (byte) 0x59, (byte) 0x2c, (byte) 0xec,
- (byte) 0x21, (byte) 0x7a, (byte) 0xb7, (byte) 0xd4, (byte) 0xf4,
- (byte) 0xa0, (byte) 0x26, (byte) 0x4e, (byte) 0x72, (byte) 0x29,
- (byte) 0x18, (byte) 0x4a, (byte) 0x1c, (byte) 0x9a, (byte) 0xc9,
- (byte) 0xcd, (byte) 0x85, (byte) 0x1b, (byte) 0x39, (byte) 0x41,
- (byte) 0x9e, (byte) 0x58, (byte) 0x16, (byte) 0xeb, (byte) 0x20,
- (byte) 0x84, (byte) 0x28, (byte) 0x2a, (byte) 0xb9, (byte) 0xce,
- (byte) 0xc7, (byte) 0x6d, (byte) 0x74, (byte) 0x99, (byte) 0xfe,
- (byte) 0xa5, (byte) 0xe8, (byte) 0x66, (byte) 0xe1, (byte) 0x48,
- (byte) 0xdd, (byte) 0x2e, (byte) 0xcf, (byte) 0xfe, (byte) 0xb9,
- (byte) 0x6a, (byte) 0x8e, (byte) 0x12, (byte) 0x4b, (byte) 0xa4,
- (byte) 0xa8, (byte) 0x87, (byte) 0xd7, (byte) 0xab, (byte) 0x26,
- (byte) 0xd6, (byte) 0xc3, (byte) 0xd1, (byte) 0x3b, (byte) 0x95,
- (byte) 0xc4, (byte) 0x97, (byte) 0x2c, (byte) 0xdc, (byte) 0xab,
- (byte) 0x5d, (byte) 0xf5, (byte) 0x55, (byte) 0xae, (byte) 0x58,
- (byte) 0x68, (byte) 0x84, (byte) 0x41, (byte) 0x99, (byte) 0x1b,
- (byte) 0xd3, (byte) 0xd0, (byte) 0xd9, (byte) 0xd3, (byte) 0xdd,
- (byte) 0xf5, (byte) 0x48, (byte) 0x04, (byte) 0xa2, (byte) 0x92,
- (byte) 0x61, (byte) 0xf8, (byte) 0xb1, (byte) 0xe6, (byte) 0x24,
- (byte) 0x65, (byte) 0x8f, (byte) 0xa4, (byte) 0x97, (byte) 0x40,
- (byte) 0x1d, (byte) 0x3f, (byte) 0x2b, (byte) 0x85, (byte) 0x00,
- (byte) 0xd5, (byte) 0xcb, (byte) 0x8d, (byte) 0x66, (byte) 0x9a,
- (byte) 0xac, (byte) 0x7b, (byte) 0x5f, (byte) 0xc7, (byte) 0x02,
- (byte) 0x15, (byte) 0x00, (byte) 0x9a, (byte) 0xfb, (byte) 0x6f,
- (byte) 0x72, (byte) 0x15, (byte) 0x01, (byte) 0x03, (byte) 0x16,
- (byte) 0x2a, (byte) 0xd6, (byte) 0xca, (byte) 0x60, (byte) 0x10,
- (byte) 0x47, (byte) 0xde, (byte) 0x4b, (byte) 0x0f, (byte) 0xd6,
- (byte) 0x73, (byte) 0x37, (byte) 0x02, (byte) 0x81, (byte) 0x80,
- (byte) 0x5d, (byte) 0x51, (byte) 0x28, (byte) 0x64, (byte) 0xb2,
- (byte) 0x2b, (byte) 0xeb, (byte) 0x85, (byte) 0xb4, (byte) 0x14,
- (byte) 0x0d, (byte) 0xad, (byte) 0xec, (byte) 0xc8, (byte) 0x1f,
- (byte) 0x96, (byte) 0x1e, (byte) 0x6a, (byte) 0x52, (byte) 0xd4,
- (byte) 0x0b, (byte) 0x69, (byte) 0xb0, (byte) 0x33, (byte) 0xa1,
- (byte) 0xd1, (byte) 0xbc, (byte) 0x64, (byte) 0xd6, (byte) 0x64,
- (byte) 0xef, (byte) 0x2c, (byte) 0x89, (byte) 0xc7, (byte) 0x39,
- (byte) 0x75, (byte) 0x87, (byte) 0x82, (byte) 0x61, (byte) 0xbe,
- (byte) 0xd1, (byte) 0xcd, (byte) 0x70, (byte) 0x41, (byte) 0x85,
- (byte) 0x99, (byte) 0x55, (byte) 0x75, (byte) 0x6f, (byte) 0x16,
- (byte) 0xc0, (byte) 0x40, (byte) 0xf1, (byte) 0x0c, (byte) 0x78,
- (byte) 0x1f, (byte) 0xe8, (byte) 0x63, (byte) 0x5d, (byte) 0xfa,
- (byte) 0x37, (byte) 0xc1, (byte) 0xce, (byte) 0x97, (byte) 0x76,
- (byte) 0xa5, (byte) 0x48, (byte) 0x5b, (byte) 0x88, (byte) 0xe4,
- (byte) 0xd5, (byte) 0xb8, (byte) 0x06, (byte) 0xf5, (byte) 0x7f,
- (byte) 0x92, (byte) 0xda, (byte) 0x99, (byte) 0xa5, (byte) 0x5a,
- (byte) 0x64, (byte) 0xc9, (byte) 0x30, (byte) 0x2c, (byte) 0x77,
- (byte) 0x58, (byte) 0x60, (byte) 0xa6, (byte) 0x35, (byte) 0x1d,
- (byte) 0x71, (byte) 0xfb, (byte) 0x49, (byte) 0x24, (byte) 0x6c,
- (byte) 0x34, (byte) 0x29, (byte) 0xa0, (byte) 0x47, (byte) 0xf1,
- (byte) 0x14, (byte) 0xad, (byte) 0xc2, (byte) 0x85, (byte) 0x41,
- (byte) 0xdd, (byte) 0x2c, (byte) 0x78, (byte) 0x2a, (byte) 0x5a,
- (byte) 0x24, (byte) 0x7f, (byte) 0x19, (byte) 0xf4, (byte) 0x0a,
- (byte) 0x2e, (byte) 0x1d, (byte) 0x92, (byte) 0x80, (byte) 0xe5,
- (byte) 0xe4, (byte) 0x05, (byte) 0x28, (byte) 0x48, (byte) 0x5c,
- (byte) 0x34, (byte) 0xc8, (byte) 0x22 };
-
- /**
- * Valid DH parameters encoding
- */
- private static final byte[] dhParamsEncoded = { (byte) 0x30, (byte) 0x82,
- (byte) 0x01, (byte) 0x0b, (byte) 0x02, (byte) 0x81, (byte) 0x81,
- (byte) 0x00, (byte) 0xce, (byte) 0x2c, (byte) 0x4f, (byte) 0xea,
- (byte) 0xf2, (byte) 0x83, (byte) 0xc5, (byte) 0x38, (byte) 0xc9,
- (byte) 0xb6, (byte) 0xd4, (byte) 0xf8, (byte) 0xb8, (byte) 0x17,
- (byte) 0xa1, (byte) 0x7d, (byte) 0x4c, (byte) 0xec, (byte) 0x6b,
- (byte) 0xd7, (byte) 0xc2, (byte) 0x1a, (byte) 0x35, (byte) 0x85,
- (byte) 0x54, (byte) 0x14, (byte) 0x6c, (byte) 0x52, (byte) 0x24,
- (byte) 0xbf, (byte) 0xe6, (byte) 0x32, (byte) 0xd8, (byte) 0x42,
- (byte) 0xac, (byte) 0xb3, (byte) 0x28, (byte) 0x4f, (byte) 0x77,
- (byte) 0xf6, (byte) 0xfc, (byte) 0xea, (byte) 0xea, (byte) 0x72,
- (byte) 0xcf, (byte) 0x1d, (byte) 0x7b, (byte) 0xe1, (byte) 0x72,
- (byte) 0xfa, (byte) 0x77, (byte) 0x12, (byte) 0xa9, (byte) 0x42,
- (byte) 0xba, (byte) 0xc4, (byte) 0xf4, (byte) 0xfb, (byte) 0xbd,
- (byte) 0x9f, (byte) 0x63, (byte) 0x9a, (byte) 0x58, (byte) 0x6b,
- (byte) 0xb6, (byte) 0xa2, (byte) 0x6e, (byte) 0x3a, (byte) 0x71,
- (byte) 0xf3, (byte) 0x43, (byte) 0x5e, (byte) 0x6f, (byte) 0x8a,
- (byte) 0xd0, (byte) 0xac, (byte) 0xe5, (byte) 0x60, (byte) 0x76,
- (byte) 0x57, (byte) 0x1f, (byte) 0x83, (byte) 0x4d, (byte) 0xbc,
- (byte) 0xaa, (byte) 0xb1, (byte) 0x18, (byte) 0x40, (byte) 0x19,
- (byte) 0xac, (byte) 0x31, (byte) 0xd4, (byte) 0xfc, (byte) 0x39,
- (byte) 0x01, (byte) 0x46, (byte) 0xab, (byte) 0xab, (byte) 0x53,
- (byte) 0x19, (byte) 0x2d, (byte) 0xf8, (byte) 0x4c, (byte) 0xd3,
- (byte) 0x9f, (byte) 0x4d, (byte) 0xa6, (byte) 0x71, (byte) 0x92,
- (byte) 0x06, (byte) 0xc7, (byte) 0x89, (byte) 0x70, (byte) 0xc4,
- (byte) 0xc6, (byte) 0xa2, (byte) 0x1f, (byte) 0x05, (byte) 0x4a,
- (byte) 0x5b, (byte) 0x84, (byte) 0xf9, (byte) 0xfb, (byte) 0x98,
- (byte) 0x63, (byte) 0xc9, (byte) 0x9c, (byte) 0x13, (byte) 0x02,
- (byte) 0x81, (byte) 0x80, (byte) 0x36, (byte) 0x55, (byte) 0x93,
- (byte) 0xb3, (byte) 0x22, (byte) 0x0c, (byte) 0xcd, (byte) 0x7c,
- (byte) 0xc3, (byte) 0xe3, (byte) 0xa3, (byte) 0x8a, (byte) 0xd7,
- (byte) 0xb4, (byte) 0xe9, (byte) 0xe0, (byte) 0xfa, (byte) 0xa9,
- (byte) 0xa8, (byte) 0x69, (byte) 0xd6, (byte) 0xa6, (byte) 0x20,
- (byte) 0xb8, (byte) 0xd4, (byte) 0xe7, (byte) 0x87, (byte) 0x4e,
- (byte) 0xf3, (byte) 0x90, (byte) 0x10, (byte) 0xdd, (byte) 0x75,
- (byte) 0x5d, (byte) 0xff, (byte) 0xee, (byte) 0xf0, (byte) 0xef,
- (byte) 0x6a, (byte) 0x0a, (byte) 0xb0, (byte) 0xf1, (byte) 0x8a,
- (byte) 0xb6, (byte) 0x7b, (byte) 0x39, (byte) 0x95, (byte) 0xd5,
- (byte) 0x24, (byte) 0x83, (byte) 0x10, (byte) 0x95, (byte) 0x34,
- (byte) 0x08, (byte) 0x77, (byte) 0x1d, (byte) 0xaf, (byte) 0x69,
- (byte) 0xf0, (byte) 0xb5, (byte) 0xdb, (byte) 0x24, (byte) 0x89,
- (byte) 0x72, (byte) 0xb2, (byte) 0x0d, (byte) 0x57, (byte) 0x94,
- (byte) 0xb0, (byte) 0xe8, (byte) 0xc2, (byte) 0x37, (byte) 0x45,
- (byte) 0x5a, (byte) 0xfc, (byte) 0xa1, (byte) 0xa0, (byte) 0x41,
- (byte) 0xe4, (byte) 0x0c, (byte) 0xa3, (byte) 0x40, (byte) 0x8b,
- (byte) 0x9c, (byte) 0x19, (byte) 0x63, (byte) 0x61, (byte) 0xd9,
- (byte) 0x05, (byte) 0xbf, (byte) 0xc5, (byte) 0xe8, (byte) 0xf7,
- (byte) 0xbd, (byte) 0x3a, (byte) 0xf5, (byte) 0x78, (byte) 0xc2,
- (byte) 0x92, (byte) 0xe8, (byte) 0x60, (byte) 0x07, (byte) 0x3e,
- (byte) 0x57, (byte) 0x12, (byte) 0xf6, (byte) 0x97, (byte) 0x1f,
- (byte) 0xea, (byte) 0x02, (byte) 0xa3, (byte) 0x19, (byte) 0xa7,
- (byte) 0x5a, (byte) 0x9b, (byte) 0xf6, (byte) 0xd2, (byte) 0x0f,
- (byte) 0xe9, (byte) 0x6b, (byte) 0xeb, (byte) 0xd7, (byte) 0x93,
- (byte) 0x9a, (byte) 0x7e, (byte) 0x4f, (byte) 0xd6, (byte) 0x29,
- (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0xff };
-
- /**
- * pretends to be encrypted private key
- */
- public static final byte[] encryptedData;
-
- private static final HashMap<String, byte[]> validEPKIEncodings = new HashMap<String, byte[]>();
-
- private static final HashMap<String, byte[]> validEPKIEncodingsNP = new HashMap<String, byte[]>();
-
- private static final HashMap<String, byte[]> validAPEncodings = new HashMap<String, byte[]>();
-
- static {
- validEPKIEncodings.put("DH", dhEncryptedPrivateKeyInfo);
- validEPKIEncodings.put("DIFFIEHELLMAN", dhEncryptedPrivateKeyInfo);
- validEPKIEncodings.put("DIFFIE-HELLMAN", dhEncryptedPrivateKeyInfo);
- validEPKIEncodings.put("1.2.840.113549.1.3.1",
- dhEncryptedPrivateKeyInfo);
- validEPKIEncodingsNP.put("DH", dhEncryptedPrivateKeyInfoNP);
- validEPKIEncodingsNP.put("DIFFIEHELLMAN", dhEncryptedPrivateKeyInfoNP);
- validEPKIEncodingsNP.put("DIFFIE-HELLMAN", dhEncryptedPrivateKeyInfoNP);
- validEPKIEncodings.put("DSA", dsaEncryptedPrivateKeyInfo);
- validEPKIEncodings.put("1.2.840.10040.4.1", dsaEncryptedPrivateKeyInfo);
- validEPKIEncodingsNP.put("DIFFIE-HELLMAN", dhEncryptedPrivateKeyInfoNP);
- validEPKIEncodingsNP.put("DSA", dsaEncryptedPrivateKeyInfoNP);
- validAPEncodings.put("DH", dhParamsEncoded);
- validAPEncodings.put("DIFFIEHELLMAN", dhParamsEncoded);
- validAPEncodings.put("DIFFIE-HELLMAN", dhParamsEncoded);
- validAPEncodings.put("1.2.840.113549.1.3.1", dhParamsEncoded);
- validAPEncodings.put("DSA", dsaParamsEncoded);
- validAPEncodings.put("1.2.840.10040.4.1", dsaParamsEncoded);
-
- encryptedData = new byte[1024];
- for (int i = 0; i < encryptedData.length; i++) {
- encryptedData[i] = (byte) i;
- }
- }
-
- /**
- * Algorithm_names/standard_names to be used in tests "DSA" and "DH" must be
- * always presented
- */
- public final static String[][] algName0 = new String[][] {
- { "DSA", "DSA" },
- { "DH", "DiffieHellman", "Diffie-Hellman" },
- { "1.2.840.10040.4.1", "DSA" },
- { "1.2.840.113549.1.1.1", "RSA" },
- { "1.2.840.113549.1.3.1", "DiffieHellman" },
- { "1.2.840.113549.1.5.3", "pbeWithMD5AndDES-CBC" },
- { "1.2.840.113549.1.12.1.3", "pbeWithSHAAnd3-KeyTripleDES-CBC" },
- // {"1.2.840.113549.1.12.1.6", "pbeWithSHAAnd40BitRC2-CBC"},
- { "1.2.840.113549.3.2", "RC2-CBC" },
- { "1.2.840.113549.3.3", "RC2-EBC" },
- { "1.2.840.113549.3.4", "RC4" },
- { "1.2.840.113549.3.5", "RC4WithMAC" },
- { "1.2.840.113549.3.6", "DESx-CBC" },
- { "1.2.840.113549.3.7", "TripleDES-CBC" },
- { "1.2.840.113549.3.8", "rc5CBC" },
- { "1.2.840.113549.3.9", "RC5-CBC" },
- { "1.2.840.113549.3.10", "DESCDMF" }, };
-
- /**
- * Returns valid encoding of EncryptedPrivateKeyInfo However encoded private
- * key field (encryptedData) does not contain valid encrypted data.
- *
- * @throws NoSuchAlgorithmException
- */
- public static byte[] getValidEncryptedPrivateKeyInfoEncoding(
- String algName, boolean includingAlgParameters)
- throws NoSuchAlgorithmException {
- String algNameUC = algName.toUpperCase();
- byte[] ret = includingAlgParameters ? validEPKIEncodings
- .get(algNameUC) : validEPKIEncodingsNP.get(algNameUC);
- if (ret != null) {
- return ret.clone();
- }
- throw new NoSuchAlgorithmException("No encoding available for "
- + algName);
- }
-
- public static byte[] getValidEncryptedPrivateKeyInfoEncoding(String algName)
- throws NoSuchAlgorithmException {
- return getValidEncryptedPrivateKeyInfoEncoding(algName, true);
- }
-
- /**
- * Returns valid encoding of EncryptedPrivateKeyInfo However encoded private
- * key field (encryptedData) does not contain valid encrypted data.
- *
- * @throws NoSuchAlgorithmException
- */
- public static byte[] getParametersEncoding(String algName)
- throws NoSuchAlgorithmException {
- String algNameUC = algName.toUpperCase();
- byte[] ret = validAPEncodings.get(algNameUC);
- if (ret != null) {
- return ret;
- }
- throw new NoSuchAlgorithmException("No AP encoding available for "
- + algName);
- }
-
-}
diff --git a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyCipher.java b/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyCipher.java
deleted file mode 100644
index 246e69a..0000000
--- a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyCipher.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.crypto.tests.support;
-
-import java.security.AlgorithmParameters;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-
-import javax.crypto.BadPaddingException;
-import javax.crypto.CipherSpi;
-import javax.crypto.IllegalBlockSizeException;
-import javax.crypto.NoSuchPaddingException;
-import javax.crypto.ShortBufferException;
-
-/**
- * Cipher implementation for testing
- */
-public class MyCipher extends CipherSpi {
-
- public MyCipher() {
- super();
- }
-
- @Override
- protected void engineSetMode(String mode) throws NoSuchAlgorithmException {
- }
-
- @Override
- protected void engineSetPadding(String padding)
- throws NoSuchPaddingException {
- if (!"PKCS5Padding".equals(padding)) {
- throw new NoSuchPaddingException(padding);
- }
- }
-
- @Override
- protected int engineGetBlockSize() {
- return 111;
- }
-
- @Override
- protected int engineGetOutputSize(int inputLen) {
- return inputLen + 10;
- }
-
- @Override
- protected byte[] engineGetIV() {
- byte[] b = { 1, 2, 3 };
- return b;
- }
-
- @Override
- protected AlgorithmParameters engineGetParameters() {
- return null;
- }
-
- @Override
- protected void engineInit(int opmode, Key key, SecureRandom random)
- throws InvalidKeyException {
- }
-
- @Override
- protected void engineInit(int opmode, Key key,
- AlgorithmParameterSpec params, SecureRandom random)
- throws InvalidKeyException, InvalidAlgorithmParameterException {
- }
-
- @Override
- protected void engineInit(int opmode, Key key, AlgorithmParameters params,
- SecureRandom random) throws InvalidKeyException,
- InvalidAlgorithmParameterException {
- }
-
- @Override
- protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) {
- return null;
- }
-
- @Override
- protected int engineUpdate(byte[] input, int inputOffset, int inputLen,
- byte[] output, int outputOffset) throws ShortBufferException {
- return 0;
- }
-
- @Override
- protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen)
- throws IllegalBlockSizeException, BadPaddingException {
- return null;
- }
-
- @Override
- protected int engineDoFinal(byte[] input, int inputOffset, int inputLen,
- byte[] output, int outputOffset) throws ShortBufferException,
- IllegalBlockSizeException, BadPaddingException {
- return 0;
- }
-
-}
diff --git a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyExemptionMechanismSpi.java b/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyExemptionMechanismSpi.java
deleted file mode 100644
index 3dc2893..0000000
--- a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyExemptionMechanismSpi.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.support;
-
-import java.security.AlgorithmParameters;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.spec.AlgorithmParameterSpec;
-
-import javax.crypto.ExemptionMechanismException;
-import javax.crypto.ExemptionMechanismSpi;
-import javax.crypto.ShortBufferException;
-
-/**
- * Additional class for verification ExemptionMechanismSpi
- * and ExemptionMechanism classes
- */
-
-public class MyExemptionMechanismSpi extends ExemptionMechanismSpi {
-
- private static final int byteArrayLength = 5;
-
- public static final int getLength() {
- return byteArrayLength;
- }
-
- @Override
- protected byte[] engineGenExemptionBlob()
- throws ExemptionMechanismException {
- return new byte[byteArrayLength];
- }
-
- @Override
- protected int engineGenExemptionBlob(byte[] output, int outputOffset)
- throws ShortBufferException, ExemptionMechanismException {
- return byteArrayLength;
- }
-
- @Override
- protected int engineGetOutputSize(int inputLen) {
- return 10;
- }
-
- @Override
- protected void engineInit(Key key) throws InvalidKeyException,
- ExemptionMechanismException {
- if (key == null) {
- throw new InvalidKeyException("key is null");
- }
- if (!(key instanceof tmpKey)) {
- throw new ExemptionMechanismException("Incorrect key");
- }
- }
-
- @Override
- protected void engineInit(Key key, AlgorithmParameters params)
- throws InvalidKeyException, InvalidAlgorithmParameterException,
- ExemptionMechanismException {
- if (key == null) {
- throw new InvalidKeyException("key is null");
- }
- if (!(key instanceof tmpKey)) {
- throw new ExemptionMechanismException("Incorrect key");
- }
- }
-
- @Override
- protected void engineInit(Key key, AlgorithmParameterSpec params)
- throws InvalidKeyException, InvalidAlgorithmParameterException,
- ExemptionMechanismException {
- if (key == null) {
- throw new InvalidKeyException("key is null");
- }
- if (!(key instanceof tmpKey)) {
- throw new ExemptionMechanismException("Incorrect key");
- }
- }
-
- @SuppressWarnings("serial")
- public class tmpKey implements Key {
- private String alg;
- private byte[] enc;
-
- public tmpKey(String alg, byte[] enc) {
- this.alg = alg;
- this.enc = enc;
- }
-
- public String getFormat() {
- return "tmpKey";
- }
-
- public String getAlgorithm() {
- return alg;
- }
-
- public byte[] getEncoded() {
- return enc;
- }
- }
-
- @SuppressWarnings("serial")
- public class tmp1Key implements Key {
- private byte[] enc;
-
- public tmp1Key(String alg, byte[] enc) {
- this.enc = enc;
- }
-
- public String getAlgorithm() {
- return "tmp1Key";
- }
-
- public String getFormat() {
- return "tmp1Key";
- }
-
- public byte[] getEncoded() {
- return enc;
- }
- }
-}
diff --git a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyKeyAgreementSpi.java b/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyKeyAgreementSpi.java
deleted file mode 100644
index 62678bb..0000000
--- a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyKeyAgreementSpi.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.support;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-
-import javax.crypto.KeyAgreementSpi;
-import javax.crypto.SecretKey;
-import javax.crypto.ShortBufferException;
-
-/**
- * Additional class for verification of KeyAgreementSpi
- * and KeyAgreement functionality
- */
-
-public class MyKeyAgreementSpi extends KeyAgreementSpi {
-
- @Override
- protected Key engineDoPhase(Key key, boolean lastPhase)
- throws InvalidKeyException, IllegalStateException {
- if (!lastPhase) {
- throw new IllegalStateException("last Phase is false");
- }
- return null;
- }
-
- @Override
- protected byte[] engineGenerateSecret() throws IllegalStateException {
- return new byte[0];
- }
-
- @Override
- protected int engineGenerateSecret(byte[] sharedSecret, int offset)
- throws IllegalStateException, ShortBufferException {
- return -1;
- }
-
- @Override
- protected SecretKey engineGenerateSecret(String algorithm)
- throws IllegalStateException, NoSuchAlgorithmException,
- InvalidKeyException {
- if (algorithm.length() == 0) {
- throw new NoSuchAlgorithmException("Algorithm is empty");
- }
- return null;
- }
-
- @Override
- protected void engineInit(Key key, SecureRandom random)
- throws InvalidKeyException {
- throw new IllegalArgumentException("Invalid parameter");
- }
-
- @Override
- protected void engineInit(Key key, AlgorithmParameterSpec params,
- SecureRandom random) throws InvalidKeyException,
- InvalidAlgorithmParameterException {
- throw new IllegalArgumentException("Invalid parameter");
- }
-} \ No newline at end of file
diff --git a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyKeyGeneratorSpi.java b/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyKeyGeneratorSpi.java
deleted file mode 100644
index d90f6d4..0000000
--- a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyKeyGeneratorSpi.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.support;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-
-import javax.crypto.KeyGeneratorSpi;
-import javax.crypto.SecretKey;
-
-/**
- * Additional class for verification of
- * KeyGeneratorSpi and KeyGenerator functionality
- */
-
-public class MyKeyGeneratorSpi extends KeyGeneratorSpi {
-
- @Override
- protected SecretKey engineGenerateKey() {
- return null;
- }
-
- @Override
- protected void engineInit(AlgorithmParameterSpec params, SecureRandom random)
- throws InvalidAlgorithmParameterException {
- if (params == null) {
- throw new InvalidAlgorithmParameterException("params is null");
- }
- }
-
- @Override
- protected void engineInit(int keysize, SecureRandom random) {
- if (keysize <= 77) {
- throw new IllegalArgumentException("Invalid keysize");
- }
- }
-
- @Override
- protected void engineInit(SecureRandom random) {
- throw new IllegalArgumentException("Invalid random");
- }
-} \ No newline at end of file
diff --git a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyMacSpi.java b/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyMacSpi.java
deleted file mode 100644
index d78d2a5..0000000
--- a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MyMacSpi.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.support;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.spec.AlgorithmParameterSpec;
-
-import javax.crypto.MacSpi;
-import javax.crypto.spec.SecretKeySpec;
-
-/**
- * Additional class for verification of MacGeneratorSpi and MacSpi
- */
-
-public class MyMacSpi extends MacSpi {
-
- private int length = 0;
-
- @Override
- protected int engineGetMacLength() {
- return length;
- }
-
- @Override
- protected void engineInit(Key key, AlgorithmParameterSpec params)
- throws InvalidKeyException, InvalidAlgorithmParameterException {
- if (params == null) {
- if (!(key instanceof SecretKeySpec)) {
- throw new IllegalArgumentException("params is null and key is SecretKeySpec");
- }
- }
- }
-
- @Override
- protected void engineUpdate(byte input) {
- }
-
- @Override
- protected void engineUpdate(byte[] input, int offset, int len) {
- if (offset >= 0 && len >= 0) {
- length = len;
- }
- }
-
- @Override
- protected byte[] engineDoFinal() {
- return new byte[length];
- }
-
- @Override
- protected void engineReset() {
- length++;
- }
-} \ No newline at end of file
diff --git a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MySecretKeyFactorySpi.java b/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MySecretKeyFactorySpi.java
deleted file mode 100644
index 97166b0..0000000
--- a/crypto/src/test/support/common/java/org/apache/harmony/crypto/tests/support/MySecretKeyFactorySpi.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.crypto.tests.support;
-
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.KeySpec;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-
-/**
- * Additional class for verification of SecretKeyFactorySpi
- * and SecretKeyFactory functionality
- */
-
-public class MySecretKeyFactorySpi extends SecretKeyFactorySpi {
- @Override
- protected SecretKey engineGenerateSecret(KeySpec keySpec)
- throws InvalidKeySpecException {
- return null;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected KeySpec engineGetKeySpec(SecretKey key, Class keySpec)
- throws InvalidKeySpecException {
- return null;
- }
-
- @Override
- protected SecretKey engineTranslateKey(SecretKey key)
- throws InvalidKeyException {
- return null;
- }
-}
diff --git a/security/src/test/api/java.injected/java/security/AlgorithmParameterGeneratorSpiTest.java b/security/src/test/api/java.injected/java/security/AlgorithmParameterGeneratorSpiTest.java
deleted file mode 100644
index c0dda62..0000000
--- a/security/src/test/api/java.injected/java/security/AlgorithmParameterGeneratorSpiTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package java.security;
-
-
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>AlgorithmParameterGeneratorSpi</code> class constructors
- * and methods.
- */
-
-public class AlgorithmParameterGeneratorSpiTest extends TestCase {
-
- /**
- * Constructor for CertPathBuilderTests.
- *
- * @param name
- */
- public AlgorithmParameterGeneratorSpiTest(String name) {
- super(name);
- }
-
- /**
- * Test for <code>AlgorithmParameterGeneratorSpi</code> constructor
- * Assertion: constructs AlgorithmParameterGeneratorSpi
- */
- public void testAlgorithmParameterGeneratorSpi01()
- throws InvalidAlgorithmParameterException {
- AlgorithmParameterGeneratorSpi algParGen = new MyAlgorithmParameterGeneratorSpi();
- AlgorithmParameters param = algParGen.engineGenerateParameters();
- assertNull("Not null parameters", param);
- AlgorithmParameterSpec pp = null;
- algParGen.engineInit(pp, new SecureRandom());
- try {
- algParGen.engineInit(pp, null);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- algParGen.engineInit(0, null);
- algParGen.engineInit(0, new SecureRandom());
-
- try {
- algParGen.engineInit(-10, null);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- try {
- algParGen.engineInit(-10, new SecureRandom());
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-}
diff --git a/security/src/test/api/java.injected/java/security/IdentityTest.java b/security/src/test/api/java.injected/java/security/IdentityTest.java
deleted file mode 100644
index c7931f0..0000000
--- a/security/src/test/api/java.injected/java/security/IdentityTest.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Aleksei Y. Semenov
- */
-
-package java.security;
-
-
-import org.apache.harmony.security.tests.support.CertificateStub;
-import org.apache.harmony.security.tests.support.IdentityStub;
-import org.apache.harmony.security.tests.support.PublicKeyStub;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for class Identity
- */
-
-public class IdentityTest extends TestCase {
-
- /**
- * Constructor for IdentityTest.
- *
- * @param name
- */
- public IdentityTest(String name) {
- super(name);
- }
-
- public void testHashCode() {
- new IdentityStub("testHashCode").hashCode();
- }
-
- public void testEquals() throws Exception {
- Identity i1 = new IdentityStub("testEquals");
- Object value[] = {
- null, Boolean.FALSE,
- new Object(), Boolean.FALSE,
- i1, Boolean.TRUE,
- new IdentityStub(i1.getName()), Boolean.TRUE
- };
-
- for (int k = 0; k < value.length; k += 2) {
- assertEquals(value[k + 1], new Boolean(i1.equals(value[k])));
- if (Boolean.TRUE.equals(value[k + 1]))
- assertEquals(i1.hashCode(), value[k].hashCode());
- }
- // check other cases
- Identity i2 = new IdentityStub("testEquals", IdentityScope.getSystemScope());
- assertEquals(i1.identityEquals(i2), i1.equals(i2));
- Identity i3 = new IdentityStub("testEquals3");
- assertEquals(i1.identityEquals(i3), i1.equals(i3));
-
- }
-
- /**
- * verify Identity.toString()
- */
- public void testToString2() {
- assertNotNull(new IdentityStub("testToString2").toString());
- }
-
- /**
- * verify Identity() creates instance
- */
- public void testIdentity() {
- assertNotNull(new IdentityStub());
- }
-
- /*
- * verify Identity(String) creates instance with given name
- */
- public void testIdentityString() {
- Identity i = new IdentityStub("iii");
- assertNotNull(i);
- assertEquals("iii", i.getName());
- i = new IdentityStub(null);
- assertNotNull(i);
- assertNull(i.getName());
- }
-
- /**
- * verify Identity(String, IdentityScope) creates instance with given name and in give scope
- */
- public void testIdentityStringIdentityScope() throws Exception {
- IdentityScope s = IdentityScope.getSystemScope();
- Identity i = new IdentityStub("iii2", s);
- assertNotNull(i);
- assertEquals("iii2", i.getName());
- assertSame(s, i.getScope());
- assertSame(i, s.getIdentity(i.getName()));
- }
-
- /**
- * verify addCertificate(Certificate certificate) adds a certificate for this identity.
- * If the identity has a public key, the public key in the certificate must be the same
- */
- public void testAddCertificate1() throws Exception {
- Identity i = new IdentityStub("iii");
- PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", new byte[] { 1, 2, 3, 4, 5 });
- i.setPublicKey(pk1);
- // try with the same key
- CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
- i.addCertificate(c1);
- assertSame(c1, i.certificates()[0]);
- // try Certificate with different key
- try {
- i.addCertificate(new CertificateStub("ccc", null, null, new PublicKeyStub("k2", "fff", new byte[] { 6, 7, 8, 9, 0 })));
- fail("KeyManagementException should be thrown");
- } catch (KeyManagementException ok) {
- }
- }
-
- /**
- * verify addCertificate(Certificate certificate) adds a certificate for this identity.
- * if the identity does not have a public key, the identity's public key is set to be that specified in the certificate.
- */
- public void testAddCertificate2() throws Exception {
- Identity i = new IdentityStub("iii");
- PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
- CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
- i.addCertificate(c1);
- assertSame(c1, i.certificates()[0]);
- assertSame(pk1, i.getPublicKey());
-
- }
-
- /**
- * verify addCertificate(Certificate certificate) throws KeyManagementException if certificate is null
- */
- public void testAddCertificate4() throws Exception {
- try {
- new IdentityStub("aaa").addCertificate(null);
- fail("KeyManagementException should be thrown");
- } catch (KeyManagementException ok) {
- } catch (NullPointerException ok) {
- }
-
- }
-//
-// Commented out since there will no be fix for the test failure
-// /**
-// * verify removeCertificate(Certificate certificate) removes certificate
-// */
-// public void testRemoveCertificate1() throws Exception{
-// Identity i = new IdentityStub("iii");
-// PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
-// CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
-// i.addCertificate(c1);
-// assertSame(c1, i.certificates()[0]);
-// i.removeCertificate(c1);
-// assertEquals(0, i.certificates().length);
-// // throw KeyManagementException if certificate not found
-// try {
-// i.removeCertificate(c1);
-// fail("KeyManagementException should be thrown");
-// } catch (KeyManagementException ok) {
-// }
-// try {
-// i.removeCertificate(null);
-// fail("KeyManagementException should be thrown");
-// } catch (KeyManagementException ok) {
-//
-// }
-// }
-
- /**
- * verify certificates() returns a copy of all certificates for this identity
- */
- public void testCertificates() throws Exception {
- Identity i = new IdentityStub("iii");
- PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
- CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
- CertificateStub c2 = new CertificateStub("zzz", null, null, pk1);
- i.addCertificate(c1);
- i.addCertificate(c2);
- Certificate[] s = i.certificates();
- assertEquals(2, s.length);
- assertTrue(c1.equals(s[0]) || c2.equals(s[0]));
- assertTrue(c1.equals(s[1]) || c2.equals(s[1]));
- s[0] = null;
- s[1] = null;
- // check that the copy was modified
- s = i.certificates();
- assertEquals(2, s.length);
- assertTrue(c1.equals(s[0]) || c2.equals(s[0]));
- assertTrue(c1.equals(s[1]) || c2.equals(s[1]));
- }
-
- /**
- * verify Identity.identityEquals(Identity) return true, only if names and public keys are equal
- */
-
- public void testIdentityEquals() throws Exception {
- String name = "nnn";
- PublicKey pk = new PublicKeyStub("aaa", "fff", new byte[] { 1, 2, 3, 4, 5 });
- Identity i = new IdentityStub(name);
- i.setPublicKey(pk);
- Object[] value = {
- //null, Boolean.FALSE,
- //new Object(), Boolean.FALSE,
- new IdentityStub("111"), Boolean.FALSE,
- new IdentityStub(name), Boolean.FALSE,
- new IdentityStub(name, IdentityScope.getSystemScope()), Boolean.FALSE,
- i, Boolean.TRUE,
- new IdentityStub(name, pk), Boolean.TRUE
- };
- for (int k = 0; k < value.length; k += 2) {
- assertEquals(value[k + 1], new Boolean(i.identityEquals((Identity) value[k])));
- if (Boolean.TRUE.equals(value[k + 1]))
- assertEquals(i.hashCode(), value[k].hashCode());
- }
- Identity i2 = IdentityScope.getSystemScope().getIdentity(name);
- i2.setPublicKey(pk);
- assertTrue(i.identityEquals(i2));
- }
-
- /**
- * verify Identity.toString(boolean) return string representation of identity
- */
- public void testToStringboolean() throws Exception {
- new IdentityStub("aaa").toString(false);
- new IdentityStub("aaa2", IdentityScope.getSystemScope()).toString(false);
- new IdentityStub("bbb").toString(true);
- new IdentityStub("bbb2", IdentityScope.getSystemScope()).toString(true);
- }
-
- /**
- * verify Identity.getScope() returns identity's scope
- */
- public void testGetScope() throws Exception {
- Identity i = new IdentityStub("testGetScope");
- assertNull(i.getScope());
- IdentityScope s = IdentityScope.getSystemScope();
-
- Identity i2 = new IdentityStub("testGetScope2", s);
- assertSame(s, i2.getScope());
-
- }
-
- /**
- * verify Identity.setPublicKey() throws KeyManagementException if key is invalid
- */
- public void testSetPublicKey2() throws Exception {
- Identity i2 = new IdentityStub("testSetPublicKey2_2", IdentityScope.getSystemScope());
- new PublicKeyStub("kkk", "testSetPublicKey2", new byte[] { 1, 2, 3, 4, 5 });
- try {
- i2.setPublicKey(null);
- //fail("KeyManagementException should be thrown - key is null");
- } catch (KeyManagementException ok) {
- }
- }
-
-//
-// Commented out since there will no be fix for the test failure
-// /**
-// *
-// * verify Identity.setPublicKey() throws KeyManagementException if key is already used
-// *
-// */
-// public void testSetPublicKey3() throws Exception {
-// Identity i1 = new IdentityStub("testSetPublicKey3_1", IdentityScope.getSystemScope());
-// Identity i2 = new IdentityStub("testSetPublicKey3_2", IdentityScope.getSystemScope());
-// PublicKey pk = new PublicKeyStub("kkk", "fff", new byte[]{1,2,3,4,5});
-// i1.setPublicKey(pk);
-// try {
-// i2.setPublicKey(pk);
-// fail("KeyManagementException should be thrown - key already used");
-// } catch (KeyManagementException ok) {};
-// }
-
- /**
- * verify Identity.setPublicKey() removes old key and all identity's certificates
- */
- public void testSetPublicKey4() throws Exception {
- Identity i = new IdentityStub("testSetPublicKey4");
- PublicKeyStub pk1 = new PublicKeyStub("kkk", "Identity.testSetPublicKey4", null);
- CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
- CertificateStub c2 = new CertificateStub("zzz", null, null, pk1);
- i.addCertificate(c1);
- i.addCertificate(c2);
- assertEquals(2, i.certificates().length);
- assertSame(pk1, i.getPublicKey());
-
- PublicKeyStub pk2 = new PublicKeyStub("zzz", "Identity.testSetPublicKey4", null);
- i.setPublicKey(pk2);
- assertSame(pk2, i.getPublicKey());
- assertEquals(0, i.certificates().length);
- }
-
- /**
- * verify Identity.getPublicKey() returns public key
- */
-
- public void testGetPublicKey() throws Exception {
- Identity i = new IdentityStub("testGetPublicKey");
- assertNull(i.getPublicKey());
- PublicKey pk = new PublicKeyStub("kkk", "Identity.testGetPublicKey", null);
- i.setPublicKey(pk);
- assertSame(pk, i.getPublicKey());
- }
-
- public void testGetInfo() {
-
- Identity i = new IdentityStub("testGetInfo");
- i.setInfo("some info");
- assertEquals("some info", i.getInfo());
- }
-
- public void testGetName() {
- Identity i = new IdentityStub("testGetName");
- assertEquals("testGetName", i.getName());
- }
-
-}
diff --git a/security/src/test/api/java.injected/java/security/ProviderTest.java b/security/src/test/api/java.injected/java/security/ProviderTest.java
deleted file mode 100644
index 3c4e956..0000000
--- a/security/src/test/api/java.injected/java/security/ProviderTest.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package java.security;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.TestUtils;
-
-import tests.support.resource.Support_Resources;
-
-
-/**
- * Tests for <code>Provider</code> constructor and methods
- */
-public class ProviderTest extends TestCase {
-
- Provider p;
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- p = new MyProvider();
- }
-
- /*
- * Class under test for void load(InputStream)
- */
- public final void testLoadInputStream() throws IOException {
-
- p.load(Support_Resources
- .getResourceStream("java/security/Provider.prop.dat"));
-
- if (!"value 1".equals(p.getProperty("Property 1").trim()) ||
- !"className".equals(p.getProperty("serviceName.algName").trim()) ||
- !"attrValue".equals(p.getProperty("serviceName.algName attrName").trim()) ||
- !"standardName".equals(p.getProperty("Alg.Alias.engineClassName.aliasName").trim()) ||
- !String.valueOf(p.getName()).equals(p.getProperty("Provider.id name").trim()) ||
- !String.valueOf(p.getVersion()).equals(p.getProperty("Provider.id version").trim()) ||
- !String.valueOf(p.getInfo()).equals(p.getProperty("Provider.id info").trim()) ||
- !p.getClass().getName().equals(p.getProperty("Provider.id className").trim()) ||
- !"SomeClassName".equals(p.getProperty("MessageDigest.SHA-1").trim())) {
- fail("Incorrect property value");
- }
- }
-
- public final void testGetService() {
- try {
- p.getService(null, "algorithm");
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- try {
- p.getService("type", null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- Provider.Service s = new Provider.Service(p, "Type", "Algorithm",
- "className", null, null);
- p.putService(s);
-
- if (p.getService("Type", "AlgoRithM") != s) {
- fail("Case 1. getService() failed");
- }
-
- Provider.Service s1 = p.getService("MessageDigest", "AbC");
- if (s1 == null) {
- fail("Case 2. getService() failed");
- }
-
- s = new Provider.Service(p, "MessageDigest", "SHA-1",
- "className", null, null);
- p.putService(s);
- if (s1 == p.getService("MessageDigest", "SHA-1")) {
- fail("Case 3. getService() failed");
- }
-
- if (p.getService("MessageDigest", "SHA1") == null) {
- fail("Case 4. getService() failed");
- }
- }
-
- public final void testGetServices() {
- Provider.Service s = new Provider.Service(p, "Type", "Algorithm",
- "className", null, null);
-
- // incomplete services should be removed
- p.put("serv.alg", "aaaaaaaaaaaaa");
- p.put("serv.alg KeySize", "11111");
- p.put("serv1.alg1 KeySize", "222222");
- p.remove("serv.alg");
-
- p.putService(s);
- Set services = p.getServices();
- if (services.size() != 3) {
- fail("incorrect size");
- }
- for (Iterator it = services.iterator(); it.hasNext(); ) {
- s = (Provider.Service) it.next();
- if ("Type".equals(s.getType()) &&
- "Algorithm".equals(s.getAlgorithm()) &&
- "className".equals(s.getClassName())) {
- continue;
- }
- if ("MessageDigest".equals(s.getType()) &&
- "SHA-1".equals(s.getAlgorithm()) &&
- "SomeClassName".equals(s.getClassName())) {
- continue;
- }
- if ("MessageDigest".equals(s.getType()) &&
- "abc".equals(s.getAlgorithm()) &&
- "SomeClassName".equals(s.getClassName())) {
- continue;
- }
- fail("Incorrect service");
- }
- }
-
- public final void testPutService() {
- HashMap hm = new HashMap();
- hm.put("KeySize", "1024");
- hm.put("AAA", "BBB");
- Provider.Service s = new Provider.Service(p, "Type", "Algorithm",
- "className", null, hm);
- p.putService(s);
- if (s != p.getService("Type", "Algorithm")) {
- fail("putService failed");
- }
- if (!"className".equals(p.getProperty("Type.Algorithm"))) {
- fail("incorrect className");
- }
- if (!"1024".equals(p.getProperty("Type.Algorithm KeySize"))) {
- fail("incorrect attribute");
- }
- }
-
- public final void testRemoveService() {
- Provider.Service s = new Provider.Service(p, "Type", "Algorithm",
- "className", null, null);
- p.putService(s);
- p.removeService(s);
- Set services = p.getServices();
- if (services.size() != 2) {
- fail("incorrect size");
- }
-
- for (Iterator it = services.iterator(); it.hasNext(); ) {
- s = (Provider.Service) it.next();
- if ("MessageDigest".equals(s.getType()) &&
- "SHA-1".equals(s.getAlgorithm()) &&
- "SomeClassName".equals(s.getClassName())) {
- continue;
- }
- if ("MessageDigest".equals(s.getType()) &&
- "abc".equals(s.getAlgorithm()) &&
- "SomeClassName".equals(s.getClassName())) {
- continue;
- }
- fail("Incorrect service");
- }
-
- if (p.getProperty("Type.Algorithm") != null) {
- fail("incorrect property");
- }
- }
-
- class MyProvider extends Provider {
- MyProvider() {
- super("MyProvider", 1.0, "Provider for testing");
- put("MessageDigest.SHA-1", "SomeClassName");
- put("MessageDigest.abc", "SomeClassName");
- put("Alg.Alias.MessageDigest.SHA1", "SHA-1");
- }
-
- MyProvider(String name, double version, String info) {
- super(name, version, info);
- }
- }
-}
diff --git a/security/src/test/api/java.injected/java/security/SecureClassLoaderTest.java b/security/src/test/api/java.injected/java/security/SecureClassLoaderTest.java
deleted file mode 100644
index 9c6bd75..0000000
--- a/security/src/test/api/java.injected/java/security/SecureClassLoaderTest.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package java.security;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.nio.ByteBuffer;
-import java.security.cert.Certificate;
-
-import junit.framework.TestCase;
-
-
-/**
- * Unit test for SecureClassLoader.
- */
-
-public class SecureClassLoaderTest extends TestCase {
-
- /**
- * A class name for the class presented as {@link klassData bytecode below}
- */
- private static final String klassName = "HiWorld";
-
- /**
- * Some class presented as bytecode<br>
- * Class src:<br>
- * <p/>
- * <code>public class HiWorld {
- * public static void main(String[] args)
- * {System.out.println("Hi, world!"); }
- * }
- * </code>
- */
-
- private static final byte[] klassData = { (byte) 0xCA, (byte) 0xFE,
- (byte) 0xBA, (byte) 0xBE, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x2E, (byte) 0x00, (byte) 0x22, (byte) 0x01, (byte) 0x00,
- (byte) 0x07, (byte) 0x48, (byte) 0x69, (byte) 0x57, (byte) 0x6F,
- (byte) 0x72, (byte) 0x6C, (byte) 0x64, (byte) 0x07, (byte) 0x00,
- (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x10, (byte) 0x6A,
- (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C,
- (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x4F,
- (byte) 0x62, (byte) 0x6A, (byte) 0x65, (byte) 0x63, (byte) 0x74,
- (byte) 0x07, (byte) 0x00, (byte) 0x03, (byte) 0x01, (byte) 0x00,
- (byte) 0x06, (byte) 0x3C, (byte) 0x69, (byte) 0x6E, (byte) 0x69,
- (byte) 0x74, (byte) 0x3E, (byte) 0x01, (byte) 0x00, (byte) 0x03,
- (byte) 0x28, (byte) 0x29, (byte) 0x56, (byte) 0x01, (byte) 0x00,
- (byte) 0x04, (byte) 0x43, (byte) 0x6F, (byte) 0x64, (byte) 0x65,
- (byte) 0x0C, (byte) 0x00, (byte) 0x05, (byte) 0x00, (byte) 0x06,
- (byte) 0x0A, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x08,
- (byte) 0x01, (byte) 0x00, (byte) 0x0F, (byte) 0x4C, (byte) 0x69,
- (byte) 0x6E, (byte) 0x65, (byte) 0x4E, (byte) 0x75, (byte) 0x6D,
- (byte) 0x62, (byte) 0x65, (byte) 0x72, (byte) 0x54, (byte) 0x61,
- (byte) 0x62, (byte) 0x6C, (byte) 0x65, (byte) 0x01, (byte) 0x00,
- (byte) 0x12, (byte) 0x4C, (byte) 0x6F, (byte) 0x63, (byte) 0x61,
- (byte) 0x6C, (byte) 0x56, (byte) 0x61, (byte) 0x72, (byte) 0x69,
- (byte) 0x61, (byte) 0x62, (byte) 0x6C, (byte) 0x65, (byte) 0x54,
- (byte) 0x61, (byte) 0x62, (byte) 0x6C, (byte) 0x65, (byte) 0x01,
- (byte) 0x00, (byte) 0x04, (byte) 0x74, (byte) 0x68, (byte) 0x69,
- (byte) 0x73, (byte) 0x01, (byte) 0x00, (byte) 0x09, (byte) 0x4C,
- (byte) 0x48, (byte) 0x69, (byte) 0x57, (byte) 0x6F, (byte) 0x72,
- (byte) 0x6C, (byte) 0x64, (byte) 0x3B, (byte) 0x01, (byte) 0x00,
- (byte) 0x04, (byte) 0x6D, (byte) 0x61, (byte) 0x69, (byte) 0x6E,
- (byte) 0x01, (byte) 0x00, (byte) 0x16, (byte) 0x28, (byte) 0x5B,
- (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61,
- (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67,
- (byte) 0x2F, (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x69,
- (byte) 0x6E, (byte) 0x67, (byte) 0x3B, (byte) 0x29, (byte) 0x56,
- (byte) 0x01, (byte) 0x00, (byte) 0x10, (byte) 0x6A, (byte) 0x61,
- (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61,
- (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x53, (byte) 0x79,
- (byte) 0x73, (byte) 0x74, (byte) 0x65, (byte) 0x6D, (byte) 0x07,
- (byte) 0x00, (byte) 0x10, (byte) 0x01, (byte) 0x00, (byte) 0x03,
- (byte) 0x6F, (byte) 0x75, (byte) 0x74, (byte) 0x01, (byte) 0x00,
- (byte) 0x15, (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76,
- (byte) 0x61, (byte) 0x2F, (byte) 0x69, (byte) 0x6F, (byte) 0x2F,
- (byte) 0x50, (byte) 0x72, (byte) 0x69, (byte) 0x6E, (byte) 0x74,
- (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x65, (byte) 0x61,
- (byte) 0x6D, (byte) 0x3B, (byte) 0x0C, (byte) 0x00, (byte) 0x12,
- (byte) 0x00, (byte) 0x13, (byte) 0x09, (byte) 0x00, (byte) 0x11,
- (byte) 0x00, (byte) 0x14, (byte) 0x01, (byte) 0x00, (byte) 0x0A,
- (byte) 0x48, (byte) 0x69, (byte) 0x2C, (byte) 0x20, (byte) 0x77,
- (byte) 0x6F, (byte) 0x72, (byte) 0x6C, (byte) 0x64, (byte) 0x21,
- (byte) 0x08, (byte) 0x00, (byte) 0x16, (byte) 0x01, (byte) 0x00,
- (byte) 0x13, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61,
- (byte) 0x2F, (byte) 0x69, (byte) 0x6F, (byte) 0x2F, (byte) 0x50,
- (byte) 0x72, (byte) 0x69, (byte) 0x6E, (byte) 0x74, (byte) 0x53,
- (byte) 0x74, (byte) 0x72, (byte) 0x65, (byte) 0x61, (byte) 0x6D,
- (byte) 0x07, (byte) 0x00, (byte) 0x18, (byte) 0x01, (byte) 0x00,
- (byte) 0x07, (byte) 0x70, (byte) 0x72, (byte) 0x69, (byte) 0x6E,
- (byte) 0x74, (byte) 0x6C, (byte) 0x6E, (byte) 0x01, (byte) 0x00,
- (byte) 0x15, (byte) 0x28, (byte) 0x4C, (byte) 0x6A, (byte) 0x61,
- (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61,
- (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x53, (byte) 0x74,
- (byte) 0x72, (byte) 0x69, (byte) 0x6E, (byte) 0x67, (byte) 0x3B,
- (byte) 0x29, (byte) 0x56, (byte) 0x0C, (byte) 0x00, (byte) 0x1A,
- (byte) 0x00, (byte) 0x1B, (byte) 0x0A, (byte) 0x00, (byte) 0x19,
- (byte) 0x00, (byte) 0x1C, (byte) 0x01, (byte) 0x00, (byte) 0x04,
- (byte) 0x61, (byte) 0x72, (byte) 0x67, (byte) 0x73, (byte) 0x01,
- (byte) 0x00, (byte) 0x13, (byte) 0x5B, (byte) 0x4C, (byte) 0x6A,
- (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C,
- (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x53,
- (byte) 0x74, (byte) 0x72, (byte) 0x69, (byte) 0x6E, (byte) 0x67,
- (byte) 0x3B, (byte) 0x01, (byte) 0x00, (byte) 0x0A, (byte) 0x53,
- (byte) 0x6F, (byte) 0x75, (byte) 0x72, (byte) 0x63, (byte) 0x65,
- (byte) 0x46, (byte) 0x69, (byte) 0x6C, (byte) 0x65, (byte) 0x01,
- (byte) 0x00, (byte) 0x0C, (byte) 0x48, (byte) 0x69, (byte) 0x57,
- (byte) 0x6F, (byte) 0x72, (byte) 0x6C, (byte) 0x64, (byte) 0x2E,
- (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x00,
- (byte) 0x21, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x04,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x05,
- (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x00,
- (byte) 0x07, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x2F,
- (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x2A, (byte) 0xB7,
- (byte) 0x00, (byte) 0x09, (byte) 0xB1, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x0A, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x01,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x14, (byte) 0x00,
- (byte) 0x0B, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0C,
- (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x05, (byte) 0x00, (byte) 0x0C, (byte) 0x00, (byte) 0x0D,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x09, (byte) 0x00,
- (byte) 0x0E, (byte) 0x00, (byte) 0x0F, (byte) 0x00, (byte) 0x01,
- (byte) 0x00, (byte) 0x07, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x37, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x01,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x09, (byte) 0xB2,
- (byte) 0x00, (byte) 0x15, (byte) 0x12, (byte) 0x17, (byte) 0xB6,
- (byte) 0x00, (byte) 0x1D, (byte) 0xB1, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x0A, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x0A, (byte) 0x00, (byte) 0x02,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x17, (byte) 0x00,
- (byte) 0x08, (byte) 0x00, (byte) 0x18, (byte) 0x00, (byte) 0x0B,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0C, (byte) 0x00,
- (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x09,
- (byte) 0x00, (byte) 0x1E, (byte) 0x00, (byte) 0x1F, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x20,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00,
- (byte) 0x21, };
-
- /**
- * Tests default ctor
- */
- public void testSecureClassLoader() {
- new SecureClassLoader();
- }
-
- /**
- * Tests SecureClassLoader(ClassLoader)
- */
- public void testSecureClassLoaderClassLoader() throws Exception {
- URL[] urls = new URL[] { new URL("http://localhost") };
- URLClassLoader ucl = URLClassLoader.newInstance(urls);
- new SecureClassLoader(ucl);
- }
-
- /**
- * Tests getPermission
- */
- public void testGetPermissions() throws Exception {
- URL url = new URL("http://localhost");
- CodeSource cs = new CodeSource(url, (Certificate[]) null);
- SecureClassLoader ldr = new SecureClassLoader();
- ldr.getPermissions(null);
- ldr.getPermissions(cs);
- }
-
- /**
- * Tests defineClass(String, byte[], int, int, CodeSource)
- */
- public void testDefineClassStringbyteArrayintintCodeSource() {
- SecureClassLoader ldr = new SecureClassLoader();
- Class klass = ldr.defineClass(null, klassData, 0, klassData.length,
- null);
- assertEquals(klass.getName(), klassName);
- }
-
- /**
- * Tests defineClass(String, ByteBuffer, CodeSource)
- */
- public void testDefineClassStringByteBufferCodeSource() {
- SecureClassLoader ldr = new SecureClassLoader();
- ByteBuffer bbuf = ByteBuffer.wrap(klassData);
- Class klass = ldr.defineClass(null, bbuf, null);
- assertEquals(klass.getName(), klassName);
- }
-}
diff --git a/security/src/test/api/java.injected/java/security/SecureRandomTest.java b/security/src/test/api/java.injected/java/security/SecureRandomTest.java
deleted file mode 100644
index 1db2446..0000000
--- a/security/src/test/api/java.injected/java/security/SecureRandomTest.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package java.security;
-
-import org.apache.harmony.security.tests.support.RandomImpl;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>SecureRandom</code> constructor and methods
- */
-public class SecureRandomTest extends TestCase {
-
- /**
- * SRProvider
- */
- Provider p;
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- p = new SRProvider();
- Security.insertProviderAt(p, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(p.getName());
- }
-
- public final void testNext() {
- SecureRandom sr = new SecureRandom();
- if (sr.next(1) != 1 || sr.next(2) != 3 || sr.next(3) != 7) {
- fail("next failed");
- }
- }
-
- /*
- * Class under test for void setSeed(long)
- */
- public final void testSetSeedlong() {
- SecureRandom sr = new SecureRandom();
- sr.setSeed(12345);
- if (!RandomImpl.runEngineSetSeed) {
- fail("setSeed failed");
- }
- }
-
- public final void testNextBytes() {
- byte[] b = new byte[5];
- SecureRandom sr = new SecureRandom();
- sr.nextBytes(b);
- for (int i = 0; i < b.length; i++) {
- if (b[i] != (byte) (i + 0xF1)) {
- fail("nextBytes failed");
- }
- }
- }
-
- /*
- * Class under test for void SecureRandom()
- */
- public final void testSecureRandom() {
- SecureRandom sr = new SecureRandom();
- if (!sr.getAlgorithm().equals("someRandom") ||
- sr.getProvider() != p) {
- fail("incorrect SecureRandom implementation" + p.getName());
- }
- }
-
- /*
- * Class under test for void SecureRandom(byte[])
- */
- public final void testSecureRandombyteArray() {
- byte[] b = { 1, 2, 3 };
- new SecureRandom(b);
- if (!RandomImpl.runEngineSetSeed) {
- fail("No setSeed");
- }
- }
-
- /*
- * Class under test for SecureRandom getInstance(String)
- */
- public final void testGetInstanceString() {
- SecureRandom sr = null;
- try {
- sr = SecureRandom.getInstance("someRandom");
- } catch (NoSuchAlgorithmException e) {
- fail(e.toString());
- }
- if (sr.getProvider() != p || !"someRandom".equals(sr.getAlgorithm())) {
- fail("getInstance failed");
- }
- }
-
- /*
- * Class under test for SecureRandom getInstance(String, String)
- */
- public final void testGetInstanceStringString() throws Exception {
- SecureRandom sr = SecureRandom.getInstance("someRandom", "SRProvider");
- if (sr.getProvider() != p || !"someRandom".equals(sr.getAlgorithm())) {
- fail("getInstance failed");
- }
- }
-
- /*
- * Class under test for SecureRandom getInstance(String, Provider)
- */
- public final void testGetInstanceStringProvider() throws Exception {
- Provider p = new SRProvider();
- SecureRandom sr = SecureRandom.getInstance("someRandom", p);
- if (sr.getProvider() != p || !"someRandom".equals(sr.getAlgorithm())) {
- fail("getInstance failed");
- }
- }
-
- /*
- * Class under test for void setSeed(byte[])
- */
- public final void testSetSeedbyteArray() {
- byte[] b = { 1, 2, 3 };
- SecureRandom sr = new SecureRandom();
- sr.setSeed(b);
- if (!RandomImpl.runEngineSetSeed) {
- fail("setSeed failed");
- }
- }
-
- public final void testGetSeed() {
- byte[] b = SecureRandom.getSeed(4);
- if (b.length != 4) {
- fail("getSeed failed");
- }
- }
-
- public final void testGenerateSeed() {
- SecureRandom sr = new SecureRandom();
- byte[] b = sr.generateSeed(4);
- for (int i = 0; i < b.length; i++) {
- if (b[i] != (byte) i) {
- fail("generateSeed failed");
- }
- }
- }
-
- class SRProvider extends Provider {
- public SRProvider() {
- super("SRProvider", 1.0, "SRProvider for testing");
- put("SecureRandom.someRandom",
- "org.apache.harmony.security.tests.support.RandomImpl");
- }
- }
-}
diff --git a/security/src/test/api/java.injected/java/security/SignatureTest.java b/security/src/test/api/java.injected/java/security/SignatureTest.java
deleted file mode 100644
index 3e2c586..0000000
--- a/security/src/test/api/java.injected/java/security/SignatureTest.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package java.security;
-
-import org.apache.harmony.security.tests.support.MySignature1;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>Signature</code> constructor and methods
- */
-public class SignatureTest extends TestCase {
-
- /*
- * Class under test for Object clone()
- */
- public void testClone() {
- MySignature1 s = new MySignature1("ABC");
- try {
- s.clone();
- fail("No expected CloneNotSupportedException");
- } catch (CloneNotSupportedException e) {
- }
- }
-
- public void testGetProvider() {
- MySignature1 s = new MySignature1("ABC");
-
- assertEquals("state", Signature.UNINITIALIZED, s.getState());
- assertNull("provider", s.getProvider());
- }
-
- public void testGetAlgorithm() {
- MySignature1 s = new MySignature1("ABC");
-
- assertEquals("state", Signature.UNINITIALIZED, s.getState());
- assertEquals("algorithm", "ABC", s.getAlgorithm());
- }
-
- /*
- * Class under test for void initVerify(PublicKey)
- */
- public void testInitVerifyPublicKey() throws InvalidKeyException {
- MySignature1 s = new MySignature1("ABC");
-
- s.initVerify(new MyPublicKey());
- assertEquals("state", Signature.VERIFY, s.getState());
- assertTrue("initVerify() failed", s.runEngineInitVerify);
- }
-
- /*
- * Class under test for void initVerify(Certificate)
- */
- public void testInitVerifyCertificate() throws InvalidKeyException {
- MySignature1 s = new MySignature1("ABC");
-
- s.initVerify(new MyCertificate());
- assertEquals("state", Signature.VERIFY, s.getState());
- assertTrue("initVerify() failed", s.runEngineInitVerify);
- }
-
- /*
- * Class under test for void initSign(PrivateKey)
- */
- public void testInitSignPrivateKey() throws InvalidKeyException {
- MySignature1 s = new MySignature1("ABC");
-
- s.initSign(new MyPrivateKey());
- assertEquals("state", Signature.SIGN, s.getState());
- assertTrue("initSign() failed", s.runEngineInitSign);
- }
-
- /*
- * Class under test for void initSign(PrivateKey, SecureRandom)
- */
- public void testInitSignPrivateKeySecureRandom() throws InvalidKeyException {
- MySignature1 s = new MySignature1("ABC");
-
- s.initSign(new MyPrivateKey(), new SecureRandom());
- assertEquals("state", Signature.SIGN, s.getState());
- assertTrue("initSign() failed", s.runEngineInitSign);
- }
-
- /*
- * Class under test for byte[] sign()
- */
- public void testSign() throws Exception {
- MySignature1 s = new MySignature1("ABC");
- try {
- s.sign();
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
-
- s.initVerify(new MyPublicKey());
-
- try {
- s.sign();
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
-
- s.initSign(new MyPrivateKey());
- s.sign();
- assertEquals("state", Signature.SIGN, s.getState());
- assertTrue("sign() failed", s.runEngineSign);
- }
-
- /*
- * Class under test for boolean verify(byte[])
- */
- public void testVerifybyteArray() throws Exception {
- MySignature1 s = new MySignature1("ABC");
- byte[] b = { 1, 2, 3, 4 };
- try {
- s.verify(b);
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
-
- s.initSign(new MyPrivateKey());
- try {
- s.verify(b);
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
-
- s.initVerify(new MyPublicKey());
- s.verify(b);
- assertEquals("state", Signature.VERIFY, s.getState());
- assertTrue("verify() failed", s.runEngineVerify);
- }
-
- /*
- * Class under test for boolean verify(byte[], int, int)
- */
- public void testVerifybyteArrayintint() throws Exception {
- MySignature1 s = new MySignature1("ABC");
- byte[] b = { 1, 2, 3, 4 };
- try {
- s.verify(b, 0, 3);
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
-
- s.initSign(new MyPrivateKey());
-
- try {
- s.verify(b, 0, 3);
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
-
- s.initVerify(new MyPublicKey());
-
- try {
- s.verify(b, 0, 5);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
-
- s.verify(b, 0, 3);
- assertEquals("state", Signature.VERIFY, s.getState());
- assertTrue("verify() failed", s.runEngineVerify);
- }
-
- /*
- * Class under test for void update(byte)
- */
- public void testUpdatebyte() throws Exception {
- MySignature1 s = new MySignature1("ABC");
- try {
- s.update((byte) 1);
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
-
- s.initVerify(new MyPublicKey());
- s.update((byte) 1);
- s.initSign(new MyPrivateKey());
- s.update((byte) 1);
-
- assertEquals("state", Signature.SIGN, s.getState());
- assertTrue("update() failed", s.runEngineUpdate1);
- }
-
- /*
- * Class under test for void update(byte[])
- */
- public void testUpdatebyteArray() throws Exception {
- MySignature1 s = new MySignature1("ABC");
- byte[] b = { 1, 2, 3, 4 };
- try {
- s.update(b);
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
-
- s.initVerify(new MyPublicKey());
- s.update(b);
- s.initSign(new MyPrivateKey());
- s.update(b);
-
- assertEquals("state", Signature.SIGN, s.getState());
- assertTrue("update() failed", s.runEngineUpdate2);
- }
-
- /*
- * Class under test for void update(byte[], int, int)
- */
- public void testUpdatebyteArrayintint() throws Exception {
- MySignature1 s = new MySignature1("ABC");
- byte[] b = { 1, 2, 3, 4 };
- try {
- s.update(b, 0, 3);
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
-
- s.initVerify(new MyPublicKey());
- s.update(b, 0, 3);
- s.initSign(new MyPrivateKey());
- s.update(b, 0, 3);
-
- assertEquals("state", Signature.SIGN, s.getState());
- assertTrue("update() failed", s.runEngineUpdate2);
- }
-
- /*
- * Class under test for void setParameter(String, Object)
- */
- public void testSetParameterStringObject() {
- MySignature1 s = new MySignature1("ABC");
- s.setParameter("aaa", new Object());
- }
-
- /*
- * Class under test for void setParameter(AlgorithmParameterSpec)
- */
- public void testSetParameterAlgorithmParameterSpec() throws InvalidAlgorithmParameterException {
- MySignature1 s = new MySignature1("ABC");
- try {
- s.setParameter((java.security.spec.AlgorithmParameterSpec) null);
- fail("No expected UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
- }
- }
-
- public void testGetParameter() {
- MySignature1 s = new MySignature1("ABC");
- s.getParameter("aaa");
- }
-
- private class MyKey implements Key {
- public String getFormat() {
- return "123";
- }
-
- public byte[] getEncoded() {
- return null;
- }
-
- public String getAlgorithm() {
- return "aaa";
- }
- }
-
- private class MyPublicKey extends MyKey implements PublicKey {
- }
-
- private class MyPrivateKey extends MyKey implements PrivateKey {
- }
-
- private class MyCertificate extends java.security.cert.Certificate {
- public MyCertificate() {
- super("MyCertificateType");
- }
-
- public PublicKey getPublicKey() {
- return new MyPublicKey();
- }
-
- public byte[] getEncoded() {
- return null;
- }
-
- public void verify(PublicKey key) {
- }
-
- public void verify(PublicKey key, String sigProvider) {
- }
-
- public String toString() {
- return "MyCertificate";
- }
- }
-}
diff --git a/security/src/test/api/java.injected/java/security/cert/myCertPath.java b/security/src/test/api/java.injected/java/security/cert/myCertPath.java
deleted file mode 100644
index 308d5e1..0000000
--- a/security/src/test/api/java.injected/java/security/cert/myCertPath.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package java.security.cert;
-
-import java.util.*;
-import java.security.cert.CertPath;
-
-/**
- * Class for CertPath creating
- */
-public class myCertPath extends CertPath {
-
- public List getCertificates() {
- return new Vector();
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public byte[] getEncoded(String s) {
- return new byte[0];
- }
-
- public Iterator getEncodings() {
- return (Iterator) (new StringTokenizer("ss ss ss ss"));
- }
-
- protected myCertPath(String s) {
- super(s);
- }
-
- public CertPath get(String s) {
- return new myCertPath(s);
- }
-
- public myCertPath(String s, String s1) {
- super(s);
- }
-
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlException2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlException2Test.java
deleted file mode 100644
index ed6bff9..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlException2Test.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.FilePermission;
-import java.security.AccessControlException;
-
-public class AccessControlException2Test extends junit.framework.TestCase {
- FilePermission filePermission;
-
- AccessControlException acException;
-
- AccessControlException acException1;
-
- /**
- * @tests java.security.AccessControlException#AccessControlException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method
- // java.security.AccessControlException(java.lang.String)
- assertTrue("AccessControlException's toString() should have returned "
- + "'java.security.AccessControlException: test message' but "
- + "returned: " + acException.toString(), acException.toString()
- .equals("java.security.AccessControlException: test message"));
- }
-
- /**
- * @tests java.security.AccessControlException#AccessControlException(java.lang.String,
- *java.security.Permission)
- */
- public void test_ConstructorLjava_lang_StringLjava_security_Permission() {
- // Test for method
- // java.security.AccessControlException(java.lang.String,
- // java.security.Permission)
- assertTrue("AccessControlException's toString() should have returned "
- + "'java.security.AccessControlException: test message "
- + "(java.io.FilePermission /* read)' but returned: "
- + acException1.toString(), acException1.toString().equals(
- "java.security.AccessControlException: test message"));
- }
-
- /**
- * @tests java.security.AccessControlException#getPermission()
- */
- public void test_getPermission() {
- // Test for method java.security.Permission
- // java.security.AccessControlException.getPermission()
- // make sure getPermission returns null when it's not set
- assertNull(
- "getPermission should have returned null if no permission was set",
- acException.getPermission());
- assertTrue(
- "getPermission should have returned the permission we assigned to it",
- acException1.getPermission() == filePermission);
- }
-
- /**
- * Sets up the fixture, for example, open a network connection. This method
- * is called before a test is executed.
- */
- protected void setUp() {
- filePermission = new FilePermission("/*", "read");
- acException = new AccessControlException("test message");
- acException1 = new AccessControlException("test message",
- filePermission);
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlExceptionTest.java
deleted file mode 100644
index 0203ece..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlExceptionTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for AccessControlException.
- */
-
-public class AccessControlExceptionTest extends TestCase {
-
- /**
- * Tests AccessControlException(String)
- */
- public void testAccessControlExceptionString() {
- new AccessControlException(null);
- new AccessControlException("Failure");
- }
-
- /**
- * Tests AccessControlException(String, Permission)
- */
- public void testAccessControlExceptionStringPermission() {
- Permission perm = new AllPermission();
- new AccessControlException("001", perm);
- }
-
- /**
- * Tests AccessControlException.getPermission()
- */
- public void testGetPermission() {
- Permission perm = new UnresolvedPermission("unresolvedType",
- "unresolvedName", "unresolvedActions", null);
- AccessControlException ex = new AccessControlException("001", perm);
- assertSame(ex.getPermission(), perm);
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator1Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator1Test.java
deleted file mode 100644
index 31bdcb1..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator1Test.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>AlgorithmParameterGenerator</code> class constructors and
- * methods.
- */
-
-public class AlgorithmParameterGenerator1Test extends TestCase {
- /**
- * Constructor for AlgorithmParameterGeneratorTests.
- *
- * @param arg0
- */
- public AlgorithmParameterGenerator1Test(String arg0) {
- super(arg0);
- }
-
- private static String[] invalidValues = SpiEngUtils.invalidValues;
- private static String validAlgName = "DSA";
- private static String[] algs = {
- "DSA", "dsa", "Dsa", "DsA", "dsA" };
-
- public static final String srvAlgorithmParameterGenerator = "AlgorithmParameterGenerator";
-
-
- private static String validProviderName = null;
-
- private static Provider validProvider = null;
-
- private static boolean DSASupported = false;
-
- static {
- validProvider = SpiEngUtils.isSupport(
- validAlgName,
- srvAlgorithmParameterGenerator);
- DSASupported = (validProvider != null);
- validProviderName = (DSASupported ? validProvider.getName() : null);
- }
-
- protected AlgorithmParameterGenerator[] createAPGen() {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return null;
- }
- AlgorithmParameterGenerator[] apg = new AlgorithmParameterGenerator[3];
- try {
- apg[0] = AlgorithmParameterGenerator.getInstance(validAlgName);
- apg[1] = AlgorithmParameterGenerator.getInstance(validAlgName,
- validProvider);
- apg[2] = AlgorithmParameterGenerator.getInstance(validAlgName,
- validProviderName);
- return apg;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion:
- * throws NullPointerException must be thrown is null
- * throws NoSuchAlgorithmException must be thrown if algorithm is not available
- */
- public void testAlgorithmParameterGenerator01()
- throws NoSuchAlgorithmException {
- try {
- AlgorithmParameterGenerator.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- AlgorithmParameterGenerator.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException should be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion: returns AlgorithmParameterGenerator instance
- * when algorithm is DSA
- */
- public void testAlgorithmParameterGenerator02()
- throws NoSuchAlgorithmException {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return;
- }
- AlgorithmParameterGenerator apg;
- for (int i = 0; i < algs.length; i++) {
- apg = AlgorithmParameterGenerator.getInstance(algs[i]);
- assertEquals("Incorrect algorithm", apg.getAlgorithm(), algs[i]);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion:
- * throws IllegalArgumentException if provider is null or empty
- */
- public void testAlgorithmParameterGenerator03()
- throws NoSuchAlgorithmException, NoSuchProviderException {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return;
- }
- String provider = null;
- for (int i = 0; i < algs.length; i++) {
- try {
- AlgorithmParameterGenerator.getInstance(algs[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- try {
- AlgorithmParameterGenerator.getInstance(algs[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion: throws NoSuchProviderException if provider is not
- * available
- */
- public void testAlgorithmParameterGenerator04()
- throws NoSuchAlgorithmException {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return;
- }
- for (int i = 0; i < algs.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- AlgorithmParameterGenerator.getInstance(algs[i],
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (provider: "
- .concat(invalidValues[j]));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion:
- * throws NullPointerException must be thrown is null
- * throws NoSuchAlgorithmException must be thrown if algorithm is not available
- */
- public void testAlgorithmParameterGenerator05()
- throws NoSuchProviderException {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return;
- }
- try {
- AlgorithmParameterGenerator.getInstance(null, validProviderName);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- AlgorithmParameterGenerator.getInstance(invalidValues[i],
- validProviderName);
- fail("NoSuchAlgorithmException must be thrown when (algorithm: "
- .concat(invalidValues[i].concat(")")));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion: return AlgorithmParameterGenerator
- */
- public void testAlgorithmParameterGenerator06()
- throws NoSuchAlgorithmException, NoSuchProviderException {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return;
- }
- AlgorithmParameterGenerator apg;
- for (int i = 0; i < algs.length; i++) {
- apg = AlgorithmParameterGenerator.getInstance(algs[i],
- validProviderName);
- assertEquals("Incorrect algorithm", algs[i], apg.getAlgorithm());
- assertEquals("Incorrect provider", apg.getProvider().getName(),
- validProviderName);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion: throws IllegalArgumentException when provider is null
- */
- public void testAlgorithmParameterGenerator07()
- throws NoSuchAlgorithmException {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return;
- }
- Provider provider = null;
- for (int i = 0; i < algs.length; i++) {
- try {
- AlgorithmParameterGenerator.getInstance(algs[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion:
- * throws NullPointerException must be thrown is null
- * throws NoSuchAlgorithmException must be thrown if algorithm is not available
- */
- public void testAlgorithmParameterGenerator08() {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return;
- }
- try {
- AlgorithmParameterGenerator.getInstance(null, validProvider);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- AlgorithmParameterGenerator.getInstance(invalidValues[i],
- validProvider);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion: returns AlgorithmParameterGenerator object
- */
- public void testAlgorithmParameterGenerator09()
- throws NoSuchAlgorithmException {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return;
- }
- AlgorithmParameterGenerator apg;
- for (int i = 0; i < algs.length; i++) {
- apg = AlgorithmParameterGenerator.getInstance(algs[i],
- validProvider);
- assertEquals("Incorrect algorithm", apg.getAlgorithm(), algs[i]);
- assertEquals("Incorrect provider", apg.getProvider(), validProvider);
- }
- }
-
- /**
- * Test for <code>generateParameters()</code> method
- * Assertion: returns AlgorithmParameters object
- */
- public void testAlgorithmParameterGenerator10()
- throws NoSuchAlgorithmException {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return;
- }
- AlgorithmParameterGenerator apg = AlgorithmParameterGenerator
- .getInstance(validAlgName);
- apg.init(512);
- AlgorithmParameters ap = apg.generateParameters();
- assertEquals("Incorrect algorithm", ap.getAlgorithm().toUpperCase(),
- apg.getAlgorithm().toUpperCase());
- }
-
- /**
- * Test for <code>init(AlgorithmParameterSpec param)</code> and
- * <code>init(AlgorithmParameterSpec param, SecureRandom random<code>
- * methods
- * Assertion: throws InvalidAlgorithmParameterException when param is null
- */
- public void testAlgorithmParameterGenerator12() {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return;
- }
- SecureRandom random = new SecureRandom();
- AlgorithmParameterSpec aps = null;
- AlgorithmParameterGenerator[] apgs = createAPGen();
- assertNotNull("AlgorithmParameterGenerator objects were not created",
- apgs);
- for (int i = 0; i < apgs.length; i++) {
- try {
- apgs[i].init(aps, random);
- fail("InvalidAlgorithmParameterException must be throws when param is null");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
- }
-
- /**
- * Test for <code>AlgorithmParameterGenerator</code> constructor
- * Assertion: returns AlgorithmParameterGenerator object
- */
- public void testAlgorithmParameterGeneratorConstr() throws NoSuchAlgorithmException {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return;
- }
- AlgorithmParameterGeneratorSpi spi = new MyAlgorithmParameterGeneratorSpi();
- AlgorithmParameterGenerator apg =
- new myAlgPG(spi, validProvider, validAlgName);
- assertEquals("Incorrect algorithm", apg.getAlgorithm(), validAlgName);
- assertEquals("Incorrect provider", apg.getProvider(), validProvider);
- try {
- apg.init(-10, null);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
-
- apg = new myAlgPG(null, null, null);
- assertNull("Incorrect algorithm", apg.getAlgorithm());
- assertNull("Incorrect provider", apg.getProvider());
- try {
- apg.init(-10, null);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- }
-
-}
-
-/**
- * Additional class to verify AlgorithmParameterGenerator constructor
- */
-class myAlgPG extends AlgorithmParameterGenerator {
- public myAlgPG(AlgorithmParameterGeneratorSpi spi, Provider prov, String alg) {
- super(spi, prov, alg);
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator2Test.java
deleted file mode 100644
index 9460956..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator2Test.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>AlgorithmParameterGenerator</code> class constructors and
- * methods.
- */
-
-public class AlgorithmParameterGenerator2Test extends TestCase {
-
- private static final String AlgorithmParameterGeneratorProviderClass = "org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi";
-
- private static final String defaultAlg = "APG";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "apG";
- validValues[3] = "ApG";
- }
-
- Provider mProv;
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyAPGProvider", "Testing provider",
- AlgorithmParameterGenerator1Test.srvAlgorithmParameterGenerator.concat(".").concat(defaultAlg),
- AlgorithmParameterGeneratorProviderClass);
- Security.insertProviderAt(mProv, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- public AlgorithmParameterGenerator2Test(String arg0) {
- super(arg0);
- }
-
- private void checkResult(AlgorithmParameterGenerator algParGen)
- throws InvalidAlgorithmParameterException {
- AlgorithmParameters param = algParGen.generateParameters();
- assertNull("Not null parameters", param);
-
- AlgorithmParameterSpec pp = null;
- algParGen.init(pp, new SecureRandom());
- algParGen.init(pp);
- try {
- algParGen.init(pp, null);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- pp = new tmpAlgorithmParameterSpec("Proba");
- algParGen.init(pp, new SecureRandom());
- algParGen.init(pp);
-
- algParGen.init(0, null);
- algParGen.init(0, new SecureRandom());
-
- try {
- algParGen.init(-10, null);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- try {
- algParGen.init(-10, new SecureRandom());
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions:
- * throws NullPointerException must be thrown is null
- * throws NoSuchAlgorithmException must be thrown if algorithm is not available
- * returns AlgorithmParameterGenerator object
- */
- public void testGetInstance01() throws NoSuchAlgorithmException,
- InvalidAlgorithmParameterException {
- try {
- AlgorithmParameterGenerator.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- AlgorithmParameterGenerator.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- AlgorithmParameterGenerator apG;
- for (int i = 0; i < validValues.length; i++) {
- apG = AlgorithmParameterGenerator.getInstance(validValues[i]);
- assertEquals("Incorrect algorithm", apG.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", apG.getProvider(), mProv);
- checkResult(apG);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertions:
- * throws NullPointerException must be thrown is null
- * throws NoSuchAlgorithmException must be thrown if algorithm is not available
- * throws IllegalArgumentException when provider is null;
- * throws NoSuchProviderException when provider is available;
- * returns AlgorithmParameterGenerator object
- */
- public void testGetInstance02() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidAlgorithmParameterException {
- try {
- AlgorithmParameterGenerator.getInstance(null, mProv.getName());
- fail("NullPointerException or NoSuchAlgorithmException should be thrown");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- AlgorithmParameterGenerator.getInstance(invalidValues[i], mProv
- .getName());
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- AlgorithmParameterGenerator.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- AlgorithmParameterGenerator.getInstance(validValues[i],
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- AlgorithmParameterGenerator apG;
- for (int i = 0; i < validValues.length; i++) {
- apG = AlgorithmParameterGenerator.getInstance(validValues[i], mProv
- .getName());
- assertEquals("Incorrect algorithm", apG.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", apG.getProvider().getName(),
- mProv.getName());
- checkResult(apG);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException must be thrown is null
- * throws NoSuchAlgorithmException must be thrown if algorithm is not available
- * throws IllegalArgumentException when provider is null;
- * returns AlgorithmParameterGenerator object
- */
- public void testGetInstance03() throws NoSuchAlgorithmException,
- IllegalArgumentException,
- InvalidAlgorithmParameterException {
- try {
- AlgorithmParameterGenerator.getInstance(null, mProv);
- fail("NullPointerException or NoSuchAlgorithmException should be thrown");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- AlgorithmParameterGenerator.getInstance(invalidValues[i], mProv);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- AlgorithmParameterGenerator.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- AlgorithmParameterGenerator apG;
- for (int i = 0; i < validValues.length; i++) {
- apG = AlgorithmParameterGenerator.getInstance(validValues[i], mProv);
- assertEquals("Incorrect algorithm", apG.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", apG.getProvider(), mProv);
- checkResult(apG);
- }
- }
-
- /**
- * Additional class for init(...) methods verification
- */
- class tmpAlgorithmParameterSpec implements AlgorithmParameterSpec {
- private final String type;
-
- public tmpAlgorithmParameterSpec(String type) {
- this.type = type;
- }
-
- public String getType() {
- return type;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator3Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator3Test.java
deleted file mode 100644
index d3156e4..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator3Test.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.math.BigInteger;
-import java.security.AlgorithmParameterGenerator;
-import java.security.AlgorithmParameters;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.Security;
-import java.security.spec.DSAParameterSpec;
-
-public class AlgorithmParameterGenerator3Test extends junit.framework.TestCase {
-
- /**
- * @tests java.security.AlgorithmParameterGenerator#generateParameters()
- */
- public void test_generateParameters() throws Exception {
-
- //fail("Takes ages. Problem with SecureRandom and stub math ?");
-
- // Test for method java.security.AlgorithmParameters
- // java.security.AlgorithmParameterGenerator.generateParameters()
- AlgorithmParameterGenerator gen = AlgorithmParameterGenerator
- .getInstance("DSA");
- gen.init(1024);
-
- // WARNING - The next line can take MINUTES to run
- AlgorithmParameters params = gen.generateParameters();
- assertNotNull("params is null", params);
- }
-
- /**
- * @tests java.security.AlgorithmParameterGenerator#getAlgorithm()
- */
- public void test_getAlgorithm() throws Exception {
- // Test for method java.lang.String
- // java.security.AlgorithmParameterGenerator.getAlgorithm()
- String alg = AlgorithmParameterGenerator.getInstance("DSA")
- .getAlgorithm();
- assertEquals("getAlgorithm ok", "DSA", alg);
- }
-
- /**
- * @tests java.security.AlgorithmParameterGenerator#getInstance(java.lang.String)
- */
- public void test_getInstanceLjava_lang_String() throws Exception {
- // Test for method java.security.AlgorithmParameterGenerator
- // java.security.AlgorithmParameterGenerator.getInstance(java.lang.String)
- AlgorithmParameterGenerator.getInstance("DSA");
- }
-
- /**
- * @tests java.security.AlgorithmParameterGenerator#getInstance(java.lang.String,
- *java.lang.String)
- */
- public void test_getInstanceLjava_lang_StringLjava_lang_String() throws Exception {
- // Test for method java.security.AlgorithmParameterGenerator
- // java.security.AlgorithmParameterGenerator.getInstance(java.lang.String,
- // java.lang.String)
-
- // Opting for DSA here as it is pretty widely supported
- Provider[] provs = Security
- .getProviders("AlgorithmParameterGenerator.DSA");
-
- for (int i = 0; i < provs.length; i++) {
- AlgorithmParameterGenerator.getInstance("DSA", provs[i].getName());
- }// end for
-
-
- // exception case - should throw IllegalArgumentException for null
- // provider
- try {
- AlgorithmParameterGenerator.getInstance("DSA", (String) null);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // Expected
- }
-
- // exception case - should throw IllegalArgumentException for empty
- // provider
- try {
- AlgorithmParameterGenerator.getInstance("DSA", "");
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // Expected
- }
-
- // exception case - should throw NoSuchProviderException
- try {
- AlgorithmParameterGenerator.getInstance("DSA", "IDontExist");
- fail("Should have thrown NoSuchProviderException");
- } catch (NoSuchProviderException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.security.AlgorithmParameterGenerator#getProvider()
- */
- public void test_getProvider() throws Exception {
- // Test for method java.security.Provider
- // java.security.AlgorithmParameterGenerator.getProvider()
- // checks that no exception is thrown
- Provider p = AlgorithmParameterGenerator.getInstance("DSA")
- .getProvider();
- assertNotNull("provider is null", p);
- }
-
- /**
- * @tests java.security.AlgorithmParameterGenerator#init(int)
- */
- public void test_initI() throws Exception {
- // Test for method void
- // java.security.AlgorithmParameterGenerator.init(int)
- // checks that no exception is thrown
- AlgorithmParameterGenerator gen = AlgorithmParameterGenerator
- .getInstance("DSA");
- gen.init(1024);
- }
-
- /**
- * @tests java.security.AlgorithmParameterGenerator#init(int,
- *java.security.SecureRandom)
- */
- public void test_initILjava_security_SecureRandom() throws Exception {
- // Test for method void
- // java.security.AlgorithmParameterGenerator.init(int,
- // java.security.SecureRandom)
- // checks that no exception is thrown
- AlgorithmParameterGenerator gen = AlgorithmParameterGenerator
- .getInstance("DSA");
- gen.init(1024, new SecureRandom());
- }
-
- /**
- * @tests java.security.AlgorithmParameterGenerator#init(java.security.spec.AlgorithmParameterSpec)
- */
- public void test_initLjava_security_spec_AlgorithmParameterSpec() throws Exception {
- // Test for method void
- // java.security.AlgorithmParameterGenerator.init(java.security.spec.AlgorithmParameterSpec)
- // checks that InvalidAlgorithmParameterException is thrown
- DSAParameterSpec spec = new DSAParameterSpec(BigInteger.ONE,
- BigInteger.ONE, BigInteger.ONE);
- AlgorithmParameterGenerator gen = AlgorithmParameterGenerator
- .getInstance("DSA");
- try {
- gen.init(spec);
- fail("No expected InvalidAlgorithmParameterException");
- } catch (InvalidAlgorithmParameterException e) {
- //expected
- }
- }
-
- /**
- * @tests java.security.AlgorithmParameterGenerator#init(java.security.spec.AlgorithmParameterSpec,
- *java.security.SecureRandom)
- */
- public void test_initLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom() throws Exception {
- // Test for method void
- // java.security.AlgorithmParameterGenerator.init(java.security.spec.AlgorithmParameterSpec,
- // java.security.SecureRandom)
- // checks that InvalidAlgorithmParameterException is thrown
- DSAParameterSpec spec = new DSAParameterSpec(BigInteger.ONE,
- BigInteger.ONE, BigInteger.ONE);
- AlgorithmParameterGenerator gen = AlgorithmParameterGenerator
- .getInstance("DSA");
- try {
- gen.init(spec, new SecureRandom());
- fail("No expected InvalidAlgorithmParameterException");
- } catch (InvalidAlgorithmParameterException e) {
- //expected
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java
deleted file mode 100644
index a2f2022..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java
+++ /dev/null
@@ -1,647 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.AlgorithmParameters;
-import java.security.AlgorithmParametersSpi;
-import java.security.Provider;
-import java.security.Security;
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.DSAParameterSpec;
-import java.security.spec.InvalidParameterSpecException;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>AlgorithmParameters</code> class constructors and
- * methods.
- */
-public class AlgorithmParametersTest extends TestCase {
-
- /**
- * Provider
- */
- Provider p;
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- p = new MyProvider();
- Security.insertProviderAt(p, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(p.getName());
- }
-
- /**
- * @tests java.security.AlgorithmParameters#getAlgorithm()
- */
- public void test_getAlgorithm() throws Exception {
-
- // test: null value
- AlgorithmParameters ap = new DummyAlgorithmParameters(null, p, null);
- assertNull(ap.getAlgorithm());
-
- // test: not null value
- ap = new DummyAlgorithmParameters(null, p, "AAA");
- assertEquals("AAA", ap.getAlgorithm());
- }
-
- /**
- * @tests java.security.AlgorithmParameters#getEncoded()
- */
- public void test_getEncoded() throws Exception {
-
- final byte[] enc = new byte[] { 0x02, 0x01, 0x03 };
-
- MyAlgorithmParameters paramSpi = new MyAlgorithmParameters() {
- protected byte[] engineGetEncoded() throws IOException {
- return enc;
- }
- };
-
- AlgorithmParameters params = new DummyAlgorithmParameters(paramSpi, p,
- "algorithm");
-
- //
- // test: IOException if not initialized
- //
- try {
- params.getEncoded();
- fail("should not get encoded from un-initialized instance");
- } catch (IOException e) {
- // expected
- }
-
- //
- // test: corresponding spi method is invoked
- //
- params.init(new MyAlgorithmParameterSpec());
- assertSame(enc, params.getEncoded());
- }
-
- /**
- * @tests java.security.AlgorithmParameters#getEncoded(String)
- */
- public void test_getEncodedLjava_lang_String() throws Exception {
-
- final byte[] enc = new byte[] { 0x02, 0x01, 0x03 };
-
- final String strFormatParam = "format";
-
- MyAlgorithmParameters paramSpi = new MyAlgorithmParameters() {
- protected byte[] engineGetEncoded(String format) throws IOException {
- assertEquals(strFormatParam, format);
- return enc;
- }
- };
-
- AlgorithmParameters params = new DummyAlgorithmParameters(paramSpi, p,
- "algorithm");
-
- //
- // test: IOException if not initialized
- //
- try {
- params.getEncoded(strFormatParam);
- fail("should not get encoded from un-initialized instance");
- } catch (IOException e) {
- // expected
- }
-
- //
- // test: corresponding spi method is invoked
- //
- params.init(new MyAlgorithmParameterSpec());
- assertSame(enc, params.getEncoded(strFormatParam));
-
- //
- // test: if format param is null
- // Regression test for HARMONY-2680
- //
- paramSpi = new MyAlgorithmParameters() {
- protected byte[] engineGetEncoded(String format) throws IOException {
- assertNull(format); // null is passed to spi-provider
- return enc;
- }
- };
-
- params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
- params.init(new MyAlgorithmParameterSpec());
- assertSame(enc, params.getEncoded(null));
- }
-
- /**
- * @tests java.security.AlgorithmParameters#getInstance(String)
- */
- public void test_getInstanceLjava_lang_String() throws Exception {
-
- AlgorithmParameters ap = AlgorithmParameters.getInstance("ABC");
-
- checkUnititialized(ap);
-
- ap.init(new MyAlgorithmParameterSpec());
-
- checkAP(ap, p);
- }
-
- /**
- * @tests java.security.AlgorithmParameters#getInstance(String, String)
- */
- public void test_getInstanceLjava_lang_StringLjava_lang_String()
- throws Exception {
-
- AlgorithmParameters ap = AlgorithmParameters.getInstance("ABC",
- "MyProvider");
-
- checkUnititialized(ap);
-
- ap.init(new byte[6]);
-
- checkAP(ap, p);
- }
-
- /**
- * @tests java.security.AlgorithmParameters#getParameterSpec(Class)
- */
- public void test_getParameterSpecLjava_lang_Class() throws Exception {
-
- final MyAlgorithmParameterSpec myParamSpec = new MyAlgorithmParameterSpec();
-
- MyAlgorithmParameters paramSpi = new MyAlgorithmParameters() {
- protected AlgorithmParameterSpec engineGetParameterSpec(
- Class paramSpec) {
- return myParamSpec;
- }
- };
-
- AlgorithmParameters params = new DummyAlgorithmParameters(paramSpi, p,
- "algorithm");
-
- //
- // test: InvalidParameterSpecException if not initialized
- //
- try {
- params.getParameterSpec(null);
- fail("No expected InvalidParameterSpecException");
- } catch (InvalidParameterSpecException e) {
- // expected
- }
- try {
- params.getParameterSpec(MyAlgorithmParameterSpec.class);
- fail("No expected InvalidParameterSpecException");
- } catch (InvalidParameterSpecException e) {
- // expected
- }
-
- //
- // test: corresponding spi method is invoked
- //
- params.init(new MyAlgorithmParameterSpec());
- assertSame(myParamSpec, params
- .getParameterSpec(MyAlgorithmParameterSpec.class));
-
- //
- // test: if paramSpec is null
- // Regression test for HARMONY-2733
- //
- paramSpi = new MyAlgorithmParameters() {
-
- protected AlgorithmParameterSpec engineGetParameterSpec(
- Class paramSpec) {
- assertNull(paramSpec); // null is passed to spi-provider
- return null;
- }
- };
-
- params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
- params.init(new MyAlgorithmParameterSpec());
- assertNull(params.getParameterSpec(null));
- }
-
- /**
- * @tests java.security.AlgorithmParameters#getInstance(String, Provider)
- */
- public void test_getInstanceLjava_lang_StringLjava_security_Provider()
- throws Exception {
-
- AlgorithmParameters ap = AlgorithmParameters.getInstance("ABC", p);
-
- checkUnititialized(ap);
-
- ap.init(new byte[6], "aaa");
-
- checkAP(ap, p);
- }
-
- /**
- * @tests java.security.AlgorithmParameters#getProvider()
- */
- public void test_getProvider() throws Exception {
- // test: null value
- AlgorithmParameters ap = new DummyAlgorithmParameters(null, null, "AAA");
- assertNull(ap.getProvider());
-
- // test: not null value
- ap = new DummyAlgorithmParameters(null, p, "AAA");
- assertSame(p, ap.getProvider());
- }
-
- /**
- * @tests java.security.AlgorithmParameters#init(java.security.spec.AlgorithmParameterSpec)
- */
- public void test_initLjava_security_spec_AlgorithmParameterSpec()
- throws Exception {
-
- //
- // test: corresponding spi method is invoked
- //
- final MyAlgorithmParameterSpec spec = new MyAlgorithmParameterSpec();
-
- MyAlgorithmParameters paramSpi = new MyAlgorithmParameters() {
- protected void engineInit(AlgorithmParameterSpec paramSpec)
- throws InvalidParameterSpecException {
- assertSame(spec, paramSpec);
- runEngineInit_AlgParamSpec = true;
- }
- };
-
- AlgorithmParameters params = new DummyAlgorithmParameters(paramSpi, p,
- "algorithm");
-
- params.init(spec);
- assertTrue(paramSpi.runEngineInit_AlgParamSpec);
-
- //
- // test: InvalidParameterSpecException if already initialized
- //
- try {
- params.init(spec);
- fail("No expected InvalidParameterSpecException");
- } catch (InvalidParameterSpecException e) {
- // expected
- }
-
- params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
- params.init(new byte[0]);
- try {
- params.init(spec);
- fail("No expected InvalidParameterSpecException");
- } catch (InvalidParameterSpecException e) {
- // expected
- }
-
- params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
- params.init(new byte[0], "format");
- try {
- params.init(spec);
- fail("No expected InvalidParameterSpecException");
- } catch (InvalidParameterSpecException e) {
- // expected
- }
-
- //
- // test: if paramSpec is null
- //
- paramSpi = new MyAlgorithmParameters() {
-
- protected void engineInit(AlgorithmParameterSpec paramSpec)
- throws InvalidParameterSpecException {
- assertNull(paramSpec);// null is passed to spi-provider
- runEngineInit_AlgParamSpec = true;
- }
- };
-
- params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
- params.init((AlgorithmParameterSpec) null);
- assertTrue(paramSpi.runEngineInit_AlgParamSpec);
- }
-
- /**
- * @tests java.security.AlgorithmParameters#init(byte[])
- */
- public void test_init$B() throws Exception {
-
- //
- // test: corresponding spi method is invoked
- //
- final byte[] enc = new byte[] { 0x02, 0x01, 0x03 };
-
- MyAlgorithmParameters paramSpi = new MyAlgorithmParameters() {
- protected void engineInit(byte[] params) throws IOException {
- runEngineInitB$ = true;
- assertSame(enc, params);
- }
- };
-
- AlgorithmParameters params = new DummyAlgorithmParameters(paramSpi, p,
- "algorithm");
-
- params.init(enc);
- assertTrue(paramSpi.runEngineInitB$);
-
- //
- // test: IOException if already initialized
- //
- try {
- params.init(enc);
- fail("No expected IOException");
- } catch (IOException e) {
- // expected
- }
-
- params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
- params.init(new MyAlgorithmParameterSpec());
- try {
- params.init(enc);
- fail("No expected IOException");
- } catch (IOException e) {
- // expected
- }
-
- params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
- params.init(enc, "format");
- try {
- params.init(enc);
- fail("No expected IOException");
- } catch (IOException e) {
- // expected
- }
-
- //
- // test: if params is null
- //
- paramSpi = new MyAlgorithmParameters() {
-
- protected void engineInit(byte[] params) throws IOException {
- runEngineInitB$ = true;
- assertNull(params); // null is passed to spi-provider
- }
- };
-
- params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
- params.init((byte[]) null);
- assertTrue(paramSpi.runEngineInitB$);
- }
-
- /**
- * @tests java.security.AlgorithmParameters#init(byte[], String)
- */
- public void test_init$BLjava_lang_String() throws Exception {
-
- //
- // test: corresponding spi method is invoked
- //
- final byte[] enc = new byte[] { 0x02, 0x01, 0x03 };
- final String strFormatParam = "format";
-
- MyAlgorithmParameters paramSpi = new MyAlgorithmParameters() {
- protected void engineInit(byte[] params, String format)
- throws IOException {
-
- runEngineInitB$String = true;
- assertSame(enc, params);
- assertSame(strFormatParam, format);
- }
- };
-
- AlgorithmParameters params = new DummyAlgorithmParameters(paramSpi, p,
- "algorithm");
-
- params.init(enc, strFormatParam);
- assertTrue(paramSpi.runEngineInitB$String);
-
- //
- // test: IOException if already initialized
- //
- try {
- params.init(enc, strFormatParam);
- fail("No expected IOException");
- } catch (IOException e) {
- // expected
- }
-
- params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
- params.init(new MyAlgorithmParameterSpec());
- try {
- params.init(enc, strFormatParam);
- fail("No expected IOException");
- } catch (IOException e) {
- // expected
- }
-
- params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
- params.init(enc);
- try {
- params.init(enc, strFormatParam);
- fail("No expected IOException");
- } catch (IOException e) {
- // expected
- }
-
- //
- // test: if params and format are null
- // Regression test for HARMONY-2724
- //
- paramSpi = new MyAlgorithmParameters() {
-
- protected void engineInit(byte[] params, String format)
- throws IOException {
-
- runEngineInitB$String = true;
-
- // null is passed to spi-provider
- assertNull(params);
- assertNull(format);
- }
- };
-
- params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
- params.init(null, null);
- assertTrue(paramSpi.runEngineInitB$String);
- }
-
- /**
- * @tests java.security.AlgorithmParameters#toString()
- */
- public void test_toString() throws Exception {
-
- final String str = "AlgorithmParameters";
-
- MyAlgorithmParameters paramSpi = new MyAlgorithmParameters() {
- protected String engineToString() {
- return str;
- }
- };
-
- AlgorithmParameters params = new DummyAlgorithmParameters(paramSpi, p,
- "algorithm");
-
- assertNull("unititialized", params.toString());
-
- params.init(new byte[0]);
-
- assertSame(str, params.toString());
- }
-
- /**
- * Tests DSA AlgorithmParameters provider
- */
- public void testDSAProvider() throws Exception {
- AlgorithmParameters params = AlgorithmParameters.getInstance("DSA");
-
- assertEquals("Algorithm", "DSA", params.getAlgorithm());
-
- // init(AlgorithmParameterSpec)
- BigInteger p = BigInteger.ONE;
- BigInteger q = BigInteger.TEN;
- BigInteger g = BigInteger.ZERO;
- params.init(new DSAParameterSpec(p, q, g));
-
- // getEncoded() and getEncoded(String) (TODO verify returned encoding)
- byte[] enc = params.getEncoded();
- assertNotNull(enc);
- assertNotNull(params.getEncoded("ASN.1"));
- // TODO assertNotNull(params.getEncoded(null)); // HARMONY-2680
-
- // getParameterSpec(Class)
- DSAParameterSpec spec = params.getParameterSpec(DSAParameterSpec.class);
- assertEquals("p is wrong ", p, spec.getP());
- assertEquals("q is wrong ", q, spec.getQ());
- assertEquals("g is wrong ", g, spec.getG());
-
- // init(byte[])
- params = AlgorithmParameters.getInstance("DSA");
- params.init(enc);
- assertTrue("param encoded is different", Arrays.equals(enc, params
- .getEncoded()));
-
- // init(byte[], String)
- params = AlgorithmParameters.getInstance("DSA");
- params.init(enc, "ASN.1");
- assertTrue("param encoded is different", Arrays.equals(enc, params
- .getEncoded()));
-
- params = AlgorithmParameters.getInstance("DSA");
- try {
- params.init(enc, "DOUGLASMAWSON");
- fail("unsupported format should have raised IOException");
- } catch (IOException e) {
- // expected
- }
- }
-
- /**
- * Tests OAEP AlgorithmParameters provider
- */
- public void testOAEPProvider() throws Exception {
- AlgorithmParameters params = AlgorithmParameters.getInstance("OAEP");
-
- assertEquals("Algorithm", "OAEP", params.getAlgorithm());
- }
-
- private void checkUnititialized(AlgorithmParameters ap) {
- assertNull("Uninitialized: toString() failed", ap.toString());
- }
-
- private void checkAP(AlgorithmParameters ap, Provider p) throws Exception {
-
- assertSame("getProvider() failed", p, ap.getProvider());
- assertEquals("getAlgorithm() failed", "ABC", ap.getAlgorithm());
-
- assertEquals("AlgorithmParameters", ap.toString());
- assertTrue("toString() failed", MyAlgorithmParameters.runEngineToString);
- }
-
- @SuppressWarnings("serial")
- private class MyProvider extends Provider {
- MyProvider() {
- super("MyProvider", 1.0, "Provider for testing");
- put("AlgorithmParameters.ABC", MyAlgorithmParameters.class
- .getName());
- }
-
- MyProvider(String name, double version, String info) {
- super(name, version, info);
- }
- }
-
- private class MyAlgorithmParameterSpec implements java.security.spec.AlgorithmParameterSpec {
- }
-
- private class DummyAlgorithmParameters extends AlgorithmParameters {
- public DummyAlgorithmParameters(AlgorithmParametersSpi paramSpi,
- Provider provider, String algorithm) {
- super(paramSpi, provider, algorithm);
- }
- }
-
- public static class MyAlgorithmParameters extends AlgorithmParametersSpi {
-
- public boolean runEngineInit_AlgParamSpec = false;
-
- public boolean runEngineInitB$ = false;
-
- public boolean runEngineInitB$String = false;
-
- public static boolean runEngineToString = false;
-
- protected void engineInit(AlgorithmParameterSpec paramSpec)
- throws InvalidParameterSpecException {
- }
-
- protected void engineInit(byte[] params) throws IOException {
- }
-
- protected void engineInit(byte[] params, String format)
- throws IOException {
- }
-
- protected AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec)
- throws InvalidParameterSpecException {
- return null;
- }
-
- protected byte[] engineGetEncoded() throws IOException {
- return null;
- }
-
- protected byte[] engineGetEncoded(String format) throws IOException {
- return null;
- }
-
- protected String engineToString() {
- runEngineToString = true;
- return "AlgorithmParameters";
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSignerTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSignerTest.java
deleted file mode 100644
index fbbe6d2..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSignerTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import java.security.cert.CertPath;
-import java.util.Date;
-
-import org.apache.harmony.security.tests.support.TestCertUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Unit test for CodeSigner.
- */
-
-public class CodeSignerTest extends TestCase {
-
- private CertPath cpath = TestCertUtils.genCertPath(3, 0);
- private Date now = new Date();
-
- private Timestamp ts = new Timestamp(now, cpath);
-
- /**
- * must throw NPE if signerCertPath is null
- */
- public void testCodeSigner_00() {
- try {
- new CodeSigner(null, ts);
- fail("must not accept null");
- } catch (NullPointerException ex) {
- /* it's ok */
- }
- }
-
- /**
- * timestamp can be null
- */
- public final void testCodeSigner_01() {
- new CodeSigner(cpath, null);
- }
-
- /**
- * Test various assertions about equals()
- */
- public final void testEqualsObject() {
-
- CodeSigner one = new CodeSigner(cpath, ts);
- CodeSigner two = new CodeSigner(cpath, ts);
- CodeSigner three = new CodeSigner(cpath, null);
-
- CertPath cpath2 = TestCertUtils.genCertPath(5, 3);
- CodeSigner four = new CodeSigner(cpath2, null);
-
- assertTrue(one.equals(one));
- assertTrue(one.equals(two));
- assertTrue(two.equals(one));
- assertFalse(one.equals(three));
- assertFalse(three.equals(one));
- assertTrue(three.equals(three));
- // different CertPaths
- assertFalse(three.equals(four));
- // special cases
- assertFalse(one.equals(null));
- assertFalse(one.equals(new Object()));
- }
-
- /**
- * Tests CodeSigner.getSignerCertPath()
- */
- public void testGetSignerCertPath() {
- assertSame(new CodeSigner(cpath, null).getSignerCertPath(), cpath);
- }
-
- /**
- * Tests CodeSigner.getTimeStamp()
- */
- public void testGetTimestamp() {
- assertNull(new CodeSigner(cpath, null).getTimestamp());
- assertSame(new CodeSigner(cpath, ts).getTimestamp(), ts);
- }
-
- /**
- * Tests CodeSigner.toString()
- */
- public void testToString() {
- new CodeSigner(cpath, null).toString();
- new CodeSigner(cpath, ts).toString();
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestExceptionTest.java
deleted file mode 100644
index 7cbfbb6..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestExceptionTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.DigestException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>DigestException</code> class constructors and methods.
- */
-public class DigestExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for DigestExceptionTests.
- *
- * @param arg0
- */
- public DigestExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>DigestException()</code> constructor Assertion:
- * constructs DigestException with no detail message
- */
- public void testDigestException01() {
- DigestException tE = new DigestException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>DigestException(String)</code> constructor Assertion:
- * constructs DigestException with detail message msg. Parameter
- * <code>msg</code> is not null.
- */
- public void testDigestException02() {
- DigestException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new DigestException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>DigestException(String)</code> constructor Assertion:
- * constructs DigestException when <code>msg</code> is null
- */
- public void testDigestException03() {
- String msg = null;
- DigestException tE = new DigestException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>DigestException(Throwable)</code> constructor Assertion:
- * constructs DigestException when <code>cause</code> is null
- */
- public void testDigestException04() {
- Throwable cause = null;
- DigestException tE = new DigestException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>DigestException(Throwable)</code> constructor Assertion:
- * constructs DigestException when <code>cause</code> is not null
- */
- public void testDigestException05() {
- DigestException tE = new DigestException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>DigestException(String, Throwable)</code> constructor
- * Assertion: constructs DigestException when <code>cause</code> is null
- * <code>msg</code> is null
- */
- public void testDigestException06() {
- DigestException tE = new DigestException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>DigestException(String, Throwable)</code> constructor
- * Assertion: constructs DigestException when <code>cause</code> is null
- * <code>msg</code> is not null
- */
- public void testDigestException07() {
- DigestException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new DigestException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>DigestException(String, Throwable)</code> constructor
- * Assertion: constructs DigestException when <code>cause</code> is not
- * null <code>msg</code> is null
- */
- public void testDigestException08() {
- DigestException tE = new DigestException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>DigestException(String, Throwable)</code> constructor
- * Assertion: constructs DigestException when <code>cause</code> is not
- * null <code>msg</code> is not null
- */
- public void testDigestException09() {
- DigestException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new DigestException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestInputStream2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestInputStream2Test.java
deleted file mode 100644
index b554199..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestInputStream2Test.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.security.DigestInputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-public class DigestInputStream2Test extends junit.framework.TestCase {
-
- ByteArrayInputStream inStream;
-
- ByteArrayInputStream inStream1;
-
- MessageDigest digest;
-
- /**
- * @tests java.security.DigestInputStream#DigestInputStream(java.io.InputStream,
- *java.security.MessageDigest)
- */
- public void test_ConstructorLjava_io_InputStreamLjava_security_MessageDigest() {
- // Test for method java.security.DigestInputStream(java.io.InputStream,
- // java.security.MessageDigest)
- DigestInputStream dis = new DigestInputStream(inStream, digest);
- assertNotNull("Constructor returned null instance", dis);
- }
-
- /**
- * @tests java.security.DigestInputStream#getMessageDigest()
- */
- public void test_getMessageDigest() {
- // Test for method java.security.MessageDigest
- // java.security.DigestInputStream.getMessageDigest()
- DigestInputStream dis = new DigestInputStream(inStream, digest);
- assertEquals("getMessageDigest returned a bogus result", digest, dis
- .getMessageDigest());
- }
-
- /**
- * @tests java.security.DigestInputStream#on(boolean)
- */
- public void test_onZ() throws Exception {
- // Test for method void java.security.DigestInputStream.on(boolean)
- MessageDigest originalDigest = (MessageDigest) (digest.clone());
- MessageDigest noChangeDigest = (MessageDigest) (digest.clone());
- DigestInputStream dis = new DigestInputStream(inStream, noChangeDigest);
- // turn off processing
- dis.on(false);
- // read some data
- int c = dis.read();
- assertEquals('T', c);
-
- // make sure the digest for the part where it was off has not
- // changed
- assertTrue("MessageDigest changed even though processing was off",
- MessageDigest.isEqual(noChangeDigest.digest(), originalDigest
- .digest()));
- MessageDigest changeDigest = (MessageDigest) (digest.clone());
- dis = new DigestInputStream(inStream, digest);
-
- // turn on processing
- dis.on(true);
- c = dis.read();
- assertEquals('h', c);
-
- // make sure the digest has changed
- assertTrue("MessageDigest did not change with processing on",
- !MessageDigest.isEqual(digest.digest(), changeDigest.digest()));
- }
-
- /**
- * @tests java.security.DigestInputStream#read()
- */
- public void test_read() throws IOException {
- // Test for method int java.security.DigestInputStream.read()
- DigestInputStream dis = new DigestInputStream(inStream, digest);
-
- // read and compare the data that the inStream has
- int c;
- while ((c = dis.read()) > -1) {
- int d = inStream1.read();
- assertEquals(d, c);
- }// end while
- }
-
- /**
- * @tests java.security.DigestInputStream#read(byte[], int, int)
- */
- public void test_read$BII() throws IOException {
- // Test for method int java.security.DigestInputStream.read(byte [],
- // int, int)
- DigestInputStream dis = new DigestInputStream(inStream, digest);
- int bytesToRead = inStream.available();
- byte buf1[] = new byte[bytesToRead + 5];
- byte buf2[] = new byte[bytesToRead + 5];
- // make sure we're actually reading some data
- assertTrue("No data to read for this test", bytesToRead > 0);
-
- // read and compare the data that the inStream has
- int bytesRead1 = dis.read(buf1, 5, bytesToRead);
- int bytesRead2 = inStream1.read(buf2, 5, bytesToRead);
- assertEquals("Didn't read the same from each stream", bytesRead1,
- bytesRead2);
- assertEquals("Didn't read the entire", bytesRead1, bytesToRead);
- // compare the arrays
- boolean same = true;
- for (int i = 0; i < bytesToRead + 5; i++) {
- if (buf1[i] != buf2[i]) {
- same = false;
- }
- }// end for
- assertTrue("Didn't get the same data", same);
- }
-
- /**
- * @tests java.security.DigestInputStream#setMessageDigest(java.security.MessageDigest)
- */
- public void test_setMessageDigestLjava_security_MessageDigest() {
- // Test for method void
- // java.security.DigestInputStream.setMessageDigest(java.security.MessageDigest)
- DigestInputStream dis = new DigestInputStream(inStream, null);
-
- // make sure the digest is null when it's not been set
- assertNull(
- "Uninitialised MessageDigest should have been returned as null",
- dis.getMessageDigest());
- dis.setMessageDigest(digest);
- assertEquals("Wrong MessageDigest was returned.", digest, dis
- .getMessageDigest());
- }
-
- /**
- * Sets up the fixture, for example, open a network connection. This method
- * is called before a test is executed.
- *
- * @throws UnsupportedEncodingException
- */
- protected void setUp() throws UnsupportedEncodingException {
- // create a ByteArrayInputStream to perform digesting on
- inStream = new ByteArrayInputStream(
- "This is a test string for digesting".getBytes("UTF-8"));
- inStream1 = new ByteArrayInputStream(
- "This is a test string for digesting".getBytes("UTF-8"));
- try {
- digest = MessageDigest.getInstance("SHA-1");
- } catch (NoSuchAlgorithmException e) {
- fail("Unable to find SHA-1 algorithm");
- }
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestInputStreamTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestInputStreamTest.java
deleted file mode 100644
index 96b7280..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestInputStreamTest.java
+++ /dev/null
@@ -1,583 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.DigestInputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Arrays;
-
-import org.apache.harmony.security.tests.support.MDGoldenData;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for fields and methods of class <code>DigestInputStream</code>
- */
-public class DigestInputStreamTest extends TestCase {
-
- /**
- * Message digest algorithm name used during testing
- */
- private static final String algorithmName[] = {
- "SHA-1",
- "SHA",
- "SHA1",
- "SHA-256",
- "SHA-384",
- "SHA-512",
- "MD5",
- };
- /**
- * Chunk size for read(byte, off, len) tests
- */
- private static final int CHUNK_SIZE = 32;
- /**
- * Test message for digest computations
- */
- private static final byte[] myMessage = MDGoldenData.getMessage();
- /**
- * The length of test message
- */
- private static final int MY_MESSAGE_LEN = myMessage.length;
-
- /**
- * Constructor for DigestInputStreamTest.
- *
- * @param name
- */
- public DigestInputStreamTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>DigestInputStream</code> constructor<br>
- * <p/>
- * Assertion: creates new <code>DigestInputStream</code> instance
- * using valid parameters (both non <code>null</code>)
- *
- * @throws NoSuchAlgorithmException
- */
- public final void testDigestInputStream01() {
- for (int i = 0; i < algorithmName.length; i++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[i]);
- InputStream is = new ByteArrayInputStream(myMessage);
- InputStream dis = new DigestInputStream(is, md);
- assertTrue(dis instanceof DigestInputStream);
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #2 for <code>DigestInputStream</code> constructor<br>
- * <p/>
- * Assertion: creates new <code>DigestInputStream</code> instance
- * using valid parameters (both <code>null</code>)
- */
- public final void testDigestInputStream02() {
- InputStream dis = new DigestInputStream(null, null);
- assertTrue(dis instanceof DigestInputStream);
- }
-
- /**
- * Test #1 for <code>read()</code> method<br>
- * <p/>
- * Assertion: returns the byte read<br>
- * Assertion: updates associated digest<br>
- */
- public final void testRead01()
- throws IOException {
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- InputStream is = new ByteArrayInputStream(myMessage);
- DigestInputStream dis = new DigestInputStream(is, md);
- for (int i = 0; i < MY_MESSAGE_LEN; i++) {
- // check that read() returns valid values
- assertTrue("retval", ((byte) dis.read() == myMessage[i]));
- }
- // check that associated digest has been updated properly
- assertTrue("update",
- Arrays.equals(
- dis.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[ii])));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #2 for <code>read()</code> method<br>
- * <p/>
- * Assertion: returns -1 if EOS had been
- * reached but not read before method call<br>
- * <p/>
- * Assertion: must not update digest if EOS had been
- * reached but not read before method call<br>
- */
- public final void testRead02()
- throws IOException {
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- InputStream is = new ByteArrayInputStream(myMessage);
- DigestInputStream dis = new DigestInputStream(is, md);
- for (int i = 0; i < MY_MESSAGE_LEN; i++) {
- dis.read();
- }
- // check that subsequent read() calls return -1 (eos)
- assertEquals("retval1", -1, dis.read());
- assertEquals("retval2", -1, dis.read());
- assertEquals("retval3", -1, dis.read());
- // check that 3 previous read() calls did not update digest
- assertTrue("update",
- Arrays.equals(dis.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[ii])));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #3 for <code>read()</code> method<br>
- * Test #1 for <code>on(boolean)</code> method<br>
- * <p/>
- * Assertion: <code>read()</code> must not update digest if it is off<br>
- * Assertion: <code>on(boolean)</code> turns digest functionality on
- * (if <code>true</code> passed as a parameter) or off (if <code>false</code>
- * passed)
- */
- public final void testRead03()
- throws IOException {
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- InputStream is = new ByteArrayInputStream(myMessage);
- DigestInputStream dis = new DigestInputStream(is, md);
-
- // turn digest off
- dis.on(false);
-
- for (int i = 0; i < MY_MESSAGE_LEN; i++) {
- dis.read();
- }
-
- // check that digest value has not been updated by read()
- assertTrue(Arrays.equals(dis.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[ii] + "_NU")));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #4 for <code>read()</code> method<br>
- * <p/>
- * Assertion: broken <code>DigestInputStream</code>instance:
- * <code>InputStream</code> not set. <code>read()</code> must
- * not work
- */
- public final void testRead04() throws IOException {
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- DigestInputStream dis = new DigestInputStream(null, md);
- // must result in an exception
- try {
- for (int i = 0; i < MY_MESSAGE_LEN; i++) {
- dis.read();
- }
- } catch (Exception e) {
- return;
- }
-
- fail("InputStream not set. read() must not work");
-
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #5 for <code>read()</code> method<br>
- * <p/>
- * Assertion: broken <code>DigestInputStream</code>instance:
- * associated <code>MessageDigest</code> not set.
- * <code>read()</code> must not work when digest
- * functionality is on
- */
- public final void testRead05() {
- InputStream is = new ByteArrayInputStream(myMessage);
- DigestInputStream dis = new DigestInputStream(is, null);
-
- // must result in an exception
- try {
- for (int i = 0; i < MY_MESSAGE_LEN; i++) {
- dis.read();
- }
- fail("read() must not work when digest functionality is on");
- } catch (Exception e) {
- }
- }
-
- /**
- * Test #6 for <code>read()</code> method<br>
- * Test #2 for <code>on(boolean)</code> method<br>
- * <p/>
- * Assertion: broken <code>DigestInputStream</code>instance:
- * associated <code>MessageDigest</code> not set.
- * <code>read()</code> must work when digest
- * functionality is off
- */
- public final void testRead06()
- throws IOException {
- InputStream is = new ByteArrayInputStream(myMessage);
- // construct object without digest
- DigestInputStream dis = new DigestInputStream(is, null);
- // set digest functionality to off
- dis.on(false);
- // the following must pass without any exception
- for (int i = 0; i < MY_MESSAGE_LEN; i++) {
- assertTrue((byte) dis.read() == myMessage[i]);
- }
- }
-
- /**
- * Test #1 for <code>read(byte[],int,int)</code> method<br>
- * <p/>
- * Assertion: returns the number of bytes read<br>
- * <p/>
- * Assertion: put bytes read into specified array at specified offset<br>
- * <p/>
- * Assertion: updates associated digest<br>
- */
- public final void testReadbyteArrayintint01()
- throws IOException {
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- InputStream is = new ByteArrayInputStream(myMessage);
- DigestInputStream dis = new DigestInputStream(is, md);
- byte[] bArray = new byte[MY_MESSAGE_LEN];
-
- // check that read(byte[],int,int) returns valid value
- assertTrue("retval",
- dis.read(bArray, 0, bArray.length) == MY_MESSAGE_LEN);
- // check that bArray has been filled properly
- assertTrue("bArray", Arrays.equals(myMessage, bArray));
- // check that associated digest has been updated properly
- assertTrue("update", Arrays.equals(dis.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[ii])));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #2 for <code>read(byte[],int,int)</code> method<br>
- * <p/>
- * Assertion: returns the number of bytes read<br>
- * <p/>
- * Assertion: put bytes read into specified array at specified offset<br>
- * <p/>
- * Assertion: updates associated digest<br>
- */
- public final void testReadbyteArrayintint02()
- throws IOException {
- // check precondition
- assertEquals(0, MY_MESSAGE_LEN % CHUNK_SIZE);
-
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- InputStream is = new ByteArrayInputStream(myMessage);
- DigestInputStream dis = new DigestInputStream(is, md);
- byte[] bArray = new byte[MY_MESSAGE_LEN];
-
- for (int i = 0; i < MY_MESSAGE_LEN / CHUNK_SIZE; i++) {
- // check that read(byte[],int,int) returns valid value
- assertTrue("retval",
- dis.read(bArray, i * CHUNK_SIZE, CHUNK_SIZE) == CHUNK_SIZE);
- }
- // check that bArray has been filled properly
- assertTrue("bArray", Arrays.equals(myMessage, bArray));
- // check that associated digest has been updated properly
- assertTrue("update", Arrays.equals(dis.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[ii])));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
-
- /**
- * Test #3 for <code>read(byte[],int,int)</code> method<br>
- * <p/>
- * Assertion: returns the number of bytes read<br>
- * <p/>
- * Assertion: put bytes read into specified array at specified offset<br>
- * <p/>
- * Assertion: updates associated digest<br>
- */
- public final void testReadbyteArrayintint03()
- throws IOException {
- // check precondition
- assertTrue(MY_MESSAGE_LEN % (CHUNK_SIZE + 1) != 0);
-
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- InputStream is = new ByteArrayInputStream(myMessage);
- DigestInputStream dis = new DigestInputStream(is, md);
- byte[] bArray = new byte[MY_MESSAGE_LEN];
-
- for (int i = 0; i < MY_MESSAGE_LEN / (CHUNK_SIZE + 1); i++) {
- // check that read(byte[],int,int) returns valid value
- assertTrue("retval1",
- dis.read(bArray, i * (CHUNK_SIZE + 1), CHUNK_SIZE + 1) ==
- CHUNK_SIZE + 1);
- }
-
- // check that last call returns right
- // number of remaining bytes
- assertTrue("retval2",
- dis.read(bArray,
- MY_MESSAGE_LEN / (CHUNK_SIZE + 1) * (CHUNK_SIZE + 1),
- MY_MESSAGE_LEN % (CHUNK_SIZE + 1)) ==
- (MY_MESSAGE_LEN % (CHUNK_SIZE + 1)));
-
- // check that bArray has been filled properly
- assertTrue("bArray", Arrays.equals(myMessage, bArray));
- // check that associated digest has been updated properly
- assertTrue("update", Arrays.equals(dis.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[ii])));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #4 for <code>read(byte[],int,int)</code> method<br>
- * <p/>
- * Assertion: returns the number of bytes read<br>
- * <p/>
- * Assertion: updates associated digest<br>
- */
- public final void testReadbyteArrayintint04()
- throws IOException {
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- InputStream is = new ByteArrayInputStream(myMessage);
- DigestInputStream dis = new DigestInputStream(is, md);
- byte[] bArray = new byte[MY_MESSAGE_LEN];
- // read all but EOS
- dis.read(bArray, 0, bArray.length);
- // check that subsequent read(byte[],int,int) calls return -1 (EOS)
- assertEquals("retval1", -1, dis.read(bArray, 0, 1));
- assertEquals("retval2", -1, dis.read(bArray, 0, bArray.length));
- assertEquals("retval3", -1, dis.read(bArray, 0, 1));
- // check that 3 previous read() calls did not update digest
- assertTrue("update",
- Arrays.equals(dis.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[ii])));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #5 for <code>read(byte[],int,int)</code> method<br>
- * <p/>
- * Assertion: returns the number of bytes read<br>
- * <p/>
- * Assertion: put bytes read into specified array at specified offset<br>
- * <p/>
- * Assertion: does not update associated digest if
- * digest functionality is off<br>
- */
- public final void testReadbyteArrayintint05()
- throws IOException {
- // check precondition
- assertEquals(0, MY_MESSAGE_LEN % CHUNK_SIZE);
-
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- InputStream is = new ByteArrayInputStream(myMessage);
- DigestInputStream dis = new DigestInputStream(is, md);
- byte[] bArray = new byte[MY_MESSAGE_LEN];
-
- // turn digest off
- dis.on(false);
-
- for (int i = 0; i < MY_MESSAGE_LEN / CHUNK_SIZE; i++) {
- dis.read(bArray, i * CHUNK_SIZE, CHUNK_SIZE);
- }
- // check that digest has not been updated
- assertTrue(Arrays.equals(dis.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[ii] + "_NU")));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test for <code>getMessageDigest()</code> method<br>
- * <p/>
- * Assertion: returns associated message digest<br>
- */
- public final void testGetMessageDigest() {
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- DigestInputStream dis = new DigestInputStream(null, md);
-
- assertTrue(dis.getMessageDigest() == md);
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
-
- /**
- * Test for <code>setMessageDigest()</code> method<br>
- * <p/>
- * Assertion: set associated message digest<br>
- */
- public final void testSetMessageDigest() {
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- DigestInputStream dis = new DigestInputStream(null, null);
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- dis.setMessageDigest(md);
-
- assertTrue(dis.getMessageDigest() == md);
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test for <code>on()</code> method<br>
- * Assertion: turns digest functionality on or off
- */
- public final void testOn() throws IOException {
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- InputStream is = new ByteArrayInputStream(myMessage);
- DigestInputStream dis = new DigestInputStream(is, md);
-
- // turn digest off
- dis.on(false);
-
- for (int i = 0; i < MY_MESSAGE_LEN - 1; i++) {
- dis.read();
- }
-
- // turn digest on
- dis.on(true);
-
- // read remaining byte
- dis.read();
-
- byte[] digest = dis.getMessageDigest().digest();
-
- // check that digest value has been
- // updated by the last read() call
- assertFalse(
- Arrays.equals(digest, MDGoldenData.getDigest(algorithmName[ii])) ||
- Arrays.equals(digest, MDGoldenData.getDigest(algorithmName[ii] + "_NU")));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * Assertion: returns <code>String</code> representation of this object
- */
- public final void testToString() {
- for (int ii = 0; ii < algorithmName.length; ii++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
- InputStream is = new ByteArrayInputStream(myMessage);
- DigestInputStream dis = new DigestInputStream(is, md);
-
- assertNotNull(dis.toString());
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java
deleted file mode 100644
index e9c7b71..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Arrays;
-
-import org.apache.harmony.security.tests.support.MDGoldenData;
-import org.apache.harmony.security.tests.support.MyMessageDigest1;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for fields and methods of class <code>DigestInputStream</code>
- */
-public class DigestOutputStreamTest extends TestCase {
-
- /**
- * Message digest algorithm name used during testing
- */
- private static final String algorithmName[] = {
- "SHA-1",
- "SHA",
- "SHA1",
- "SHA-256",
- "SHA-384",
- "SHA-512",
- "MD5",
- };
- /**
- * Chunk size for read(byte, off, len) tests
- */
- private static final int CHUNK_SIZE = 32;
- /**
- * Test message for digest computations
- */
- private static final byte[] myMessage = MDGoldenData.getMessage();
- /**
- * The length of test message
- */
- private static final int MY_MESSAGE_LEN = myMessage.length;
-
- /**
- * Constructor for DigestInputStreamTest.
- *
- * @param name
- */
- public DigestOutputStreamTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * @tests java.security.DigestOutputStream#DigestOutputStream(java.io.OutputStream,
- *java.security.MessageDigest)
- */
- public void test_CtorLjava_io_OutputStreamLjava_security_MessageDigest() {
-
- // non-null parameters
- MessageDigest md = new MyMessageDigest1();
- MyOutputStream out = new MyOutputStream();
-
- MyDigestOutputStream dos = new MyDigestOutputStream(out, md);
- assertSame(out, dos.myOutputStream());
- assertSame(md, dos.myMessageDigest());
-
- // null parameters
- dos = new MyDigestOutputStream(null, null);
- assertNull(dos.myOutputStream());
- assertNull(dos.myMessageDigest());
- }
-
- /**
- * @tests java.security.DigestOutputStream#getMessageDigest()
- */
- public void test_getMessageDigest() {
-
- MessageDigest digest = new MyMessageDigest1();
- OutputStream out = new MyOutputStream();
-
- // non-null parameter
- DigestOutputStream dos = new DigestOutputStream(out, digest);
- assertSame(digest, dos.getMessageDigest());
-
- // null parameter
- dos = new DigestOutputStream(out, null);
- assertNull("getMessageDigest should have returned null", dos
- .getMessageDigest());
- }
-
- /**
- * @tests java.security.DigestOutputStream#setMessageDigest(MessageDigest)
- */
- public void test_setMessageDigestLjava_security_MessageDigest() {
-
- MessageDigest digest = new MyMessageDigest1();
- OutputStream out = new MyOutputStream();
-
- DigestOutputStream dos = new DigestOutputStream(out, null);
-
- // non-null parameter
- dos.setMessageDigest(digest);
- assertSame(digest, dos.getMessageDigest());
-
- // null parameter
- dos.setMessageDigest(null);
- assertNull("getMessageDigest should have returned null", dos
- .getMessageDigest());
- }
-
-
- /**
- * Test #1 for <code>write(int)</code> method<br>
- * <p/>
- * Assertion: writes the byte to the output stream<br>
- * Assertion: updates associated digest<br>
- */
- public final void testWriteint01()
- throws IOException {
- for (int k = 0; k < algorithmName.length; k++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[k]);
- ByteArrayOutputStream bos = new ByteArrayOutputStream(MY_MESSAGE_LEN);
- DigestOutputStream dos = new DigestOutputStream(bos, md);
- for (int i = 0; i < MY_MESSAGE_LEN; i++) {
- dos.write(myMessage[i]);
- }
- // check that bytes have been written correctly
- assertTrue("write", Arrays.equals(MDGoldenData.getMessage(),
- bos.toByteArray()));
- // check that associated digest has been updated properly
- assertTrue("update", Arrays.equals(dos.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[k])));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #2 for <code>write(int)</code> method<br>
- * Test #1 for <code>on(boolean)</code> method<br>
- * <p/>
- * Assertion: <code>write(int)</code> must not update digest if it is off<br>
- * Assertion: <code>on(boolean)</code> turns digest functionality on
- * if <code>true</code> passed as a parameter or off if <code>false</code>
- * passed
- */
- public final void testWriteint02()
- throws IOException {
- for (int k = 0; k < algorithmName.length; k++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[k]);
- ByteArrayOutputStream bos = new ByteArrayOutputStream(MY_MESSAGE_LEN);
- DigestOutputStream dos = new DigestOutputStream(bos, md);
-
- // turn digest off
- dos.on(false);
-
- for (int i = 0; i < MY_MESSAGE_LEN; i++) {
- dos.write(myMessage[i]);
- }
-
- // check that bytes have been written correctly
- assertTrue("write", Arrays.equals(MDGoldenData.getMessage(),
- bos.toByteArray()));
- // check that digest value has not been updated by write()
- assertTrue("update", Arrays.equals(dos.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[k] + "_NU")));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #3 for <code>write(int)</code> method<br>
- * <p/>
- * Assertion: broken <code>DigestOutputStream</code>instance:
- * <code>OutputStream</code> not set. <code>write(int)</code> must
- * not work
- */
- public final void testWriteint03() throws IOException {
- for (int k = 0; k < algorithmName.length; k++) {
- try {
- MessageDigest md = MessageDigest.getInstance(algorithmName[k]);
- DigestOutputStream dos = new DigestOutputStream(null, md);
- // must result in an exception
- try {
- for (int i = 0; i < MY_MESSAGE_LEN; i++) {
- dos.write(myMessage[i]);
- }
- fail("OutputStream not set. write(int) must not work");
- } catch (Exception e) {
- return;
- }
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #4 for <code>write(int)</code> method<br>
- * <p/>
- * Assertion: broken <code>DigestOutputStream</code>instance:
- * associated <code>MessageDigest</code> not set.
- * <code>write(int)</code> must not work when digest
- * functionality is on
- */
- public final void testWriteint04() throws IOException {
- OutputStream os = new ByteArrayOutputStream(MY_MESSAGE_LEN);
- DigestOutputStream dos = new DigestOutputStream(os, null);
-
- // must result in an exception
- try {
- for (int i = 0; i < MY_MESSAGE_LEN; i++) {
- dos.write(myMessage[i]);
- }
- fail("OutputStream not set. write(int) must not work");
- } catch (Exception e) {
- return;
- }
- }
-
- /**
- * Test #5 for <code>write(int)</code> method<br>
- * Test #2 for <code>on(boolean)</code> method<br>
- * <p/>
- * Assertion: broken <code>DigestOutputStream</code>instance:
- * associated <code>MessageDigest</code> not set.
- * <code>write(int)</code> must work when digest
- * functionality is off
- */
- public final void testWriteint05() throws IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream(MY_MESSAGE_LEN);
- DigestOutputStream dos = new DigestOutputStream(bos, null);
- // set digest functionality to off
- dos.on(false);
- // the following must pass without any exception
- for (int i = 0; i < MY_MESSAGE_LEN; i++) {
- dos.write(myMessage[i]);
- }
- // check that bytes have been written correctly
- assertTrue(Arrays.equals(MDGoldenData.getMessage(),
- bos.toByteArray()));
- }
-
- /**
- * Test #1 for <code>write(byte[],int,int)</code> method<br>
- * <p/>
- * Assertion: put bytes into output stream<br>
- * <p/>
- * Assertion: updates associated digest<br>
- */
- public final void testWritebyteArrayintint01()
- throws IOException {
- for (int k = 0; k < algorithmName.length; k++) {
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream(MY_MESSAGE_LEN);
- MessageDigest md = MessageDigest.getInstance(algorithmName[k]);
- DigestOutputStream dos = new DigestOutputStream(bos, md);
-
- // write message at once
- dos.write(myMessage, 0, MY_MESSAGE_LEN);
-
- // check write
- assertTrue("write", Arrays.equals(myMessage, bos.toByteArray()));
- // check that associated digest has been updated properly
- assertTrue("update", Arrays.equals(dos.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[k])));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #2 for <code>write(byte[],int,int)</code> method<br>
- * <p/>
- * Assertion: put bytes into output stream<br>
- * <p/>
- * Assertion: updates associated digest<br>
- */
- public final void testWritebyteArrayintint02()
- throws IOException {
- // check precondition
- assertEquals(0, MY_MESSAGE_LEN % CHUNK_SIZE);
- for (int k = 0; k < algorithmName.length; k++) {
- try {
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream(MY_MESSAGE_LEN);
- MessageDigest md = MessageDigest.getInstance(algorithmName[k]);
- DigestOutputStream dos = new DigestOutputStream(bos, md);
-
- // write message by chunks
- for (int i = 0; i < MY_MESSAGE_LEN / CHUNK_SIZE; i++) {
- dos.write(myMessage, i * CHUNK_SIZE, CHUNK_SIZE);
- }
- // check write
- assertTrue("write", Arrays.equals(myMessage, bos.toByteArray()));
- // check that associated digest has been updated properly
- assertTrue("update", Arrays.equals(dos.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[k])));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
-
- /**
- * Test #3 for <code>write(byte[],int,int)</code> method<br>
- * <p/>
- * Assertion: put bytes into output stream<br>
- * <p/>
- * Assertion: updates associated digest<br>
- */
- public final void testWritebyteArrayintint03()
- throws NoSuchAlgorithmException,
- IOException {
- // check precondition
- assertTrue(MY_MESSAGE_LEN % (CHUNK_SIZE + 1) != 0);
-
- for (int k = 0; k < algorithmName.length; k++) {
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream(MY_MESSAGE_LEN);
- MessageDigest md = MessageDigest.getInstance(algorithmName[k]);
- DigestOutputStream dos = new DigestOutputStream(bos, md);
-
- // write message by chunks
- for (int i = 0; i < MY_MESSAGE_LEN / (CHUNK_SIZE + 1); i++) {
- dos.write(myMessage, i * (CHUNK_SIZE + 1), CHUNK_SIZE + 1);
- }
- // write remaining bytes
- dos.write(myMessage,
- MY_MESSAGE_LEN / (CHUNK_SIZE + 1) * (CHUNK_SIZE + 1),
- MY_MESSAGE_LEN % (CHUNK_SIZE + 1));
- // check write
- assertTrue("write", Arrays.equals(myMessage, bos.toByteArray()));
- // check that associated digest has been updated properly
- assertTrue("update", Arrays.equals(dos.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[k])));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test #4 for <code>write(byte[],int,int)</code> method<br>
- * <p/>
- * Assertion: put bytes into output stream<br>
- * <p/>
- * Assertion: does not update associated digest if digest
- * functionality is off<br>
- */
- public final void testWritebyteArrayintint04()
- throws NoSuchAlgorithmException,
- IOException {
- // check precondition
- assertEquals(0, MY_MESSAGE_LEN % CHUNK_SIZE);
-
- for (int k = 0; k < algorithmName.length; k++) {
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream(MY_MESSAGE_LEN);
- MessageDigest md = MessageDigest.getInstance(algorithmName[k]);
- DigestOutputStream dos = new DigestOutputStream(bos, md);
-
- // set digest functionality off
- dos.on(false);
-
- // write message by chunks
- for (int i = 0; i < MY_MESSAGE_LEN / CHUNK_SIZE; i++) {
- dos.write(myMessage, i * CHUNK_SIZE, CHUNK_SIZE);
- }
-
- // check write
- assertTrue("write", Arrays.equals(myMessage, bos.toByteArray()));
- // check that associated digest has not been updated
- assertTrue("update", Arrays.equals(dos.getMessageDigest().digest(),
- MDGoldenData.getDigest(algorithmName[k] + "_NU")));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * @tests java.security.DigestOutputStream#write(byte[], int, int)
- */
- public void test_writeLB$LILI() throws Exception {
-
- // Regression form HARMONY-1091.
- MessageDigest md = new MyMessageDigest1();
- byte[] bytes = new byte[] { 1, 2 };
- DigestOutputStream dig = new DigestOutputStream(
- new ByteArrayOutputStream(), md);
- // buf == null
- try {
- dig.write(null, -1, 0);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- // offset + len > buf.length
- try {
- dig.write(bytes, 0, bytes.length + 1);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- // offset < 0
- try {
- dig.write(bytes, -1, 1);
- fail("No expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
- }
- // len < 0
- try {
- dig.write(bytes, 0, -1);
- fail("No expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
- }
- }
-
- /**
- * Test for <code>on()</code> method<br>
- * Assertion: turns digest functionality on or off
- */
- public final void testOn() throws IOException {
- for (int k = 0; k < algorithmName.length; k++) {
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream(MY_MESSAGE_LEN);
- MessageDigest md = MessageDigest.getInstance(algorithmName[k]);
- DigestOutputStream dos = new DigestOutputStream(bos, md);
-
- // turn digest off
- dos.on(false);
-
- for (int i = 0; i < MY_MESSAGE_LEN - 1; i++) {
- dos.write(myMessage[i]);
- }
-
- // turn digest on
- dos.on(true);
-
- // read remaining byte
- dos.write(myMessage[MY_MESSAGE_LEN - 1]);
-
- byte[] digest = dos.getMessageDigest().digest();
-
- // check that digest value has been
- // updated by the last write(int) call
- assertFalse(
- Arrays.equals(digest, MDGoldenData.getDigest(algorithmName[k])) ||
- Arrays.equals(digest, MDGoldenData.getDigest(algorithmName[k] + "_NU")));
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * Assertion: returns <code>String</code> representation of this object
- */
- public final void testToString() throws NoSuchAlgorithmException {
- for (int k = 0; k < algorithmName.length; k++) {
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream(MY_MESSAGE_LEN);
- MessageDigest md = MessageDigest.getInstance(algorithmName[k]);
- DigestOutputStream dos = new DigestOutputStream(bos, md);
-
- assertNotNull(dos.toString());
- return;
- } catch (NoSuchAlgorithmException e) {
- // allowed failure
- }
- }
- fail(getName() + ": no MessageDigest algorithms available - test not performed");
- }
-
- /**
- * @tests java.security.DigestOutputStream#on(boolean)
- */
- public void test_onZ() throws Exception {
- // Test for method void java.security.DigestOutputStream.on(boolean)
- DigestOutputStream dos = new DigestOutputStream(
- new ByteArrayOutputStream(), MessageDigest
- .getInstance("SHA"));
- dos.on(false);
- byte digestArray[] = { 23, 43, 44 };
- dos.write(digestArray, 1, 1);
- byte digestResult[] = dos.getMessageDigest().digest();
- byte expected[] = { -38, 57, -93, -18, 94, 107, 75, 13, 50, 85,
- -65, -17, -107, 96, 24, -112, -81, -40, 7, 9 };
- assertTrue("Digest did not return expected result.",
- java.util.Arrays.equals(digestResult, expected));
- // now turn on processing and re-run
- dos.on(true);
- dos.write(digestArray, 1, 1);
- digestResult = dos.getMessageDigest().digest();
- byte expected1[] = { -87, 121, -17, 16, -52, 111, 106, 54, -33,
- 107, -118, 50, 51, 7, -18, 59, -78, -30, -37, -100 };
-
- assertTrue("Digest did not return expected result.",
- java.util.Arrays.equals(digestResult, expected1));
- }
-
- /**
- * @tests java.security.DigestOutputStream#write(byte[], int, int)
- */
- public void test_write$BII() throws Exception {
- // Test for method void java.security.DigestOutputStream.write(byte [],
- // int, int)
- DigestOutputStream dos = new DigestOutputStream(
- new ByteArrayOutputStream(), MessageDigest.getInstance("SHA"));
- byte digestArray[] = { 23, 43, 44 };
- dos.write(digestArray, 1, 1);
- byte digestResult[] = dos.getMessageDigest().digest();
- byte expected[] = { -87, 121, -17, 16, -52, 111, 106, 54, -33, 107,
- -118, 50, 51, 7, -18, 59, -78, -30, -37, -100 };
-
- assertTrue("Digest did not return expected result.",
- java.util.Arrays.equals(digestResult, expected));
- }
-
- /**
- * @tests java.security.DigestOutputStream#write(int)
- */
- public void test_writeI() throws Exception {
- // Test for method void java.security.DigestOutputStream.write(int)
- DigestOutputStream dos = new DigestOutputStream(
- new ByteArrayOutputStream(), MessageDigest.getInstance("SHA"));
- dos.write((byte) 43);
- byte digestResult[] = dos.getMessageDigest().digest();
- byte expected[] = { -87, 121, -17, 16, -52, 111, 106, 54, -33, 107,
- -118, 50, 51, 7, -18, 59, -78, -30, -37, -100 };
-
- assertTrue("Digest did not return expected result.",
- java.util.Arrays.equals(digestResult, expected));
- }
-
-
- private class MyOutputStream extends OutputStream {
- @Override
- public void write(int arg0) throws IOException {
- }
- }
-
- private class MyDigestOutputStream extends DigestOutputStream {
- public MyDigestOutputStream(OutputStream out, MessageDigest digest) {
- super(out, digest);
- }
-
- public MessageDigest myMessageDigest() {
- return digest;
- }
-
- public OutputStream myOutputStream() {
- return out;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GeneralSecurityExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GeneralSecurityExceptionTest.java
deleted file mode 100644
index bfb793b..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GeneralSecurityExceptionTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.GeneralSecurityException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>GeneralSecurityException</code> class constructors and
- * methods.
- */
-public class GeneralSecurityExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for GeneralSecurityExceptionTests.
- *
- * @param arg0
- */
- public GeneralSecurityExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>GeneralSecurityException()</code> constructor Assertion:
- * constructs GeneralSecurityException with no detail message
- */
- public void testGeneralSecurityException01() {
- GeneralSecurityException tE = new GeneralSecurityException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>GeneralSecurityException(String)</code> constructor
- * Assertion: constructs GeneralSecurityException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testGeneralSecurityException02() {
- GeneralSecurityException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new GeneralSecurityException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>GeneralSecurityException(String)</code> constructor
- * Assertion: constructs GeneralSecurityException when <code>msg</code> is
- * null
- */
- public void testGeneralSecurityException03() {
- String msg = null;
- GeneralSecurityException tE = new GeneralSecurityException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>GeneralSecurityException(Throwable)</code> constructor
- * Assertion: constructs GeneralSecurityException when <code>cause</code>
- * is null
- */
- public void testGeneralSecurityException04() {
- Throwable cause = null;
- GeneralSecurityException tE = new GeneralSecurityException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>GeneralSecurityException(Throwable)</code> constructor
- * Assertion: constructs GeneralSecurityException when <code>cause</code>
- * is not null
- */
- public void testGeneralSecurityException05() {
- GeneralSecurityException tE = new GeneralSecurityException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>GeneralSecurityException(String, Throwable)</code>
- * constructor Assertion: constructs GeneralSecurityException when
- * <code>cause</code> is null <code>msg</code> is null
- */
- public void testGeneralSecurityException06() {
- GeneralSecurityException tE = new GeneralSecurityException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>GeneralSecurityException(String, Throwable)</code>
- * constructor Assertion: constructs GeneralSecurityException when
- * <code>cause</code> is null <code>msg</code> is not null
- */
- public void testGeneralSecurityException07() {
- GeneralSecurityException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new GeneralSecurityException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>GeneralSecurityException(String, Throwable)</code>
- * constructor Assertion: constructs GeneralSecurityException when
- * <code>cause</code> is not null <code>msg</code> is null
- */
- public void testGeneralSecurityException08() {
- GeneralSecurityException tE = new GeneralSecurityException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>GeneralSecurityException(String, Throwable)</code>
- * constructor Assertion: constructs GeneralSecurityException when
- * <code>cause</code> is not null <code>msg</code> is not null
- */
- public void testGeneralSecurityException09() {
- GeneralSecurityException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new GeneralSecurityException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GuardedObjectTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GuardedObjectTest.java
deleted file mode 100644
index 35c0b1c..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GuardedObjectTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexey V. Varlamov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>GuardedObject</code>
- */
-
-public class GuardedObjectTest extends TestCase {
-
- /**
- * Null guard imposes no restriction.
- */
- public void testNoGuard() {
- Object obj = null;
- GuardedObject go = new GuardedObject(obj, null);
- assertNull(go.getObject());
-
- obj = "ewte rtw3456";
- go = new GuardedObject(obj, null);
- assertEquals(obj, go.getObject());
- }
-
- /**
- * Test real guard can both allow and deny access.
- */
- public void testGuard() {
- final String message = "test message";
- final StringBuffer objBuffer = new StringBuffer("235345 t");
- GuardedObject go = new GuardedObject(objBuffer, new Guard() {
-
- public void checkGuard(Object object) throws SecurityException {
- if (object == objBuffer && objBuffer.length() == 0) {
- throw new SecurityException(message);
- }
- }
- });
- assertEquals(objBuffer, go.getObject());
-
- objBuffer.setLength(0);
- try {
- go.getObject();
- fail("SecurityException is not thrown");
- } catch (Exception ok) {
- assertEquals(message, ok.getMessage());
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Identity2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Identity2Test.java
deleted file mode 100644
index fec09fa..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Identity2Test.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.security.Identity;
-import java.security.IdentityScope;
-import java.security.KeyManagementException;
-import java.security.KeyPairGenerator;
-import java.security.Principal;
-import java.security.PublicKey;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-
-import org.apache.harmony.security.tests.java.security.IdentityScope2Test.IdentityScopeSubclass;
-
-public class Identity2Test extends junit.framework.TestCase {
-
- static PublicKey pubKey;
-
- static {
- try {
- pubKey = KeyPairGenerator.getInstance("DSA").genKeyPair().getPublic();
- } catch (Exception e) {
- fail(e.toString());
- }
- }
-
- public static class CertificateImpl implements java.security.Certificate {
-
- X509Certificate cert;
-
- public CertificateImpl(X509Certificate cert) {
- this.cert = cert;
- }
-
- public Principal getGuarantor() {
- return cert.getIssuerDN();
- }
-
- public void encode(OutputStream out) {
- }
-
- public void decode(InputStream in) {
- }
-
- public String toString() {
- return "";
- }
-
- public String toString(boolean b) {
- return "";
- }
-
- public String getFormat() {
- return cert.getType();
- }
-
- public Principal getPrincipal() {
- return cert.getSubjectDN();
- }
-
- public PublicKey getPublicKey() {
- return cert.getPublicKey();
- }
- }
-
- String certificate = "-----BEGIN CERTIFICATE-----\n"
- + "MIICZTCCAdICBQL3AAC2MA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMSAw\n"
- + "HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJl\n"
- + "IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NzAyMjAwMDAwMDBa\n"
- + "Fw05ODAyMjAyMzU5NTlaMIGWMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZv\n"
- + "cm5pYTESMBAGA1UEBxMJUGFsbyBBbHRvMR8wHQYDVQQKExZTdW4gTWljcm9zeXN0\n"
- + "ZW1zLCBJbmMuMSEwHwYDVQQLExhUZXN0IGFuZCBFdmFsdWF0aW9uIE9ubHkxGjAY\n"
- + "BgNVBAMTEWFyZ29uLmVuZy5zdW4uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB\n"
- + "iQKBgQCofmdY+PiUWN01FOzEewf+GaG+lFf132UpzATmYJkA4AEA/juW7jSi+LJk\n"
- + "wJKi5GO4RyZoyimAL/5yIWDV6l1KlvxyKslr0REhMBaD/3Z3EsLTTEf5gVrQS6sT\n"
- + "WMoSZAyzB39kFfsB6oUXNtV8+UKKxSxKbxvhQn267PeCz5VX2QIDAQABMA0GCSqG\n"
- + "SIb3DQEBAgUAA34AXl3at6luiV/7I9MN5CXYoPJYI8Bcdc1hBagJvTMcmlqL2uOZ\n"
- + "H9T5hNMEL9Tk6aI7yZPXcw/xI2K6pOR/FrMp0UwJmdxX7ljV6ZtUZf7pY492UqwC\n"
- + "1777XQ9UEZyrKJvF5ntleeO0ayBqLGVKCWzWZX9YsXCpv47FNLZbupE=\n"
- + "-----END CERTIFICATE-----\n";
-
- ByteArrayInputStream certArray;
-
- String certificate2 = "-----BEGIN CERTIFICATE-----\n"
- + "MIICZzCCAdCgAwIBAgIBGzANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJVUzEY\n"
- + "MBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsT\n"
- + "A1BLSTEcMBoGA1UEAxMTRG9EIFBLSSBNZWQgUm9vdCBDQTAeFw05ODA4MDMyMjAy\n"
- + "MjlaFw0wODA4MDQyMjAyMjlaMGExCzAJBgNVBAYTAlVTMRgwFgYDVQQKEw9VLlMu\n"
- + "IEdvdmVybm1lbnQxDDAKBgNVBAsTA0RvRDEMMAoGA1UECxMDUEtJMRwwGgYDVQQD\n"
- + "ExNEb0QgUEtJIE1lZCBSb290IENBMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n"
- + "gQDbrM/J9FrJSX+zxFUbsI9Vw5QbguVBIa95rwW/0M8+sM0r5gd+DY6iubm6wnXk\n"
- + "CSvbfQlFEDSKr4WYeeGp+d9WlDnQdtDFLdA45tCi5SHjnW+hGAmZnld0rz6wQekF\n"
- + "5xQaa5A6wjhMlLOjbh27zyscrorMJ1O5FBOWnEHcRv6xqQIDAQABoy8wLTAdBgNV\n"
- + "HQ4EFgQUVrmYR6m9701cHQ3r5kXyG7zsCN0wDAYDVR0TBAUwAwEB/zANBgkqhkiG\n"
- + "9w0BAQUFAAOBgQDVX1Y0YqC7vekeZjVxtyuC8Mnxbrz6D109AX07LEIRzNYzwZ0w\n"
- + "MTImSp9sEzWW+3FueBIU7AxGys2O7X0qmN3zgszPfSiocBuQuXIYQctJhKjF5KVc\n"
- + "VGQRYYlt+myhl2vy6yPzEVCjiKwMEb1Spu0irCf+lFW2hsdjvmSQMtZvOw==\n"
- + "-----END CERTIFICATE-----\n";
-
- ByteArrayInputStream certArray2;
-
- {
- try {
- certArray = new ByteArrayInputStream(certificate
- .getBytes("UTF-8"));
- certArray2 = new ByteArrayInputStream(certificate2
- .getBytes("UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e.getMessage());
- }
- }
-
- public static class IdentitySubclass extends Identity {
- public IdentitySubclass() {
- super();
- }
-
- public IdentitySubclass(String name) {
- super(name);
- }
-
- public IdentitySubclass(String name, IdentityScope scope)
- throws KeyManagementException {
- super(name, scope);
- }
- }
-
- /**
- * @tests java.security.Identity#Identity()
- */
- public void test_Constructor() {
- new IdentitySubclass();
- }
-
- /**
- * @tests java.security.Identity#Identity(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- new IdentitySubclass("test");
- }
-
- /**
- * @tests java.security.Identity#Identity(java.lang.String,
- *java.security.IdentityScope)
- */
- public void test_ConstructorLjava_lang_StringLjava_security_IdentityScope() throws Exception {
- new IdentitySubclass("test", new IdentityScopeSubclass());
- }
-
- /**
- * @tests java.security.Identity#getScope()
- */
- public void test_getScope() throws Exception {
- IdentityScope scope = new IdentityScopeSubclass();
- IdentitySubclass sub = new IdentitySubclass("test", scope);
- IdentityScope returnedScope = sub.getScope();
- assertEquals("Wrong Scope returned", scope, returnedScope);
- }
-
- /**
- * @tests java.security.Identity#getPublicKey()
- */
- public void test_getPublicKey() throws Exception {
- IdentitySubclass sub = new IdentitySubclass("test",
- new IdentityScopeSubclass());
- sub.setPublicKey(pubKey);
- PublicKey returnedPubKey = sub.getPublicKey();
- assertEquals("Wrong PublicKey returned", pubKey, returnedPubKey);
- }
-
- /**
- * @tests java.security.Identity#getName()
- */
- public void test_getName() throws Exception {
- String name = "test";
- IdentitySubclass sub = new IdentitySubclass(name,
- new IdentityScopeSubclass());
- assertEquals("Wrong Name returned", name, sub.getName());
- }
-
- /**
- * @tests java.security.Identity#getInfo()
- */
- public void test_getInfo() throws Exception {
- String info = "This is the general information.";
- IdentitySubclass sub = new IdentitySubclass("test",
- new IdentityScopeSubclass());
- sub.setInfo(info);
- assertEquals("Wrong Info returned", info, sub.getInfo());
- }
-
- /**
- * @tests java.security.Identity#certificates()
- */
- public void test_certificates() throws Exception {
- IdentitySubclass sub = new IdentitySubclass("test",
- new IdentityScopeSubclass());
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[1];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- sub.setPublicKey(cert[0].getPublicKey());
- CertificateImpl certImpl = new CertificateImpl(cert[0]);
- sub.addCertificate(certImpl);
- java.security.Certificate[] certs = sub.certificates();
- assertEquals("Certificate not contained in the identity",
- certs[0], certImpl);
- }
-
- /**
- * @tests java.security.Identity#addCertificate(java.security.Certificate)
- */
- public void test_addCertificateLjava_security_Certificate() throws Exception {
- IdentitySubclass sub = new IdentitySubclass("test",
- new IdentityScopeSubclass());
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[1];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- sub.setPublicKey(cert[0].getPublicKey());
- CertificateImpl certImpl = new CertificateImpl(cert[0]);
- sub.addCertificate(certImpl);
- }
-
- /**
- * @tests java.security.Identity#removeCertificate(java.security.Certificate)
- */
- public void test_removeCertificateLjava_security_Certificate() throws Exception {
- IdentitySubclass sub = new IdentitySubclass("test",
- new IdentityScopeSubclass());
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[1];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- sub.setPublicKey(cert[0].getPublicKey());
- CertificateImpl certImpl = new CertificateImpl(cert[0]);
- sub.addCertificate(certImpl);
- sub.removeCertificate(certImpl);
- java.security.Certificate[] certs = sub.certificates();
- assertEquals("Certificate not removed", 0, certs.length);
- }
-
- /**
- * @tests java.security.Identity#equals(java.lang.Object)
- */
- public void test_equalsLjava_lang_Object() throws Exception {
- IdentitySubclass sub = new IdentitySubclass("test",
- new IdentityScopeSubclass());
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[1];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- sub.setPublicKey(cert[0].getPublicKey());
- CertificateImpl certImpl = new CertificateImpl(cert[0]);
- sub.addCertificate(certImpl);
- IdentitySubclass sub2 = new IdentitySubclass("test",
- new IdentityScopeSubclass());
- assertEquals("the two Identity objects are not equal", sub2, sub);
- }
-
- /**
- * @tests java.security.Identity#identityEquals(java.security.Identity)
- */
- public void test_identityEqualsLjava_security_Identity() throws Exception {
- IdentitySubclass sub = new IdentitySubclass("test", null);
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[1];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- sub.setPublicKey(cert[0].getPublicKey());
- CertificateImpl certImpl = new CertificateImpl(cert[0]);
- sub.addCertificate(certImpl);
- IdentitySubclass sub2 = new IdentitySubclass("test", null);
- sub2.setPublicKey(cert[0].getPublicKey());
- assertEquals("the two Identity objects are not identity-equal",
- sub2, sub);
- }
-
- /**
- * @tests java.security.Identity#toString()
- */
- public void test_toString() throws Exception {
- IdentitySubclass sub = new IdentitySubclass("test", null);
- assertNotNull(sub.toString());
- assertTrue("The String returned is not valid", sub.toString()
- .length() > 0);
- // Regression for HARMONY-1566
- assertNotNull(new IdentitySubclass().toString());
- }
-
- /**
- * @tests java.security.Identity#toString(boolean)
- */
- public void test_toStringZ() throws Exception {
- IdentitySubclass sub = new IdentitySubclass("test", null);
- assertNotNull(sub.toString(true));
- assertTrue("The String returned is not valid", sub.toString(true)
- .length() > 0);
- }
-
- /**
- * @tests java.security.Identity#hashCode()
- */
- public void test_hashCode() throws Exception {
- IdentitySubclass sub = new IdentitySubclass("test", null);
- IdentitySubclass sub2 = new IdentitySubclass("test", null);
- assertEquals("The 2 hash codes are not equal", sub.hashCode(), sub2
- .hashCode());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScope2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScope2Test.java
deleted file mode 100644
index 5528399..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScope2Test.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.Identity;
-import java.security.IdentityScope;
-import java.security.KeyManagementException;
-import java.security.KeyPairGenerator;
-import java.security.PublicKey;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass;
-
-public class IdentityScope2Test extends junit.framework.TestCase {
-
- static PublicKey pubKey;
-
- static {
- try {
- pubKey = KeyPairGenerator.getInstance("DSA").genKeyPair().getPublic();
- } catch (Exception e) {
- fail(e.toString());
- }
- }
-
- public static class IdentityScopeSubclass extends IdentityScope {
- Hashtable identities;
-
- public IdentityScopeSubclass(String name, PublicKey pk) {
- super(name);
- try {
- setPublicKey(pk);
- } catch (KeyManagementException e) {
- }
- identities = new Hashtable();
- }
-
- public IdentityScopeSubclass() {
- super();
- identities = new Hashtable();
- }
-
- public IdentityScopeSubclass(String name) {
- super(name);
- identities = new Hashtable();
- }
-
- public IdentityScopeSubclass(String name, IdentityScope scope)
- throws KeyManagementException {
- super(name, scope);
- identities = new Hashtable();
- }
-
- public int size() {
- return identities.size();
- }
-
- public Identity getIdentity(String name) {
- Enumeration en = identities();
- while (en.hasMoreElements()) {
- Identity current = (Identity) en.nextElement();
- if (current.getName().equals(name))
- return current;
- }
- return null;
- }
-
- public Identity getIdentity(PublicKey pk) {
- Enumeration en = identities();
- while (en.hasMoreElements()) {
- Identity current = (Identity) en.nextElement();
- if (current.getPublicKey() == pk)
- return current;
- }
- return null;
- }
-
- public Enumeration identities() {
- return identities.elements();
- }
-
- public void addIdentity(Identity id) throws KeyManagementException {
- if (identities.containsKey(id))
- throw new KeyManagementException(
- "This Identity is already contained in the scope");
- if (getIdentity(id.getPublicKey()) != null)
- throw new KeyManagementException(
- "This Identity's public key already exists in the scope");
- identities.put(id, id);
- }
-
- public void removeIdentity(Identity id) throws KeyManagementException {
- if (!identities.containsKey(id))
- throw new KeyManagementException(
- "This Identity is not contained in the scope");
- identities.remove(id);
- }
- }
-
- /**
- * @tests java.security.IdentityScope#IdentityScope()
- */
- public void test_Constructor() {
- new IdentityScopeSubclass();
- }
-
- /**
- * @tests java.security.IdentityScope#IdentityScope(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- new IdentityScopeSubclass("test");
- }
-
- /**
- * @tests java.security.IdentityScope#IdentityScope(java.lang.String,
- *java.security.IdentityScope)
- */
- public void test_ConstructorLjava_lang_StringLjava_security_IdentityScope() throws Exception {
- new IdentityScopeSubclass("test", new IdentityScopeSubclass());
- }
-
- /**
- * @tests java.security.IdentityScope#addIdentity(java.security.Identity)
- */
- public void test_addIdentityLjava_security_Identity() throws Exception {
- IdentityScopeSubclass sub = new IdentityScopeSubclass("test",
- new IdentityScopeSubclass());
- Identity id = new IdentitySubclass("id1");
- id.setPublicKey(pubKey);
- sub.addIdentity(id);
- try {
- Identity id2 = new IdentitySubclass("id2");
- id2.setPublicKey(pubKey);
- sub.addIdentity(id2);
- fail("KeyManagementException should have been thrown");
- } catch (KeyManagementException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.security.IdentityScope#removeIdentity(java.security.Identity)
- */
- public void test_removeIdentityLjava_security_Identity() throws Exception {
- IdentityScopeSubclass sub = new IdentityScopeSubclass("test",
- new IdentityScopeSubclass());
- Identity id = new IdentitySubclass();
- id.setPublicKey(pubKey);
- sub.addIdentity(id);
- sub.removeIdentity(id);
- try {
- sub.removeIdentity(id);
- fail("KeyManagementException should have been thrown");
- } catch (KeyManagementException e) {
- // expected
- }
- }
-
- /**
- * @tests java.security.IdentityScope#identities()
- */
- public void test_identities() throws Exception {
- IdentityScopeSubclass sub = new IdentityScopeSubclass("test",
- new IdentityScopeSubclass());
- Identity id = new IdentitySubclass();
- id.setPublicKey(pubKey);
- sub.addIdentity(id);
- Enumeration en = sub.identities();
- assertTrue("Wrong object contained in identities", en.nextElement()
- .equals(id));
- assertTrue("Contains too many elements", !en.hasMoreElements());
- }
-
- /**
- * @tests java.security.IdentityScope#getIdentity(java.security.Principal)
- */
- public void test_getIdentityLjava_security_Principal() throws Exception {
- Identity id = new IdentitySubclass("principal name");
- id.setPublicKey(pubKey);
- IdentityScopeSubclass sub = new IdentityScopeSubclass("test",
- new IdentityScopeSubclass());
- sub.addIdentity(id);
- Identity returnedId = sub.getIdentity(id);
- assertEquals("Returned Identity not the same as the added one", id,
- returnedId);
- }
-
- /**
- * @tests java.security.IdentityScope#getIdentity(java.security.PublicKey)
- */
- public void test_getIdentityLjava_security_PublicKey() throws Exception {
- IdentityScopeSubclass sub = new IdentityScopeSubclass("test",
- new IdentityScopeSubclass());
- Identity id = new IdentitySubclass();
- id.setPublicKey(pubKey);
- sub.addIdentity(id);
- Identity returnedId = sub.getIdentity(pubKey);
- assertEquals("Returned Identity not the same as the added one", id,
- returnedId);
- }
-
- /**
- * @tests java.security.IdentityScope#getIdentity(java.lang.String)
- */
- public void test_getIdentityLjava_lang_String() throws Exception {
- IdentityScopeSubclass sub = new IdentityScopeSubclass("test",
- new IdentityScopeSubclass());
- Identity id = new IdentitySubclass("test");
- id.setPublicKey(pubKey);
- sub.addIdentity(id);
- Identity returnedId = sub.getIdentity("test");
- assertEquals("Returned Identity not the same as the added one", id,
- returnedId);
- }
-
- /**
- * @tests java.security.IdentityScope#size()
- */
- public void test_size() throws Exception {
- IdentityScopeSubclass sub = new IdentityScopeSubclass("test",
- new IdentityScopeSubclass());
- Identity id = new IdentitySubclass();
- id.setPublicKey(pubKey);
- sub.addIdentity(id);
- assertEquals("Wrong size", 1, sub.size());
- }
-
- /**
- * @tests java.security.IdentityScope#toString()
- */
- public void test_toString() throws Exception {
- IdentityScopeSubclass sub = new IdentityScopeSubclass("test",
- new IdentityScopeSubclass());
- Identity id = new IdentitySubclass();
- id.setPublicKey(pubKey);
- sub.addIdentity(id);
- assertNotNull("toString returned a null", sub.toString());
- assertTrue("Not a valid String ", sub.toString().length() > 0);
- }
-
- public void test_getIdentity() throws Exception {
- //Regression for HARMONY-1173
- IdentityScope scope = IdentityScope.getSystemScope();
- try {
- scope.getIdentity((String) null);
- fail("NPE expected");
- } catch (NullPointerException npe) {
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java
deleted file mode 100644
index 578944b..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Aleksei Y. Semenov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import org.apache.harmony.security.tests.support.IdentityScopeStub;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>IdentityScope</code>
- */
-
-public class IdentityScopeTest extends TestCase {
-
- IdentityScope is;
-
- /**
- * Constructor for IdentityScopeTest.
- *
- * @param arg0
- */
- public IdentityScopeTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Class under test for String toString()
- */
- public final void testToString() {
- assertNotNull(new IdentityScopeStub("Aleksei Semenov").toString());
- }
-
- /**
- * test default constructor void IdentityScope()
- */
- public final void testIdentityScope() {
- assertNotNull(new IdentityScopeStub());
- }
-
- /**
- * check that void IdentityScope(String) creates instance with given name
- */
- public final void testIdentityScopeString() {
- is = new IdentityScopeStub("Aleksei Semenov");
- assertNotNull(is);
- assertEquals("Aleksei Semenov", is.getName());
- }
-
- /**
- * check that void IdentityScope(String, IdentityScope) creates instance with given name and within given scope
- */
- public final void testIdentityScopeStringIdentityScope() throws Exception {
- IdentityScope scope = new IdentityScopeStub("my scope");
- is = new IdentityScopeStub("Aleksei Semenov", scope);
- assertNotNull(is);
- assertEquals("Aleksei Semenov", is.getName());
- assertEquals(scope.getName(), is.getScope().getName());
- }
-
- /**
- * just call IdentityScope.getSystemScope()
- */
- public final void testGetSystemScope() {
- String name = Security.getProperty("system.scope");
- assertNotNull(name);
- IdentityScope scope = IdentityScope.getSystemScope();
- assertNotNull(scope);
- assertEquals(name, scope.getClass().getName());
- }
-
- /**
- * Class under test for Identity getIdentity(Principal)
- */
- public final void testGetIdentityPrincipal() {
- is = new IdentityScopeStub("Aleksei Semenov");
- IdentityScope sc2 = new IdentityScopeStub("aaa");
- assertSame(is, is.getIdentity(sc2));
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidAlgorithmParameterExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidAlgorithmParameterExceptionTest.java
deleted file mode 100644
index 4794599..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidAlgorithmParameterExceptionTest.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.InvalidAlgorithmParameterException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>InvalidAlgorithmParameterException</code> class
- * constructors and methods.
- */
-public class InvalidAlgorithmParameterExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for InvalidAlgorithmParameterExceptionTests.
- *
- * @param arg0
- */
- public InvalidAlgorithmParameterExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>InvalidAlgorithmParameterException()</code> constructor
- * Assertion: constructs InvalidAlgorithmParameterException with no detail
- * message
- */
- public void testInvalidAlgorithmParameterException01() {
- InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidAlgorithmParameterException(String)</code>
- * constructor Assertion: constructs InvalidAlgorithmParameterException with
- * detail message msg. Parameter <code>msg</code> is not null.
- */
- public void testInvalidAlgorithmParameterException02() {
- InvalidAlgorithmParameterException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new InvalidAlgorithmParameterException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>InvalidAlgorithmParameterException(String)</code>
- * constructor Assertion: constructs InvalidAlgorithmParameterException when
- * <code>msg</code> is null
- */
- public void testInvalidAlgorithmParameterException03() {
- String msg = null;
- InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException(
- msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidAlgorithmParameterException(Throwable)</code>
- * constructor Assertion: constructs InvalidAlgorithmParameterException when
- * <code>cause</code> is null
- */
- public void testInvalidAlgorithmParameterException04() {
- Throwable cause = null;
- InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException(
- cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidAlgorithmParameterException(Throwable)</code>
- * constructor Assertion: constructs InvalidAlgorithmParameterException when
- * <code>cause</code> is not null
- */
- public void testInvalidAlgorithmParameterException05() {
- InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException(
- tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for
- * <code>InvalidAlgorithmParameterException(String, Throwable)</code>
- * constructor Assertion: constructs InvalidAlgorithmParameterException when
- * <code>cause</code> is null <code>msg</code> is null
- */
- public void testInvalidAlgorithmParameterException06() {
- InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException(
- null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for
- * <code>InvalidAlgorithmParameterException(String, Throwable)</code>
- * constructor Assertion: constructs InvalidAlgorithmParameterException when
- * <code>cause</code> is null <code>msg</code> is not null
- */
- public void testInvalidAlgorithmParameterException07() {
- InvalidAlgorithmParameterException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new InvalidAlgorithmParameterException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for
- * <code>InvalidAlgorithmParameterException(String, Throwable)</code>
- * constructor Assertion: constructs InvalidAlgorithmParameterException when
- * <code>cause</code> is not null <code>msg</code> is null
- */
- public void testInvalidAlgorithmParameterException08() {
- InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException(
- null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for
- * <code>InvalidAlgorithmParameterException(String, Throwable)</code>
- * constructor Assertion: constructs InvalidAlgorithmParameterException when
- * <code>cause</code> is not null <code>msg</code> is not null
- */
- public void testInvalidAlgorithmParameterException09() {
- InvalidAlgorithmParameterException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new InvalidAlgorithmParameterException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidKeyExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidKeyExceptionTest.java
deleted file mode 100644
index 5ccc3fc..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidKeyExceptionTest.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.InvalidKeyException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>InvalidKeyException</code> class constructors and methods.
- */
-public class InvalidKeyExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for InvalidKeyExceptionTests.
- *
- * @param arg0
- */
- public InvalidKeyExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>InvalidKeyException()</code> constructor Assertion:
- * constructs InvalidKeyException with no detail message
- */
- public void testInvalidKeyException01() {
- InvalidKeyException tE = new InvalidKeyException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidKeyException(String)</code> constructor
- * Assertion: constructs InvalidKeyException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testInvalidKeyException02() {
- InvalidKeyException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new InvalidKeyException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>InvalidKeyException(String)</code> constructor
- * Assertion: constructs InvalidKeyException when <code>msg</code> is null
- */
- public void testInvalidKeyException03() {
- String msg = null;
- InvalidKeyException tE = new InvalidKeyException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidKeyException(Throwable)</code> constructor
- * Assertion: constructs InvalidKeyException when <code>cause</code> is
- * null
- */
- public void testInvalidKeyException04() {
- Throwable cause = null;
- InvalidKeyException tE = new InvalidKeyException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidKeyException(Throwable)</code> constructor
- * Assertion: constructs InvalidKeyException when <code>cause</code> is
- * not null
- */
- public void testInvalidKeyException05() {
- InvalidKeyException tE = new InvalidKeyException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>InvalidKeyException(String, Throwable)</code>
- * constructor Assertion: constructs InvalidKeyException when
- * <code>cause</code> is null <code>msg</code> is null
- */
- public void testInvalidKeyException06() {
- InvalidKeyException tE = new InvalidKeyException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidKeyException(String, Throwable)</code>
- * constructor Assertion: constructs InvalidKeyException when
- * <code>cause</code> is null <code>msg</code> is not null
- */
- public void testInvalidKeyException07() {
- InvalidKeyException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new InvalidKeyException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>InvalidKeyException(String, Throwable)</code>
- * constructor Assertion: constructs InvalidKeyException when
- * <code>cause</code> is not null <code>msg</code> is null
- */
- public void testInvalidKeyException08() {
- InvalidKeyException tE = new InvalidKeyException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>InvalidKeyException(String, Throwable)</code>
- * constructor Assertion: constructs InvalidKeyException when
- * <code>cause</code> is not null <code>msg</code> is not null
- */
- public void testInvalidKeyException09() {
- InvalidKeyException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new InvalidKeyException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidParameterExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidParameterExceptionTest.java
deleted file mode 100644
index 018fbf9..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidParameterExceptionTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.InvalidParameterException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>InvalidParameterException</code> class constructors and
- * methods.
- */
-public class InvalidParameterExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for InvalidParameterExceptionTests.
- *
- * @param arg0
- */
- public InvalidParameterExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>InvalidParameterException()</code> constructor
- * Assertion: constructs InvalidParameterException with no detail message
- */
- public void testInvalidParameterException01() {
- InvalidParameterException tE = new InvalidParameterException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidParameterException(String)</code> constructor
- * Assertion: constructs InvalidParameterException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testInvalidParameterException02() {
- InvalidParameterException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new InvalidParameterException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>InvalidParameterException(String)</code> constructor
- * Assertion: constructs InvalidParameterException when <code>msg</code>
- * is null
- */
- public void testInvalidParameterException03() {
- String msg = null;
- InvalidParameterException tE = new InvalidParameterException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSCallbackHandlerProtectionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSCallbackHandlerProtectionTest.java
deleted file mode 100644
index cf2cabe..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSCallbackHandlerProtectionTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.KeyStore;
-
-import javax.security.auth.callback.CallbackHandler;
-
-import org.apache.harmony.security.tests.support.tmpCallbackHandler;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyStore.CallbackHandlerProtection> class constructor and methods
- */
-
-public class KSCallbackHandlerProtectionTest extends TestCase {
-
- /**
- * Constructor for KSCallbackHandlerProtectionTest.
- *
- * @param arg0
- */
- public KSCallbackHandlerProtectionTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>KeyStore.CallbackHandlerProtection(CallbackHandler handler)</code>
- * constructor
- * Assertion: throws NullPointerException when handler is null
- */
- public void testCallbackHandlerProtection() {
- try {
- new KeyStore.CallbackHandlerProtection(null);
- fail("NullPointerException must be thrown when handler is null");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test for <code>getCallbackHandler()</code> method
- * Assertion: returns CallbackHandler
- */
- public void testGetCallBackHandler() {
- CallbackHandler cbh = new tmpCallbackHandler();
- KeyStore.CallbackHandlerProtection ksCBH = new KeyStore.CallbackHandlerProtection(cbh);
- assertEquals("Incorrect CallbackHandler", cbh,
- ksCBH.getCallbackHandler());
- }
-}
-
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSPasswordProtectionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSPasswordProtectionTest.java
deleted file mode 100644
index b13afd5..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSPasswordProtectionTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import javax.security.auth.DestroyFailedException;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyStore.PasswordProtection</code> class constructor and methods
- */
-
-public class KSPasswordProtectionTest extends TestCase {
-
- /**
- * Constructor for KSPasswordProtectionTest.
- *
- * @param arg0
- */
- public KSPasswordProtectionTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>KeyStore.PasswordProtection(char[] password)</code> constructor
- * and the following methods
- * <code>getPassword()<code>
- * <code>destroy()<code>
- * <code>isDestroyed()<code>
- * Assertions: constructor created new PasswordProtection object
- * getPassword() returns password or throws IllegalArgumentException
- * if PasswordProtection is destroyed
- */
- public void testGetPassword() throws DestroyFailedException {
- char[] pass = { 'a', 'b', 'c' };
- KeyStore.PasswordProtection ksPWP = new KeyStore.PasswordProtection(pass);
- char[] rPass = ksPWP.getPassword();
- assertFalse("PasswordProtection Should not be destroyed", ksPWP.isDestroyed());
- assertEquals("Incorrect password length", pass.length, rPass.length);
- for (int i = 0; i < pass.length; i++) {
- assertEquals("Incorrect password (item: ".concat(Integer.toString(i))
- .concat(")"), pass[i], rPass[i]);
- }
- ksPWP.destroy();
- assertTrue("PasswordProtection must be destroyed", ksPWP.isDestroyed());
- try {
- ksPWP.getPassword();
- fail("IllegalStateException must be thrown because PasswordProtection is destroyed");
- } catch (IllegalStateException e) {
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSPrivateKeyEntryTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSPrivateKeyEntryTest.java
deleted file mode 100644
index e594c3d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSPrivateKeyEntryTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import java.security.cert.Certificate;
-
-import org.apache.harmony.security.tests.support.cert.MyCertificate;
-
-import junit.framework.TestCase;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Tests for <code>KeyStore.PrivateKeyEntry</code> class constructor and methods
- */
-
-public class KSPrivateKeyEntryTest extends TestCase {
-
- /**
- * Constructor for KSPrivateKeyEntryTest.
- *
- * @param arg0
- */
- public KSPrivateKeyEntryTest(String arg0) {
- super(arg0);
- }
-
- private PrivateKey testPrivateKey;
- private Certificate[] testChain;
-
- private void createParams(boolean diffCerts, boolean diffKeys) {
- byte[] encoded = { (byte) 0, (byte) 1, (byte) 2, (byte) 3 };
- testChain = new Certificate[5];
- for (int i = 0; i < testChain.length; i++) {
- String s = (diffCerts ? Integer.toString(i) : "NEW");
- testChain[i] = new MyCertificate("MY_TEST_CERTIFICATE_"
- .concat(s), encoded);
- }
- testPrivateKey = (diffKeys ? (PrivateKey) new tmpPrivateKey() :
- (PrivateKey) new tmpPrivateKey(testChain[0].getPublicKey().getAlgorithm()));
- }
-
- /**
- * Test for <code>PrivateKeyEntry(PrivateKey privateKey, Certificate[] chain)</code>
- * constructor
- * Assertion: throws NullPointerException when privateKey is null
- */
- public void testPrivateKeyEntry01() {
- Certificate[] certs = new MyCertificate[1];//new Certificate[1];
- PrivateKey pk = null;
- try {
- new KeyStore.PrivateKeyEntry(pk, certs);
- fail("NullPointerException must be thrown when privateKey is null");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test for <code>PrivateKeyEntry(PrivateKey privateKey, Certificate[] chain)</code>
- * constructor
- * Assertion: throws NullPointerException when chain is null
- * and throws IllegalArgumentException when chain length is 0
- */
- public void testPrivateKeyEntry02() {
- Certificate[] chain = null;
- PrivateKey pk = new tmpPrivateKey();
- try {
- new KeyStore.PrivateKeyEntry(pk, chain);
- fail("NullPointerException must be thrown when chain is null");
- } catch (NullPointerException e) {
- }
- try {
- chain = new Certificate[0];
- new KeyStore.PrivateKeyEntry(pk, chain);
- fail("IllegalArgumentException must be thrown when chain length is 0");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Test for <code>PrivateKeyEntry(PrivateKey privateKey, Certificate[] chain)</code>
- * constructor
- * Assertion: throws IllegalArgumentException when chain contains certificates
- * of different types
- */
- public void testPrivateKeyEntry03() {
- createParams(true, false);
- try {
- new KeyStore.PrivateKeyEntry(testPrivateKey, testChain);
- fail("IllegalArgumentException must be thrown when chain contains certificates of different types");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Test for <code>PrivateKeyEntry(PrivateKey privateKey, Certificate[] chain)</code>
- * constructor
- * Assertion: throws IllegalArgumentException when algorithm of privateKey
- * does not match the algorithm of PublicKey in the end certificate (with 0 index)
- */
- public void testPrivateKeyEntry04() {
- createParams(false, true);
- try {
- new KeyStore.PrivateKeyEntry(testPrivateKey, testChain);
- fail("IllegalArgumentException must be thrown when key algorithms do not match");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Test for <code>getPrivateKey()</code> method
- * Assertion: returns PrivateKey object
- */
- public void testGetPrivateKey() {
- createParams(false, false);
- KeyStore.PrivateKeyEntry ksPKE = new KeyStore.PrivateKeyEntry(
- testPrivateKey, testChain);
- assertEquals("Incorrect PrivateKey", testPrivateKey, ksPKE
- .getPrivateKey());
- }
-
- /**
- * Test for <code>getCertificateChain()</code> method Assertion: returns
- * array of the Certificates corresponding to chain
- */
- public void testGetCertificateChain() {
- createParams(false, false);
- KeyStore.PrivateKeyEntry ksPKE = new KeyStore.PrivateKeyEntry(
- testPrivateKey, testChain);
- Certificate[] res = ksPKE.getCertificateChain();
- assertEquals("Incorrect chain length", testChain.length, res.length);
- for (int i = 0; i < res.length; i++) {
- assertEquals("Incorrect chain element: "
- .concat(Integer.toString(i)), testChain[i], res[i]);
- }
- }
-
- /**
- * Test for <code>getCertificate()</code> method
- * Assertion: returns end Certificate (with 0 index in chain)
- */
- public void testGetCertificate() {
- createParams(false, false);
- KeyStore.PrivateKeyEntry ksPKE = new KeyStore.PrivateKeyEntry(
- testPrivateKey, testChain);
- Certificate res = ksPKE.getCertificate();
- assertEquals("Incorrect end certificate (number 0)", testChain[0], res);
- }
-
- /**
- * Test for <code>toString()</code> method
- * Assertion: returns non null String
- */
- public void testToString() {
- createParams(false, false);
- KeyStore.PrivateKeyEntry ksPKE = new KeyStore.PrivateKeyEntry(
- testPrivateKey, testChain);
- String res = ksPKE.toString();
- assertNotNull("toString() returns null", res);
- }
-
- public static Test suite() {
- return new TestSuite(KSPrivateKeyEntryTest.class);
- }
-
- private static class tmpPrivateKey implements PrivateKey {
- private String alg = "My algorithm";
-
- public String getAlgorithm() {
- return alg;
- }
-
- public String getFormat() {
- return "My Format";
- }
-
- public byte[] getEncoded() {
- return new byte[1];
- }
-
- public tmpPrivateKey() {
- }
-
- public tmpPrivateKey(String algorithm) {
- super();
- alg = algorithm;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSSecretKeyEntryTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSSecretKeyEntryTest.java
deleted file mode 100644
index 91b3ae6..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSSecretKeyEntryTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import javax.crypto.SecretKey;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyStore.SecretKeyEntry</code> class constructor and methods
- */
-
-public class KSSecretKeyEntryTest extends TestCase {
-
- /**
- * Constructor for KSSecretKeyTest.
- *
- * @param arg0
- */
- public KSSecretKeyEntryTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>SecretKeyEntry(SecretKey secretKey)</code> constructor
- * Assertion: throws NullPointerException when secretKey is null
- */
- public void testSecretKeyEntry() {
- SecretKey sk = null;
- try {
- new KeyStore.SecretKeyEntry(sk);
- fail("NullPointerException must be thrown when secretKey is null");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test for <code>getSecretKey()</code> method
- * Assertion: returns SecretKey from the given entry
- */
- public void testGetSecretKey() {
- SecretKey sk = new tmpSecretKey();
- KeyStore.SecretKeyEntry ske = new KeyStore.SecretKeyEntry(sk);
- assertEquals("Incorrect SecretKey", sk, ske.getSecretKey());
- }
-
- /**
- * Test for <code>toString()</code> method
- * Assertion: returns non null string
- */
- public void testToString() {
- SecretKey sk = new tmpSecretKey();
- KeyStore.SecretKeyEntry ske = new KeyStore.SecretKeyEntry(sk);
- assertNotNull("toString() returns null string", ske.toString());
- }
-}
-
-class tmpSecretKey implements SecretKey {
- public String getAlgorithm() {
- return "My algorithm";
- }
-
- public String getFormat() {
- return "My Format";
- }
-
- public byte[] getEncoded() {
- return new byte[1];
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSTrustedCertificateEntryTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSTrustedCertificateEntryTest.java
deleted file mode 100644
index ba9ab3a..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSTrustedCertificateEntryTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import java.security.cert.Certificate;
-
-import org.apache.harmony.security.tests.support.cert.MyCertificate;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyStore.TrustedCertificateEntry</code> class constructor and methods
- */
-
-public class KSTrustedCertificateEntryTest extends TestCase {
-
- /**
- * Test for <codfe>KeyStore.TrustedCertificateEntry(Certificate trustCert)</code>
- * constructor
- * Assertion: throws NullPointerException when trustCert is null
- */
- public void testTrustedCertificateEntry() {
- Certificate cert = null;
- try {
- new KeyStore.TrustedCertificateEntry(cert);
- fail("NullPointerException must be thrown when trustCert is null");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test for <codfe>getTrustedCertificate()</code> method
- * Assertion: returns trusted Certificate from goven entry
- */
- public void testGetTrustedCertificate() {
- Certificate cert = new MyCertificate("TEST", new byte[10]);
- KeyStore.TrustedCertificateEntry ksTCE =
- new KeyStore.TrustedCertificateEntry(cert);
- assertEquals("Incorrect certificate", cert, ksTCE.getTrustedCertificate());
- }
-
- /**
- * Test for <codfe>toString()</code> method
- * Assertion: returns non null string
- */
- public void testToString() {
- Certificate cert = new MyCertificate("TEST", new byte[10]);
- KeyStore.TrustedCertificateEntry ksTCE =
- new KeyStore.TrustedCertificateEntry(cert);
- assertNotNull("toString() returns null string", ksTCE.toString());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyExceptionTest.java
deleted file mode 100644
index 843809d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyExceptionTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.KeyException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>KeyException</code> class constructors and methods.
- */
-public class KeyExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for KeyExceptionTests.
- *
- * @param arg0
- */
- public KeyExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>KeyException()</code> constructor Assertion: constructs
- * KeyException with no detail message
- */
- public void testKeyException01() {
- KeyException tE = new KeyException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>KeyException(String)</code> constructor Assertion:
- * constructs KeyException with detail message msg. Parameter
- * <code>msg</code> is not null.
- */
- public void testKeyException02() {
- KeyException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new KeyException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>KeyException(String)</code> constructor Assertion:
- * constructs KeyException when <code>msg</code> is null
- */
- public void testKeyException03() {
- String msg = null;
- KeyException tE = new KeyException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>KeyException(Throwable)</code> constructor Assertion:
- * constructs KeyException when <code>cause</code> is null
- */
- public void testKeyException04() {
- Throwable cause = null;
- KeyException tE = new KeyException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>KeyException(Throwable)</code> constructor Assertion:
- * constructs KeyException when <code>cause</code> is not null
- */
- public void testKeyException05() {
- KeyException tE = new KeyException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>KeyException(String, Throwable)</code> constructor
- * Assertion: constructs KeyException when <code>cause</code> is null
- * <code>msg</code> is null
- */
- public void testKeyException06() {
- KeyException tE = new KeyException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>KeyException(String, Throwable)</code> constructor
- * Assertion: constructs KeyException when <code>cause</code> is null
- * <code>msg</code> is not null
- */
- public void testKeyException07() {
- KeyException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new KeyException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>KeyException(String, Throwable)</code> constructor
- * Assertion: constructs KeyException when <code>cause</code> is not null
- * <code>msg</code> is null
- */
- public void testKeyException08() {
- KeyException tE = new KeyException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>KeyException(String, Throwable)</code> constructor
- * Assertion: constructs KeyException when <code>cause</code> is not null
- * <code>msg</code> is not null
- */
- public void testKeyException09() {
- KeyException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new KeyException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java
deleted file mode 100644
index 63dd0d8..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.InvalidKeyException;
-import java.security.KeyFactory;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.PublicKey;
-import java.security.SecureRandom;
-import java.security.Security;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.KeySpec;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.Vector;
-
-public class KeyFactory2Test extends junit.framework.TestCase {
-
- private static final String KEYFACTORY_ID = "KeyFactory.";
-
- private String[] keyfactAlgs = null;
-
- private String providerName = null;
-
- static class KeepAlive extends Thread {
- int sleepTime, iterations;
-
- public KeepAlive(int sleepTime, int iterations) {
- this.sleepTime = sleepTime;
- this.iterations = iterations;
- }
-
- public void run() {
- synchronized (this) {
- this.notify();
- }
- for (int i = 0; i < iterations; i++) {
- try {
- Thread.sleep(sleepTime);
- System.out.print("[KA]");
- } catch (InterruptedException e) {
- System.out.print("[I]");
- break;
- }
- }
- }
- }
-
- private KeepAlive createKeepAlive(String alg) {
- if (alg.equals("RSA")) {
- // 32 minutes
- KeepAlive keepalive = new KeepAlive(240000, 8);
- synchronized (keepalive) {
- keepalive.start();
- try {
- keepalive.wait();
- } catch (InterruptedException e) {
- // ignore
- }
- }
- return keepalive;
- }
- return null;
- }
-
- /**
- * @tests java.security.KeyFactory#generatePrivate(java.security.spec.KeySpec)
- */
- public void test_generatePrivateLjava_security_spec_KeySpec() {
- // Test for method java.security.PrivateKey
- // java.security.KeyFactory.generatePrivate(java.security.spec.KeySpec)
- for (int i = 0; i < keyfactAlgs.length; i++) {
- try {
- KeyFactory fact = KeyFactory.getInstance(keyfactAlgs[i],
- providerName);
- KeyPairGenerator keyGen = KeyPairGenerator
- .getInstance(keyfactAlgs[i]);
- SecureRandom random = new SecureRandom(); // We don't use
- // getInstance
- keyGen.initialize(1024, random);
- KeepAlive keepalive = createKeepAlive(keyfactAlgs[i]);
- KeyPair keys = keyGen.generateKeyPair();
- if (keepalive != null) {
- keepalive.interrupt();
- }
-
- KeySpec privateKeySpec = fact.getKeySpec(keys.getPrivate(),
- getPrivateKeySpecClass(keyfactAlgs[i]));
- PrivateKey privateKey = fact.generatePrivate(privateKeySpec);
- boolean samePrivate = Arrays.equals(keys.getPrivate()
- .getEncoded(), privateKey.getEncoded());
- assertTrue(
- "generatePrivate generated different key for algorithm "
- + keyfactAlgs[i], samePrivate);
- fact.generatePrivate(new PKCS8EncodedKeySpec(keys.getPrivate()
- .getEncoded()));
- } catch (InvalidKeySpecException e) {
- fail("invalid key spec for algorithm " + keyfactAlgs[i]);
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + keyfactAlgs[i]);
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find provider " + providerName);
- }
- }
- }
-
- /**
- * @tests java.security.KeyFactory#generatePublic(java.security.spec.KeySpec)
- */
- public void test_generatePublicLjava_security_spec_KeySpec() {
- // Test for method java.security.PublicKey
- // java.security.KeyFactory.generatePublic(java.security.spec.KeySpec)
- for (int i = 0; i < keyfactAlgs.length; i++) {
- try {
- KeyFactory fact = KeyFactory.getInstance(keyfactAlgs[i],
- providerName);
- KeyPairGenerator keyGen = KeyPairGenerator
- .getInstance(keyfactAlgs[i]);
- // We don't use getInstance
- SecureRandom random = new SecureRandom();
- keyGen.initialize(1024, random);
- KeepAlive keepalive = createKeepAlive(keyfactAlgs[i]);
- KeyPair keys = keyGen.generateKeyPair();
- if (keepalive != null) {
- keepalive.interrupt();
- }
- KeySpec publicKeySpec = fact.getKeySpec(keys.getPublic(),
- getPublicKeySpecClass(keyfactAlgs[i]));
- PublicKey publicKey = fact.generatePublic(publicKeySpec);
- boolean samePublic = Arrays.equals(keys.getPublic()
- .getEncoded(), publicKey.getEncoded());
- assertTrue(
- "generatePublic generated different key for algorithm "
- + keyfactAlgs[i], samePublic);
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + keyfactAlgs[i]);
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find provider " + providerName);
- } catch (InvalidKeySpecException e) {
- fail("invalid key spec for algorithm " + keyfactAlgs[i]);
- }
- }
- }
-
- /**
- * @tests java.security.KeyFactory#getAlgorithm()
- */
- public void test_getAlgorithm() {
- // Test for method java.lang.String
- // java.security.KeyFactory.getAlgorithm()
- for (int i = 0; i < keyfactAlgs.length; i++) {
- try {
- KeyFactory fact = KeyFactory.getInstance(keyfactAlgs[i],
- providerName);
- assertTrue("getAlgorithm ok for algorithm " + keyfactAlgs[i],
- fact.getAlgorithm().equals(keyfactAlgs[i]));
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + keyfactAlgs[i]);
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find provider " + providerName);
- }
- }// end for
- }
-
- /**
- * @tests java.security.KeyFactory#getInstance(java.lang.String)
- */
- public void test_getInstanceLjava_lang_String() {
- // Test for method java.security.KeyFactory
- // java.security.KeyFactory.getInstance(java.lang.String)
- for (int i = 0; i < keyfactAlgs.length; i++) {
- try {
- assertNotNull(KeyFactory.getInstance(keyfactAlgs[i]));
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + keyfactAlgs[i]);
- }
- }// end for
- }
-
- /**
- * @tests java.security.KeyFactory#getInstance(java.lang.String,
- *java.lang.String)
- */
- public void test_getInstanceLjava_lang_StringLjava_lang_String() throws Exception {
-
- // Test1: Test for method java.security.KeyFactory
- // java.security.KeyFactory.getInstance(java.lang.String,
- // java.lang.String)
- try {
- Provider[] providers = Security.getProviders("KeyFactory.DSA");
- if (providers != null) {
- for (int i = 0; i < providers.length; i++) {
- KeyFactory.getInstance("DSA", providers[i].getName());
- }// end for
- } else {
- fail("No providers support KeyFactory.DSA");
- }
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm");
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find the provider");
- }
-
- // Test2: Test with null provider name
- try {
- KeyFactory.getInstance("DSA", (String) null);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.security.KeyFactory#getKeySpec(java.security.Key,
- *java.lang.Class)
- */
- public void test_getKeySpecLjava_security_KeyLjava_lang_Class() {
- // Test for method java.security.spec.KeySpec
- // java.security.KeyFactory.getKeySpec(java.security.Key,
- // java.lang.Class)
- for (int i = 0; i < keyfactAlgs.length; i++) {
- try {
- KeyFactory fact = KeyFactory.getInstance(keyfactAlgs[i],
- providerName);
- KeyPairGenerator keyGen = KeyPairGenerator
- .getInstance(keyfactAlgs[i]);
-
- // We don't use getInstance
- SecureRandom random = new SecureRandom();
- keyGen.initialize(1024, random);
- KeepAlive keepalive = createKeepAlive(keyfactAlgs[i]);
- KeyPair keys = keyGen.generateKeyPair();
- if (keepalive != null) {
- keepalive.interrupt();
- }
- KeySpec privateKeySpec = fact.getKeySpec(keys.getPrivate(),
- getPrivateKeySpecClass(keyfactAlgs[i]));
- KeySpec publicKeySpec = fact.getKeySpec(keys.getPublic(),
- getPublicKeySpecClass(keyfactAlgs[i]));
- PrivateKey privateKey = fact.generatePrivate(privateKeySpec);
- PublicKey publicKey = fact.generatePublic(publicKeySpec);
- boolean samePublic = Arrays.equals(keys.getPublic()
- .getEncoded(), publicKey.getEncoded());
- boolean samePrivate = Arrays.equals(keys.getPrivate()
- .getEncoded(), privateKey.getEncoded());
- assertTrue(
- "generatePrivate generated different key for algorithm "
- + keyfactAlgs[i], samePrivate);
- assertTrue(
- "generatePublic generated different key for algorithm "
- + keyfactAlgs[i], samePublic);
- KeySpec encodedSpec = fact.getKeySpec(keys.getPublic(),
- X509EncodedKeySpec.class);
- assertTrue("improper key spec for encoded public key",
- encodedSpec.getClass().equals(X509EncodedKeySpec.class));
- encodedSpec = fact.getKeySpec(keys.getPrivate(),
- PKCS8EncodedKeySpec.class);
- assertTrue("improper key spec for encoded private key",
- encodedSpec.getClass()
- .equals(PKCS8EncodedKeySpec.class));
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + keyfactAlgs[i]);
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find provider " + providerName);
- } catch (InvalidKeySpecException e) {
- fail("invalid key spec for algorithm " + keyfactAlgs[i]);
- }
- }
- }
-
- /**
- * @tests java.security.KeyFactory#getProvider()
- */
- public void test_getProvider() {
- // Test for method java.security.Provider
- // java.security.KeyFactory.getProvider()
- for (int i = 0; i < keyfactAlgs.length; i++) {
- try {
- KeyFactory fact = KeyFactory.getInstance(keyfactAlgs[i]);
- Provider p = fact.getProvider();
- assertNotNull("provider is null for algorithm "
- + keyfactAlgs[i], p);
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + keyfactAlgs[i]);
- }
- }// end for
- }
-
- /**
- * @tests java.security.KeyFactory#translateKey(java.security.Key)
- */
- public void test_translateKeyLjava_security_Key() {
- // Test for method java.security.Key
- // java.security.KeyFactory.translateKey(java.security.Key)
- for (int i = 0; i < keyfactAlgs.length; i++) {
- try {
- KeyFactory fact = KeyFactory.getInstance(keyfactAlgs[i],
- providerName);
- KeyPairGenerator keyGen = KeyPairGenerator
- .getInstance(keyfactAlgs[i]);
-
- // We don't use getInstance
- SecureRandom random = new SecureRandom();
- keyGen.initialize(1024, random);
- KeepAlive keepalive = createKeepAlive(keyfactAlgs[i]);
- KeyPair keys = keyGen.generateKeyPair();
- if (keepalive != null) {
- keepalive.interrupt();
- }
- fact.translateKey(keys.getPrivate());
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + keyfactAlgs[i]);
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find provider " + providerName);
- } catch (InvalidKeyException e) {
- fail("generatePublic did not generate right spec for algorithm "
- + keyfactAlgs[i]);
- }
- }
- }
-
- protected void setUp() {
- if (keyfactAlgs == null) {
- Provider[] providers = Security.getProviders();
- // Arbitrarily use the first provider that supports
- // KeyFactory algorithms
- for (Provider provider : providers) {
- providerName = provider.getName();
- keyfactAlgs = getKeyFactoryAlgorithms(providerName);
- if (keyfactAlgs.length != 0) {
- break;
- }
- }
- }
- }
-
- /*
- * Returns the key algorithms that the given provider supports.
- */
- private String[] getKeyFactoryAlgorithms(String providerName) {
- Vector algs = new Vector();
-
- Provider provider = Security.getProvider(providerName);
- if (provider == null)
- return new String[0];
- Enumeration e = provider.keys();
- while (e.hasMoreElements()) {
- String algorithm = (String) e.nextElement();
- if (algorithm.startsWith(KEYFACTORY_ID) && !algorithm.contains(" ")) {
- algs.addElement(algorithm.substring(KEYFACTORY_ID.length()));
- }
- }
-
- return (String[]) algs.toArray(new String[algs.size()]);
- }
-
- /**
- * Returns the public key spec class for a given algorithm, or null if it is
- * not known.
- */
- private Class getPrivateKeySpecClass(String algName) {
- if (algName.equals("RSA")) {
- return java.security.spec.RSAPrivateCrtKeySpec.class;
- }
- if (algName.equals("DSA")) {
- return java.security.spec.DSAPrivateKeySpec.class;
- }
- return null;
- }
-
- /**
- * Returns the private key spec class for a given algorithm, or null if it
- * is not known.
- */
- private Class getPublicKeySpecClass(String algName) {
- if (algName.equals("RSA")) {
- return java.security.spec.RSAPublicKeySpec.class;
- }
- if (algName.equals("DSA")) {
- return java.security.spec.DSAPublicKeySpec.class;
- }
- return null;
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyManagementExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyManagementExceptionTest.java
deleted file mode 100644
index 9090144..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyManagementExceptionTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.KeyManagementException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>KeyManagementException</code> class constructors and
- * methods.
- */
-public class KeyManagementExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for KeyManagementExceptionTests.
- *
- * @param arg0
- */
- public KeyManagementExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>KeyManagementException()</code> constructor Assertion:
- * constructs KeyManagementException with no detail message
- */
- public void testKeyManagementException01() {
- KeyManagementException tE = new KeyManagementException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>KeyManagementException(String)</code> constructor
- * Assertion: constructs KeyManagementException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testKeyManagementException02() {
- KeyManagementException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new KeyManagementException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>KeyManagementException(String)</code> constructor
- * Assertion: constructs KeyManagementException when <code>msg</code> is
- * null
- */
- public void testKeyManagementException03() {
- String msg = null;
- KeyManagementException tE = new KeyManagementException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>KeyManagementException(Throwable)</code> constructor
- * Assertion: constructs KeyManagementException when <code>cause</code> is
- * null
- */
- public void testKeyManagementException04() {
- Throwable cause = null;
- KeyManagementException tE = new KeyManagementException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>KeyManagementException(Throwable)</code> constructor
- * Assertion: constructs KeyManagementException when <code>cause</code> is
- * not null
- */
- public void testKeyManagementException05() {
- KeyManagementException tE = new KeyManagementException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>KeyManagementException(String, Throwable)</code>
- * constructor Assertion: constructs KeyManagementException when
- * <code>cause</code> is null <code>msg</code> is null
- */
- public void testKeyManagementException06() {
- KeyManagementException tE = new KeyManagementException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>KeyManagementException(String, Throwable)</code>
- * constructor Assertion: constructs KeyManagementException when
- * <code>cause</code> is null <code>msg</code> is not null
- */
- public void testKeyManagementException07() {
- KeyManagementException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new KeyManagementException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>KeyManagementException(String, Throwable)</code>
- * constructor Assertion: constructs KeyManagementException when
- * <code>cause</code> is not null <code>msg</code> is null
- */
- public void testKeyManagementException08() {
- KeyManagementException tE = new KeyManagementException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>KeyManagementException(String, Throwable)</code>
- * constructor Assertion: constructs KeyManagementException when
- * <code>cause</code> is not null <code>msg</code> is not null
- */
- public void testKeyManagementException09() {
- KeyManagementException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new KeyManagementException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator1Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator1Test.java
deleted file mode 100644
index 4337e8f..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator1Test.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import java.math.BigInteger;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.apache.harmony.security.tests.support.MyKeyPairGenerator1;
-import org.apache.harmony.security.tests.support.MyKeyPairGenerator2;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyPairGenerator</code> class constructors and methods.
- */
-
-public class KeyPairGenerator1Test extends TestCase {
-
- /**
- * Constructor for KayPairGeneratorTest.
- *
- * @param arg0
- */
- public KeyPairGenerator1Test(String arg0) {
- super(arg0);
- }
-
- private static String[] invalidValues = SpiEngUtils.invalidValues;
-
- public static final String srvKeyPairGenerator = "KeyPairGenerator";
-
- public static String[] algs = {
- "DSA", "dsa", "Dsa", "DsA", "dsA" };
-
- public static String validAlgName = "DSA";
-
- private static String validProviderName = null;
-
- public static Provider validProvider = null;
-
- private static boolean DSASupported = false;
-
- public static String NotSupportMsg = "";
-
- static {
- validProvider = SpiEngUtils.isSupport(
- validAlgName,
- srvKeyPairGenerator);
- DSASupported = (validProvider != null);
- if (!DSASupported) {
- NotSupportMsg = validAlgName + " algorithm is not supported";
- }
- validProviderName = (DSASupported ? validProvider.getName() : null);
- }
-
- protected KeyPairGenerator[] createKPGen() {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return null;
- }
- KeyPairGenerator[] kpg = new KeyPairGenerator[3];
- try {
- kpg[0] = KeyPairGenerator.getInstance(validAlgName);
- kpg[1] = KeyPairGenerator.getInstance(validAlgName, validProvider);
- kpg[2] = KeyPairGenerator.getInstance(validAlgName, validProviderName);
- return kpg;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is incorrect;
- */
- public void testKeyPairGenerator01() throws NoSuchAlgorithmException {
- try {
- KeyPairGenerator.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyPairGenerator.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown when algorithm is not available: "
- .concat(invalidValues[i]));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion: returns KeyPairGenerator object
- */
- public void testKeyPairGenerator02() throws NoSuchAlgorithmException {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyPairGenerator kpg;
- for (int i = 0; i < algs.length; i++) {
- kpg = KeyPairGenerator.getInstance(algs[i]);
- assertEquals("Incorrect algorithm ", kpg.getAlgorithm().toUpperCase(),
- algs[i].toUpperCase());
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion: throws IllegalArgumentException when provider is null or empty
- */
- public void testKeyPairGenerator03() throws NoSuchAlgorithmException,
- NoSuchProviderException {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return;
- }
- String provider = null;
- for (int i = 0; i < algs.length; i++) {
- try {
- KeyPairGenerator.getInstance(algs[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- try {
- KeyPairGenerator.getInstance(algs[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is incorrect;
- */
- public void testKeyPairGenerator04() throws NoSuchAlgorithmException,
- IllegalArgumentException {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return;
- }
- for (int i = 0; i < algs.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- KeyPairGenerator.getInstance(algs[i], invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(algs[i]).concat(" provider: ").concat(
- invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion: throws NoSuchAlgorithmException when algorithm is not
- * available oe null
- */
- public void testKeyPairGenerator05() throws NoSuchProviderException,
- IllegalArgumentException {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return;
- }
- try {
- KeyPairGenerator.getInstance(null, validProviderName);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyPairGenerator.getInstance(invalidValues[i],
- validProviderName);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(algs[i]).concat(" provider: ").concat(
- validProviderName).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion: returns KeyPairGenerator object
- */
- public void testKeyPairGenerator06() throws NoSuchProviderException,
- NoSuchAlgorithmException, IllegalArgumentException {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyPairGenerator kpg;
- for (int i = 0; i < algs.length; i++) {
- kpg = KeyPairGenerator.getInstance(algs[i], validProviderName);
- assertEquals("Incorrect algorithm", kpg.getAlgorithm().toUpperCase(),
- algs[i].toUpperCase());
- assertEquals("Incorrect provider", kpg.getProvider().getName(),
- validProviderName);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion: throws IllegalArgumentException when provider is null
- */
- public void testKeyPairGenerator07() throws NoSuchAlgorithmException {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return;
- }
- Provider provider = null;
- for (int i = 0; i < algs.length; i++) {
- try {
- KeyPairGenerator.getInstance(algs[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is incorrect;
- */
- public void testKeyPairGenerator08() throws IllegalArgumentException {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return;
- }
- try {
- KeyPairGenerator.getInstance(null, validProvider);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyPairGenerator.getInstance(invalidValues[i], validProvider);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(algs[i]).concat(" provider: ").concat(
- validProviderName).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion: returns KeyPairGenerator object
- */
- public void testKeyPairGenerator09() throws NoSuchAlgorithmException,
- IllegalArgumentException {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyPairGenerator kpg;
- for (int i = 0; i < algs.length; i++) {
- kpg = KeyPairGenerator.getInstance(algs[i], validProvider);
- assertEquals("Incorrect algorithm", kpg.getAlgorithm().toUpperCase(),
- algs[i].toUpperCase());
- assertEquals("Incorrect provider", kpg.getProvider(), validProvider);
- }
- }
-
- /**
- * Test for <code>generateKeyPair()</code> and <code>genKeyPair()</code>
- * methods
- * Assertion: KeyPairGenerator was initialized before the invocation
- * of these methods
- */
- public void testKeyPairGenerator10() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyPairGenerator[] kpg = createKPGen();
- assertNotNull("KeyPairGenerator objects were not created", kpg);
- KeyPair kp, kp1;
- for (int i = 0; i < kpg.length; i++) {
- kpg[i].initialize(512);
- kp = kpg[i].generateKeyPair();
- kp1 = kpg[i].genKeyPair();
-
- assertFalse("Incorrect private key", kp.getPrivate().equals(
- kp1.getPrivate()));
- assertFalse("Incorrect public key", kp.getPublic().equals(
- kp1.getPublic()));
- }
- }
-
- /**
- * Test for methods:
- * <code>initialize(int keysize)</code>
- * <code>initialize(int keysize, SecureRandom random)</code>
- * <code>initialize(AlgorithmParameterSpec param)</code>
- * <code>initialize(AlgorithmParameterSpec param, SecureRandom random)</code>
- * Assertion: throws InvalidParameterException or
- * InvalidAlgorithmParameterException when parameters keysize or param are
- * incorrect
- */
- public void testKeyPairGenerator11() throws NoSuchAlgorithmException,
- NoSuchProviderException {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return;
- }
- int[] keys = { -10000, -1024, -1, 0, 10000 };
- KeyPairGenerator[] kpg = createKPGen();
- assertNotNull("KeyPairGenerator objects were not created", kpg);
- SecureRandom random = new SecureRandom();
- AlgorithmParameterSpec aps = null;
-
- for (int i = 0; i < kpg.length; i++) {
-
- for (int j = 0; j < keys.length; j++) {
- try {
- kpg[i].initialize(keys[j]);
- kpg[i].initialize(keys[j], random);
- } catch (InvalidParameterException e) {
- }
- }
-
- try {
- kpg[i].initialize(aps);
- kpg[i].initialize(aps, random);
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
- }
-
- /**
- * Test for methods: <code>initialize(int keysize)</code>
- * <code>initialize(int keysize, SecureRandom random)</code>
- * <code>initialize(AlgorithmParameterSpec param)</code>
- * <code>initialize(AlgorithmParameterSpec param, SecureRandom random)</code>
- * <code>generateKeyPair()</code>
- * <code>genKeyPair()</code>
- * Assertion: throws InvalidParameterException or
- * InvalidAlgorithmParameterException when parameters keysize or param are
- * incorrect Assertion: generateKeyPair() and genKeyPair() return null
- * KeyPair Additional class MyKeyPairGenerator1 is used
- */
- public void testKeyPairGenerator12() {
- int[] keys = { -1, -250, 1, 64, 512, 1024 };
- SecureRandom random = new SecureRandom();
- AlgorithmParameterSpec aps;
- KeyPairGenerator mKPG = new MyKeyPairGenerator1("");
- assertEquals("Incorrect algorithm", mKPG.getAlgorithm(),
- MyKeyPairGenerator1.getResAlgorithm());
-
- mKPG.generateKeyPair();
- mKPG.genKeyPair();
-
- for (int i = 0; i < keys.length; i++) {
- try {
- mKPG.initialize(keys[i]);
- fail("InvalidParameterException must be thrown (key: "
- + Integer.toString(keys[i]) + ")");
- } catch (InvalidParameterException e) {
- }
- try {
- mKPG.initialize(keys[i], random);
- fail("InvalidParameterException must be thrown (key: "
- + Integer.toString(keys[i]) + ")");
- } catch (InvalidParameterException e) {
- }
- }
- try {
- mKPG.initialize(100, null);
- fail("InvalidParameterException must be thrown when random is null");
- } catch (InvalidParameterException e) {
- }
-
- mKPG.initialize(100, random);
- assertEquals("Incorrect random", random,
- ((MyKeyPairGenerator1) mKPG).secureRandom);
- assertEquals("Incorrect keysize", 100,
- ((MyKeyPairGenerator1) mKPG).keySize);
- try {
- mKPG.initialize(null, random);
- fail("InvalidAlgorithmParameterException must be thrown when param is null");
- } catch (InvalidAlgorithmParameterException e) {
- }
- if (DSASupported) {
- BigInteger bInt = new BigInteger("1");
- aps = new java.security.spec.DSAParameterSpec(bInt, bInt, bInt);
- try {
- mKPG.initialize(aps, null);
- fail("InvalidParameterException must be thrown when random is null");
- } catch (InvalidParameterException e) {
- } catch (InvalidAlgorithmParameterException e) {
- fail("Unexpected InvalidAlgorithmParameterException was thrown");
- }
- try {
- mKPG.initialize(aps, random);
- assertEquals("Incorrect random", random,
- ((MyKeyPairGenerator1) mKPG).secureRandom);
- assertEquals("Incorrect params", aps,
- ((MyKeyPairGenerator1) mKPG).paramSpec);
- } catch (InvalidAlgorithmParameterException e) {
- fail("Unexpected InvalidAlgorithmParameterException was thrown");
- }
- }
- }
-
- /**
- * Test for methods: <code>initialize(int keysize)</code>
- * <code>initialize(int keysize, SecureRandom random)</code>
- * <code>initialize(AlgorithmParameterSpec param)</code>
- * <code>initialize(AlgorithmParameterSpec param, SecureRandom random)</code>
- * <code>generateKeyPair()</code>
- * <code>genKeyPair()</code>
- * Assertion: initialize(int ...) throws InvalidParameterException when
- * keysize in incorrect Assertion: initialize(AlgorithmParameterSpec
- * ...)throws UnsupportedOperationException Assertion: generateKeyPair() and
- * genKeyPair() return not null KeyPair Additional class MyKeyPairGenerator2
- * is used
- */
- public void testKeyPairGenerator13() {
- int[] keys = { -1, -250, 1, 63, -512, -1024 };
- SecureRandom random = new SecureRandom();
- KeyPairGenerator mKPG = new MyKeyPairGenerator2(null);
- assertEquals("Algorithm must be null", mKPG.getAlgorithm(),
- MyKeyPairGenerator2.getResAlgorithm());
- assertNull("genKeyPair() must return null", mKPG.genKeyPair());
- assertNull("generateKeyPair() mut return null", mKPG.generateKeyPair());
- for (int i = 0; i < keys.length; i++) {
- try {
- mKPG.initialize(keys[i]);
- fail("InvalidParameterException must be thrown (key: "
- + Integer.toString(keys[i]) + ")");
- } catch (InvalidParameterException e) {
- }
- try {
- mKPG.initialize(keys[i], random);
- fail("InvalidParameterException must be thrown (key: "
- + Integer.toString(keys[i]) + ")");
- } catch (InvalidParameterException e) {
- }
- }
- try {
- mKPG.initialize(64);
- } catch (InvalidParameterException e) {
- fail("Unexpected InvalidParameterException was thrown");
- }
- try {
- mKPG.initialize(64, null);
- } catch (InvalidParameterException e) {
- fail("Unexpected InvalidParameterException was thrown");
- }
- try {
- mKPG.initialize(null, random);
- } catch (UnsupportedOperationException e) {
- // on j2se1.4 this exception is not thrown
- } catch (InvalidAlgorithmParameterException e) {
- fail("Unexpected InvalidAlgorithmParameterException was thrown");
- }
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator2Test.java
deleted file mode 100644
index c6a9d17..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator2Test.java
+++ /dev/null
@@ -1,426 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.apache.harmony.security.tests.support.MyKeyPairGenerator1;
-import org.apache.harmony.security.tests.support.MyKeyPairGenerator2;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>KeyPairGenerator</code> class constructors and methods.
- */
-
-public class KeyPairGenerator2Test extends TestCase {
- private String KeyPairGeneratorProviderClass = "";
-
- private static final String KeyPairGeneratorProviderClass1 = "org.apache.harmony.security.tests.support.MyKeyPairGenerator1";
- private static final String KeyPairGeneratorProviderClass2 = "org.apache.harmony.security.tests.support.MyKeyPairGenerator2";
- private static final String KeyPairGeneratorProviderClass3 = "org.apache.harmony.security.tests.support.MyKeyPairGenerator3";
- private static final String KeyPairGeneratorProviderClass4 = "org.apache.harmony.security.tests.support.MyKeyPairGeneratorSpi";
-
- private static final String defaultAlg = "KPGen";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- String post;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "kpGEN";
- validValues[3] = "kPGEn";
- }
-
- Provider mProv;
- String resAlg;
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- protected void setProv() {
- mProv = (new SpiEngUtils()).new MyProvider("MyKPGenProvider".concat(post),
- "Testing provider", KeyPairGenerator1Test.srvKeyPairGenerator.concat(".")
- .concat(defaultAlg.concat(post)),
- KeyPairGeneratorProviderClass);
- Security.insertProviderAt(mProv, 1);
- }
-
- public KeyPairGenerator2Test(String arg0) {
- super(arg0);
- }
-
- private void checkResult(KeyPairGenerator keyPairGen, int mode)
- throws InvalidAlgorithmParameterException {
- AlgorithmParameterSpec pp = null;
- switch (mode) {
- case 1:
- try {
- keyPairGen.initialize(pp, new SecureRandom());
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- keyPairGen.initialize(1000, new SecureRandom());
- try {
- keyPairGen.initialize(-1024, new SecureRandom());
- fail("InvalidParameterException must be thrown");
- } catch (InvalidParameterException e) {
- assertEquals("Incorrect exception", e.getMessage(),
- "Incorrect keysize parameter");
- }
- try {
- keyPairGen.initialize(100, null);
- fail("InvalidParameterException must be thrown");
- } catch (InvalidParameterException e) {
- assertEquals("Incorrect exception", e.getMessage(),
- "Incorrect random");
- }
- keyPairGen.generateKeyPair();
- keyPairGen.genKeyPair();
- break;
- case 2:
- try {
- keyPairGen.initialize(pp, new SecureRandom());
- } catch (UnsupportedOperationException e) {
- // js2e does not throw this exception
- }
- keyPairGen.initialize(1000, new SecureRandom());
- try {
- keyPairGen.initialize(63, new SecureRandom());
- fail("InvalidParameterException must be thrown");
- } catch (InvalidParameterException e) {
- }
- keyPairGen.initialize(100, null);
- assertNull("Not null KeyPair", keyPairGen.generateKeyPair());
- assertNull("Not null KeyPair", keyPairGen.genKeyPair());
- break;
- case 3:
- keyPairGen.initialize(pp, new SecureRandom());
- keyPairGen.initialize(pp);
- keyPairGen.initialize(1000, new SecureRandom());
- keyPairGen.initialize(100);
-
- assertNotNull("Null KeyPair", keyPairGen.generateKeyPair());
- assertNotNull("Null KeyPair", keyPairGen.genKeyPair());
- break;
- case 4:
- try {
- keyPairGen.initialize(pp, null);
- fail("UnsupportedOperationException must be thrown");
- } catch (UnsupportedOperationException e) {
- }
- keyPairGen.initialize(pp, new SecureRandom());
- keyPairGen.initialize(101, new SecureRandom());
- keyPairGen.initialize(10000);
- try {
- keyPairGen.initialize(101, null);
- fail("IllegalArgumentException must be thrown for null random");
- } catch (IllegalArgumentException e) {
- }
- try {
- keyPairGen.initialize(99, new SecureRandom());
- fail("InvalidParameterException must be thrown for invalid key");
- } catch (InvalidParameterException e) {
- }
- try {
- keyPairGen.initialize(99);
- fail("InvalidParameterException must be thrown for invalid key");
- } catch (InvalidParameterException e) {
- }
- try {
- keyPairGen.initialize(199, null);
- fail("IllegalArgumentException must be thrown for null random");
- } catch (IllegalArgumentException e) {
- }
- assertNull("Not null KeyPair", keyPairGen.generateKeyPair());
- assertNull("Not null KeyPair", keyPairGen.genKeyPair());
- break;
- }
-
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method Assertions:
- * throws NullPointerException when algorithm is null throws
- * NoSuchAlgorithmException when algorithm is incorrect; returns
- * KeyPairGenerator object
- */
- private void GetInstance01(int mode) throws NoSuchAlgorithmException,
- InvalidAlgorithmParameterException {
- try {
- KeyPairGenerator.getInstance(null);
- fail("NullPointerException or KeyStoreException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyPairGenerator.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- KeyPairGenerator kpG;
- for (int i = 0; i < validValues.length; i++) {
- String alg = validValues[i].concat(post);
- kpG = KeyPairGenerator.getInstance(alg);
- assertEquals("Incorrect algorithm", kpG.getAlgorithm()
- .toUpperCase(), (mode <= 2 ? resAlg : alg).toUpperCase());
- assertEquals("Incorrect provider", kpG.getProvider(), mProv);
- checkResult(kpG, mode);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is incorrect;
- * throws IllegalArgumentException when provider is null;
- * throws NoSuchProviderException when provider is available;
- * returns
- * KeyPairGenerator object
- */
- public void GetInstance02(int mode) throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidAlgorithmParameterException {
- try {
- KeyPairGenerator.getInstance(null, mProv.getName());
- fail("NullPointerException or KeyStoreException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyPairGenerator.getInstance(invalidValues[i], mProv.getName());
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- String alg = validValues[i].concat(post);
- try {
- KeyPairGenerator.getInstance(alg, prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(alg).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- String alg = validValues[i].concat(post);
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- KeyPairGenerator.getInstance(alg, invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(alg).concat(" provider: ").concat(
- invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- KeyPairGenerator kpG;
- for (int i = 0; i < validValues.length; i++) {
- String alg = validValues[i].concat(post);
- kpG = KeyPairGenerator.getInstance(alg, mProv.getName());
- assertEquals("Incorrect algorithm", kpG.getAlgorithm()
- .toUpperCase(), (mode <= 2 ? resAlg : alg).toUpperCase());
- assertEquals("Incorrect provider", kpG.getProvider().getName(),
- mProv.getName());
- checkResult(kpG, mode);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is incorrect;
- * throws IllegalArgumentException when provider is null;
- * returns KeyPairGenerator object
- */
- private void GetInstance03(int mode) throws NoSuchAlgorithmException,
- IllegalArgumentException, InvalidAlgorithmParameterException {
- try {
- KeyPairGenerator.getInstance(null, mProv);
- fail("NullPointerException or KeyStoreException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyPairGenerator.getInstance(invalidValues[i], mProv);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- String alg = validValues[i].concat(post);
- try {
- KeyPairGenerator.getInstance(alg, prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(alg).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- KeyPairGenerator kpG;
- for (int i = 0; i < validValues.length; i++) {
- String alg = validValues[i].concat(post);
- kpG = KeyPairGenerator.getInstance(alg, mProv);
- assertEquals("Incorrect algorithm", kpG.getAlgorithm()
- .toUpperCase(), (mode <= 2 ? resAlg : alg).toUpperCase());
- assertEquals("Incorrect provider", kpG.getProvider(), mProv);
- checkResult(kpG, mode);
- }
- }
-
- public void testGetInstance01() throws NoSuchAlgorithmException,
- InvalidAlgorithmParameterException {
- KeyPairGeneratorProviderClass = KeyPairGeneratorProviderClass1;
- resAlg = MyKeyPairGenerator1.getResAlgorithm();
- post = "_1";
- setProv();
- GetInstance01(1);
- }
-
- public void testGetInstance02() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidAlgorithmParameterException {
- KeyPairGeneratorProviderClass = KeyPairGeneratorProviderClass1;
- resAlg = MyKeyPairGenerator1.getResAlgorithm();
- post = "_1";
- setProv();
- GetInstance02(1);
- }
-
- public void testGetInstance03() throws NoSuchAlgorithmException,
- IllegalArgumentException, InvalidAlgorithmParameterException {
- KeyPairGeneratorProviderClass = KeyPairGeneratorProviderClass1;
- resAlg = MyKeyPairGenerator1.getResAlgorithm();
- post = "_1";
- setProv();
- GetInstance03(1);
- }
-
- public void testGetInstance04() throws NoSuchAlgorithmException,
- InvalidAlgorithmParameterException {
- KeyPairGeneratorProviderClass = KeyPairGeneratorProviderClass2;
- resAlg = MyKeyPairGenerator2.getResAlgorithm();
- post = "_2";
- setProv();
- GetInstance01(2);
- }
-
- public void testGetInstance05() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidAlgorithmParameterException {
- KeyPairGeneratorProviderClass = KeyPairGeneratorProviderClass2;
- resAlg = MyKeyPairGenerator2.getResAlgorithm();
- post = "_2";
- setProv();
- GetInstance02(2);
- }
-
- public void testGetInstance06() throws NoSuchAlgorithmException,
- IllegalArgumentException, InvalidAlgorithmParameterException {
- KeyPairGeneratorProviderClass = KeyPairGeneratorProviderClass2;
- resAlg = MyKeyPairGenerator2.getResAlgorithm();
- post = "_2";
- setProv();
- GetInstance03(2);
- }
-
- public void testGetInstance07() throws NoSuchAlgorithmException,
- InvalidAlgorithmParameterException {
- KeyPairGeneratorProviderClass = KeyPairGeneratorProviderClass3;
- resAlg = "";
- post = "_3";
- setProv();
- GetInstance01(3);
- }
-
- public void testGetInstance08() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidAlgorithmParameterException {
- KeyPairGeneratorProviderClass = KeyPairGeneratorProviderClass3;
- resAlg = "";
- post = "_3";
- setProv();
- GetInstance02(3);
- }
-
- public void testGetInstance09() throws NoSuchAlgorithmException,
- IllegalArgumentException, InvalidAlgorithmParameterException {
- KeyPairGeneratorProviderClass = KeyPairGeneratorProviderClass3;
- resAlg = "";
- post = "_3";
- setProv();
- GetInstance03(3);
- }
-
- public void testGetInstance10() throws NoSuchAlgorithmException,
- InvalidAlgorithmParameterException {
- KeyPairGeneratorProviderClass = KeyPairGeneratorProviderClass4;
- resAlg = "";
- post = "_4";
- setProv();
- GetInstance01(4);
- }
-
- public void testGetInstance11() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidAlgorithmParameterException {
- KeyPairGeneratorProviderClass = KeyPairGeneratorProviderClass4;
- resAlg = "";
- post = "_4";
- setProv();
- GetInstance02(4);
- }
-
- public void testGetInstance12() throws NoSuchAlgorithmException,
- IllegalArgumentException, InvalidAlgorithmParameterException {
- KeyPairGeneratorProviderClass = KeyPairGeneratorProviderClass4;
- resAlg = "";
- post = "_4";
- setProv();
- GetInstance03(4);
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator3Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator3Test.java
deleted file mode 100644
index 7c0f0f0..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator3Test.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for KeyPairGenerator class
- */
-
-public class KeyPairGenerator3Test extends TestCase {
-
- /**
- * Constructor for KeyPairGenerator3Test.
- *
- * @param arg0
- */
- public KeyPairGenerator3Test(String arg0) {
- super(arg0);
- }
-
- private static String validProviderName = null;
-
- public static Provider validProvider = null;
-
- private static boolean DSASupported = false;
-
- private static String NotSupportMsg = KeyPairGenerator1Test.NotSupportMsg;
-
- static {
- validProvider = SpiEngUtils.isSupport(
- KeyPairGenerator1Test.validAlgName,
- KeyPairGenerator1Test.srvKeyPairGenerator);
- DSASupported = (validProvider != null);
- validProviderName = (DSASupported ? validProvider.getName() : null);
- }
-
- protected KeyPairGenerator[] createKPGen() {
- if (!DSASupported) {
- fail(KeyPairGenerator1Test.validAlgName
- + " algorithm is not supported");
- return null;
- }
- KeyPairGenerator[] kpg = new KeyPairGenerator[3];
- try {
- kpg[0] = KeyPairGenerator
- .getInstance(KeyPairGenerator1Test.validAlgName);
- kpg[1] = KeyPairGenerator.getInstance(
- KeyPairGenerator1Test.validAlgName, validProvider);
- kpg[2] = KeyPairGenerator.getInstance(
- KeyPairGenerator1Test.validAlgName, validProviderName);
- return kpg;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
-
- /**
- * Test for <code>generateKeyPair()</code> and <code>genKeyPair()</code>
- * methods
- * Assertion: KeyPairGenerator was initialized before the invocation
- * of these methods
- */
- public void testGenKeyPair01() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyPairGenerator[] kpg = createKPGen();
- assertNotNull("KeyPairGenerator objects were not created", kpg);
- KeyPair kp, kp1;
- SecureRandom rr = new SecureRandom();
- for (int i = 0; i < kpg.length; i++) {
- kpg[i].initialize(512, rr);
- kp = kpg[i].generateKeyPair();
- kp1 = kpg[i].genKeyPair();
- assertFalse("Incorrect private key", kp.getPrivate().equals(
- kp1.getPrivate()));
- assertFalse("Incorrect public key", kp.getPublic().equals(
- kp1.getPublic()));
- }
- }
-
- /**
- * Test for <code>generateKeyPair()</code> and <code>genKeyPair()</code>
- * methods
- * Assertion: these methods are used without previously initialization
- */
- public void testGenKeyPair02() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException {
- if (!DSASupported) {
- fail(NotSupportMsg);
- return;
- }
- KeyPairGenerator[] kpg = createKPGen();
- assertNotNull("KeyPairGenerator objects were not created", kpg);
- KeyPair kp, kp1;
- for (int i = 0; i < kpg.length; i++) {
- kp = kpg[i].generateKeyPair();
- kp1 = kpg[i].genKeyPair();
- assertFalse("Incorrect private key", kp.getPrivate().equals(
- kp1.getPrivate()));
- assertFalse("Incorrect public key", kp.getPublic().equals(
- kp1.getPublic()));
- }
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator4Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator4Test.java
deleted file mode 100644
index e93e34e..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator4Test.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.math.BigInteger;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.Security;
-import java.security.spec.DSAParameterSpec;
-import java.security.interfaces.DSAPublicKey;
-import java.security.interfaces.DSAParams;
-
-public class KeyPairGenerator4Test extends junit.framework.TestCase {
-
- /**
- * @tests java.security.KeyPairGenerator#genKeyPair()
- */
- public void test_genKeyPair() throws Exception {
- KeyPairGenerator gen = KeyPairGenerator.getInstance("DSA");
- gen.initialize(1024);
- assertNotNull("KeyPair is null", gen.genKeyPair());
- }
-
- /**
- * @tests java.security.KeyPairGenerator#getAlgorithm()
- */
- public void test_getAlgorithm() throws Exception {
- String alg = KeyPairGenerator.getInstance("DSA").getAlgorithm();
- assertEquals("getAlgorithm returned unexpected value", "DSA", alg);
- }
-
- /**
- * @tests java.security.KeyPairGenerator#getInstance(java.lang.String)
- */
- public void test_getInstanceLjava_lang_String() throws Exception {
- KeyPairGenerator.getInstance("DSA");
- }
-
- /**
- * @tests java.security.KeyPairGenerator#getInstance(java.lang.String,
- *java.lang.String)
- */
- public void test_getInstanceLjava_lang_StringLjava_lang_String()
- throws Exception {
-
- // Test1: Test with named provider
- Provider[] providers = Security.getProviders("KeyPairGenerator.DSA");
-
- for (int i = 0; i < providers.length; i++) {
- KeyPairGenerator.getInstance("DSA", providers[i].getName());
- }// end for
-
- // Test2: Test with empty provider name - should raise
- // IllegalArgumentException
- try {
- KeyPairGenerator.getInstance("DSA", "");
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- /**
- * @tests java.security.KeyPairGenerator#getProvider()
- */
- public void test_getProvider() throws Exception {
- Provider p = KeyPairGenerator.getInstance("DSA").getProvider();
- assertNotNull("provider is null", p);
- }
-
- /**
- * @tests java.security.KeyPairGenerator#initialize(int)
- */
- public void test_initializeI() throws Exception {
- KeyPairGenerator keyPair = KeyPairGenerator.getInstance("DSA");
- keyPair.initialize(1024);
- }
-
- /**
- * @tests java.security.KeyPairGenerator#initialize(int,
- *java.security.SecureRandom)
- */
- public void test_initializeILjava_security_SecureRandom() throws Exception {
- KeyPairGenerator keyPair = KeyPairGenerator.getInstance("DSA");
- keyPair.initialize(1024, new SecureRandom());
- }
-
-
- /**
- * @tests java.security.KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec)
- */
- public void test_initializeLjava_security_spec_AlgorithmParameterSpec()
- throws Exception {
- // create DSAParams
- KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
- keyPairGenerator.initialize(1024);
- DSAPublicKey key = (DSAPublicKey) keyPairGenerator.genKeyPair()
- .getPublic();
- DSAParams params = key.getParams();
-
- KeyPairGenerator keyPair = KeyPairGenerator.getInstance("DSA");
- keyPair.initialize(new DSAParameterSpec(params.getP(), params.getQ(),
- params.getG()));
- }
-
- /**
- * @tests java.security.KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec,
- *java.security.SecureRandom)
- */
- public void test_initializeLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom()
- throws Exception {
- // create DSAParams
- KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
- keyPairGenerator.initialize(1024);
- DSAPublicKey key = (DSAPublicKey) keyPairGenerator.genKeyPair()
- .getPublic();
- DSAParams params = key.getParams();
-
- KeyPairGenerator keyPair = KeyPairGenerator.getInstance("DSA");
- keyPair.initialize(new DSAParameterSpec(params.getP(), params.getQ(),
- params.getG()), new SecureRandom());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator5Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator5Test.java
deleted file mode 100644
index 3bad2aa..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator5Test.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.math.BigInteger;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.Security;
-import java.security.spec.DSAParameterSpec;
-import java.security.interfaces.DSAPublicKey;
-import java.security.interfaces.DSAParams;
-
-public class KeyPairGenerator5Test extends junit.framework.TestCase {
-
- private class MockKeyPairGenerator extends KeyPairGenerator {
-
- protected MockKeyPairGenerator(String algorithm) {
- super(algorithm);
- }
- }
-
-
- public void test_generateKeyPair() {
- MockKeyPairGenerator mockKeyPairGenerator = new MockKeyPairGenerator("MOCKKEYPAIRGENERATOR");
- assertNull(mockKeyPairGenerator.generateKeyPair());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGeneratorSpiTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGeneratorSpiTest.java
deleted file mode 100644
index 1b30784..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGeneratorSpiTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.apache.harmony.security.tests.support.MyKeyPairGeneratorSpi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyPairGeneratorSpi</code> class constructors and methods.
- */
-
-public class KeyPairGeneratorSpiTest extends TestCase {
-
- /**
- * Constructor for KeyPairGeneratorSpiTest.
- *
- * @param arg0
- */
- public KeyPairGeneratorSpiTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>KeyPairGeneratorSpi</code> constructor
- * Assertion: constructs KeyPairGeneratorSpi
- */
- public void testKeyPairGeneratorSpi01()
- throws InvalidAlgorithmParameterException,
- InvalidParameterException {
- KeyPairGeneratorSpi keyPairGen = new MyKeyPairGeneratorSpi();
-
- AlgorithmParameterSpec pp = null;
- try {
- keyPairGen.initialize(pp, null);
- fail("UnsupportedOperationException must be thrown");
- } catch (UnsupportedOperationException e) {
- }
- keyPairGen.initialize(pp, new SecureRandom());
- keyPairGen.initialize(1024, new SecureRandom());
- try {
- keyPairGen.initialize(-1024, new SecureRandom());
- fail("IllegalArgumentException must be thrown for incorrect keysize");
- } catch (IllegalArgumentException e) {
- }
- try {
- keyPairGen.initialize(1024, null);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- assertEquals("Incorrect exception", e.getMessage(),
- "Invalid random");
- }
- KeyPair kp = keyPairGen.generateKeyPair();
- assertNull("Not null KeyPair", kp);
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairTest.java
deleted file mode 100644
index 69e2638..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import java.security.spec.InvalidKeySpecException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for fields and methods of class <code>KeyPair</code>
- */
-public class KeyPairTest extends TestCase {
-
- private static class TestKeyPair {
- static PublicKey getPublic() {
- return new PublicKey() {
- public String getAlgorithm() {
- return "never mind";
- }
-
- public String getFormat() {
- return "never mind";
- }
-
- public byte[] getEncoded() {
- return null;
- }
- };
- }
-
- static PrivateKey getPrivate() {
- return new PrivateKey() {
- public String getAlgorithm() {
- return "never mind";
- }
-
- public String getFormat() {
- return "never mind";
- }
-
- public byte[] getEncoded() {
- return null;
- }
- };
- }
- }
-
- /**
- * Constructor for KeyPairTest.
- *
- * @param name
- */
- public KeyPairTest(String name) {
- super(name);
- }
-
- /**
- * Test #1 for <code>KeyPair(PublicKey, PrivateKey)</code> constructor<br>
- * Assertion: creates new <code>KeyPair</code> instance using valid
- * parameters (both <code>null</code>)
- */
- public final void testKeyPair01() {
- Object kp = new KeyPair(null, null);
- assertTrue(kp instanceof KeyPair);
- }
-
- /**
- * Test #2 for <code>KeyPair(PublicKey, PrivateKey)</code> constructor<br>
- * Assertion: creates new <code>KeyPair</code> instance using valid
- * parameters (both valid keys)
- *
- * @throws InvalidKeySpecException
- */
- public final void testKeyPair02() throws InvalidKeySpecException {
- Object kp = new KeyPair(TestKeyPair.getPublic(), TestKeyPair.getPrivate());
- assertTrue(kp instanceof KeyPair);
- }
-
- /**
- * Test #1 for <code>getPrivate()</code> method<br>
- * Assertion: returns private key (<code>null</code> in this case)
- */
- public final void testGetPrivate01() {
- KeyPair kp = new KeyPair(null, null);
- assertNull(kp.getPrivate());
- }
-
- /**
- * Test #2 for <code>getPrivate()</code> method<br>
- * Assertion: returns private key (valid private key in this case)
- *
- * @throws InvalidKeySpecException
- */
- public final void testGetPrivate02() throws InvalidKeySpecException {
- PrivateKey pk = TestKeyPair.getPrivate();
- KeyPair kp = new KeyPair(null, pk);
- assertSame(pk, kp.getPrivate());
- }
-
- /**
- * Test #1 for <code>getPublic()</code> method<br>
- * Assertion: returns public key (<code>null</code> in this case)
- */
- public final void testGetPublic01() {
- KeyPair kp = new KeyPair(null, null);
- assertNull(kp.getPublic());
- }
-
- /**
- * Test #2 for <code>getPublic()</code> method<br>
- * Assertion: returns public key (valid public key in this case)
- *
- * @throws InvalidKeySpecException
- */
- public final void testGetPublic02() throws InvalidKeySpecException {
- PublicKey pk = TestKeyPair.getPublic();
- KeyPair kp = new KeyPair(pk, null);
- assertSame(pk, kp.getPublic());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyRepTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyRepTest.java
deleted file mode 100644
index a03bdc8..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyRepTest.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import junit.framework.TestCase;
-
-/**
- *
- *
- */
-public class KeyRepTest extends TestCase {
- //
-// private static final Set<String> keyFactoryAlgorithm;
-// static {
-// keyFactoryAlgorithm = Security.getAlgorithms("KeyFactory");
-// }
-//
- public final void testKeyRep01() {
-// KeyRep kr = new KeyRep(KeyRep.Type.SECRET, "", "", new byte[] {});
-// kr = new KeyRep(KeyRep.Type.PUBLIC, "", "", new byte[] {});
-// kr = new KeyRep(KeyRep.Type.PRIVATE, "", "", new byte[] {});
- }
-//
-// public final void testKeyRep02() {
-// try {
-// KeyRep kr = new KeyRep(null, "", "", new byte[] {});
-// fail("NullPointerException has not been thrown (type)");
-// } catch (NullPointerException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-// try {
-// KeyRep kr = new KeyRep(KeyRep.Type.SECRET, null, "", new byte[] {});
-// fail("NullPointerException has not been thrown (alg)");
-// } catch (NullPointerException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-// try {
-// KeyRep kr = new KeyRep(KeyRep.Type.PRIVATE, "", null, new byte[] {});
-// fail("NullPointerException has not been thrown (format)");
-// } catch (NullPointerException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-// try {
-// KeyRep kr = new KeyRep(KeyRep.Type.PUBLIC, "", "", null);
-// fail("NullPointerException has not been thrown (encoding)");
-// } catch (NullPointerException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-// }
-//
-// public final void testReadResolve01() throws ObjectStreamException {
-// KeyRep kr = new KeyRep(KeyRep.Type.SECRET, "", "", new byte[] {});
-// try {
-// kr.readResolve();
-// fail("NotSerializableException has not been thrown (no format)");
-// } catch (NotSerializableException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-//
-// kr = new KeyRep(KeyRep.Type.SECRET, "", "X.509", new byte[] {});
-// try {
-// kr.readResolve();
-// fail("NotSerializableException has not been thrown (unacceptable format)");
-// } catch (NotSerializableException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-//
-// kr = new KeyRep(KeyRep.Type.SECRET, "", "RAW", new byte[] {});
-// try {
-// kr.readResolve();
-// fail("NotSerializableException has not been thrown (empty key)");
-// } catch (NotSerializableException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-// }
-//
-// public final void testReadResolve02() throws ObjectStreamException {
-// KeyRep kr = new KeyRep(KeyRep.Type.PUBLIC, "", "", new byte[] {});
-// try {
-// kr.readResolve();
-// fail("NotSerializableException has not been thrown (no format)");
-// } catch (NotSerializableException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-//
-// kr = new KeyRep(KeyRep.Type.PUBLIC, "", "RAW", new byte[] {});
-// try {
-// kr.readResolve();
-// fail("NotSerializableException has not been thrown (unacceptable format)");
-// } catch (NotSerializableException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-//
-// kr = new KeyRep(KeyRep.Type.PUBLIC, "bla-bla", "X.509", new byte[] {});
-// try {
-// kr.readResolve();
-// fail("NotSerializableException has not been thrown (unknown KeyFactory algorithm)");
-// } catch (NotSerializableException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-// }
-//
-// public final void testReadResolve03() throws ObjectStreamException {
-// KeyRep kr = new KeyRep(KeyRep.Type.PRIVATE, "", "", new byte[] {});
-// try {
-// kr.readResolve();
-// fail("NotSerializableException has not been thrown (no format)");
-// } catch (NotSerializableException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-//
-// kr = new KeyRep(KeyRep.Type.PRIVATE, "", "RAW", new byte[] {});
-// try {
-// kr.readResolve();
-// fail("NotSerializableException has not been thrown (unacceptable format)");
-// } catch (NotSerializableException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-//
-// kr = new KeyRep(KeyRep.Type.PRIVATE, "bla-bla", "PKCS#8", new byte[] {});
-// try {
-// kr.readResolve();
-// fail("NotSerializableException has not been thrown (unknown KeyFactory algorithm)");
-// } catch (NotSerializableException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-// }
-//
-// public final void testReadResolve04() throws ObjectStreamException {
-// if (keyFactoryAlgorithm.isEmpty()) {
-// System.err.println(getName() + ": skipped - no KeyFactory algorithms available");
-// return;
-// } else {
-// System.out.println(getName() + ": available algorithms - " +
-// keyFactoryAlgorithm);
-// }
-// for (Iterator<String> i = keyFactoryAlgorithm.iterator(); i.hasNext();) {
-// KeyRep kr = new KeyRep(KeyRep.Type.PUBLIC,
-// i.next(), "X.509", new byte[] {1,2,3});
-// try {
-// kr.readResolve();
-// fail("NotSerializableException has not been thrown (no format)");
-// } catch (NotSerializableException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-// }
-// }
-//
-// public final void testReadResolve05() throws ObjectStreamException {
-// if (keyFactoryAlgorithm.isEmpty()) {
-// System.err.println(getName() + ": skipped - no KeyFactory algorithms available");
-// return;
-// } else {
-// System.out.println(getName() + ": available algorithms - " +
-// keyFactoryAlgorithm);
-// }
-// for (Iterator<String> i = keyFactoryAlgorithm.iterator(); i.hasNext();) {
-// KeyRep kr = new KeyRep(KeyRep.Type.PRIVATE,
-// i.next(), "PKCS#8", new byte[] {1,2,3});
-// try {
-// kr.readResolve();
-// fail("NotSerializableException has not been thrown (no format)");
-// } catch (NotSerializableException ok) {
-// System.out.println(getName() + ": " + ok);
-// }
-// }
-// }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java
deleted file mode 100644
index c8482aa..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java
+++ /dev/null
@@ -1,732 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.Key;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.KeyStoreSpi;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.PublicKey;
-import java.security.SecureRandom;
-import java.security.Security;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Set;
-
-import tests.support.Support_TestProvider;
-import tests.support.resource.Support_Resources;
-
-public class KeyStore2Test extends junit.framework.TestCase {
- static PrivateKey privateKey;
-
- static {
- try {
- KeyPairGenerator keyPairGenerator = KeyPairGenerator
- .getInstance("DSA");
-
- SecureRandom secureRandom = new SecureRandom();
- keyPairGenerator.initialize(1024, secureRandom);
- KeyPair keyPair = keyPairGenerator.genKeyPair();
- privateKey = keyPair.getPrivate();
- } catch (Exception e) {
- fail("initialization failed: " + e);
- }
- }
-
- final char[] pssWord = { 'a', 'b', 'c' };
- private Provider support_TestProvider;
-
- // creating a certificate
- String certificate = "-----BEGIN CERTIFICATE-----\n"
- + "MIICZTCCAdICBQL3AAC2MA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMSAw\n"
- + "HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJl\n"
- + "IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NzAyMjAwMDAwMDBa\n"
- + "Fw05ODAyMjAyMzU5NTlaMIGWMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZv\n"
- + "cm5pYTESMBAGA1UEBxMJUGFsbyBBbHRvMR8wHQYDVQQKExZTdW4gTWljcm9zeXN0\n"
- + "ZW1zLCBJbmMuMSEwHwYDVQQLExhUZXN0IGFuZCBFdmFsdWF0aW9uIE9ubHkxGjAY\n"
- + "BgNVBAMTEWFyZ29uLmVuZy5zdW4uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB\n"
- + "iQKBgQCofmdY+PiUWN01FOzEewf+GaG+lFf132UpzATmYJkA4AEA/juW7jSi+LJk\n"
- + "wJKi5GO4RyZoyimAL/5yIWDV6l1KlvxyKslr0REhMBaD/3Z3EsLTTEf5gVrQS6sT\n"
- + "WMoSZAyzB39kFfsB6oUXNtV8+UKKxSxKbxvhQn267PeCz5VX2QIDAQABMA0GCSqG\n"
- + "SIb3DQEBAgUAA34AXl3at6luiV/7I9MN5CXYoPJYI8Bcdc1hBagJvTMcmlqL2uOZ\n"
- + "H9T5hNMEL9Tk6aI7yZPXcw/xI2K6pOR/FrMp0UwJmdxX7ljV6ZtUZf7pY492UqwC\n"
- + "1777XQ9UEZyrKJvF5ntleeO0ayBqLGVKCWzWZX9YsXCpv47FNLZbupE=\n"
- + "-----END CERTIFICATE-----\n";
-
- ByteArrayInputStream certArray = new ByteArrayInputStream(certificate
- .getBytes());
-
- String certificate2 = "-----BEGIN CERTIFICATE-----\n"
- + "MIICZzCCAdCgAwIBAgIBGzANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJVUzEY\n"
- + "MBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsT\n"
- + "A1BLSTEcMBoGA1UEAxMTRG9EIFBLSSBNZWQgUm9vdCBDQTAeFw05ODA4MDMyMjAy\n"
- + "MjlaFw0wODA4MDQyMjAyMjlaMGExCzAJBgNVBAYTAlVTMRgwFgYDVQQKEw9VLlMu\n"
- + "IEdvdmVybm1lbnQxDDAKBgNVBAsTA0RvRDEMMAoGA1UECxMDUEtJMRwwGgYDVQQD\n"
- + "ExNEb0QgUEtJIE1lZCBSb290IENBMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n"
- + "gQDbrM/J9FrJSX+zxFUbsI9Vw5QbguVBIa95rwW/0M8+sM0r5gd+DY6iubm6wnXk\n"
- + "CSvbfQlFEDSKr4WYeeGp+d9WlDnQdtDFLdA45tCi5SHjnW+hGAmZnld0rz6wQekF\n"
- + "5xQaa5A6wjhMlLOjbh27zyscrorMJ1O5FBOWnEHcRv6xqQIDAQABoy8wLTAdBgNV\n"
- + "HQ4EFgQUVrmYR6m9701cHQ3r5kXyG7zsCN0wDAYDVR0TBAUwAwEB/zANBgkqhkiG\n"
- + "9w0BAQUFAAOBgQDVX1Y0YqC7vekeZjVxtyuC8Mnxbrz6D109AX07LEIRzNYzwZ0w\n"
- + "MTImSp9sEzWW+3FueBIU7AxGys2O7X0qmN3zgszPfSiocBuQuXIYQctJhKjF5KVc\n"
- + "VGQRYYlt+myhl2vy6yPzEVCjiKwMEb1Spu0irCf+lFW2hsdjvmSQMtZvOw==\n"
- + "-----END CERTIFICATE-----\n";
-
- ByteArrayInputStream certArray2 = new ByteArrayInputStream(certificate2
- .getBytes());
-
- String certificate3 = "-----BEGIN CERTIFICATE-----\n"
- + "MIIDXDCCAsWgAwIBAgIBSjANBgkqhkiG9w0BAQUFADBWMQswCQYDVQQGEwJVUzEY\n"
- + "MBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsT\n"
- + "A1BLSTERMA8GA1UEAxMITWVkIENBLTEwHhcNOTgwODAyMTgwMjQwWhcNMDEwODAy\n"
- + "MTgwMjQwWjB0MQswCQYDVQQGEwJVUzEYMBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50\n"
- + "MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsTA1BLSTENMAsGA1UECxMEVVNBRjEgMB4G\n"
- + "A1UEAxMXR3VtYnkuSm9zZXBoLjAwMDAwMDUwNDQwgZ8wDQYJKoZIhvcNAQEBBQAD\n"
- + "gY0AMIGJAoGBALT/R7bPqs1c1YqXAg5HNpZLgW2HuAc7RCaP06cE4R44GBLw/fQc\n"
- + "VRNLn5pgbTXsDnjiZVd8qEgYqjKFQka4/tNhaF7No2tBZB+oYL/eP0IWtP+h/W6D\n"
- + "KR5+UvIIdgmx7k3t9jp2Q51JpHhhKEb9WN54trCO9Yu7PYU+LI85jEIBAgMBAAGj\n"
- + "ggEaMIIBFjAWBgNVHSAEDzANMAsGCWCGSAFlAgELAzAfBgNVHSMEGDAWgBQzOhTo\n"
- + "CWdhiGUkIOx5cELXppMe9jAdBgNVHQ4EFgQUkLBJl+ayKgzOp/wwBX9M1lSkCg4w\n"
- + "DgYDVR0PAQH/BAQDAgbAMAwGA1UdEwEB/wQCMAAwgZ0GA1UdHwSBlTCBkjCBj6CB\n"
- + "jKCBiYaBhmxkYXA6Ly9kcy0xLmNoYW1iLmRpc2EubWlsL2NuJTNkTWVkJTIwQ0El\n"
- + "MmQxJTJjb3UlM2RQS0klMmNvdSUzZERvRCUyY28lM2RVLlMuJTIwR292ZXJubWVu\n"
- + "dCUyY2MlM2RVUz9jZXJ0aWZpY2F0ZVJldm9jYXRpb25MaXN0JTNiYmluYXJ5MA0G\n"
- + "CSqGSIb3DQEBBQUAA4GBAFjapuDHMvIdUeYRyEYdShBR1JZC20tJ3MQnyBQveddz\n"
- + "LGFDGpIkRAQU7T/5/ne8lMexyxViC21xOlK9LdbJCbVyywvb9uEm/1je9wieQQtr\n"
- + "kjykuB+WB6qTCIslAO/eUmgzfzIENvnH8O+fH7QTr2PdkFkiPIqBJYHvw7F3XDqy\n"
- + "-----END CERTIFICATE-----\n";
-
- ByteArrayInputStream certArray3 = new ByteArrayInputStream(certificate3
- .getBytes());
-
- private byte[] creatCertificate() throws Exception {
- ByteArrayOutputStream out = null;
-
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[2];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
- // alias 1
- keyTest.setCertificateEntry("alias1", cert[0]);
-
- // alias 2
- keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
-
- // alias 3
- keyTest.setCertificateEntry("alias3", cert[1]);
-
- out = new ByteArrayOutputStream();
- keyTest.store(out, pssWord);
- out.close();
-
- return out.toByteArray();
- }
-
- /**
- * @tests java.security.KeyStore#aliases()
- */
- public void test_aliases() throws Exception {
- // Test for method java.util.Enumeration
- // java.security.KeyStore.aliases()
- // NOT COMPATIBLE WITH PCS#12
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[2];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
-
- // KeyStore keyTest =
- // KeyStore.getInstance(KeyStore.getDefaultType());
- // alias 1
- keyTest.setCertificateEntry("alias1", cert[0]);
-
- // alias 2
- keyTest.setCertificateEntry("alias2", cert[0]);
-
- // alias 3
- keyTest.setCertificateEntry("alias3", cert[0]);
-
- // obtaining the aliase
- Enumeration aliase = keyTest.aliases();
- Set alia = new HashSet();
- int i = 0;
- while (aliase.hasMoreElements()) {
- alia.add(aliase.nextElement());
- i++;
- }
- assertTrue("the alias names were returned wrong", i == 3
- && alia.contains("alias1") && alia.contains("alias2")
- && alia.contains("alias3"));
- }
-
- /**
- * @tests java.security.KeyStore#containsAlias(java.lang.String)
- */
- public void test_containsAliasLjava_lang_String() throws Exception {
- // Test for method boolean
- // java.security.KeyStore.containsAlias(java.lang.String)
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[2];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
-
- // alias 1
- keyTest.setCertificateEntry("alias1", cert[0]);
-
- // alias 2
- keyTest.setCertificateEntry("alias2", cert[0]);
-
- assertTrue("alias1 does not exist", keyTest.containsAlias("alias1"));
- assertTrue("alias2 does not exist", keyTest.containsAlias("alias2"));
- assertFalse("alias3 exists", keyTest.containsAlias("alias3"));
- }
-
- /**
- * @tests java.security.KeyStore#getCertificate(java.lang.String)
- */
- public void test_getCertificateLjava_lang_String() throws Exception {
- // Test for method java.security.cert.Certificate
- // java.security.KeyStore.getCertificate(java.lang.String)
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[2];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
-
- // alias 1
- PublicKey pub = cert[0].getPublicKey();
- keyTest.setCertificateEntry("alias1", cert[0]);
-
- java.security.cert.Certificate certRes = keyTest
- .getCertificate("alias1");
- assertTrue("the public key of the certificate from getCertificate() "
- + "did not equal the original certificate", certRes
- .getPublicKey() == pub);
-
- // alias 2
- keyTest.setCertificateEntry("alias2", cert[0]);
-
- // testing for a certificate chain
- java.security.cert.Certificate cert2 = keyTest.getCertificate("alias2");
- assertTrue("the certificate for alias2 is supposed to exist",
- cert2 != null && cert2.equals(cert[0]));
-
- }
-
- /**
- * @tests java.security.KeyStore#getCertificateAlias(java.security.cert.Certificate)
- */
- public void test_getCertificateAliasLjava_security_cert_Certificate()
- throws Exception {
- // Test for method java.lang.String
- // java.security.KeyStore.getCertificateAlias(java.security.cert.Certificate)
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[2];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
-
- // certificate entry
- keyTest.setCertificateEntry("alias1", cert[1]);
- String alias = keyTest.getCertificateAlias(cert[1]);
- assertTrue("certificate entry - the alias returned for this "
- + "certificate was wrong", alias.equals("alias1"));
-
- // key entry
-
- keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
- alias = keyTest.getCertificateAlias(cert[0]);
- assertTrue("key entry - the alias returned for this "
- + "certificate was wrong", alias.equals("alias2"));
-
- // testing case with a nonexistent certificate
- X509Certificate cert2 = (X509Certificate) cf
- .generateCertificate(certArray3);
- String aliasNull = keyTest.getCertificateAlias(cert2);
- assertNull("the alias returned for the nonexist certificate "
- + "was NOT null", aliasNull);
- }
-
- /**
- * @tests java.security.KeyStore#getCertificateChain(java.lang.String)
- */
- public void test_getCertificateChainLjava_lang_String() throws Exception {
- // Test for method java.security.cert.Certificate []
- // java.security.KeyStore.getCertificateChain(java.lang.String)
- // creatCertificate();
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[2];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
-
- // alias 1
- keyTest.setCertificateEntry("alias1", cert[0]);
-
- // alias 2
- keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
-
- java.security.cert.Certificate[] certRes = keyTest
- .getCertificateChain("alias2");
- assertTrue("there are more than two certificate returned "
- + "from getCertificateChain", certRes.length == 2);
- assertTrue("the certificates returned from getCertificateChain "
- + "is not correct", cert[0].getPublicKey() == certRes[0]
- .getPublicKey()
- && cert[1].getPublicKey() == certRes[1].getPublicKey());
- java.security.cert.Certificate[] certResNull = keyTest
- .getCertificateChain("alias1");
- assertNull("the certificate chain returned from "
- + "getCertificateChain is NOT null", certResNull);
- }
-
- /**
- * @tests java.security.KeyStore#getInstance(java.lang.String)
- */
- public void test_getInstanceLjava_lang_String() throws Exception {
- // Test for method java.security.KeyStore
- // java.security.KeyStore.getInstance(java.lang.String)
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- assertTrue("the method getInstance did not obtain "
- + "the correct type", keyTest.getType().equals(
- KeyStore.getDefaultType()));
- }
-
- /**
- * @tests java.security.KeyStore#getInstance(java.lang.String,
- *java.lang.String)
- */
- public void test_getInstanceLjava_lang_StringLjava_lang_String()
- throws Exception {
- // Test for method java.security.KeyStore
- // java.security.KeyStore.getInstance(java.lang.String,
- // java.lang.String)
- KeyStore keyTest = KeyStore.getInstance("PKCS#12/Netscape",
- "TestProvider");
- assertTrue("the method getInstance did not obtain the "
- + "correct provider and type", keyTest.getProvider().getName()
- .equals("TestProvider")
- && keyTest.getType().equals("PKCS#12/Netscape"));
- }
-
- /**
- * @tests java.security.KeyStore#getKey(java.lang.String, char[])
- */
- public void test_getKeyLjava_lang_String$C() throws Exception {
-
- // Test for method java.security.Key
- // java.security.KeyStore.getKey(java.lang.String, char [])
- // creatCertificate();
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[2];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
-
- keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
- PrivateKey returnedKey = (PrivateKey) keyTest.getKey("alias2", pssWord);
- byte[] retB = returnedKey.getEncoded();
- byte[] priB = privateKey.getEncoded();
- boolean equality = Arrays.equals(retB, priB);
- equality &= returnedKey.getAlgorithm()
- .equals(privateKey.getAlgorithm());
- equality &= returnedKey.getFormat().equals(privateKey.getFormat());
- assertTrue("the private key returned from getKey for a "
- + "key entry did not equal the original key", equality);
-
- try {
- keyTest.getKey("alias2", "wrong".toCharArray());
- fail("Should have thrown UnrecoverableKeyException");
- } catch (UnrecoverableKeyException e) {
- // expected
- }
-
- keyTest.setCertificateEntry("alias1", cert[1]);
- assertNull("the private key returned from getKey for "
- + "a certificate entry is not null", keyTest.getKey("alias1",
- pssWord));
- }
-
- /**
- * @tests java.security.KeyStore#getProvider()
- */
- public void test_getProvider() throws Exception {
- // Test for method java.security.Provider
- // java.security.KeyStore.getProvider()
- KeyStore keyTest = KeyStore.getInstance("PKCS#12/Netscape",
- "TestProvider");
- Provider provKeyStore = keyTest.getProvider();
- assertEquals("the provider should be TestProvider", "TestProvider",
- provKeyStore.getName());
- }
-
- /**
- * @tests java.security.KeyStore#getType()
- */
- public void test_getType() throws Exception {
- // Test for method java.lang.String java.security.KeyStore.getType()
- KeyStore keyTest = KeyStore.getInstance("PKCS#12/Netscape",
- "TestProvider");
- assertEquals(
- "type should be PKCS#12/Netscape for provider TestProvider",
- "PKCS#12/Netscape", keyTest.getType());
- }
-
- /**
- * @tests java.security.KeyStore#isCertificateEntry(java.lang.String)
- */
- public void test_isCertificateEntryLjava_lang_String() throws Exception {
- // Test for method boolean
- // java.security.KeyStore.isCertificateEntry(java.lang.String)
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[2];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
- // alias 1
- keyTest.setCertificateEntry("alias1", cert[0]);
-
- // alias 2
- keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
-
- assertTrue("isCertificateEntry method returns false for a certificate",
- keyTest.isCertificateEntry("alias1"));
- assertFalse("isCertificateEntry method returns true for noncertificate",
- keyTest.isCertificateEntry("alias2"));
- }
-
- /**
- * @tests java.security.KeyStore#isKeyEntry(java.lang.String)
- */
- public void test_isKeyEntryLjava_lang_String() throws Exception {
- // Test for method boolean
- // java.security.KeyStore.isKeyEntry(java.lang.String)
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[2];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
- // alias 1
- keyTest.setCertificateEntry("alias1", cert[0]);
-
- // alias 2
- keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
-
- assertTrue("isKeyEntry method returns false for a certificate", keyTest
- .isKeyEntry("alias2"));
- assertFalse("isKeyEntry method returns true for noncertificate", keyTest
- .isKeyEntry("alias1"));
- }
-
- /**
- * @tests java.security.KeyStore#load(java.io.InputStream, char[])
- */
- public void test_loadLjava_io_InputStream$C() throws Exception {
- // Test for method void java.security.KeyStore.load(java.io.InputStream,
- // char [])
- byte[] keyStore = creatCertificate();
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- InputStream in = new ByteArrayInputStream(keyStore);
- keyTest.load(in, pssWord);
- in.close();
- assertTrue("alias1 is not a certificate", keyTest
- .isCertificateEntry("alias1"));
- assertTrue("alias2 is not a keyEntry",
- keyTest.isKeyEntry("alias2"));
- assertTrue("alias3 is not a certificate", keyTest
- .isCertificateEntry("alias3"));
-
- // test with null password
- keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- in = new ByteArrayInputStream(keyStore);
- keyTest.load(in, null);
- in.close();
- assertTrue("alias1 is not a certificate", keyTest
- .isCertificateEntry("alias1"));
- assertTrue("alias2 is not a keyEntry",
- keyTest.isKeyEntry("alias2"));
- assertTrue("alias3 is not a certificate", keyTest
- .isCertificateEntry("alias3"));
-
- keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- InputStream v1in = Support_Resources.getStream("hyts_ks.bks");
- char[] pass = "abcdef".toCharArray();
- keyTest.load(v1in, pass);
- v1in.close();
- keyTest.getKey("mykey", pass);
- }
-
- /**
- * @tests java.security.KeyStore#setCertificateEntry(java.lang.String,
- *java.security.cert.Certificate)
- */
- public void test_setCertificateEntryLjava_lang_StringLjava_security_cert_Certificate()
- throws Exception {
- // Test for method void
- // java.security.KeyStore.setCertificateEntry(java.lang.String,
- // java.security.cert.Certificate)
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert = (X509Certificate) cf
- .generateCertificate(certArray);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
-
- PublicKey pub = cert.getPublicKey();
- keyTest.setCertificateEntry("alias1", cert);
- assertTrue(
- "the entry specified by the alias alias1 is not a certificate",
- keyTest.isCertificateEntry("alias1"));
- java.security.cert.Certificate resultCert = keyTest
- .getCertificate("alias1");
- assertTrue(
- "the public key of the certificate from getCertificate() did not equal the original certificate",
- resultCert.getPublicKey() == pub);
- }
-
- /**
- * @tests java.security.KeyStore#setKeyEntry(java.lang.String, byte[],
- *java.security.cert.Certificate[])
- */
- public void test_setKeyEntryLjava_lang_String$B$Ljava_security_cert_Certificate()
- throws Exception {
-
-// fail("Test hangs - requires a full math implementation ??");
-
- // Test for method void
- // java.security.KeyStore.setKeyEntry(java.lang.String, byte [],
- // java.security.cert.Certificate [])
-
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[2];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
-
- // set the same alias as keyEntry
- keyTest.setKeyEntry("alias2", privateKey.getEncoded(), cert);
- assertTrue("the entry specified by the alias alias2 is not a keyEntry",
- keyTest.isKeyEntry("alias2"));
- }
-
- /**
- * @tests java.security.KeyStore#setKeyEntry(java.lang.String,
- *java.security.Key, char[], java.security.cert.Certificate[])
- */
- public void test_setKeyEntryLjava_lang_StringLjava_security_Key$C$Ljava_security_cert_Certificate()
- throws Exception {
-
- // Test for method void
- // java.security.KeyStore.setKeyEntry(java.lang.String,
- // java.security.Key, char [], java.security.cert.Certificate [])
-
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[2];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
-
- keyTest.setKeyEntry("alias3", privateKey, pssWord, cert);
- assertTrue("the entry specified by the alias alias3 is not a keyEntry",
- keyTest.isKeyEntry("alias3"));
- }
-
- /**
- * @tests java.security.KeyStore#size()
- */
- public void test_size() throws Exception {
- // Test for method int java.security.KeyStore.size()
-
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert[] = new X509Certificate[2];
- cert[0] = (X509Certificate) cf.generateCertificate(certArray);
- cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
- KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
- keyTest.load(null, null);
- // alias 1
- keyTest.setCertificateEntry("alias1", cert[0]);
-
- // alias 2
- keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
-
- // alias 3
- keyTest.setCertificateEntry("alias3", cert[1]);
-
- assertEquals("the size of the keyStore is not 3", 3, keyTest.size());
- }
-
-
- public void test_Constructor() throws Exception {
- KeyStore ks = new MockKeyStore(new MockKeyStoreSpi(), null,
- "MockKeyStore");
- ks.load(null, null);
- ks.store(null, null);
-
- ks = new MockKeyStore(new MockKeyStoreSpi(), null, "MockKeyStore");
- ks.load(null);
- try {
- ks.store(null);
- fail("should throw UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
- // expected.
- }
- }
-
- public class MockKeyStore extends KeyStore {
-
- public MockKeyStore(KeyStoreSpi keyStoreSpi, Provider provider, String type) {
- super(keyStoreSpi, provider, type);
- }
- }
-
- public class MockKeyStoreSpi extends KeyStoreSpi {
-
- @Override
- public Enumeration<String> engineAliases() {
- return null;
- }
-
- @Override
- public boolean engineContainsAlias(String alias) {
- return false;
- }
-
- @Override
- public void engineDeleteEntry(String alias) throws KeyStoreException {
- return;
- }
-
- @Override
- public Certificate engineGetCertificate(String alias) {
- return null;
- }
-
- @Override
- public String engineGetCertificateAlias(Certificate cert) {
- return null;
- }
-
- @Override
- public Certificate[] engineGetCertificateChain(String alias) {
- return null;
- }
-
- @Override
- public Date engineGetCreationDate(String alias) {
- return null;
- }
-
- @Override
- public Key engineGetKey(String alias, char[] password)
- throws NoSuchAlgorithmException, UnrecoverableKeyException {
- return null;
- }
-
- @Override
- public boolean engineIsCertificateEntry(String alias) {
- return false;
- }
-
- @Override
- public boolean engineIsKeyEntry(String alias) {
- return false;
- }
-
- @Override
- public void engineLoad(InputStream stream, char[] password)
- throws IOException, NoSuchAlgorithmException,
- CertificateException {
- return;
- }
-
- @Override
- public void engineSetCertificateEntry(String alias, Certificate cert)
- throws KeyStoreException {
- return;
- }
-
- @Override
- public void engineSetKeyEntry(String alias, Key key, char[] password,
- Certificate[] chain) throws KeyStoreException {
- return;
- }
-
- @Override
- public void engineSetKeyEntry(String alias, byte[] key,
- Certificate[] chain) throws KeyStoreException {
- return;
- }
-
- @Override
- public int engineSize() {
- return 0;
- }
-
- @Override
- public void engineStore(OutputStream stream, char[] password)
- throws IOException, NoSuchAlgorithmException,
- CertificateException {
- return;
- }
-
- }
-
- /**
- * Sets up the fixture, for example, open a network connection. This method
- * is called before a test is executed.
- */
- protected void setUp() throws Exception {
- super.setUp();
- support_TestProvider = new Support_TestProvider();
- Security.addProvider(support_TestProvider);
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(support_TestProvider.getName());
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore3Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore3Test.java
deleted file mode 100644
index 5a5df46..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore3Test.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.security.Key;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.KeyStoreSpi;
-import java.security.NoSuchAlgorithmException;
-import java.security.Provider;
-import java.security.UnrecoverableKeyException;
-import java.security.KeyStore.Builder;
-import java.security.KeyStore.PasswordProtection;
-import java.security.KeyStore.ProtectionParameter;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.util.Date;
-import java.util.Enumeration;
-
-import junit.framework.TestCase;
-
-public class KeyStore3Test extends TestCase {
-
- private KeyStore mockKeyStore;
-
- private KeyPair keyPair;
-
- private Certificate certificate;
-
- public KeyStore3Test() throws Exception {
- KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
- keyPair = keyPairGenerator.generateKeyPair();
-
- String certificateData = "-----BEGIN CERTIFICATE-----\n"
- + "MIICZTCCAdICBQL3AAC2MA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMSAw\n"
- + "HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJl\n"
- + "IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NzAyMjAwMDAwMDBa\n"
- + "Fw05ODAyMjAyMzU5NTlaMIGWMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZv\n"
- + "cm5pYTESMBAGA1UEBxMJUGFsbyBBbHRvMR8wHQYDVQQKExZTdW4gTWljcm9zeXN0\n"
- + "ZW1zLCBJbmMuMSEwHwYDVQQLExhUZXN0IGFuZCBFdmFsdWF0aW9uIE9ubHkxGjAY\n"
- + "BgNVBAMTEWFyZ29uLmVuZy5zdW4uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB\n"
- + "iQKBgQCofmdY+PiUWN01FOzEewf+GaG+lFf132UpzATmYJkA4AEA/juW7jSi+LJk\n"
- + "wJKi5GO4RyZoyimAL/5yIWDV6l1KlvxyKslr0REhMBaD/3Z3EsLTTEf5gVrQS6sT\n"
- + "WMoSZAyzB39kFfsB6oUXNtV8+UKKxSxKbxvhQn267PeCz5VX2QIDAQABMA0GCSqG\n"
- + "SIb3DQEBAgUAA34AXl3at6luiV/7I9MN5CXYoPJYI8Bcdc1hBagJvTMcmlqL2uOZ\n"
- + "H9T5hNMEL9Tk6aI7yZPXcw/xI2K6pOR/FrMp0UwJmdxX7ljV6ZtUZf7pY492UqwC\n"
- + "1777XQ9UEZyrKJvF5ntleeO0ayBqLGVKCWzWZX9YsXCpv47FNLZbupE=\n"
- + "-----END CERTIFICATE-----\n";
-
- ByteArrayInputStream certArray;
- {
- try {
- certArray = new ByteArrayInputStream(certificateData.getBytes("UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e.getMessage());
- }
- }
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- certificate = cf.generateCertificate(certArray);
- }
-
- public void test_load() throws Exception {
- // No exception should be thrown out.
- mockKeyStore.load(null);
- }
-
- public void test_store() throws Exception {
- try {
- mockKeyStore.store(null);
- fail("should throw KeyStoreException: not initialized");
- } catch (KeyStoreException e) {
- // expected
- }
-
- // No exception should be thrown out.
- mockKeyStore.load(null, null);
- mockKeyStore.store(null);
- }
-
- public void test_setKeyEntry_null() throws Exception {
- mockKeyStore.load(null, null);
- // No exception should be thrown out.
- mockKeyStore.setKeyEntry(null, null, null, null);
- }
-
- public void test_setKeyEntry_key_is_null() throws Exception {
- mockKeyStore.load(null, null);
- // No exception should be thrown out.
- mockKeyStore.setKeyEntry("Alias", null, null, new Certificate[] { certificate });
- }
-
- public void test_setKeyEntry_key_is_private() throws Exception {
- mockKeyStore.load(null, null);
- Key key = keyPair.getPrivate();
- try {
- mockKeyStore.setKeyEntry("Alias", key, null, null);
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // expected
- }
-
- try {
- mockKeyStore.setKeyEntry("Alias", key, null,
- new Certificate[0]);
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // expected
- }
-
- mockKeyStore.setKeyEntry("Alias", key, null, new Certificate[] { certificate });
- }
-
- public void test_setKeyEntry_key_is_public() throws Exception {
- mockKeyStore.load(null, null);
- Key key = keyPair.getPublic();
- mockKeyStore.setKeyEntry("Alias1", key, null, null);
- mockKeyStore.setKeyEntry("Alias2", key, null,
- new Certificate[0]);
- mockKeyStore.setKeyEntry("Alias3", key, null, new Certificate[] { certificate });
- }
-
- public void test_setCertificateEntry_null() throws Exception {
- mockKeyStore.load(null, null);
-
- mockKeyStore.setCertificateEntry(null, null);
-
- mockKeyStore.setCertificateEntry(null, certificate);
-
- mockKeyStore.setCertificateEntry("Alias", null);
- }
-
- public void test_store_null() throws Exception {
- mockKeyStore.load(null, null);
- mockKeyStore.store(null, null);
- }
-
- public void test_getKeyStore() throws KeyStoreException,
- NoSuchAlgorithmException, CertificateException,
- FileNotFoundException, IOException {
-
- String alias = "BKS";
- char[] pwd = new char[] { '1', '2', '3', '4', '5', '6' };
- InputStream fis = KeyStore2Test.class
- .getResourceAsStream("builderimpl.ks");
- KeyStore ks = KeyStore.getInstance(alias);
- ks.load(fis, pwd);
- Builder b = Builder.newInstance(ks, new PasswordProtection(pwd));
- KeyStore firstKeyStore = b.getKeyStore();
- ProtectionParameter firstProtParameter = b
- .getProtectionParameter(alias);
- assertSame(firstKeyStore, b.getKeyStore());
- assertSame(firstProtParameter, b.getProtectionParameter(alias));
-
- b = Builder.newInstance(alias, ks.getProvider(),
- new KeyStore.PasswordProtection(pwd));
- firstKeyStore = b.getKeyStore();
- firstProtParameter = b.getProtectionParameter(alias);
- assertNotSame(firstKeyStore, b.getKeyStore());
- assertSame(firstProtParameter, b.getProtectionParameter(alias));
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- mockKeyStore = new MyKeyStore(new MyKeyStoreSpi(), null, "MyKeyStore");
- }
-
- private static class MyKeyStore extends KeyStore {
-
- public MyKeyStore(KeyStoreSpi keyStoreSpi, Provider provider,
- String type) {
- super(keyStoreSpi, provider, type);
- }
- }
-
- private static class MyKeyStoreSpi extends KeyStoreSpi {
-
- public Enumeration<String> engineAliases() {
- return null;
- }
-
- public boolean engineContainsAlias(String arg0) {
- return false;
- }
-
- public void engineDeleteEntry(String arg0) throws KeyStoreException {
- }
-
- public Certificate engineGetCertificate(String arg0) {
- return null;
- }
-
- public String engineGetCertificateAlias(Certificate arg0) {
- return null;
- }
-
- public Certificate[] engineGetCertificateChain(String arg0) {
- return null;
- }
-
- public Date engineGetCreationDate(String arg0) {
- return null;
- }
-
- public Key engineGetKey(String arg0, char[] arg1)
- throws NoSuchAlgorithmException, UnrecoverableKeyException {
- return null;
- }
-
- public boolean engineIsCertificateEntry(String arg0) {
- return false;
- }
-
- public boolean engineIsKeyEntry(String arg0) {
- return false;
- }
-
- public void engineLoad(InputStream arg0, char[] arg1)
- throws IOException, NoSuchAlgorithmException,
- CertificateException {
- return;
- }
-
- public void engineSetCertificateEntry(String arg0, Certificate arg1)
- throws KeyStoreException {
- return;
- }
-
- public void engineSetKeyEntry(String arg0, byte[] arg1,
- Certificate[] arg2) throws KeyStoreException {
- return;
- }
-
- public void engineSetKeyEntry(String arg0, Key arg1, char[] arg2,
- Certificate[] arg3) throws KeyStoreException {
- return;
- }
-
- public int engineSize() {
- return 0;
- }
-
- public void engineStore(KeyStore.LoadStoreParameter param) {
- return;
- }
-
- public void engineStore(OutputStream arg0, char[] arg1)
- throws IOException, NoSuchAlgorithmException,
- CertificateException {
- return;
- }
- }
-
-}
-
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreExceptionTest.java
deleted file mode 100644
index bc9eba6..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreExceptionTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.KeyStoreException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>KeyStoreException</code> class constructors and methods.
- */
-public class KeyStoreExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for KeyStoreExceptionTests.
- *
- * @param arg0
- */
- public KeyStoreExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>KeyStoreException()</code> constructor Assertion:
- * constructs KeyStoreException with no detail message
- */
- public void testKeyStoreException01() {
- KeyStoreException tE = new KeyStoreException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>KeyStoreException(String)</code> constructor Assertion:
- * constructs KeyStoreException with detail message msg. Parameter
- * <code>msg</code> is not null.
- */
- public void testKeyStoreException02() {
- KeyStoreException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new KeyStoreException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>KeyStoreException(String)</code> constructor Assertion:
- * constructs KeyStoreException when <code>msg</code> is null
- */
- public void testKeyStoreException03() {
- String msg = null;
- KeyStoreException tE = new KeyStoreException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>KeyStoreException(Throwable)</code> constructor
- * Assertion: constructs KeyStoreException when <code>cause</code> is null
- */
- public void testKeyStoreException04() {
- Throwable cause = null;
- KeyStoreException tE = new KeyStoreException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>KeyStoreException(Throwable)</code> constructor
- * Assertion: constructs KeyStoreException when <code>cause</code> is not
- * null
- */
- public void testKeyStoreException05() {
- KeyStoreException tE = new KeyStoreException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>KeyStoreException(String, Throwable)</code> constructor
- * Assertion: constructs KeyStoreException when <code>cause</code> is null
- * <code>msg</code> is null
- */
- public void testKeyStoreException06() {
- KeyStoreException tE = new KeyStoreException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>KeyStoreException(String, Throwable)</code> constructor
- * Assertion: constructs KeyStoreException when <code>cause</code> is null
- * <code>msg</code> is not null
- */
- public void testKeyStoreException07() {
- KeyStoreException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new KeyStoreException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>KeyStoreException(String, Throwable)</code> constructor
- * Assertion: constructs KeyStoreException when <code>cause</code> is not
- * null <code>msg</code> is null
- */
- public void testKeyStoreException08() {
- KeyStoreException tE = new KeyStoreException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>KeyStoreException(String, Throwable)</code> constructor
- * Assertion: constructs KeyStoreException when <code>cause</code> is not
- * null <code>msg</code> is not null
- */
- public void testKeyStoreException09() {
- KeyStoreException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new KeyStoreException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStorePrivateKeyEntryTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStorePrivateKeyEntryTest.java
deleted file mode 100644
index 838523a..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStorePrivateKeyEntryTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.ByteArrayInputStream;
-import java.io.UnsupportedEncodingException;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.KeyStore;
-import java.security.PrivateKey;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-
-import junit.framework.TestCase;
-
-public class KeyStorePrivateKeyEntryTest extends TestCase {
-
- public void testGetCertificateChain() throws Exception {
-
- String certificateData = "-----BEGIN CERTIFICATE-----\n"
- + "MIICZTCCAdICBQL3AAC2MA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMSAw\n"
- + "HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJl\n"
- + "IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NzAyMjAwMDAwMDBa\n"
- + "Fw05ODAyMjAyMzU5NTlaMIGWMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZv\n"
- + "cm5pYTESMBAGA1UEBxMJUGFsbyBBbHRvMR8wHQYDVQQKExZTdW4gTWljcm9zeXN0\n"
- + "ZW1zLCBJbmMuMSEwHwYDVQQLExhUZXN0IGFuZCBFdmFsdWF0aW9uIE9ubHkxGjAY\n"
- + "BgNVBAMTEWFyZ29uLmVuZy5zdW4uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB\n"
- + "iQKBgQCofmdY+PiUWN01FOzEewf+GaG+lFf132UpzATmYJkA4AEA/juW7jSi+LJk\n"
- + "wJKi5GO4RyZoyimAL/5yIWDV6l1KlvxyKslr0REhMBaD/3Z3EsLTTEf5gVrQS6sT\n"
- + "WMoSZAyzB39kFfsB6oUXNtV8+UKKxSxKbxvhQn267PeCz5VX2QIDAQABMA0GCSqG\n"
- + "SIb3DQEBAgUAA34AXl3at6luiV/7I9MN5CXYoPJYI8Bcdc1hBagJvTMcmlqL2uOZ\n"
- + "H9T5hNMEL9Tk6aI7yZPXcw/xI2K6pOR/FrMp0UwJmdxX7ljV6ZtUZf7pY492UqwC\n"
- + "1777XQ9UEZyrKJvF5ntleeO0ayBqLGVKCWzWZX9YsXCpv47FNLZbupE=\n"
- + "-----END CERTIFICATE-----\n";
-
- ByteArrayInputStream certArray;
- {
- try {
- certArray = new ByteArrayInputStream(
- certificateData.getBytes("UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e.getMessage());
- }
- }
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- Certificate certificate = cf.generateCertificate(certArray);
- assertTrue(certificate instanceof X509Certificate);
-
- String algorithm = certificate.getPublicKey().getAlgorithm();
- KeyPairGenerator keyPairGenerator = KeyPairGenerator
- .getInstance(algorithm);
- KeyPair keyPair = keyPairGenerator.generateKeyPair();
- PrivateKey privateKey = keyPair.getPrivate();
-
- // If all the certificate in the chain is X509Certificate,
- // KeyStore.PrivateKeyEntry will return a X509Certificate array.
- KeyStore.PrivateKeyEntry privateKeyEntry = new KeyStore.PrivateKeyEntry(
- privateKey, new Certificate[] { certificate });
- Certificate[] chain = privateKeyEntry.getCertificateChain();
- assertTrue(chain instanceof X509Certificate[]);
-
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java
deleted file mode 100644
index fa3fb89..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.KeyStoreSpi;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableEntryException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.MyKeyStoreSpi;
-import org.apache.harmony.security.tests.support.MyLoadStoreParams;
-import org.apache.harmony.security.tests.support.cert.MyCertificate;
-
-
-/**
- * Tests for <code>KeyStoreSpi</code> constructor and methods
- */
-
-public class KeyStoreSpiTest extends TestCase {
-
- /**
- * Constructor for KeyStoreSpi.
- *
- * @param arg0
- */
- public KeyStoreSpiTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>KeyStoreSpi()</code> constructor
- * and the following methods:
- * <code>engineLoad(KeyStore.LoadStoreParameter param)</code>
- * <code>engineStore(KeyStore.LoadStoreParameter param)</code>
- * <code>engineGetEntry(String alias, KeyStore.ProtectionParameter param)</code>
- * <code>engineSetEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter param)</code>
- * Assertions:
- * creates new KeyStoreSpi object;
- * engineGetEntry(..) returns null entry;
- * engineStore(..) throws UnexpectedOperationException;
- * engineSetEntry(..) throws KeyStoreException or NullPointerException
- */
- public void testKeyStoteSpi01() throws IOException,
- NoSuchAlgorithmException, CertificateException,
- UnrecoverableEntryException, KeyStoreException {
- KeyStoreSpi ksSpi = new MyKeyStoreSpi();
-
- tmpEntry entry = new tmpEntry();
- tmpProtection pPar = new tmpProtection();
-
- try {
- ksSpi.engineStore(null);
- } catch (UnsupportedOperationException e) {
- }
- assertNull("Not null entry", ksSpi.engineGetEntry("aaa", null));
- assertNull("Not null entry", ksSpi.engineGetEntry(null, pPar));
- assertNull("Not null entry", ksSpi.engineGetEntry("aaa", pPar));
-
- try {
- ksSpi.engineSetEntry("", null, null);
- fail("KeyStoreException or NullPointerException must be thrown");
- } catch (KeyStoreException e) {
- } catch (NullPointerException e) {
- }
-
- try {
- ksSpi.engineSetEntry("", new KeyStore.TrustedCertificateEntry(
- new MyCertificate("type", new byte[0])), null);
- fail("KeyStoreException must be thrown");
- } catch (KeyStoreException e) {
- }
-
- try {
- ksSpi.engineSetEntry("aaa", entry, null);
- fail("KeyStoreException must be thrown");
- } catch (KeyStoreException e) {
- }
- }
-
-
- /**
- * Test for <code>KeyStoreSpi()</code> constructor
- * and abstract engine methods.
- * Assertion: creates new KeyStoreSpi object.
- */
- public void testKeyStoteSpi02() throws NoSuchAlgorithmException,
- UnrecoverableKeyException, CertificateException {
- KeyStoreSpi ksSpi = new MyKeyStoreSpi();
- assertNull("engineGetKey(..) must return null", ksSpi.engineGetKey("",
- new char[0]));
- assertNull("engineGetCertificateChain(..) must return null", ksSpi
- .engineGetCertificateChain(""));
- assertNull("engineGetCertificate(..) must return null", ksSpi
- .engineGetCertificate(""));
- assertEquals("engineGetCreationDate(..) must return Date(0)",
- new Date(0), ksSpi.engineGetCreationDate(""));
- try {
- ksSpi.engineSetKeyEntry("", null, new char[0], new Certificate[0]);
- fail("KeyStoreException must be thrown from engineSetKeyEntry(..)");
- } catch (KeyStoreException e) {
- }
- try {
- ksSpi.engineSetKeyEntry("", new byte[0], new Certificate[0]);
- fail("KeyStoreException must be thrown from engineSetKeyEntry(..)");
- } catch (KeyStoreException e) {
- }
- try {
- ksSpi.engineSetCertificateEntry("", null);
- fail("KeyStoreException must be thrown from engineSetCertificateEntry(..)");
- } catch (KeyStoreException e) {
- }
- try {
- ksSpi.engineDeleteEntry("");
- fail("KeyStoreException must be thrown from engineDeleteEntry(..)");
- } catch (KeyStoreException e) {
- }
- assertNull("engineAliases() must return null", ksSpi.engineAliases());
- assertFalse("engineContainsAlias(..) must return false", ksSpi
- .engineContainsAlias(""));
- assertEquals("engineSize() must return 0", 0, ksSpi.engineSize());
- try {
- ksSpi.engineStore(null, null);
- fail("IOException must be thrown");
- } catch (IOException e) {
- }
- }
-
- /**
- * @tests java.security.KeyStoreSpi#engineLoad(KeyStore.LoadStoreParameter)
- */
- public void test_engineLoadLjava_security_KeyStore_LoadStoreParameter()
- throws Exception {
-
- final String msg = "error";
-
- KeyStoreSpi ksSpi = new MyKeyStoreSpi() {
- public void engineLoad(InputStream stream, char[] password) {
- assertNull(stream);
- assertNull(password);
- throw new RuntimeException(msg);
- }
- };
- try {
- ksSpi.engineLoad(null);
- fail("Should throw exception");
- } catch (RuntimeException e) {
- assertSame(msg, e.getMessage());
- }
-
- // test: protection parameter is null
- try {
- ksSpi.engineLoad(new MyLoadStoreParams(null));
- fail("No expected UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
- }
-
- // test: protection parameter is not instanceof
- // PasswordProtection or CallbackHandlerProtection
- try {
- ksSpi.engineLoad(new MyLoadStoreParams(new tmpProtection()));
- fail("No expected UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
- }
- }
-
-}
-
-/**
- * Additional class implements KeyStore.Entry interface
- */
-class tmpEntry implements KeyStore.Entry {
-}
-
-class tmpProtection implements KeyStore.ProtectionParameter {
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java
deleted file mode 100644
index b13a12c..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.SignatureException;
-import java.security.Principal;
-import java.security.PublicKey;
-import java.security.InvalidKeyException;
-import java.security.NoSuchProviderException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateExpiredException;
-import java.security.cert.CertificateNotYetValidException;
-import java.security.cert.X509Certificate;
-import java.util.Date;
-import java.util.Set;
-import java.math.BigInteger;
-
-import javax.crypto.KeyGenerator;
-import javax.crypto.SecretKey;
-
-import org.apache.harmony.security.tests.support.KeyStoreTestSupport;
-import org.apache.harmony.security.tests.support.MyLoadStoreParams;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyStore</code> constructor and methods
- */
-
-public class KeyStoreTest extends TestCase {
-
- private static final String KeyStoreProviderClass = "org.apache.harmony.security.tests.support.MyKeyStore";
-
- private static final String defaultType = "KeyStore";
-
- public static boolean KSSupported = false;
-
- public static String defaultProviderName = null;
-
- public static Provider defaultProvider = null;
-
- private static String NotSupportMsg = "Default KeyStore type is not supported";
-
- Provider mProv;
-
- public KeyStore[] createKS() throws Exception {
- assertTrue(NotSupportMsg, KSSupported);
- KeyStore[] kpg = new KeyStore[3];
-
- kpg[0] = KeyStore.getInstance(defaultType);
- kpg[1] = KeyStore.getInstance(defaultType, defaultProvider);
- kpg[2] = KeyStore.getInstance(defaultType, defaultProviderName);
- return kpg;
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyKSProvider",
- "Testing provider", KeyStoreTestSupport.srvKeyStore.concat(".")
- .concat(defaultType), KeyStoreProviderClass);
- Security.insertProviderAt(mProv, 2);
- defaultProvider = SpiEngUtils.isSupport(defaultType,
- KeyStoreTestSupport.srvKeyStore);
- KSSupported = (defaultProvider != null);
- defaultProviderName = (KSSupported ? defaultProvider.getName() : null);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- /**
- * Test for <code>load(LoadStoreParameter param)</code>
- * <code>store(LoadStoreParameter param)</code>
- * methods
- * Assertions: throw IllegalArgumentException if param is null;
- */
- public void testLoadStore02() throws Exception {
- assertTrue(NotSupportMsg, KSSupported);
-
- KeyStore[] kss = createKS();
- assertNotNull("KeyStore objects were not created", kss);
-
- for (int i = 0; i < kss.length; i++) {
- try {
- kss[i].load(null);
- fail("IOException or IllegalArgumentException should be thrown for null parameter");
- } catch (IOException e) {
- } catch (IllegalArgumentException e) {
- }
- kss[i].load(null, null);
- try {
- kss[i].store(null);
- fail("IOException or IllegalArgumentException should be thrown for null parameter");
- } catch (IOException e) {
- } catch (IllegalArgumentException e) {
- }
- }
- KeyStore.LoadStoreParameter lParam = new MyLoadStoreParams(
- new KeyStore.PasswordProtection(new char[0]));
- for (int i = 0; i < kss.length; i++) {
- kss[i].load(lParam);
- assertEquals("Incorrect result", kss[i].size(), 0);
- kss[i].store(lParam);
- }
- }
-
-
- /**
- * Test for <code>setKeyEntry(String alias, byte[] key, Certificate[] chain)</code>
- * method
- * Assertion: stores KeyEntry.
- */
- public void testSetKeyEntry() throws Exception {
- assertTrue(NotSupportMsg, KSSupported);
-
- KeyStore[] kss = createKS();
- assertNotNull("KeyStore objects were not created", kss);
- byte[] kk = { (byte) 1, (byte) 2, (byte) 127, (byte) 77 };
- String alias = "keyEntry";
- char[] pwd = new char[0];
- byte[] res;
- Certificate certs[] = {
- new KeyStoreTestSupport.MCertificate(alias, kk),
- new KeyStoreTestSupport.MCertificate(alias, kk) };
- for (int i = 0; i < kss.length; i++) {
- kss[i].load(null, null);
- try {
- kss[i].setKeyEntry("proba", null, null);
- fail("KeyStoreException must be thrown");
- } catch (KeyStoreException e) {
- }
- kss[i].setKeyEntry(alias, kk, certs);
- res = kss[i].getKey(alias, pwd).getEncoded();
- assertEquals(kk.length, res.length);
- for (int j = 0; j < res.length; j++) {
- assertEquals(res[j], kk[j]);
- }
- assertEquals(kss[i].getCertificateChain(alias).length, certs.length);
- kss[i].setKeyEntry(alias, kk, null);
- res = kss[i].getKey(alias, pwd).getEncoded();
- assertEquals(kk.length, res.length);
- for (int j = 0; j < res.length; j++) {
- assertEquals(res[j], kk[j]);
- }
- assertNull(kss[i].getCertificateChain(alias));
- }
- }
-
- /**
- * Test for <code>getDefaultType()</code> method Assertion: returns
- * default security key store type or "jks" string
- */
- public void testKeyStore01() {
- String propName = "keystore.type";
- String defKSType = Security.getProperty(propName);
- String dType = KeyStore.getDefaultType();
- String resType = defKSType;
- if (resType == null) {
- resType = defaultType;
- }
- assertNotNull("Default type have not be null", dType);
- assertEquals("Incorrect default type", dType, resType);
-
- if (defKSType == null) {
- Security.setProperty(propName, defaultType);
- dType = KeyStore.getDefaultType();
- resType = Security.getProperty(propName);
- assertNotNull("Incorrect default type", resType);
- assertNotNull("Default type have not be null", dType);
- assertEquals("Incorrect default type", dType, resType);
- }
- }
-
- /**
- * Test for <code>getInstance(String type)</code> method
- * Assertion:
- * throws NullPointerException when type is null
- * throws KeyStoreException when type is not available
- */
- public void testKeyStore02() throws KeyStoreException {
- String[] invalidValues = SpiEngUtils.invalidValues;
- try {
- KeyStore.getInstance(null);
- fail("NullPointerException must be thrown when type is null");
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyStore.getInstance(invalidValues[i]);
- fail("KeyStoreException must be thrown (type: ".concat(
- invalidValues[i]).concat(" )"));
- } catch (KeyStoreException e) {
- }
- }
- }
-
- public void testKeyStorePPGetPassword() {
- // Regression for HARMONY-1539
- // no exception expected
- assertNull(new KeyStore.PasswordProtection(null).getPassword());
- char[] password = new char[] { 'a', 'b', 'c' };
- KeyStore.PasswordProtection pp = new KeyStore.PasswordProtection(password);
- assertNotSame(pp.getPassword(), password);
- assertSame(pp.getPassword(), pp.getPassword());
-
- }
-
-
- /*
- * @tests java.security.KeyStoreSpi.engineEntryInstanceOf(String, Class<? extends Entry>)
- */
- public void testEngineEntryInstanceOf() throws Exception {
- //Regression for HARMONY-615
-
- // create a KeyStore
- KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
- keyStore.load(null, "pwd".toCharArray());
-
- // generate a key
- KeyGenerator keyGen = KeyGenerator.getInstance("DES");
- keyGen.init(56);
- SecretKey secretKey = keyGen.generateKey();
-
- // put the key into keystore
- String alias = "alias";
- keyStore.setKeyEntry(alias, secretKey, "pwd".toCharArray(), null);
-
- // check if it is a secret key
- assertTrue(keyStore.entryInstanceOf(alias,
- KeyStore.SecretKeyEntry.class));
-
- // check if it is NOT a private key
- assertFalse(keyStore.entryInstanceOf(alias,
- KeyStore.PrivateKeyEntry.class));
- }
-
- /**
- * @tests java.security.KeyStore.TrustedCertificateEntry.toString()
- */
- public void testKeyStoreTCToString() {
- // Regression for HARMONY-1542
- // no exception expected
- class TestX509Certificate extends X509Certificate {
- private static final long serialVersionUID = 1L;
-
- public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException {
- }
-
- public void checkValidity(Date p) throws CertificateExpiredException, CertificateNotYetValidException {
- }
-
- public int getVersion() {
- return 0;
- }
-
- public BigInteger getSerialNumber() {
- return null;
- }
-
- public Principal getIssuerDN() {
- return null;
- }
-
- public Principal getSubjectDN() {
- return null;
- }
-
- public Date getNotBefore() {
- return null;
- }
-
- public Date getNotAfter() {
- return null;
- }
-
- public byte[] getTBSCertificate() throws CertificateEncodingException {
- return null;
- }
-
- public byte[] getSignature() {
- return null;
- }
-
- public String getSigAlgName() {
- return null;
- }
-
- public String getSigAlgOID() {
- return null;
- }
-
- public byte[] getSigAlgParams() {
- return null;
- }
-
- public boolean[] getIssuerUniqueID() {
- return null;
- }
-
- public boolean[] getSubjectUniqueID() {
- return null;
- }
-
- public boolean[] getKeyUsage() {
- return null;
- }
-
- public int getBasicConstraints() {
- return 0;
- }
-
- public byte[] getEncoded() throws CertificateEncodingException {
- return null;
- }
-
- public void verify(PublicKey p)
- throws CertificateException,
- NoSuchAlgorithmException,
- InvalidKeyException,
- NoSuchProviderException,
- SignatureException {
- }
-
- public void verify(PublicKey p0, String p1)
- throws CertificateException,
- NoSuchAlgorithmException,
- InvalidKeyException,
- NoSuchProviderException,
- SignatureException {
- }
-
- public String toString() {
- return null;
- }
-
- public PublicKey getPublicKey() {
- return null;
- }
-
- public boolean hasUnsupportedCriticalExtension() {
- return false;
- }
-
- public Set getCriticalExtensionOIDs() {
- return null;
- }
-
- public Set getNonCriticalExtensionOIDs() {
- return null;
- }
-
- public byte[] getExtensionValue(String p) {
- return null;
- }
- }
- assertNotNull(new KeyStore.TrustedCertificateEntry(new TestX509Certificate()).toString());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyTest.java
deleted file mode 100644
index c9a2560..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.Key;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>Key</code> class field
- */
-
-public class KeyTest extends TestCase {
-
- /**
- * Constructor for KeyTest.
- *
- * @param arg0
- */
- public KeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkKey mk = new checkKey();
- assertEquals("Incorrect serialVersionUID", mk.getSerVerUID(), //Key.serialVersionUID,
- 6603384152749567654L);
- }
-
- public class checkKey implements Key {
- public String getAlgorithm() {
- return "Key";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
- }
-
-}
-
-
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest1Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest1Test.java
deleted file mode 100644
index 084fa24..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest1Test.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.nio.ByteBuffer;
-import java.security.DigestException;
-import java.security.MessageDigest;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.MyMessageDigest1;
-
-/**
- * Tests for <code>MessageDigest</code> constructor and methods
- */
-public class MessageDigest1Test extends TestCase {
-
- /**
- * @tests java.security.MessageDigest#reset()
- */
- public void test_reset() {
- MyMessageDigest1 md = new MyMessageDigest1("ABC");
- md.reset();
- assertTrue(md.runEngineReset);
- }
-
- /**
- * @tests java.security.MessageDigest#update(byte)
- */
- public void test_updateLB() {
- MyMessageDigest1 md = new MyMessageDigest1("ABC");
- md.update((byte) 1);
- assertTrue(md.runEngineUpdate1);
- }
-
- /**
- * @tests java.security.MessageDigest#update(byte[], int, int)
- */
- public void test_updateLB$LILI() {
- MyMessageDigest1 md = new MyMessageDigest1("ABC");
- final byte[] bytes = { 1, 2, 3, 4, 5 };
- md.update(bytes, 1, 2);
- assertTrue(md.runEngineUpdate2);
-
- // Regression for HARMONY-1120
- try {
- // buf == null
- md.update(null, 0, 1);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- try {
- // offset + len > buf.length
- md.update(bytes, 0, bytes.length + 1);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- try {
- // offset + len > Integer.MAX_VALUE
- md.update(bytes, Integer.MAX_VALUE, 1);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- // offset<0 and len<0 are passed to provider
- final int offset = -1;
- final int len = -1;
- md = new MyMessageDigest1("ABC") {
- @Override
- public void engineUpdate(byte[] arg0, int arg1, int arg2) {
- assertSame("buf", bytes, arg0);
- assertEquals("offset", offset, arg1);
- assertEquals("len", len, arg2);
- runEngineUpdate2 = true;
- }
- };
- md.update(bytes, offset, len);
- assertTrue(md.runEngineUpdate2);
- }
-
- /**
- * @tests java.security.MessageDigest#update(byte[])
- */
- public void test_updateLB$() {
- MyMessageDigest1 md = new MyMessageDigest1("ABC");
- byte[] b = { 1, 2, 3, 4, 5 };
- md.update(b);
- assertTrue(md.runEngineUpdate2);
- }
-
- /**
- * @tests java.security.MessageDigest#update(ByteBuffer)
- */
- public void test_updateLjava_nio_ByteBuffer() {
- MyMessageDigest1 md = new MyMessageDigest1("ABC");
- byte[] b = { 1, 2, 3, 4, 5 };
- ByteBuffer byteBuffer = ByteBuffer.wrap(b);
-
- int limit = byteBuffer.limit();
- md.update(byteBuffer);
- assertTrue(md.runEngineUpdate2);
- assertEquals(byteBuffer.limit(), byteBuffer.position());
- assertEquals(limit, byteBuffer.limit());
- }
-
- /**
- * @tests java.security.MessageDigest#digest()
- */
- public void test_digest() {
- MyMessageDigest1 md = new MyMessageDigest1("ABC");
- assertEquals("incorrect result", 0, md.digest().length);
- assertTrue(md.runEngineDigest);
- }
-
- /**
- * @tests java.security.MessageDigest#digest(byte[])
- */
- public void test_digestLB$() {
- MyMessageDigest1 md = new MyMessageDigest1("ABC");
- byte[] b = { 1, 2, 3, 4, 5 };
- assertEquals("incorrect result", 0, md.digest(b).length);
- assertTrue(md.runEngineDigest);
- }
-
- /**
- * @tests java.security.MessageDigest#digest(byte[], int, int)
- */
- public void test_digestLB$LILI() throws Exception {
- MyMessageDigest1 md = new MyMessageDigest1("ABC");
- byte[] b = { 1, 2, 3, 4, 5 };
- assertEquals("incorrect result", 0, md.digest(b, 2, 3));
- assertTrue("digest failed", md.runEngineDigest);
-
- // Regression for Harmony-1148
- md = new MyMessageDigest1();
- final byte[] bytes = new byte[] { 2, 4, 1 };
- try {
- // buf == null
- md.digest(null, 0, 1);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- try {
- // offset + len > buf.length
- md.digest(bytes, 0, bytes.length + 1);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- try {
- // offset + len > Integer.MAX_VALUE
- md.digest(bytes, Integer.MAX_VALUE, 1);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- // offset<0 and len<0 are passed to provider
- final int offset = -1;
- final int len = -1;
- final int status = 33;
- md = new MyMessageDigest1("ABC") {
- @Override
- public int engineDigest(byte[] arg0, int arg1, int arg2) {
- assertSame("buf", bytes, arg0);
- assertEquals("offset", offset, arg1);
- assertEquals("len", len, arg2);
- return status;
- }
- };
- assertEquals("returned status", status, md.digest(bytes, offset, len));
- }
-
- /**
- * @tests java.security.MessageDigest#isEqual(byte[], byte[])
- */
- public void test_isEqualLB$LB$() {
- byte[] b1 = { 1, 2, 3, 4 };
- byte[] b2 = { 1, 2, 3, 4, 5 };
- byte[] b3 = { 1, 3, 3, 4 };
- byte[] b4 = { 1, 2, 3, 4 };
-
- assertTrue(MessageDigest.isEqual(b1, b4));
- assertFalse(MessageDigest.isEqual(b1, b2));
- assertFalse(MessageDigest.isEqual(b1, b3));
- }
-
- /**
- * @tests java.security.MessageDigest#getAlgorithm()
- */
- public void test_getAlgorithm() {
- MyMessageDigest1 md = new MyMessageDigest1("ABC");
- assertEquals("ABC", md.getAlgorithm());
- }
-
- /**
- * @tests java.security.MessageDigest#getProvider()
- */
- public void test_getProvider() {
- MyMessageDigest1 md = new MyMessageDigest1("ABC");
- assertNull(md.getProvider());
- }
-
- /**
- * @tests java.security.MessageDigest#getDigestLength()
- */
- public void test_getDigestLength() {
- MyMessageDigest1 md = new MyMessageDigest1("ABC");
- assertEquals(0, md.getDigestLength());
- }
-
- /**
- * Tests SHA MessageDigest provider
- */
- public void testSHAProvider() throws Exception {
- MessageDigest md = MessageDigest.getInstance("SHA");
- byte[] bytes = new byte[] { 1, 1, 1, 1, 1 };
-
- // Regression for HARMONY-1120
- // testing combination with provider
- try {
- // offset < 0
- md.update(bytes, -1, 1);
- fail("No expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
- }
- // No exception for len < 0
- md.update(bytes, 1, -1);
-
- //Regression for Harmony-1148
- md = MessageDigest.getInstance("SHA");
- try {
- // offset < 0
- md.digest(bytes, 0, -1);
- fail("No expected DigestException");
- } catch (DigestException e) {
- }
- try {
- // len < 0
- md.digest(bytes, -1, 0);
- fail("No expected DigestException");
- } catch (DigestException e) {
- }
-
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java
deleted file mode 100644
index ea91454..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.security.DigestException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.Vector;
-
-public class MessageDigest2Test extends junit.framework.TestCase {
-
- private static final String MESSAGEDIGEST_ID = "MessageDigest.";
-
- private String[] digestAlgs = null;
-
- private String providerName = null;
-
- private static final byte[] AR1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
-
- private static final byte[] AR2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
-
- private static final String MESSAGE = "abc";
-
- private static final byte[] MESSAGE_DIGEST = { -87, -103, 62, 54, 71, 6,
- -127, 106, -70, 62, 37, 113, 120, 80, -62, 108, -100, -48, -40,
- -99, };
-
- private static final byte[] MESSAGE_DIGEST_63_As = { 3, -16, -97, 91, 21,
- -118, 122, -116, -38, -39, 32, -67, -36, 41, -72, 28, 24, -91, 81,
- -11, };
-
- private static final byte[] MESSAGE_DIGEST_64_As = { 0, -104, -70, -126,
- 75, 92, 22, 66, 123, -41, -95, 18, 42, 90, 68, 42, 37, -20, 100,
- 77, };
-
- private static final byte[] MESSAGE_DIGEST_65_As = { 17, 101, 83, 38, -57,
- 8, -41, 3, 25, -66, 38, 16, -24, -91, 125, -102, 91, -107, -99, 59, };
-
- /**
- * @tests java.security.MessageDigest#clone()
- */
- public void test_clone() {
- for (int i = 0; i < digestAlgs.length; i++) {
- try {
- MessageDigest d1 = MessageDigest.getInstance(digestAlgs[i],
- providerName);
- for (byte b = 0; b < 84; b++) {
- d1.update(b);
- }
-
- MessageDigest d2 = (MessageDigest) d1.clone();
- d1.update((byte) 1);
- d2.update((byte) 1);
-
- assertTrue("cloned hash differs from original for algorithm "
- + digestAlgs[i], MessageDigest.isEqual(d1.digest(), d2
- .digest()));
- } catch (CloneNotSupportedException e) {
- // Expected - a Signature may not be cloneable
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + digestAlgs[i]);
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find provider " + providerName);
- }
- }
- }
-
- private static final byte[] SHA_DATA_2 = { 70, -54, 124, 120, -29, 57, 56,
- 119, -108, -54, -97, -76, -97, -50, -63, -73, 2, 85, -53, -79, };
-
- private void testSerializationSHA_DATA_2(MessageDigest sha) {
- try {
- sha.reset();
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- DataOutputStream output = new DataOutputStream(out);
- // -----------------------------------------------------------------------
-
- // Made up data
- output
- .writeUTF("tests.api.java.security.MessageDigestTest$InitializerFieldsTest3");
- output.writeInt(0); // class modifiers
- output.writeUTF("java.io.Serializable"); // interfaces
-
- // Fields
- output.writeUTF("sub_toBeNotSerialized"); // name
- output.writeInt(9); // modifiers
- output.writeUTF("Ljava/lang/String;"); // signature
-
- output.writeUTF("sub_toBeNotSerialized2"); // name
- output.writeInt(9); // modifiers
- output.writeUTF("Ljava/lang/String;"); // signature
-
- output.writeUTF("sub_toBeSerialized"); // name
- output.writeInt(1); // modifiers
- output.writeUTF("Ljava/lang/String;"); // signature
-
- output.writeUTF("sub_toBeSerialized3"); // name
- output.writeInt(1); // modifiers
- output.writeUTF("Ljava/lang/String;"); // signature
-
- output.writeUTF("sub_toBeSerialized4"); // name
- output.writeInt(1); // modifiers
- output.writeUTF("Ljava/lang/String;"); // signature
-
- output.writeUTF("sub_toBeSerialized5"); // name
- output.writeInt(1); // modifiers
- output.writeUTF("Ljava/lang/String;"); // signature
-
- // clinit
- output.writeUTF("<clinit>"); // name
- output.writeInt(8); // modifiers
- output.writeUTF("()V"); // signature
-
- // constructors
- output.writeUTF("<init>"); // name
- output.writeInt(0); // modifiers
- output.writeUTF("()V"); // signature
-
- // methods
- output.writeUTF("equals"); // name
- output.writeInt(1); // modifiers
- output.writeUTF("(Ljava.lang.Object;)Z"); // signature
-
- // -----------------------------------------------------------------------
-
- output.flush();
-
- byte[] data = out.toByteArray();
- byte[] hash = sha.digest(data);
- assertTrue("SHA_DATA_2 NOT ok", Arrays.equals(hash, SHA_DATA_2));
- } catch (IOException e) {
- fail("SHA_DATA_2 NOT ok");
- }
- }
-
- private static final byte[] SHA_DATA_1 = { 90, 36, 111, 106, -32, 38, 4,
- 126, 21, -51, 107, 45, -64, -68, -109, 112, -31, -46, 34, 115, };
-
- private void testSerializationSHA_DATA_1(MessageDigest sha) {
- try {
- sha.reset();
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- DataOutputStream output = new DataOutputStream(out);
- // -----------------------------------------------------------------------
-
- // Made up data
- output
- .writeUTF("tests.api.java.security.MessageDigestTest$OptionalDataNotRead");
- // name
- output.writeInt(0); // class modifiers
- output.writeUTF("java.io.Serializable"); // interfaces
-
- // Fields
- output.writeUTF("class$0"); // name
- output.writeInt(8); // modifiers
- output.writeUTF("Ljava/lang/Class;"); // signature
-
- output.writeUTF("field1"); // name
- output.writeInt(2); // modifiers
- output.writeUTF("I"); // signature
-
- output.writeUTF("field2"); // name
- output.writeInt(2); // modifiers
- output.writeUTF("I"); // signature
-
- // clinit
- output.writeUTF("<clinit>"); // name
- output.writeInt(8); // modifiers
- output.writeUTF("()V"); // signature
-
- // constructors
- output.writeUTF("<init>"); // name
- output.writeInt(1); // modifiers
- output.writeUTF("()V"); // signature
- // -----------------------------------------------------------------------
-
- output.flush();
- byte[] data = out.toByteArray();
- byte[] hash = sha.digest(data);
- assertTrue("SHA_DATA_1 NOT ok", Arrays.equals(hash, SHA_DATA_1));
- } catch (IOException e) {
- fail("SHA_DATA_1 NOT ok");
- }
- }
-
- /**
- * @throws UnsupportedEncodingException
- * @tests java.security.MessageDigest#digest()
- */
- public void test_digest() throws UnsupportedEncodingException {
- MessageDigest sha = null;
- try {
- sha = MessageDigest.getInstance("SHA");
- assertNotNull(sha);
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm");
- }
- sha.update(MESSAGE.getBytes("UTF-8"));
- byte[] digest = sha.digest();
- assertTrue("bug in SHA", MessageDigest.isEqual(digest, MESSAGE_DIGEST));
-
- sha.reset();
- for (int i = 0; i < 63; i++) {
- // just under buffer capacity
- sha.update((byte) 'a');
- }
- digest = sha.digest();
- assertTrue("bug in SHA", MessageDigest.isEqual(digest,
- MESSAGE_DIGEST_63_As));
-
- sha.reset();
- for (int i = 0; i < 64; i++) {
- // exact SHA buffer capacity
- sha.update((byte) 'a');
- }
- digest = sha.digest();
- assertTrue("bug in SHA", MessageDigest.isEqual(digest,
- MESSAGE_DIGEST_64_As));
-
- sha.reset();
- for (int i = 0; i < 65; i++) {
- // just above SHA buffer capacity
- sha.update((byte) 'a');
- }
- digest = sha.digest();
- assertTrue("bug in SHA", MessageDigest.isEqual(digest,
- MESSAGE_DIGEST_65_As));
-
- testSerializationSHA_DATA_1(sha);
- testSerializationSHA_DATA_2(sha);
- }
-
- /**
- * @tests java.security.MessageDigest#digest(byte[])
- */
- public void test_digest$B() {
- for (int i = 0; i < digestAlgs.length; i++) {
- try {
- MessageDigest digest = MessageDigest.getInstance(digestAlgs[i],
- providerName);
- assertNotNull(digest);
- digest.digest(AR1);
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + digestAlgs[i]);
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find provider " + providerName);
- }
- }
- }
-
- /**
- * @tests java.security.MessageDigest#digest(byte[], int, int)
- */
- public void test_digest$BII() {
- for (int i = 0; i < digestAlgs.length; i++) {
- try {
- MessageDigest digest = MessageDigest.getInstance(digestAlgs[i],
- providerName);
- assertNotNull(digest);
- int len = digest.getDigestLength();
- byte[] digestBytes = new byte[len];
- digest.digest(digestBytes, 0, digestBytes.length);
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + digestAlgs[i]);
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find provider " + providerName);
- } catch (DigestException e) {
- fail("digest caused exception for algorithm " + digestAlgs[i]
- + " : " + e);
- }
- }
- try {
- MessageDigest.getInstance("SHA").digest(new byte[] { }, Integer.MAX_VALUE, 755);
- } catch (NoSuchAlgorithmException e) {
- //allowed
- } catch (DigestException e) {
- //allowed
- } catch (IllegalArgumentException e) {
- //expected
- }
- }
-
- /**
- * @tests java.security.MessageDigest#update(byte[], int, int)
- */
- public void test_update$BII() {
- try {
- MessageDigest.getInstance("SHA").update(new byte[] { }, Integer.MAX_VALUE, Integer.MAX_VALUE);
- } catch (NoSuchAlgorithmException e) {
- //allowed
- } catch (IllegalArgumentException e) {
- //expected
- }
- }
-
- /**
- * @tests java.security.MessageDigest#getAlgorithm()
- */
- public void test_getAlgorithm() {
- for (int i = 0; i < digestAlgs.length; i++) {
- try {
- String alg = MessageDigest.getInstance(digestAlgs[i],
- providerName).getAlgorithm();
- assertTrue("getAlgorithm ok", alg.equals(digestAlgs[i]));
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + digestAlgs[i]);
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find provider " + providerName);
- }
- }
- }
-
- /**
- * @tests java.security.MessageDigest#getDigestLength()
- */
- public void test_getDigestLength() {
- for (int i = 0; i < digestAlgs.length; i++) {
- try {
- int len = MessageDigest
- .getInstance(digestAlgs[i], providerName)
- .getDigestLength();
- assertTrue("length not ok", len > 0);
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + digestAlgs[i]);
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find provider " + providerName);
- }
- }// end for
- }
-
- /**
- * @tests java.security.MessageDigest#getInstance(java.lang.String)
- */
- public void test_getInstanceLjava_lang_String() {
- for (int i = 0; i < digestAlgs.length; i++) {
- try {
- MessageDigest.getInstance(digestAlgs[i]);
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + digestAlgs[i]);
- }
- }
- }
-
- /**
- * @tests java.security.MessageDigest#getInstance(java.lang.String,
- *java.lang.String)
- */
- public void test_getInstanceLjava_lang_StringLjava_lang_String() {
- for (int i = 0; i < digestAlgs.length; i++) {
- try {
- MessageDigest.getInstance(digestAlgs[i], providerName);
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + digestAlgs[i]);
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find provider " + providerName);
- }
- }
- }
-
- /**
- * @tests java.security.MessageDigest#getProvider()
- */
- public void test_getProvider() {
- for (int i = 0; i < digestAlgs.length; i++) {
- try {
- Provider p = MessageDigest.getInstance(digestAlgs[i],
- providerName).getProvider();
- assertNotNull("provider is null", p);
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm " + digestAlgs[i]);
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find provider " + providerName);
- }
- }
- }
-
- /**
- * @tests java.security.MessageDigest#isEqual(byte[], byte[])
- */
- public void test_isEqual$B$B() {
- assertTrue("isEqual is not correct", MessageDigest.isEqual(AR1, AR2));
- }
-
- /**
- * @tests java.security.MessageDigest#toString()
- */
- public void test_toString() {
- try {
- String str = MessageDigest.getInstance("SHA").toString();
- assertNotNull("toString is null", str);
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find algorithm");
- }
- }
-
- protected void setUp() {
- if (digestAlgs == null) {
- Provider[] providers = Security.getProviders("MessageDigest.SHA");
- if (providers == null) {
- fail("No providers available for test");
- }
-
- // Arbitrarily select the first available provider
- providerName = providers[0].getName();
- digestAlgs = getDigestAlgorithms(providerName);
- if (digestAlgs == null || digestAlgs.length == 0) {
- fail("No digest algorithms were found");
- }
- }
- }
-
- /*
- * Returns the digest algorithms that the given provider supports.
- */
- private String[] getDigestAlgorithms(String providerName) {
- Vector algs = new Vector();
-
- Provider provider = Security.getProvider(providerName);
- if (provider == null)
- return new String[0];
- Enumeration e = provider.keys();
- while (e.hasMoreElements()) {
- String algorithm = (String) e.nextElement();
- if (algorithm.startsWith(MESSAGEDIGEST_ID) && !algorithm.contains(" ")) {
- algs.addElement(algorithm.substring(MESSAGEDIGEST_ID.length()));
- }
- }// end while
-
- return (String[]) algs.toArray(new String[algs.size()]);
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java
deleted file mode 100644
index 4e911fe..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.nio.ByteBuffer;
-import java.security.DigestException;
-import java.security.MessageDigestSpi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>MessageDigestSpi</code> constructor and methods
- */
-public class MessageDigestSpiTest extends TestCase {
-
- /**
- * java.security.MessageDigestSpi#engineDigest(byte[], int, int)
- */
- public void test_engineDigestLB$LILI() throws Exception {
-
- final int DIGEST_LENGTH = 2;
-
- MyMessageDigest md = new MyMessageDigest() {
-
- public int engineGetDigestLength() {
- return DIGEST_LENGTH;
- }
-
- public byte[] engineDigest() {
- return new byte[DIGEST_LENGTH]; // return non-null value
- }
- };
-
- byte[] b = new byte[5];
- try {
- // test: null output buffer
- md.engineDigest(null, 1, DIGEST_LENGTH);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- try {
- //test: len param < digest length
- md.engineDigest(b, 1, DIGEST_LENGTH - 1);
- fail("No expected DigestException");
- } catch (DigestException e) {
- }
-
- assertEquals("incorrect result", DIGEST_LENGTH, md
- .engineDigest(b, 1, 3));
-
- // Regression for HARMONY-3045
- md = new MyMessageDigest();
- try {
- md.engineDigest(b, 0, 1);
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- /**
- * java.security.MessageDigestSpi#engineGetDigestLength()
- */
- public void test_engineGetDigestLength() {
- MyMessageDigest md = new MyMessageDigest();
- assertEquals(0, md.engineGetDigestLength());
- }
-
- /**
- * java.security.MessageDigestSpi#engineUpdate(ByteBuffer)
- */
- public void test_engineUpdateLjava_nio_ByteBuffer() {
- MyMessageDigest md = new MyMessageDigest();
- byte[] b = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
-
- ByteBuffer buf = ByteBuffer.wrap(b, 0, b.length);
- buf.get(b);
- int limit = buf.limit();
- md.engineUpdate(buf);
- assertEquals(limit, buf.limit());
- assertEquals(limit, buf.position());
-
- buf = ByteBuffer.wrap(b, 0, b.length);
- buf.get();
- buf.get();
- buf.get();
- md.engineUpdate(buf);
- assertEquals(limit, buf.limit());
- assertEquals(limit, buf.position());
- }
-
- /**
- * @tests java.security.MessageDigestSpi#clone()
- */
- public void test_clone() throws CloneNotSupportedException {
- MyMessageDigest md = new MyMessageDigest();
- try {
- md.clone();
- fail("No expected CloneNotSupportedException");
- } catch (CloneNotSupportedException e) {
- }
-
- MyMessageDigestCloneable mdc = new MyMessageDigestCloneable();
- assertNotSame(mdc, mdc.clone());
- }
-
- private class MyMessageDigest extends MessageDigestSpi {
-
- @Override
- public void engineReset() {
- }
-
- @Override
- public byte[] engineDigest() {
- return null;
- }
-
- @Override
- public void engineUpdate(byte arg0) {
- }
-
- @Override
- public void engineUpdate(byte[] arg0, int arg1, int arg2) {
- }
-
- @Override
- protected int engineDigest(byte[] buf, int offset, int len)
- throws DigestException {
- return super.engineDigest(buf, offset, len);
- }
-
- @Override
- protected int engineGetDigestLength() {
- return super.engineGetDigestLength();
- }
-
- @Override
- protected void engineUpdate(ByteBuffer input) {
- super.engineUpdate(input);
- }
- }
-
- private class MyMessageDigestCloneable extends MyMessageDigest implements
- Cloneable {
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmExceptionTest.java
deleted file mode 100644
index 8499797..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmExceptionTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.NoSuchAlgorithmException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>NoSuchAlgorithmException</code> class constructors and
- * methods.
- */
-public class NoSuchAlgorithmExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for NoSuchAlgorithmExceptionTests.
- *
- * @param arg0
- */
- public NoSuchAlgorithmExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>NoSuchAlgorithmException()</code> constructor Assertion:
- * constructs NoSuchAlgorithmException with no detail message
- */
- public void testNoSuchAlgorithmException01() {
- NoSuchAlgorithmException tE = new NoSuchAlgorithmException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>NoSuchAlgorithmException(String)</code> constructor
- * Assertion: constructs NoSuchAlgorithmException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testNoSuchAlgorithmException02() {
- NoSuchAlgorithmException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new NoSuchAlgorithmException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>NoSuchAlgorithmException(String)</code> constructor
- * Assertion: constructs NoSuchAlgorithmException when <code>msg</code> is
- * null
- */
- public void testNoSuchAlgorithmException03() {
- String msg = null;
- NoSuchAlgorithmException tE = new NoSuchAlgorithmException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>NoSuchAlgorithmException(Throwable)</code> constructor
- * Assertion: constructs NoSuchAlgorithmException when <code>cause</code>
- * is null
- */
- public void testNoSuchAlgorithmException04() {
- Throwable cause = null;
- NoSuchAlgorithmException tE = new NoSuchAlgorithmException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>NoSuchAlgorithmException(Throwable)</code> constructor
- * Assertion: constructs NoSuchAlgorithmException when <code>cause</code>
- * is not null
- */
- public void testNoSuchAlgorithmException05() {
- NoSuchAlgorithmException tE = new NoSuchAlgorithmException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>NoSuchAlgorithmException(String, Throwable)</code>
- * constructor Assertion: constructs NoSuchAlgorithmException when
- * <code>cause</code> is null <code>msg</code> is null
- */
- public void testNoSuchAlgorithmException06() {
- NoSuchAlgorithmException tE = new NoSuchAlgorithmException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>NoSuchAlgorithmException(String, Throwable)</code>
- * constructor Assertion: constructs NoSuchAlgorithmException when
- * <code>cause</code> is null <code>msg</code> is not null
- */
- public void testNoSuchAlgorithmException07() {
- NoSuchAlgorithmException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new NoSuchAlgorithmException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>NoSuchAlgorithmException(String, Throwable)</code>
- * constructor Assertion: constructs NoSuchAlgorithmException when
- * <code>cause</code> is not null <code>msg</code> is null
- */
- public void testNoSuchAlgorithmException08() {
- NoSuchAlgorithmException tE = new NoSuchAlgorithmException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>NoSuchAlgorithmException(String, Throwable)</code>
- * constructor Assertion: constructs NoSuchAlgorithmException when
- * <code>cause</code> is not null <code>msg</code> is not null
- */
- public void testNoSuchAlgorithmException09() {
- NoSuchAlgorithmException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new NoSuchAlgorithmException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderExceptionTest.java
deleted file mode 100644
index 34e7f1a..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderExceptionTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.NoSuchProviderException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>NoSuchProviderException</code> class constructors and
- * methods.
- */
-public class NoSuchProviderExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for NoSuchProviderExceptionTests.
- *
- * @param arg0
- */
- public NoSuchProviderExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>NoSuchProviderException()</code> constructor Assertion:
- * constructs NoSuchProviderException with no detail message
- */
- public void testNoSuchProviderException01() {
- NoSuchProviderException tE = new NoSuchProviderException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>NoSuchProviderException(String)</code> constructor
- * Assertion: constructs NoSuchProviderException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testNoSuchProviderException02() {
- NoSuchProviderException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new NoSuchProviderException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>NoSuchProviderException(String)</code> constructor
- * Assertion: constructs NoSuchProviderException when <code>msg</code> is
- * null
- */
- public void testNoSuchProviderException03() {
- String msg = null;
- NoSuchProviderException tE = new NoSuchProviderException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivateKeyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivateKeyTest.java
deleted file mode 100644
index 29f064f..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivateKeyTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.PrivateKey;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>PrivateKey</code> class field
- */
-
-public class PrivateKeyTest extends TestCase {
-
- /**
- * Constructor for PrivateKeyTest.
- *
- * @param arg0
- */
- public PrivateKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkPrivateKey cPrKey = new checkPrivateKey();
- assertEquals("Incorrect serialVersionUID", cPrKey.getSerVerUID(), //PrivateKey.serialVersionUID,
- 6034044314589513430L);
- }
-
- public class checkPrivateKey implements PrivateKey {
- public String getAlgorithm() {
- return "PublicKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
- }
-}
-
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java
deleted file mode 100644
index 24cc1a1..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.IOException;
-import java.security.PrivilegedActionException;
-
-public class PrivilegedActionException2Test extends junit.framework.TestCase {
-
- /**
- * @tests java.security.PrivilegedActionException#PrivilegedActionException(java.lang.Exception)
- */
- public void test_ConstructorLjava_lang_Exception() {
- Exception e = new Exception("test exception");
- PrivilegedActionException pe = new PrivilegedActionException(e);
- assertEquals("Did not encapsulate test exception!", e, pe
- .getException());
-
- // try it with a null exception
- pe = new PrivilegedActionException(null);
- assertNull("Did not encapsulate null test exception properly!", pe
- .getException());
- }
-
- /**
- * @tests java.security.PrivilegedActionException#getException()
- */
- public void test_getException() {
- Exception e = new IOException("test IOException");
- PrivilegedActionException pe = new PrivilegedActionException(e);
- assertEquals("Did not encapsulate test IOException!", e, pe
- .getException());
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionExceptionTest.java
deleted file mode 100644
index e813fac..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionExceptionTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import junit.framework.TestCase;
-
-/**
- * Unit test for java.security.PrivilegedActionException.
- */
-
-public class PrivilegedActionExceptionTest extends TestCase {
-
- /**
- * Tests PrivilegedActionException(Exception)
- */
- public void testPrivilegedActionException() {
- new PrivilegedActionException(null);
- Exception ex = new Exception();
- new PrivilegedActionException(ex);
- }
-
- /**
- * Tests PrivilegedActionException.getException()
- */
- public void testGetException() {
- assertNull(new PrivilegedActionException(null).getException());
- Exception ex = new Exception();
- assertSame(new PrivilegedActionException(ex).getException(), ex);
- }
-
- /**
- * Tests PrivilegedActionException.toString()
- */
- public void testToString() {
- assertNotNull(new PrivilegedActionException(null).toString());
- assertNotNull(new PrivilegedActionException(new Exception()).toString());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProtectionDomainTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProtectionDomainTest.java
deleted file mode 100644
index 61bbc6d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProtectionDomainTest.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.net.URLClassLoader;
-
-import junit.framework.TestCase;
-
-
-/**
- * Unit tests for java.security.ProtectionDomain.
- */
-
-public class ProtectionDomainTest extends TestCase {
-
- private final AllPermission allperm = new AllPermission();
-
- private URL url = null;
-
- private CodeSource cs = null;
-
- private PermissionCollection perms = null;
-
- private ClassLoader classldr = null;
-
- private Principal[] principals = null; // changed in setUp()
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- try {
- url = new URL("http://localhost");
- } catch (MalformedURLException ex) {
- throw new Error(ex);
- }
- cs = new CodeSource(url, (java.security.cert.Certificate[]) null);
- perms = allperm.newPermissionCollection();
- perms.add(allperm);
- classldr = URLClassLoader.newInstance(new URL[] { url });
- principals = new Principal[] { new TestPrincipal("0"),
- new TestPrincipal("1"), new TestPrincipal("2"),
- new TestPrincipal("3"), new TestPrincipal("4"), };
- }
-
- /**
- * Class under test for void ProtectionDomain(CodeSource,
- * PermissionCollection)
- */
- public void testProtectionDomainCodeSourcePermissionCollection_00() {
- new ProtectionDomain(null, null);
- new ProtectionDomain(cs, null);
-
- new ProtectionDomain(cs, perms);
- }
-
- /**
- * the ctor must set the PermissionCollection read-only
- */
- public void testProtectionDomainCodeSourcePermissionCollection_01() {
- assertFalse(perms.isReadOnly());
- new ProtectionDomain(null, perms);
- assertTrue(perms.isReadOnly());
- }
-
- /**
- * Test for ProtectionDomain(CodeSource, PermissionCollection, ClassLoader, Principal[])
- */
- public void testProtectionDomainCodeSourcePermissionCollectionClassLoaderPrincipalArray() {
- new ProtectionDomain(null, null, null, null);
-
- new ProtectionDomain(cs, null, null, null);
- new ProtectionDomain(null, perms, null, null);
- new ProtectionDomain(null, null, classldr, null);
- new ProtectionDomain(null, null, null, principals);
-
- new ProtectionDomain(cs, perms, classldr, principals);
- }
-
- /**
- * Tests for ProtectionDomain.getClassLoader()
- */
- public void testGetClassLoader() {
- assertNull(new ProtectionDomain(null, null).getClassLoader());
- assertSame(new ProtectionDomain(null, null, classldr, null)
- .getClassLoader(), classldr);
- }
-
- /**
- * Tests for ProtectionDomain.getCodeSource()
- */
- public void testGetCodeSource() {
- assertNull(new ProtectionDomain(null, null).getCodeSource());
- assertSame(new ProtectionDomain(cs, null).getCodeSource(), cs);
- }
-
- /**
- * Tests for ProtectionDomain.getPermissions()
- */
- public void testGetPermissions() {
- assertNull(new ProtectionDomain(null, null).getPermissions());
- assertSame(new ProtectionDomain(null, perms).getPermissions(), perms);
- }
-
- /**
- * getPrincipals() always returns non null array
- */
- public void testGetPrincipals_00() {
- assertNotNull(new ProtectionDomain(null, null).getPrincipals());
- }
-
- /**
- * getPrincipals() returns new array each time it's called
- */
- public void testGetPrincipals_01() {
- ProtectionDomain pd = new ProtectionDomain(null, null, null, principals);
- Principal[] got = pd.getPrincipals();
- assertNotNull(got);
- assertNotSame(got, principals);
- assertNotSame(got, pd.getPrincipals());
- assertTrue(got.length == principals.length);
- }
-
- /**
- * ProtectionDomain with null Permissions must not imply() permissions.
- */
- public void testImplies_00() {
- assertFalse(new ProtectionDomain(null, null).implies(allperm));
- }
-
- /**
- * ProtectionDomain with PermissionCollection which contains AllPermission
- * must imply() AllPermission.
- */
- public void testImplies_01() {
- assertTrue(new ProtectionDomain(null, perms).implies(allperm));
- }
-
- /**
- * ProtectionDomain created with a static set of permissions must not query
- * policy.
- */
- public void testImplies_02() {
- TestPolicy policy = new TestPolicy();
- // null set of permissions [must] force the PD to use Policy - for
- // dynamic permissions
- ProtectionDomain pd = new ProtectionDomain(cs, null);
- policy.setTrackPD(pd);
- try {
- Policy.setPolicy(policy);
- pd.implies(allperm);
- } finally {
- Policy.setPolicy(null);
- }
- assertFalse(policy.getPdTracked());
- }
-
- /**
- * ProtectionDomain created with dynamic set of permissions must query
- * policy.
- */
- public void testImplies_03() {
- TestPolicy policy = new TestPolicy();
- ProtectionDomain pd = new ProtectionDomain(cs, null, ClassLoader
- .getSystemClassLoader(), principals);
- policy.setTrackPD(pd);
- try {
- Policy.setPolicy(policy);
- pd.implies(allperm);
- } finally {
- Policy.setPolicy(null);
- }
- assertTrue(policy.getPdTracked());
- }
-
- /**
- * Simply checks that it's working somehow
- */
- public void testToString() {
- new ProtectionDomain(null, null).toString();
- new ProtectionDomain(cs, perms).toString();
- new ProtectionDomain(null, null, null, null).toString();
- new ProtectionDomain(cs, perms, classldr, principals).toString();
- }
-
- /**
- * Test principal used during the testing. Does nothing.
- */
-
- private static class TestPrincipal implements Principal {
- private String name;
-
- TestPrincipal(String name) {
- this.name = name;
- }
-
- public String getName() {
- return "TestPrincipal: " + name;
- }
- }
-
- private static class TestPolicy extends Policy {
- ProtectionDomain trackPD = null;
-
- boolean pdTracked = false;
-
- ProtectionDomain setTrackPD(ProtectionDomain pd) {
- ProtectionDomain tmp = trackPD;
- trackPD = pd;
- pdTracked = false;
- return tmp;
- }
-
- boolean getPdTracked() {
- return pdTracked;
- }
-
- public PermissionCollection getPermissions(CodeSource cs) {
- return new Permissions();
- }
-
- // public PermissionCollection getPermissions(ProtectionDomain domain) {
- // return super.getPermissions(domain);
- // }
- public boolean implies(ProtectionDomain domain, Permission permission) {
- if (trackPD != null && trackPD == domain) {
- pdTracked = true;
- }
- return super.implies(domain, permission);
- }
-
- public void refresh() {
- // do nothing
- }
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Provider2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Provider2Test.java
deleted file mode 100644
index 2e426ad..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Provider2Test.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.Provider;
-import java.security.Security;
-
-public class Provider2Test extends junit.framework.TestCase {
-
- class TestProvider extends Provider {
- TestProvider(String name, double version, String info) {
- super(name, version, info);
- }
- }
-
- class MyEntry implements java.util.Map.Entry {
- public Object getKey() {
- return null;
- }
-
- public Object getValue() {
- return null;
- }
-
- public Object setValue(Object value) {
- return null;
- }
- }
-
- TestProvider provTest = new TestProvider("provTest", 1.2,
- "contains nothings, purely for testing the class");
-
-
- /**
- * @tests java.security.Provider#entrySet()
- */
- public void test_entrySet() {
- // test method of java.security.provider.entrySet
- provTest.put("test.prop", "this is a test property");
- try {
- //make it compilable on 1.5
- provTest.entrySet().add(new MyEntry());
- fail("was able to modify the entrySet");
- } catch (UnsupportedOperationException e) {
- // expected
- }
- }
-
- /**
- * @tests java.security.Provider#getInfo()
- */
- public void test_getInfo() {
- // test method of java.security.provider.getInfo
- assertEquals("the information of the provider is not stored properly",
- "contains nothings, purely for testing the class", provTest
- .getInfo());
- }
-
- /**
- * @tests java.security.Provider#getName()
- */
- public void test_getName() {
- // test method of java.security.provider.getName
- assertEquals("the name of the provider is not stored properly",
- "provTest", provTest.getName());
- }
-
- /**
- * @tests java.security.Provider#getVersion()
- */
- public void test_getVersion() {
- // test method of java.security.provider.getVersion
- assertEquals("the version of the provider is not stored properly",
- 1.2, provTest.getVersion(), 0);
- }
-
- /**
- * @tests java.security.Provider#keySet()
- */
- public void test_keySet() {
- // test method of java.security.provider.keySet
- provTest.put("test.prop", "this is a test property");
- try {
- provTest.keySet().add("another property key");
- fail("was able to modify the keySet");
- } catch (UnsupportedOperationException e) {
- // expected
- }
- }
-
- /**
- * @tests java.security.Provider#values()
- */
- public void test_values() {
- // test method of java.security.provider.values
- provTest.put("test.prop", "this is a test property");
- try {
- provTest.values().add("another property value");
- fail("was able to modify the values collection");
- } catch (UnsupportedOperationException e) {
- // expected
- }
- }
-
-
- /**
- * @tests java.security.Provider#toString()
- */
- public void test_toString() {
- // Regression for HARMONY-3734
- assertEquals("provTest version 1.2", provTest.toString());
- }
-
- // Regression Test for Provider.Service.getAlias(), which is an package
- // private method but will lead to NPE thrown at
- // Secure.SecurityDorr.getAliases
- public void test_getAlias() throws Exception {
- MockProvider mockProvider = new MockProvider("MOCKNAME", 1.0,
- "MOCKINFO");
- Provider.Service service = new Provider.Service(mockProvider,
- "MOCKTYPE", "MOCKALGORITHM", "TESTCLASSNAME", null, null);
- mockProvider.putService(service);
- Security.addProvider(mockProvider);
- try {
- MessageDigest messageDigest = MessageDigest
- .getInstance("NOTEXISTS");
- } catch (NoSuchAlgorithmException e) {
- // expected
- } finally {
- Security.removeProvider("MOCKNAME");
- }
- }
-
- public static class MockProvider extends Provider {
-
- private static final long serialVersionUID = 1L;
-
- public MockProvider(String name, double version, String info) {
- super(name, version, info);
-
- }
-
- public void putService(Provider.Service service) {
- super.putService(service);
- }
-
- public void removeService(Provider.Service service) {
- super.removeService(service);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderExceptionTest.java
deleted file mode 100644
index bc0129c..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderExceptionTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.ProviderException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>ProviderException</code> class constructors and methods.
- */
-public class ProviderExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for ProviderExceptionTests.
- *
- * @param arg0
- */
- public ProviderExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>ProviderException()</code> constructor Assertion:
- * constructs ProviderException with no detail message
- */
- public void testProviderException01() {
- ProviderException tE = new ProviderException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>ProviderException(String)</code> constructor Assertion:
- * constructs ProviderException with detail message msg. Parameter
- * <code>msg</code> is not null.
- */
- public void testProviderException02() {
- ProviderException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new ProviderException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>ProviderException(String)</code> constructor Assertion:
- * constructs ProviderException when <code>msg</code> is null
- */
- public void testProviderException03() {
- String msg = null;
- ProviderException tE = new ProviderException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>ProviderException(Throwable)</code> constructor
- * Assertion: constructs ProviderException when <code>cause</code> is null
- */
- public void testProviderException04() {
- Throwable cause = null;
- ProviderException tE = new ProviderException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>ProviderException(Throwable)</code> constructor
- * Assertion: constructs ProviderException when <code>cause</code> is not
- * null
- */
- public void testProviderException05() {
- ProviderException tE = new ProviderException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>ProviderException(String, Throwable)</code> constructor
- * Assertion: constructs ProviderException when <code>cause</code> is null
- * <code>msg</code> is null
- */
- public void testProviderException06() {
- ProviderException tE = new ProviderException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>ProviderException(String, Throwable)</code> constructor
- * Assertion: constructs ProviderException when <code>cause</code> is null
- * <code>msg</code> is not null
- */
- public void testProviderException07() {
- ProviderException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new ProviderException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>ProviderException(String, Throwable)</code> constructor
- * Assertion: constructs ProviderException when <code>cause</code> is not
- * null <code>msg</code> is null
- */
- public void testProviderException08() {
- ProviderException tE = new ProviderException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>ProviderException(String, Throwable)</code> constructor
- * Assertion: constructs ProviderException when <code>cause</code> is not
- * null <code>msg</code> is not null
- */
- public void testProviderException09() {
- ProviderException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new ProviderException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java
deleted file mode 100644
index 97de2b8..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.Provider;
-import java.security.NoSuchAlgorithmException;
-import java.util.HashMap;
-
-import org.apache.harmony.security.tests.support.RandomImpl;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>Provider.Service</code> constructor and methods
- */
-public class ProviderServiceTest extends TestCase {
-
- public void testService() {
- Provider p = new MyProvider();
- try {
- new Provider.Service(null, "type", "algorithm",
- "className", null, null);
- fail("provider is null: No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- try {
- new Provider.Service(p, null, "algorithm",
- "className", null, null);
- fail("type is null: No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- try {
- new Provider.Service(p, "type", null,
- "className", null, null);
- fail("algorithm is null: No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- try {
- new Provider.Service(p, "type", "algorithm",
- null, null, null);
- fail("className is null: No expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- Provider.Service s = new Provider.Service(p,
- "type", "algorithm", "className", null, null);
-
- assertEquals("getType() failed", "type", s.getType());
- assertEquals("getAlgorithm() failed", "algorithm", s.getAlgorithm());
- assertSame("getProvider() failed", p, s.getProvider());
- assertEquals("getClassName() failed", "className", s.getClassName());
- assertTrue("supportsParameter() failed", s
- .supportsParameter(new Object()));
- }
-
- public void testGetAttribute() {
- Provider p = new MyProvider();
- Provider.Service s = new Provider.Service(p,
- "type", "algorithm", "className", null, null);
- try {
- s.getAttribute(null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- assertNull("getAttribute(aaa) failed", s.getAttribute("aaa"));
-
- HashMap hm = new HashMap();
- hm.put("attribute", "value");
- hm.put("KeySize", "1024");
- hm.put("AAA", "BBB");
-
- s = new Provider.Service(p, "type", "algorithm", "className",
- null, hm);
- assertNull("getAttribute(bbb) failed", s.getAttribute("bbb"));
- assertEquals("getAttribute(attribute) failed", "value", s
- .getAttribute("attribute"));
- assertEquals("getAttribute(KeySize) failed", "1024", s
- .getAttribute("KeySize"));
- }
-
- public void testNewInstance() throws NoSuchAlgorithmException {
- Provider p = new MyProvider();
- Provider.Service s = new Provider.Service(p, "SecureRandom",
- "algorithm",
- "org.apache.harmony.security.tests.support.RandomImpl",
- null, null);
-
- Object o = s.newInstance(null);
- assertTrue("incorrect instance", o instanceof RandomImpl);
-
- try {
- o = s.newInstance(new Object());
- fail("No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
- }
-
- class MyProvider extends Provider {
- MyProvider() {
- super("MyProvider", 1.0, "Provider for testing");
- put("MessageDigest.SHA-1", "SomeClassName");
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderTest.java
deleted file mode 100644
index 53fddff..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderTest.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>Provider</code> constructor and methods
- */
-public class ProviderTest extends TestCase {
-
- Provider p;
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- p = new MyProvider();
- }
-
- /*
- * Class under test for void Provider()
- */
- public final void testProvider() {
- assertEquals("Provider.id name", p.getProperty("Provider.id name"),
- String.valueOf(p.getName()));
- assertEquals("Provider.id version", p
- .getProperty("Provider.id version"), String.valueOf(p
- .getVersion()));
- assertEquals("Provider.id info", p.getProperty("Provider.id info"),
- String.valueOf(p.getInfo()));
- assertEquals("Provider.id className", p
- .getProperty("Provider.id className"), p.getClass().getName());
- }
-
- public final void testClear() {
- p.clear();
- assertNull(p.getProperty("MessageDigest.SHA-1"));
- }
-
- /*
- * Class under test for void Provider(String, double, String)
- */
- public final void testProviderStringdoubleString() {
- Provider p = new MyProvider("Provider name", 123.456, "Provider info");
-
- assertEquals("Provider name", p.getName());
- assertEquals(123.456, p.getVersion(), 0L);
- assertEquals("Provider info", p.getInfo());
- }
-
- public final void testGetName() {
- assertEquals("MyProvider", p.getName());
- }
-
- public final void testGetVersion() {
- assertEquals(1.0, p.getVersion(), 0L);
- }
-
- public final void testGetInfo() {
- assertEquals("Provider for testing", p.getInfo());
- }
-
- /*
- * Class under test for void putAll(Map)
- */
- public final void testPutAllMap() {
- HashMap hm = new HashMap();
- hm.put("MessageDigest.SHA-1", "aaa.bbb.ccc.ddd");
- hm.put("Property 1", "value 1");
- hm.put("serviceName.algName attrName", "attrValue");
- hm.put("Alg.Alias.engineClassName.aliasName", "standardName");
- p.putAll(hm);
- if (!"value 1".equals(p.getProperty("Property 1").trim()) ||
- !"attrValue".equals(p.getProperty("serviceName.algName attrName").trim()) ||
- !"standardName".equals(p.getProperty("Alg.Alias.engineClassName.aliasName").trim()) ||
- !"aaa.bbb.ccc.ddd".equals(p.getProperty("MessageDigest.SHA-1").trim())) {
- fail("Incorrect property value");
- }
- }
-
- /*
- * Class under test for Set entrySet()
- */
- public final void testEntrySet() {
- p.put("MessageDigest.SHA-256", "aaa.bbb.ccc.ddd");
-
- Set s = p.entrySet();
- try {
- s.clear();
- fail("Must return unmodifiable set");
- } catch (UnsupportedOperationException e) {
- }
-
- assertEquals("Incorrect set size", 8, s.size());
-
- for (Iterator it = s.iterator(); it.hasNext(); ) {
- Entry e = (Entry) it.next();
- String key = (String) e.getKey();
- String val = (String) e.getValue();
- if (key.equals("MessageDigest.SHA-1") && val.equals("SomeClassName")) {
- continue;
- }
- if (key.equals("Alg.Alias.MessageDigest.SHA1") && val.equals("SHA-1")) {
- continue;
- }
- if (key.equals("MessageDigest.abc") && val.equals("SomeClassName")) {
- continue;
- }
- if (key.equals("Provider.id className") && val.equals(p.getClass().getName())) {
- continue;
- }
- if (key.equals("Provider.id name") && val.equals("MyProvider")) {
- continue;
- }
- if (key.equals("MessageDigest.SHA-256") && val.equals("aaa.bbb.ccc.ddd")) {
- continue;
- }
- if (key.equals("Provider.id version") && val.equals("1.0")) {
- continue;
- }
- if (key.equals("Provider.id info") && val.equals("Provider for testing")) {
- continue;
- }
- fail("Incorrect set");
- }
- }
-
- /*
- * Class under test for Set keySet()
- */
- public final void testKeySet() {
- p.put("MessageDigest.SHA-256", "aaa.bbb.ccc.ddd");
-
- Set s = p.keySet();
- try {
- s.clear();
- } catch (UnsupportedOperationException e) {
- }
- Set s1 = p.keySet();
-
- assertNotSame(s, s1);
- assertFalse(s1.isEmpty());
- assertEquals(8, s1.size());
-
- assertTrue(s1.contains("MessageDigest.SHA-256"));
- assertTrue(s1.contains("MessageDigest.SHA-1"));
- assertTrue(s1.contains("Alg.Alias.MessageDigest.SHA1"));
- assertTrue(s1.contains("MessageDigest.abc"));
- assertTrue(s1.contains("Provider.id info"));
- assertTrue(s1.contains("Provider.id className"));
- assertTrue(s1.contains("Provider.id version"));
- assertTrue(s1.contains("Provider.id name"));
- }
-
- /*
- * Class under test for Collection values()
- */
- public final void testValues() {
- p.put("MessageDigest.SHA-256", "aaa.bbb.ccc.ddd");
-
- Collection c = p.values();
- try {
- c.clear();
- } catch (UnsupportedOperationException e) {
- }
- Collection c1 = p.values();
-
- assertNotSame(c, c1);
- assertFalse(c1.isEmpty());
- assertEquals(8, c1.size());
-
- assertTrue(c1.contains("MyProvider"));
- assertTrue(c1.contains("aaa.bbb.ccc.ddd"));
- assertTrue(c1.contains("Provider for testing"));
- assertTrue(c1.contains("1.0"));
- assertTrue(c1.contains("SomeClassName"));
- assertTrue(c1.contains("SHA-1"));
- assertTrue(c1.contains(p.getClass().getName()));
- }
-
- /*
- * Class under test for Object put(Object, Object)
- */
- public final void testPutObjectObject() {
- p.put("MessageDigest.SHA-1", "aaa.bbb.ccc.ddd");
- p.put("Type.Algorithm", "className");
- assertEquals("aaa.bbb.ccc.ddd", p.getProperty("MessageDigest.SHA-1")
- .trim());
-
- Set services = p.getServices();
- assertEquals(3, services.size());
-
- for (Iterator it = services.iterator(); it.hasNext(); ) {
- Provider.Service s = (Provider.Service) it.next();
- if ("Type".equals(s.getType()) &&
- "Algorithm".equals(s.getAlgorithm()) &&
- "className".equals(s.getClassName())) {
- continue;
- }
- if ("MessageDigest".equals(s.getType()) &&
- "SHA-1".equals(s.getAlgorithm()) &&
- "aaa.bbb.ccc.ddd".equals(s.getClassName())) {
- continue;
- }
- if ("MessageDigest".equals(s.getType()) &&
- "abc".equals(s.getAlgorithm()) &&
- "SomeClassName".equals(s.getClassName())) {
- continue;
- }
- fail("Incorrect service");
- }
- }
-
- /*
- * Class under test for Object remove(Object)
- */
- public final void testRemoveObject() {
- Object o = p.remove("MessageDigest.SHA-1");
-
- assertEquals("SomeClassName", o);
- assertNull(p.getProperty("MessageDigest.SHA-1"));
- assertEquals(1, p.getServices().size());
- }
-
- public final void testService1() {
- p.put("MessageDigest.SHA-1", "AnotherClassName");
- Provider.Service s = p.getService("MessageDigest", "SHA-1");
-
- assertEquals("AnotherClassName", s.getClassName());
- }
-
- /*
- public final void testService2() {
- Provider[] pp = Security.getProviders("MessageDigest.SHA-1");
- if (pp == null) {
- return;
- }
- Provider p2 = pp[0];
- String old = p2.getProperty("MessageDigest.SHA-1");
- try {
- p2.put("MessageDigest.SHA-1", "AnotherClassName");
- Provider.Service s = p2.getService("MessageDigest", "SHA-1");
- if (!"AnotherClassName".equals(s.getClassName())) {
- fail("Incorrect class name "+ s.getClassName());
- }
- try {
- s.newInstance(null);
- fail("No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
- } finally {
- p2.put("MessageDigest.SHA-1", old);
- }
- }
- */
- //Regression for HARMONY-2760.
- public void testConstructor() {
- MyProvider myProvider = new MyProvider(null, 1, null);
- assertNull(myProvider.getName());
- assertNull(myProvider.getInfo());
- assertEquals("null", myProvider.getProperty("Provider.id name"));
- assertEquals("null", myProvider.getProperty("Provider.id info"));
- }
-
- class MyProvider extends Provider {
- MyProvider() {
- super("MyProvider", 1.0, "Provider for testing");
- put("MessageDigest.SHA-1", "SomeClassName");
- put("MessageDigest.abc", "SomeClassName");
- put("Alg.Alias.MessageDigest.SHA1", "SHA-1");
- }
-
- MyProvider(String name, double version, String info) {
- super(name, version, info);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PublicKeyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PublicKeyTest.java
deleted file mode 100644
index 36e896c..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PublicKeyTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.PublicKey;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>PublicKey</code> class field
- */
-
-public class PublicKeyTest extends TestCase {
-
-
- /**
- * Constructor for PublicKeyTest.
- *
- * @param arg0
- */
- public PublicKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkPublicKey cPK = new checkPublicKey();
- assertEquals("Incorrect serialVersionUID", cPK.getSerVerUID(), //PublicKey.serialVersionUID,
- 7187392471159151072L);
- }
-
- public class checkPublicKey implements PublicKey {
- public String getAlgorithm() {
- return "PublicKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java
deleted file mode 100644
index 7ba7fd4..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.CodeSource;
-import java.security.PermissionCollection;
-import java.security.ProtectionDomain;
-import java.security.SecureClassLoader;
-import java.security.cert.Certificate;
-import java.util.Enumeration;
-import java.util.jar.JarFile;
-
-import org.apache.harmony.luni.util.InputStreamHelper;
-
-import tests.support.Support_GetLocal;
-
-public class SecureClassLoader2Test extends junit.framework.TestCase {
-
- /**
- * @tests java.security.SecureClassLoader#getPermissions(java.security.CodeSource)
- */
- public void test_getPermissionsLjava_security_CodeSource() throws IOException {
- class MyClassLoader extends SecureClassLoader {
- public PermissionCollection getPerms() {
- return super.getPermissions(new CodeSource(null,
- (Certificate[]) null));
- }
-
- public Class define(String name, byte[] bytes) {
- return defineClass(name, bytes, 0, bytes.length,
- (ProtectionDomain) null);
- }
- }
-
- MyClassLoader myloader = new MyClassLoader();
- PermissionCollection pc = myloader.getPerms();
- Enumeration e1 = pc.elements();
- int count = 0;
- while (e1.hasMoreElements()) {
- e1.nextElement();
- count++;
- }
- assertEquals("expected no permissions", 0, count);
-
- File file = Support_GetLocal.getLocalFile("hyts_security.jar");
- JarFile jar = new JarFile(file);
- InputStream in = jar.getInputStream(jar.getEntry("packA/SecurityTest.class"));
- byte[] bytes = InputStreamHelper.readFullyAndClose(in);
- Class c = myloader.define("packA.SecurityTest", bytes);
- ProtectionDomain pd = c.getProtectionDomain();
- assertNotNull("Expected dynamic policy", pd.getClassLoader());
- assertNull("Expected null permissions", pd.getPermissions());
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java
deleted file mode 100644
index cfeaf16..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.SecureRandomSpi;
-import java.security.Security;
-
-public class SecureRandom2Test extends junit.framework.TestCase {
-
- private static final byte[] SEED_BYTES = { (byte) 33, (byte) 15, (byte) -3,
- (byte) 22, (byte) 77, (byte) -16, (byte) -33, (byte) 56 };
-
- private static final int SEED_SIZE = 539;
-
- private static final long SEED_VALUE = 5335486759L;
-
- /**
- * @tests java.security.SecureRandom#SecureRandom()
- */
- public void test_Constructor() {
- // Test for method java.security.SecureRandom()
- new SecureRandom();
- }
-
- /**
- * @tests java.security.SecureRandom#SecureRandom(byte[])
- */
- public void test_Constructor$B() {
- // Test for method java.security.SecureRandom(byte [])
- new SecureRandom(SEED_BYTES);
- }
-
- /**
- * @tests java.security.SecureRandom#generateSeed(int)
- */
- public void test_generateSeedI() {
- // Test for method byte [] java.security.SecureRandom.generateSeed(int)
- byte[] seed = new SecureRandom().generateSeed(SEED_SIZE);
- assertEquals("seed has incorrect size", SEED_SIZE, seed.length);
- }
-
- /**
- * @tests java.security.SecureRandom#getInstance(java.lang.String)
- */
- public void test_getInstanceLjava_lang_String() {
- // Test for method java.security.SecureRandom
- // java.security.SecureRandom.getInstance(java.lang.String)
- try {
- SecureRandom.getInstance("SHA1PRNG");
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find a SHA1PRNG algorithm");
- }
- }
-
- /**
- * @tests java.security.SecureRandom#getInstance(java.lang.String,
- *java.lang.String)
- */
- public void test_getInstanceLjava_lang_StringLjava_lang_String() {
- // Test for method java.security.SecureRandom
- // java.security.SecureRandom.getInstance(java.lang.String,
- // java.lang.String)
- try {
- Provider[] providers = Security
- .getProviders("SecureRandom.SHA1PRNG");
- if (providers != null) {
- for (int i = 0; i < providers.length; i++) {
- SecureRandom
- .getInstance("SHA1PRNG", providers[i].getName());
- }// end for
- } else {
- fail("No providers support SHA1PRNG");
- }
- } catch (NoSuchAlgorithmException e) {
- fail("getInstance did not find a SHA1PRNG algorithm");
- } catch (NoSuchProviderException e) {
- fail("getInstance did not find the provider for SHA1PRNG");
- }
- }
-
- /**
- * @tests java.security.SecureRandom#getSeed(int)
- */
- public void test_getSeedI() {
- // Test for method byte [] java.security.SecureRandom.getSeed(int)
- byte[] seed = SecureRandom.getSeed(SEED_SIZE);
- assertEquals("seed has incorrect size", SEED_SIZE, seed.length);
- }
-
- /**
- * @tests java.security.SecureRandom#nextBytes(byte[])
- */
- public void test_nextBytes$B() {
- // Test for method void java.security.SecureRandom.nextBytes(byte [])
- byte[] bytes = new byte[313];
- new SecureRandom().nextBytes(bytes);
- }
-
- /**
- * @tests java.security.SecureRandom#setSeed(byte[])
- */
- public void test_setSeed$B() {
- // Test for method void java.security.SecureRandom.setSeed(byte [])
- new SecureRandom().setSeed(SEED_BYTES);
- }
-
- /**
- * @tests java.security.SecureRandom#setSeed(long)
- */
- public void test_setSeedJ() {
- // Test for method void java.security.SecureRandom.setSeed(long)
- new SecureRandom().setSeed(SEED_VALUE);
- }
-
- /**
- * @tests java.security.SecureRandom#getAlgorithm()
- */
- public void test_getAlgorithm() {
- // Regression for HARMONY-750
-
- SecureRandomSpi spi = new SecureRandomSpi() {
-
- protected void engineSetSeed(byte[] arg) {
- }
-
- protected void engineNextBytes(byte[] arg) {
- }
-
- protected byte[] engineGenerateSeed(int arg) {
- return null;
- }
- };
-
- SecureRandom sr = new SecureRandom(spi, null) {
- };
-
- assertEquals("unknown", sr.getAlgorithm());
- }
-
- //Regression Test for HARMONY-3552.
- public void test_nextJ() throws Exception {
- MySecureRandom mySecureRandom = new MySecureRandom(
- new MySecureRandomSpi(), null);
- int numBits = 29;
- int random = mySecureRandom.getNext(numBits);
- assertEquals(numBits, Integer.bitCount(random));
-
- numBits = 0;
- random = mySecureRandom.getNext(numBits);
- assertEquals(numBits, Integer.bitCount(random));
-
- numBits = 40;
- random = mySecureRandom.getNext(numBits);
- assertEquals(32, Integer.bitCount(random));
-
- numBits = -1;
- random = mySecureRandom.getNext(numBits);
- assertEquals(0, Integer.bitCount(random));
- }
-
- class MySecureRandom extends SecureRandom {
- private static final long serialVersionUID = 1L;
-
- public MySecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) {
- super(secureRandomSpi, provider);
- }
-
- public int getNext(int numBits) {
- return super.next(numBits);
- }
- }
-
- class MySecureRandomSpi extends SecureRandomSpi {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected byte[] engineGenerateSeed(int arg0) {
- return null;
- }
-
- @Override
- protected void engineNextBytes(byte[] bytes) {
- for (int i = 0; i < bytes.length; i++) {
- bytes[i] = (byte) 0xFF;
- }
- }
-
- @Override
- protected void engineSetSeed(byte[] arg0) {
- return;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java
deleted file mode 100644
index d06fe4b..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.InvalidParameterException;
-import java.security.Provider;
-import java.security.Security;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import tests.support.Support_ProviderTrust;
-import tests.support.Support_TestProvider;
-
-public class Security2Test extends junit.framework.TestCase {
-
- /**
- * @tests java.security.Security#getProviders(java.lang.String)
- */
- public void test_getProvidersLjava_lang_String() {
- // Test for method void
- // java.security.Security.getProviders(java.lang.String)
-
- Hashtable allSupported = new Hashtable();
- Provider[] allProviders = Security.getProviders();
-
- // Add all non-alias entries to allSupported
- for (int i = 0; i < allProviders.length; i++) {
- Provider provider = allProviders[i];
- Iterator it = provider.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry entry = (Map.Entry) it.next();
- String key = (String) entry.getKey();
- // No aliases and no provider data
- if (!isAlias(key) && !isProviderData(key)) {
- addOrIncrementTable(allSupported, key);
- }
- }// end while more entries
- }// end for all providers
-
- // Now walk through aliases. If an alias has actually been added
- // to the allSupported table then increment the count of the
- // entry that is being aliased.
- for (int i = 0; i < allProviders.length; i++) {
- Provider provider = allProviders[i];
- Iterator it = provider.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry entry = (Map.Entry) it.next();
- String key = (String) entry.getKey();
- if (isAlias(key)) {
- String aliasVal = key.substring("ALG.ALIAS.".length());
- String aliasKey = aliasVal.substring(0, aliasVal
- .indexOf('.') + 1)
- + entry.getValue();
- // Skip over nonsense alias declarations where alias and
- // aliased are identical. Such entries can occur.
- if (!aliasVal.equals(aliasKey)) {
- // Has a real entry been added for aliasValue ?
- if (allSupported.containsKey(aliasVal)) {
- // Add 1 to the provider count of the thing being
- // aliased
- addOrIncrementTable(allSupported, aliasKey);
- }
- }
- }
- }// end while more entries
- }// end for all providers
-
- Provider provTest[] = null;
- Iterator it = allSupported.keySet().iterator();
- while (it.hasNext()) {
- String filterString = (String) it.next();
- try {
- provTest = Security.getProviders(filterString);
- int expected = ((Integer) allSupported.get(filterString))
- .intValue();
- assertEquals(
- "Unexpected number of providers returned for filter "
- + filterString, expected, provTest.length);
- } catch (InvalidParameterException e) {
- // NO OP
- }
- }// end while
-
- // exception
- try {
- provTest = Security.getProviders("Signature.SHA1withDSA :512");
- fail("InvalidParameterException should be thrown <Signature.SHA1withDSA :512>");
- } catch (InvalidParameterException e) {
- // Expected
- }
- }
-
- /**
- * @param key
- * @return
- */
- private boolean isProviderData(String key) {
- return key.toUpperCase().startsWith("PROVIDER.");
- }
-
- /**
- * @param key
- * @return
- */
- private boolean isAlias(String key) {
- return key.toUpperCase().startsWith("ALG.ALIAS.");
- }
-
- /**
- * @param table
- * @param key
- */
- private void addOrIncrementTable(Hashtable table, String key) {
- if (table.containsKey(key)) {
- Integer before = (Integer) table.get(key);
- table.put(key, new Integer(before.intValue() + 1));
- } else {
- table.put(key, new Integer(1));
- }
- }
-
- /**
- * @param filterMap
- * @return
- */
- private int getProvidersCount(Map filterMap) {
- int result = 0;
- Provider[] allProviders = Security.getProviders();
-
- // for each provider
- for (int i = 0; i < allProviders.length; i++) {
- Provider provider = allProviders[i];
- Set allProviderKeys = provider.keySet();
- boolean noMatchFoundForFilterEntry = false;
-
- // for each filter item
- Set allFilterKeys = filterMap.keySet();
- Iterator fkIter = allFilterKeys.iterator();
- while (fkIter.hasNext()) {
- String filterString = ((String) fkIter.next()).trim();
-
- // Remove any "=" characters that may be on the end of the
- // map keys (no, I don't know why they might be there either
- // but I have seen them)
- if (filterString.endsWith("=")) {
- filterString = filterString.substring(0, filterString
- .length() - 1);
- }
-
- if (filterString != null) {
- if (filterString.indexOf(' ') == -1) {
- // Is this filter string in the keys of the
- // current provider ?
- if (!allProviderKeys.contains(filterString)) {
- // Check that the key is not contained as an
- // alias.
- if (!allProviderKeys.contains("Alg.Alias."
- + filterString)) {
- noMatchFoundForFilterEntry = true;
- break; // out of while loop
- }
- }
- } else {
- // handle filter strings with attribute names
- if (allProviderKeys.contains(filterString)) {
- // Does the corresponding values match ?
- String filterVal = (String) filterMap
- .get(filterString);
- String providerVal = (String) provider
- .get(filterString);
- if (providerVal == null
- || !providerVal.equals(filterVal)) {
- noMatchFoundForFilterEntry = true;
- break; // out of while loop
- }
- }// end if filter string with named attribute is
- // found
- }// end else
- }// end if non-null key
- }// end while there are more filter strings for current map
-
- if (!noMatchFoundForFilterEntry) {
- // Current provider is a match for the filterMap
- result++;
- }
- }// end for each provider
-
- return result;
- }
-
- /**
- * @tests java.security.Security#getProviders(java.util.Map)
- */
- public void test_getProvidersLjava_util_Map() {
- // Test for method void
- // java.security.Security.getProviders(java.util.Map)
-
- Map filter = new Hashtable();
- filter.put("KeyStore.BKS", "");
- filter.put("Signature.SHA1withDSA", "");
- Provider provTest[] = Security.getProviders(filter);
- if (provTest == null) {
- assertEquals("Filter : <KeyStore.BKS>,<Signature.SHA1withDSA>",
- 0, getProvidersCount(filter));
- } else {
- assertEquals("Filter : <KeyStore.BKS>,<Signature.SHA1withDSA>",
- getProvidersCount(filter), provTest.length);
- }
-
- filter = new Hashtable();
- filter.put("MessageDigest.MD2", "");
- filter.put("CertificateFactory.X.509", "");
- filter.put("KeyFactory.RSA", "");
- provTest = Security.getProviders(filter);
- if (provTest == null) {
- assertEquals("Filter : <MessageDigest.MD2>,<CertificateFactory.X.509>,<KeyFactory.RSA>",
- 0, getProvidersCount(filter));
- } else {
- assertEquals(
- "Filter : <MessageDigest.MD2>,<CertificateFactory.X.509>,<KeyFactory.RSA>",
- getProvidersCount(filter), provTest.length);
- }
-
- filter = new Hashtable();
- filter.put("MessageDigest.SHA", "");
- filter.put("CertificateFactory.X.509", "");
- provTest = Security.getProviders(filter);
- if (provTest == null) {
- assertEquals("Filter : <MessageDigest.SHA><CertificateFactory.X.509>",
- 0, getProvidersCount(filter));
- } else {
- assertEquals(
- "Filter : <MessageDigest.SHA><CertificateFactory.X.509>",
- getProvidersCount(filter), provTest.length);
- }
-
- filter = new Hashtable();
- filter.put("CertificateFactory.X509", "");
- provTest = Security.getProviders(filter);
- if (provTest == null) {
- assertEquals("Filter : <CertificateFactory.X509>",
- 0, getProvidersCount(filter));
- } else {
- assertEquals("Filter : <CertificateFactory.X509>",
- getProvidersCount(filter), provTest.length);
- }
-
- filter = new Hashtable();
- filter.put("Provider.id name", "DRLCertFactory");
- provTest = Security.getProviders(filter);
- assertNull("Filter : <Provider.id name, DRLCertFactory >",
- provTest);
-
- // exception - no attribute name after the service.algorithm yet we
- // still supply an expected value. This is not valid.
- try {
- filter = new Hashtable();
- filter.put("Signature.SHA1withDSA", "512");
- provTest = Security.getProviders(filter);
- fail("InvalidParameterException should be thrown <Signature.SHA1withDSA><512>");
- } catch (InvalidParameterException e) {
- // Expected
- }
-
- // exception - space character in the service.algorithm pair. Not valid.
- try {
- filter = new Hashtable();
- filter.put("Signature. KeySize", "512");
- provTest = Security.getProviders(filter);
- fail("InvalidParameterException should be thrown <Signature. KeySize><512>");
- } catch (InvalidParameterException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.security.Security#removeProvider(java.lang.String)
- */
- public void test_removeProviderLjava_lang_String() {
- // Test for method void
- // java.security.Security.removeProvider(java.lang.String)
- Provider test = new Support_TestProvider();
- Provider entrust = new Support_ProviderTrust();
- try {
- // Make sure provider not already loaded. Should do nothing
- // if not already loaded.
- Security.removeProvider(test.getName());
-
- // Now add it
- int addResult = Security.addProvider(test);
- assertTrue("Failed to add provider", addResult != -1);
-
- Security.removeProvider(test.getName());
- assertNull(
- "the provider TestProvider is found after it was removed",
- Security.getProvider(test.getName()));
-
- // Make sure entrust provider not already loaded. Should do nothing
- // if not already loaded.
- Security.removeProvider(entrust.getName());
-
- // Now add entrust
- addResult = Security.addProvider(entrust);
- assertTrue("Failed to add provider", addResult != -1);
-
- Security.removeProvider(entrust.getName());
- Provider provTest[] = Security.getProviders();
- for (int i = 0; i < provTest.length; i++) {
- assertTrue(
- "the provider entrust is found after it was removed",
- provTest[i].getName() != entrust.getName());
- }
- } finally {
- // Tidy up - the following calls do nothing if the providers were
- // already removed above.
- Security.removeProvider(test.getName());
- Security.removeProvider(entrust.getName());
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
deleted file mode 100644
index 4822db2..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.InvalidParameterException;
-import java.security.KeyFactory;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.Signature;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.TestKeyPair;
-
-/**
- * Tests for <code>Security</code> constructor and methods
- */
-public class SecurityTest extends TestCase {
-
- public final void testMixed() {
-
- TestKeyPair tkp = null;
- try {
- tkp = new TestKeyPair("DSA");
- } catch (NoSuchAlgorithmException e1) {
- e1.printStackTrace();
- return;
- }
-
- try {
- MessageDigest.getInstance("SHA-1");
- KeyFactory.getInstance("DSA");
- Signature ss = Signature.getInstance("DSA");
- ss.initSign(tkp.getPrivate());
- Signature.getInstance("aaaaaaaaaaaa");
- } catch (Exception e) {
- // ignore
- }
-
- }
-
- /**
- * @tests java.security.Security#insertProviderAt(Provider, int)
- */
- public final void test_insertProviderAtLjava_security_ProviderLI() {
-
- try {
- Security.insertProviderAt(null, 1);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- Provider p = new MyProvider();
- int initNum = Security.getProviders().length; // initial number of providers
- Provider initialSecondProviderName = Security.getProviders()[1];
-
- try {
-
- // Insert at position -1, the provider is inserted at the end
- assertEquals(initNum + 1, Security.insertProviderAt(p, -1));
- assertSame(p, Security.getProviders()[initNum]);
-
- // A provider cannot be added if it is already installed
- assertEquals(-1, Security.insertProviderAt(p, 1));
-
- Security.removeProvider(p.getName());
-
- // insert at the end
- assertEquals(initNum + 1, Security.insertProviderAt(p,
- initNum + 100));
- assertSame(p, Security.getProviders()[initNum]);
-
- Security.removeProvider(p.getName());
-
- // insert at the first position
- assertEquals(1, Security.insertProviderAt(p, 1));
- assertSame(p, Security.getProviders()[0]);
- assertSame(initialSecondProviderName, // provider shifted down
- Security.getProviders()[2]);
- } finally { //clean up
- Security.removeProvider(p.getName());
- }
- }
-
- /**
- * @tests java.security.Security#addProvider(Provider)
- */
- public final void test_addProviderLjava_security_Provider() {
-
- try {
- Security.addProvider(null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- Provider p = new MyProvider();
- int initNum = Security.getProviders().length; // initial number of providers
-
- try {
- // add
- assertEquals(initNum + 1, Security.addProvider(p));
- assertSame(p, Security.getProviders()[initNum]);
-
- // A provider cannot be added if it is already installed
- assertEquals(-1, Security.addProvider(p));
- } finally { //clean up
- Security.removeProvider(p.getName());
- }
- }
-
- public final void testRemoveProvider() {
- Provider[] providers;
- Provider[] providers1;
-
- providers = Security.getProviders();
-
- try {
- for (int i = 0; i < providers.length; i++) {
- Security.removeProvider(providers[i].getName());
- }
- assertEquals("Providers not removed", 0,
- Security.getProviders().length);
- } finally { // restore providers
- for (int i = 0; i < providers.length; i++) {
- Security.addProvider(providers[i]);
- }
- providers1 = Security.getProviders();
- for (int i = 0; i < providers1.length; i++) {
- assertEquals("Providers not restored correctly", providers[i],
- providers1[i]);
- }
- }
- }
-
- /**
- * @tests java.security.Security#getProvider(String)
- */
- public final void test_getProviderLjava_lang_String() {
-
- // Returns null if no provider with the specified name is installed
- assertNull(Security.getProvider("SOMEINCORRECTPROVIDERNAME"));
-
- // Returns null if name is null
- assertNull(Security.getProvider(null));
-
- // test for existing providers
- Provider[] providers = Security.getProviders();
- assertTrue("getProviders returned zero length array",
- providers.length > 0);
- for (Provider p : providers) {
- String providerName = p.getName();
- assertSame(p, Security.getProvider(providerName));
- }
-
- // test for newly installed provider
- Provider p = new MyProvider();
- try {
- Security.addProvider(p);
-
- assertSame(p, Security.getProvider(p.getName()));
- } finally { //clean up
- Security.removeProvider(p.getName());
- }
- }
-
- /**
- * @tests java.security.Security#getProviders(String)
- */
- public void test_getProvidersLjava_lang_String() {
-
- try {
- Security.getProviders("");
- fail("No expected InvalidParameterException");
- } catch (InvalidParameterException e) {
- }
-
- try {
- Security.getProviders((String) null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- Provider p = new MyProvider();
- try {
- Security.addProvider(p);
-
- String filter = "MyService.MyAlgorithm";
- assertTrue(filter, Arrays.equals(new Provider[] { p }, Security
- .getProviders(filter)));
-
- filter = "MyService.MyAlgorithm KeySize:512";
- assertTrue(filter, Arrays.equals(new Provider[] { p }, Security
- .getProviders(filter)));
-
- filter = "MyService.MyAlgorithm KeySize:1025";
- assertNull(filter, Security.getProviders(filter));
-
- // attribute name and value are case insensitive
- filter = "MyService.MyAlgorithm imPLementedIn:softWARE";
- assertTrue(filter, Arrays.equals(new Provider[] { p }, Security
- .getProviders(filter)));
- filter = "MyService.MyAlgorithm ATTribute:attributeVALUE";
- assertTrue(filter, Arrays.equals(new Provider[] { p }, Security
- .getProviders(filter)));
-
- // Regression for HARMONY-2761
- filter = "MyService.NoKeySize KeySize:512";
- assertNull(filter, Security.getProviders(filter));
-
- filter = "MyService.NoImplementedIn ImplementedIn:Software";
- assertNull(filter, Security.getProviders(filter));
-
- filter = "ABCService.NoAttribute Attribute:ABC";
- assertNull(filter, Security.getProviders(filter));
- } finally { //clean up
- Security.removeProvider(p.getName());
- }
- }
-
- /**
- * @tests java.security.Security#getProviders(java.util.Map)
- */
- public void test_getProvidersLjava_util_Map() {
-
- Map<String, String> m = new HashMap<String, String>();
- Security.getProviders(m);
-
- assertNull("Not null result on empty map", Security.getProviders(m));
-
- try {
- Security.getProviders((Map<String, String>) null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- m.put("AAA.BBB.CCC", "aaaa"); // key has dot instead of space
- try {
- Security.getProviders(m);
- fail("No expected InvalidParameterException");
- } catch (InvalidParameterException e) {
- }
-
- Provider p = new MyProvider();
- try {
- Security.addProvider(p);
-
- m.clear();
- m.put("MyService.MyAlgorithm", "");
- m.put("MessageDigest.SHA-1", "");
- assertTrue("MyService.MyAlgorithm", Arrays.equals(
- new Provider[] { p }, Security.getProviders(m)));
-
- m.clear();
- m.put("MyService.MyAlgorithm KeySize", "512");
- m.put("MessageDigest.SHA-1", "");
- assertTrue("MyService.MyAlgorithm KeySize:512", Arrays.equals(
- new Provider[] { p }, Security.getProviders(m)));
-
- m.clear();
- m.put("MyService.MyAlgorithm KeySize", "1025");
- m.put("MessageDigest.SHA-1", "");
- assertNull("MyService.MyAlgorithm KeySize:1025", Security
- .getProviders(m));
-
- // attribute name and value are case insensitive
- m.clear();
- m.put("MyService.MyAlgorithm imPLementedIn", "softWARE");
- assertTrue(Arrays.equals(new Provider[] { p }, Security
- .getProviders(m)));
- m.clear();
- m.put("MyService.MyAlgorithm ATTribute", "attributeVALUE");
- assertTrue(Arrays.equals(new Provider[] { p }, Security
- .getProviders(m)));
-
- // Regression for HARMONY-2761
- m.clear();
- m.put("MyService.NoKeySize KeySize", "512");
- assertNull("No KeySize attribute", Security.getProviders(m));
-
- m.clear();
- m.put("MyService.NoImplementedIn ImplementedIn", "Software");
- assertNull("No ImplementedIn attribute", Security.getProviders(m));
-
- m.clear();
- m.put("ABCService.NoAttribute Attribute", "ABC");
- assertNull(Security.getProviders(m));
- } finally { //clean up
- Security.removeProvider(p.getName());
- }
- }
-
- /**
- * @tests java.security.Security#getProperty(String)
- */
- public void test_getPropertyLjava_lang_String() {
-
- try {
- Security.getProperty(null);
- fail("No expected NullPointerException.");
- } catch (NullPointerException e) {
- }
-
- Security.setProperty("myprop", "test white space ");
- assertEquals("test white space", Security.getProperty("myprop"));
- }
-
- /**
- * @tests java.security.Security#setProperty(String, String)
- */
- public void test_setPropertyLjava_lang_StringLjava_lang_String() {
-
- try {
- Security.setProperty(null, "");
- fail("No expected NullPointerException.");
- } catch (NullPointerException e) {
- }
-
- try {
- Security.setProperty("", null);
- fail("No expected NullPointerException.");
- } catch (NullPointerException e) {
- }
-
- Security.setProperty("", "");
- assertEquals("Empty property", "", Security.getProperty(""));
-
- Security.setProperty("My Test Property", "My property value");
- assertEquals("My property value", Security
- .getProperty("My Test Property"));
- }
-
- @SuppressWarnings("serial")
- class MyProvider extends Provider {
- MyProvider() {
- super("MyProvider", 1.0, "Provider for testing");
- put("MessageDigest.SHA-1", "SomeClassName");
- put("MyService.MyAlgorithm", "SomeClassName");
- put("MyService.MyAlgorithm KeySize", "1024");
- put("MyService.MyAlgorithm ImplementedIn", "Software");
- put("MyService.MyAlgorithm Attribute", "AttributeValue");
-
- // service has no KeySize attribute
- put("MyService.NoKeySize", "SomeClassName");
-
- // service has no ImplementedIn attribute
- put("MyService.NoImplementedIn", "SomeClassName");
-
- // service has no 'Attribute' attribute
- put("ABCService.NoAttribute", "SomeClassName");
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signature2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signature2Test.java
deleted file mode 100644
index 0f34c47..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signature2Test.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.math.BigInteger;
-import java.security.InvalidParameterException;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.Provider;
-import java.security.Security;
-import java.security.Signature;
-import java.security.spec.DSAParameterSpec;
-import java.util.Locale;
-
-public class Signature2Test extends junit.framework.TestCase {
-
- private static final String MESSAGE = "abc";
- static KeyPair keys;
-
- static {
- try {
- KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
- keyGen.initialize(1024);
- keys = keyGen.generateKeyPair();
- } catch (Exception e) {
- fail(e.toString());
- }
- }
-
- /**
- * @tests java.security.Signature#clone()
- */
- public void test_clone() throws Exception {
- Signature s = Signature.getInstance("DSA");
- try {
- s.clone();
- fail("A Signature may not be cloneable");
- } catch (CloneNotSupportedException e) {
- // Expected - a Signature may not be cloneable
- }
- }
-
- /**
- * @tests java.security.Signature#getAlgorithm()
- */
- public void test_getAlgorithm() throws Exception {
- String alg = Signature.getInstance("DSA").getAlgorithm();
- assertTrue("getAlgorithm did not get DSA (" + alg + ")", alg
- .indexOf("DSA") != -1);
- }
-
- /**
- * @tests java.security.Signature#getInstance(java.lang.String)
- */
- public void test_getInstanceLjava_lang_String() throws Exception {
- Signature.getInstance("DSA");
- }
-
- /**
- * @tests java.security.Signature#getInstance(java.lang.String,
- *java.lang.String)
- */
- public void test_getInstanceLjava_lang_StringLjava_lang_String() throws Exception {
- Provider[] providers = Security.getProviders("Signature.DSA");
-
- for (int i = 0; i < providers.length; i++) {
- Signature.getInstance("DSA", providers[i].getName());
- }// end for
- }
-
- /**
- * @tests java.security.Signature#getParameters()
- */
- public void test_getParameters() throws Exception {
- Signature sig = Signature.getInstance("DSA");
- try {
- sig.getParameters();
- } catch (UnsupportedOperationException e) {
- // Could be that the operation is not supported
- }
- }
-
- /**
- * @tests java.security.Signature#getParameter(java.lang.String)
- */
- public void test_getParameterLjava_lang_String() throws Exception {
- Signature sig = Signature.getInstance("DSA");
-
- try {
- sig.getParameter("r");
- sig.getParameter("s");
- } catch (UnsupportedOperationException e) {
- }
- }
-
- /**
- * @tests java.security.Signature#getProvider()
- */
- public void test_getProvider() throws Exception {
- Provider p = Signature.getInstance("DSA").getProvider();
- assertNotNull("provider is null", p);
- }
-
- /**
- * @tests java.security.Signature#initSign(java.security.PrivateKey)
- */
- public void test_initSignLjava_security_PrivateKey() throws Exception {
- Signature.getInstance("DSA").initSign(keys.getPrivate());
- }
-
- /**
- * @tests java.security.Signature#initVerify(java.security.PublicKey)
- */
- public void test_initVerifyLjava_security_PublicKey() throws Exception {
- Signature.getInstance("DSA").initVerify(keys.getPublic());
- }
-
- /**
- * @tests java.security.Signature#setParameter(java.lang.String,
- *java.lang.Object)
- */
- public void test_setParameterLjava_lang_StringLjava_lang_Object() throws Exception {
- Signature sig = Signature.getInstance("DSA");
-
- try {
- sig.setParameter("r", BigInteger.ONE);
- sig.setParameter("s", BigInteger.ONE);
- } catch (InvalidParameterException e) {
- // Could be that it's an invalid param for the found algorithm
- } catch (UnsupportedOperationException e) {
- // Could be that the operation is not supported
- }
- }
-
- /**
- * @tests java.security.Signature#setParameter(java.security.spec.AlgorithmParameterSpec)
- */
- public void test_setParameterLjava_security_spec_AlgorithmParameterSpec() throws Exception {
- Signature sig = Signature.getInstance("DSA");
-
- try {
- DSAParameterSpec spec = new DSAParameterSpec(BigInteger.ONE,
- BigInteger.ONE, BigInteger.ONE);
- sig.setParameter(spec);
- } catch (InvalidParameterException e) {
- // Could be that it's an invalid param for the found algorithm
- } catch (UnsupportedOperationException e) {
- // Could be that the operation is not supported
- }
- }
-
- /**
- * @tests java.security.Signature#sign()
- */
- public void test_sign() throws Exception {
- Signature sig = Signature.getInstance("DSA");
- sig.initSign(keys.getPrivate());
- sig.update(MESSAGE.getBytes());
- sig.sign();
- }
-
- /**
- * @tests java.security.Signature#toString()
- */
- public void test_toString() throws Exception {
- String str = Signature.getInstance("DSA").toString();
- assertNotNull("toString is null", str);
- }
-
- /**
- * @tests java.security.Signature#update(byte[])
- */
- public void test_update$B() throws Exception {
- Signature sig = Signature.getInstance("DSA");
- sig.initSign(keys.getPrivate());
-
- byte[] bytes = MESSAGE.getBytes();
- sig.update(bytes);
- }
-
- /**
- * @tests java.security.Signature#update(byte[], int, int)
- */
- public void test_update$BII() throws Exception {
- Signature sig = Signature.getInstance("DSA");
- sig.initSign(keys.getPrivate());
-
- byte[] bytes = MESSAGE.getBytes();
- sig.update(bytes, 0, bytes.length);
- }
-
- /**
- * @tests java.security.Signature#update(byte)
- */
- public void test_updateB() throws Exception {
- Signature sig = Signature.getInstance("DSA");
- sig.initSign(keys.getPrivate());
-
- sig.update(MESSAGE.getBytes()[0]);
- }
-
- /**
- * @tests java.security.Signature#verify(byte[])
- */
- public void test_verify$B() throws Exception {
- Signature sig = Signature.getInstance("DSA");
- sig.initSign(keys.getPrivate());
- sig.update(MESSAGE.getBytes());
- byte[] signature = sig.sign();
-
-
- sig.initVerify(keys.getPublic());
- sig.update(MESSAGE.getBytes());
- assertTrue("Sign/Verify does not pass", sig.verify(signature));
- }
-
- //Regression Test for HARMONY-4916
- public void test_getInstance_withI18n() throws Exception {
- // Enfore that providers information has been loaded.
- Signature.getInstance("DSA");
- Locale defaultLocale = Locale.getDefault();
- try {
- /**
- * In locale("tr"), char 'i' will be transferred to an upper case
- * other char than 'I'. Thus in security architecture, all
- * manipulation to the string representing an algorithm name or
- * standard property shall be treated as locale neutral
- */
- Locale.setDefault(new Locale("tr"));
- Signature.getInstance("MD5withRSA");
- } finally {
- Locale.setDefault(defaultLocale);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignatureExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignatureExceptionTest.java
deleted file mode 100644
index f550537..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignatureExceptionTest.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.SignatureException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SignatureException</code> class constructors and methods.
- */
-public class SignatureExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for SignatureExceptionTests.
- *
- * @param arg0
- */
- public SignatureExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>SignatureException()</code> constructor Assertion:
- * constructs SignatureException with no detail message
- */
- public void testSignatureException01() {
- SignatureException tE = new SignatureException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>SignatureException(String)</code> constructor Assertion:
- * constructs SignatureException with detail message msg. Parameter
- * <code>msg</code> is not null.
- */
- public void testSignatureException02() {
- SignatureException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new SignatureException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>SignatureException(String)</code> constructor Assertion:
- * constructs SignatureException when <code>msg</code> is null
- */
- public void testSignatureException03() {
- String msg = null;
- SignatureException tE = new SignatureException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>SignatureException(Throwable)</code> constructor
- * Assertion: constructs SignatureException when <code>cause</code> is
- * null
- */
- public void testSignatureException04() {
- Throwable cause = null;
- SignatureException tE = new SignatureException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>SignatureException(Throwable)</code> constructor
- * Assertion: constructs SignatureException when <code>cause</code> is not
- * null
- */
- public void testSignatureException05() {
- SignatureException tE = new SignatureException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>SignatureException(String, Throwable)</code> constructor
- * Assertion: constructs SignatureException when <code>cause</code> is
- * null <code>msg</code> is null
- */
- public void testSignatureException06() {
- SignatureException tE = new SignatureException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>SignatureException(String, Throwable)</code> constructor
- * Assertion: constructs SignatureException when <code>cause</code> is
- * null <code>msg</code> is not null
- */
- public void testSignatureException07() {
- SignatureException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new SignatureException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>SignatureException(String, Throwable)</code> constructor
- * Assertion: constructs SignatureException when <code>cause</code> is not
- * null <code>msg</code> is null
- */
- public void testSignatureException08() {
- SignatureException tE = new SignatureException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>SignatureException(String, Throwable)</code> constructor
- * Assertion: constructs SignatureException when <code>cause</code> is not
- * null <code>msg</code> is not null
- */
- public void testSignatureException09() {
- SignatureException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new SignatureException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java
deleted file mode 100644
index 59269d2..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.Signature;
-import java.security.SignedObject;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.TestKeyPair;
-
-/**
- * Tests for <code>SignedObject</code> constructor and methods
- */
-public class SignedObjectTest extends TestCase {
-
- public void testSignedObject() throws Exception {
- TestKeyPair tkp = null;
- Properties prop;
-
- Signature sig = Signature.getInstance("SHA1withDSA");
-
- try {
- tkp = new TestKeyPair("DSA");
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- return;
- }
- prop = new Properties();
- prop.put("aaa", "bbb");
-
- SignedObject so = new SignedObject(prop, tkp.getPrivate(), sig);
-
- assertEquals("SHA1withDSA", so.getAlgorithm());
- assertEquals(prop, so.getObject());
-
- assertTrue("verify() failed", so.verify(tkp.getPublic(), sig));
-
- assertNotNull("signature is null", so.getSignature());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignerTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignerTest.java
deleted file mode 100644
index d5743ef..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignerTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Aleksei Y. Semenov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import org.apache.harmony.security.tests.support.PrivateKeyStub;
-import org.apache.harmony.security.tests.support.PublicKeyStub;
-import org.apache.harmony.security.tests.support.SignerStub;
-
-import junit.framework.TestCase;
-
-
-/**
- * tests for class Signer
- */
-
-public class SignerTest extends TestCase {
-
- /**
- * Constructor for SignerTest.
- *
- * @param arg0
- */
- public SignerTest(String arg0) {
- super(arg0);
- }
-
- /**
- * @tests java.security.Signer#toString()
- */
- public void test_toString() throws Exception {
- Signer s1 = new SignerStub("testToString1");
- assertEquals("[Signer]testToString1", s1.toString());
-
- Signer s2 = new SignerStub("testToString2", IdentityScope.getSystemScope());
- s2.toString();
-
- KeyPair kp = new KeyPair(new PublicKeyStub("public", "SignerTest.testToString", null), new PrivateKeyStub("private", "SignerTest.testToString", null));
- s1.setKeyPair(kp);
- s1.toString();
-
- s2.setKeyPair(kp);
- s2.toString();
- }
-
- /**
- * verify Signer() creates instance
- */
- public void testSigner() {
- Signer s = new SignerStub();
- assertNotNull(s);
- //assertNull(s.getName(), s.getName());
- assertNull(s.getPrivateKey());
- }
-
- /**
- * verify Signer(String) creates instance
- */
- public void testSignerString() throws Exception {
- Signer s = new SignerStub("sss3");
- assertNotNull(s);
- assertEquals("sss3", s.getName());
- assertNull(s.getPrivateKey());
- }
-
- /**
- * verify Signer(String, IdentityScope) creates instance
- */
- public void testSignerStringIdentityScope() throws Exception {
- Signer s = new SignerStub("sss4", IdentityScope.getSystemScope());
- assertNotNull(s);
- assertEquals("sss4", s.getName());
- assertSame(IdentityScope.getSystemScope(), s.getScope());
- assertNull(s.getPrivateKey());
- }
-
- /**
- * verify Signer.getPrivateKey() returns null or private key
- */
- public void testGetPrivateKey() throws Exception {
- byte[] privateKeyData = { 1, 2, 3, 4, 5 };
- PrivateKeyStub privateKey = new PrivateKeyStub("private", "fff", privateKeyData);
- PublicKeyStub publicKey = new PublicKeyStub("public", "fff", null);
- KeyPair kp = new KeyPair(publicKey, privateKey);
-
- Signer s = new SignerStub("sss5");
-
- assertNull(s.getPrivateKey());
-
- s.setKeyPair(kp);
- assertSame(privateKey, s.getPrivateKey());
- }
-
- /**
- * @tests java.security.Signer#setKeyPair(java.security.KeyPair)
- */
- public void test_setKeyPairLjava_security_KeyPair() throws Exception {
-
- // Regression for HARMONY-2408
- // test: NullPointerException if pair is null
- try {
- new SignerStub("name").setKeyPair(null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/TimestampTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/TimestampTest.java
deleted file mode 100644
index 0eb6047..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/TimestampTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import java.security.cert.CertPath;
-import java.util.Date;
-
-import org.apache.harmony.security.tests.support.cert.MyCertPath;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>Timestamp</code> class fields and methods
- */
-
-public class TimestampTest extends TestCase {
-
- private Date now = new Date();
-
- private static final byte[] encoding = { 1, 2, 3 };
-
- private CertPath cpath = new MyCertPath(encoding);
-
- public void testTimestamp() {
- try {
- new Timestamp(null, cpath);
- fail("null was accepted");
- } catch (NullPointerException ex) { /* ok */
- }
-
- try {
- new Timestamp(now, null);
- fail("null was accepted");
- return;
- } catch (NullPointerException ex) { /* ok */
- }
- }
-
- /*
- * Class under test for boolean equals(Object)
- */
- public void testEqualsObject() {
- Timestamp one = new Timestamp(now, cpath);
- Timestamp two = new Timestamp(now, cpath);
-
- assertTrue(one.equals(one));
- assertTrue(one.equals(two));
- assertTrue(two.equals(one));
- assertFalse(one.equals(null));
- assertFalse(one.equals(new Object()));
-
- Timestamp two1 = new Timestamp(new Date(9999), cpath);
- assertFalse(one.equals(two1));
- assertTrue(two1.equals(two1));
- }
-
- public void testGetSignerCertPath() {
- assertSame(new Timestamp(now, cpath).getSignerCertPath(), cpath);
- }
-
- public void testGetTimestamp() {
- Timestamp t = new Timestamp(now, cpath);
- assertEquals(now, t.getTimestamp());
- assertNotSame(now, t.getTimestamp());
- }
-
- /*
- * Class under test for String toString()
- */
- public void testToString() {
- new Timestamp(now, cpath).toString();
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnrecoverableEntryExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnrecoverableEntryExceptionTest.java
deleted file mode 100644
index e60883e..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnrecoverableEntryExceptionTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.*;
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>UnrecoverableEntryException</code> class
- */
-
-public class UnrecoverableEntryExceptionTest extends TestCase {
-
- /**
- * Constructor for UnrecoverableEntryExceptionTest.
- *
- * @param arg0
- */
- public UnrecoverableEntryExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static String errNotExc = "Not UnrecoverableEntryException object";
-
- /*
- * Class under test for void UnrecoverableEntryException()
- */
- public void testUnrecoverableEntryException() {
- UnrecoverableEntryException tE = new UnrecoverableEntryException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /*
- * Class under test for void UnrecoverableEntryException(String)
- */
- public void testUnrecoverableEntryExceptionString() {
- UnrecoverableEntryException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new UnrecoverableEntryException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnrecoverableKeyExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnrecoverableKeyExceptionTest.java
deleted file mode 100644
index 213cec4..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnrecoverableKeyExceptionTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.UnrecoverableKeyException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>UnrecoverableKeyException</code> class constructors and
- * methods.
- */
-public class UnrecoverableKeyExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for UnrecoverableKeyExceptionTests.
- *
- * @param arg0
- */
- public UnrecoverableKeyExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>UnrecoverableKeyException()</code> constructor
- * Assertion: constructs UnrecoverableKeyException with no detail message
- */
- public void testUnrecoverableKeyException01() {
- UnrecoverableKeyException tE = new UnrecoverableKeyException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>UnrecoverableKeyException(String)</code> constructor
- * Assertion: constructs UnrecoverableKeyException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testUnrecoverableKeyException02() {
- UnrecoverableKeyException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new UnrecoverableKeyException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>UnrecoverableKeyException(String)</code> constructor
- * Assertion: constructs UnrecoverableKeyException when <code>msg</code>
- * is null
- */
- public void testUnrecoverableKeyException03() {
- String msg = null;
- UnrecoverableKeyException tE = new UnrecoverableKeyException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java
deleted file mode 100644
index 2a6ce72..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Aleksei Y. Semenov
- */
-
-package org.apache.harmony.security.tests.java.security.acl;
-
-import java.security.acl.AclNotFoundException;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for AclNotFoundException.
- */
-
-public class AclNotFoundExceptionTest extends TestCase {
-
- /**
- * @tests java.security.acl.AclNotFoundException#AclNotFoundException()
- */
- public void testAclNotFoundException() {
- AclNotFoundException ex = new AclNotFoundException();
- assertNull(ex.getMessage());
- assertNull(ex.getCause());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java
deleted file mode 100644
index 4ff49ff..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security.acl;
-
-import java.security.acl.LastOwnerException;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for LastOwnerException.
- */
-
-public class LastOwnerExceptionTest extends TestCase {
-
- /**
- * @tests java.security.acl.LastOwnerException#LastOwnerException()
- */
- public void testLastOwnerException() {
- LastOwnerException ex = new LastOwnerException();
- assertNull(ex.getMessage());
- assertNull(ex.getCause());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java
deleted file mode 100644
index bbc4fef..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security.acl;
-
-import java.security.acl.NotOwnerException;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for NotOwnerException.
- */
-
-public class NotOwnerExceptionTest extends TestCase {
-
- /**
- * @tests java.security.acl.NotOwnerException#NotOwnerException()
- */
- public void testNotOwnerException() {
- NotOwnerException ex = new NotOwnerException();
- assertNull(ex.getMessage());
- assertNull(ex.getCause());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLExceptionTest.java
deleted file mode 100644
index cfc3d2d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLExceptionTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CRLException;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CRLException</code> class constructors and methods.
- */
-public class CRLExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CRLExceptionTests.
- *
- * @param arg0
- */
- public CRLExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CRLException()</code> constructor Assertion: constructs
- * CRLException with no detail message
- */
- public void testCRLException01() {
- CRLException tE = new CRLException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CRLException(String)</code> constructor Assertion:
- * constructs CRLException with detail message msg. Parameter
- * <code>msg</code> is not null.
- */
- public void testCRLException02() {
- CRLException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CRLException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CRLException(String)</code> constructor Assertion:
- * constructs CRLException when <code>msg</code> is null
- */
- public void testCRLException03() {
- String msg = null;
- CRLException tE = new CRLException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CRLException(Throwable)</code> constructor Assertion:
- * constructs CRLException when <code>cause</code> is null
- */
- public void testCRLException04() {
- Throwable cause = null;
- CRLException tE = new CRLException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CRLException(Throwable)</code> constructor Assertion:
- * constructs CRLException when <code>cause</code> is not null
- */
- public void testCRLException05() {
- CRLException tE = new CRLException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CRLException(String, Throwable)</code> constructor
- * Assertion: constructs CRLException when <code>cause</code> is null
- * <code>msg</code> is null
- */
- public void testCRLException06() {
- CRLException tE = new CRLException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CRLException(String, Throwable)</code> constructor
- * Assertion: constructs CRLException when <code>cause</code> is null
- * <code>msg</code> is not null
- */
- public void testCRLException07() {
- CRLException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CRLException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CRLException(String, Throwable)</code> constructor
- * Assertion: constructs CRLException when <code>cause</code> is not null
- * <code>msg</code> is null
- */
- public void testCRLException08() {
- CRLException tE = new CRLException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CRLException(String, Throwable)</code> constructor
- * Assertion: constructs CRLException when <code>cause</code> is not null
- * <code>msg</code> is not null
- */
- public void testCRLException09() {
- CRLException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CRLException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLTest.java
deleted file mode 100644
index 6f24275..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CRL;
-
-import org.apache.harmony.security.tests.support.cert.MyCRL;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>java.security.cert.CRL</code> fields and methods
- */
-public class CRLTest extends TestCase {
-
- /**
- * Constructor for CRLTest.
- *
- * @param name
- */
- public CRLTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>getType()</code> method<br>
- * Assertion: returns <code>CRL</code> type
- */
- public final void testGetType01() {
- CRL crl = new MyCRL("TEST_TYPE");
- assertEquals("TEST_TYPE", crl.getType());
- }
-
- /**
- * Test #2 for <code>getType()</code> method<br>
- * Assertion: returns <code>CRL</code> type
- */
- public final void testGetType02() {
- CRL crl = new MyCRL(null);
- assertNull(crl.getType());
- }
-
- //
- // the following tests just call methods
- // that are abstract in <code>Certificate</code>
- // (So they just like signature tests)
- //
-
- /**
- * Test for <code>toString()</code> method
- */
- public final void testToString() {
- CRL crl = new MyCRL("TEST_TYPE");
- crl.toString();
- }
-
- /**
- * Test for <code>isRevoked()</code> method
- */
- public final void testIsRevoked() {
- CRL crl = new MyCRL("TEST_TYPE");
- crl.isRevoked(null);
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java
deleted file mode 100644
index 84191e8..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.cert.CertPathBuilder;
-import java.security.cert.CertPathBuilderException;
-import java.security.cert.CertPathBuilderSpi;
-import java.security.cert.CertificateException;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.cert.MyCertPathBuilderSpi;
-
-import tests.support.Support_Exec;
-
-/**
- * Tests for <code>CertPathBuilder</code> class constructors and
- * methods.
- */
-
-public class CertPathBuilder1Test extends TestCase {
-
- /**
- * Constructor for CertPathBuilderTests.
- *
- * @param name
- */
- public CertPathBuilder1Test(String name) {
- super(name);
- }
-
- public static final String srvCertPathBuilder = "CertPathBuilder";
-
- public static final String defaultType = "PKIX";
- public static final String[] validValues = {
- "PKIX", "pkix", "PkiX", "pKiX" };
-
- private static String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static boolean PKIXSupport = false;
-
- private static Provider defaultProvider;
- private static String defaultProviderName;
-
- private static String NotSupportMsg = "";
-
- public static final String DEFAULT_TYPE_PROPERTY = "certpathbuilder.type";
-
- static {
- defaultProvider = SpiEngUtils.isSupport(defaultType,
- srvCertPathBuilder);
- PKIXSupport = (defaultProvider != null);
- defaultProviderName = (PKIXSupport ? defaultProvider.getName() : null);
- NotSupportMsg = defaultType.concat(" is not supported");
- }
-
- private static CertPathBuilder[] createCPBs() {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return null;
- }
- try {
- CertPathBuilder[] certPBs = new CertPathBuilder[3];
- certPBs[0] = CertPathBuilder.getInstance(defaultType);
- certPBs[1] = CertPathBuilder.getInstance(defaultType,
- defaultProviderName);
- certPBs[2] = CertPathBuilder.getInstance(defaultType,
- defaultProvider);
- return certPBs;
- } catch (Exception e) {
- return null;
- }
- }
-
- /**
- * @tests java.security.cert.CertPathBuilder#getDefaultType()
- */
- public void test_getDefaultType() throws Exception {
-
- // Regression for HARMONY-2785
-
- // test: default value
- assertNull(Security.getProperty(DEFAULT_TYPE_PROPERTY));
- assertEquals("PKIX", CertPathBuilder.getDefaultType());
-
- // test: security property. fork new VM to keep testing env. clean
- Support_Exec.execJava(new String[] { DefaultType.class.getName() },
- null, true);
- }
-
- public static class DefaultType {
-
- public static void main(String[] args) {
-
- Security.setProperty(DEFAULT_TYPE_PROPERTY, "MyType");
- assertEquals("MyType", CertPathBuilder.getDefaultType());
-
- Security.setProperty(DEFAULT_TYPE_PROPERTY, "AnotherType");
- assertEquals("AnotherType", CertPathBuilder.getDefaultType());
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not correct
- * or it is not available
- */
- public void testCertPathBuilder02() throws NoSuchAlgorithmException {
- try {
- CertPathBuilder.getInstance(null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertPathBuilder.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion: returns CertPathBuilder object
- */
- public void testCertPathBuilder03() throws NoSuchAlgorithmException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- for (int i = 0; i < validValues.length; i++) {
- CertPathBuilder cpb = CertPathBuilder.getInstance(validValues[i]);
- assertEquals("Incorrect algorithm", cpb.getAlgorithm(), validValues[i]);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion: throws IllegalArgumentException when provider is null or empty
- * <p/>
- * FIXME: verify what exception will be thrown if provider is empty
- */
- public void testCertPathBuilder04()
- throws NoSuchAlgorithmException, NoSuchProviderException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- String provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertPathBuilder.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown thrown");
- } catch (IllegalArgumentException e) {
- }
- try {
- CertPathBuilder.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
- * throws NoSuchProviderException when provider has invalid value
- */
- public void testCertPathBuilder05()
- throws NoSuchAlgorithmException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- CertPathBuilder.getInstance(validValues[i], invalidValues[j]);
- fail("NoSuchProviderException must be hrown");
- } catch (NoSuchProviderException e1) {
- }
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not correct
- */
- public void testCertPathBuilder06()
- throws NoSuchAlgorithmException, NoSuchProviderException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- try {
- CertPathBuilder.getInstance(null, defaultProviderName);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertPathBuilder.getInstance(invalidValues[i], defaultProviderName);
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e1) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion: returns CertPathBuilder object
- */
- public void testCertPathBuilder07()
- throws NoSuchAlgorithmException, NoSuchProviderException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- CertPathBuilder certPB;
- for (int i = 0; i < validValues.length; i++) {
- certPB = CertPathBuilder.getInstance(validValues[i], defaultProviderName);
- assertEquals("Incorrect algorithm", certPB.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider name", certPB.getProvider().getName(), defaultProviderName);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code> method
- * Assertion: throws IllegalArgumentException when provider is null
- */
- public void testCertPathBuilder08()
- throws NoSuchAlgorithmException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- Provider prov = null;
- for (int t = 0; t < validValues.length; t++) {
- try {
- CertPathBuilder.getInstance(validValues[t], prov);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e1) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not correct
- */
- public void testCertPathBuilder09()
- throws NoSuchAlgorithmException, NoSuchProviderException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- try {
- CertPathBuilder.getInstance(null, defaultProvider);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertPathBuilder.getInstance(invalidValues[i], defaultProvider);
- fail("NoSuchAlgorithm must be thrown");
- } catch (NoSuchAlgorithmException e1) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion: returns CertPathBuilder object
- */
- public void testCertPathBuilder10()
- throws NoSuchAlgorithmException, NoSuchProviderException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- CertPathBuilder certPB;
- for (int i = 0; i < invalidValues.length; i++) {
- certPB = CertPathBuilder.getInstance(validValues[i], defaultProvider);
- assertEquals("Incorrect algorithm", certPB.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider name", certPB.getProvider(), defaultProvider);
- }
- }
-
- /**
- * Test for <code>build(CertPathParameters params)</code> method
- * Assertion: throws InvalidAlgorithmParameterException params is null
- */
- public void testCertPathBuilder11()
- throws NoSuchAlgorithmException, NoSuchProviderException,
- CertPathBuilderException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- CertPathBuilder[] certPB = createCPBs();
- assertNotNull("CertPathBuilder objects were not created", certPB);
- for (int i = 0; i < certPB.length; i++) {
- try {
- certPB[i].build(null);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
- }
-
- /**
- * Test for
- * <code>CertPathBuilder</code> constructor
- * Assertion: returns CertPathBuilder object
- */
- public void testCertPathBuilder12()
- throws CertificateException, NoSuchProviderException,
- NoSuchAlgorithmException, InvalidAlgorithmParameterException,
- CertPathBuilderException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- CertPathBuilderSpi spi = new MyCertPathBuilderSpi();
- CertPathBuilder certPB = new myCertPathBuilder(spi,
- defaultProvider, defaultType);
- assertEquals("Incorrect algorithm", certPB.getAlgorithm(), defaultType);
- assertEquals("Incorrect provider", certPB.getProvider(), defaultProvider);
- try {
- certPB.build(null);
- fail("CertPathBuilderException must be thrown ");
- } catch (CertPathBuilderException e) {
- }
- certPB = new myCertPathBuilder(null, null, null);
- assertNull("Incorrect algorithm", certPB.getAlgorithm());
- assertNull("Incorrect provider", certPB.getProvider());
- try {
- certPB.build(null);
- fail("NullPointerException must be thrown ");
- } catch (NullPointerException e) {
- }
- }
-}
-
-/**
- * Additional class to verify CertPathBuilder constructor
- */
-class myCertPathBuilder extends CertPathBuilder {
-
- public myCertPathBuilder(CertPathBuilderSpi spi, Provider prov, String type) {
- super(spi, prov, type);
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java
deleted file mode 100644
index 9654d92..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.cert.CertPathBuilder;
-import java.security.cert.CertPathBuilderException;
-import java.security.cert.CertPathBuilderResult;
-
-import org.apache.harmony.security.tests.java.security.cert.CertPathBuilder1Test;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for CertPathBuilder class constructors and methods
- */
-
-public class CertPathBuilder2Test extends TestCase {
- private static final String defaultAlg = "CertPB";
- private static final String CertPathBuilderProviderClass = "org.apache.harmony.security.tests.support.cert.MyCertPathBuilderSpi";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "CeRtPb";
- validValues[3] = "cERTpb";
- }
-
- Provider mProv;
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyCertPathBuilderProvider",
- "Provider for testing", CertPathBuilder1Test.srvCertPathBuilder
- .concat(".").concat(defaultAlg),
- CertPathBuilderProviderClass);
- Security.insertProviderAt(mProv, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- /**
- * Constructor for CertPathBuilder2Test.
- *
- * @param arg0
- */
- public CertPathBuilder2Test(String arg0) {
- super(arg0);
- }
-
- private void checkResult(CertPathBuilder certBuild)
- throws InvalidAlgorithmParameterException,
- CertPathBuilderException {
- String dt = CertPathBuilder.getDefaultType();
- String propName = CertPathBuilder1Test.DEFAULT_TYPE_PROPERTY;
- String dtN;
- for (int i = 0; i < invalidValues.length; i++) {
- Security.setProperty(propName, invalidValues[i]);
- dtN = CertPathBuilder.getDefaultType();
- if (!dtN.equals(invalidValues[i]) && !dtN.equals(dt)) {
- fail("Incorrect default type: ".concat(dtN));
- }
- }
- Security.setProperty(propName, dt);
- assertEquals("Incorrect default type", CertPathBuilder.getDefaultType(),
- dt);
- try {
- certBuild.build(null);
- fail("CertPathBuilderException must be thrown");
- } catch (CertPathBuilderException e) {
- }
- CertPathBuilderResult cpbResult = certBuild.build(null);
- assertNull("Not null CertPathBuilderResult", cpbResult);
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions:
- * throws
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not correct
- * returns CertPathBuilder object
- */
- public void testGetInstance01() throws NoSuchAlgorithmException,
- InvalidAlgorithmParameterException, CertPathBuilderException {
- try {
- CertPathBuilder.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertPathBuilder.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- CertPathBuilder cerPB;
- for (int i = 0; i < validValues.length; i++) {
- cerPB = CertPathBuilder.getInstance(validValues[i]);
- assertEquals("Incorrect type", cerPB.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider", cerPB.getProvider(), mProv);
- checkResult(cerPB);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not correct
- * throws IllegalArgumentException when provider is null or empty;
- * throws NoSuchProviderException when provider is available;
- * returns CertPathBuilder object
- */
- public void testGetInstance02() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidAlgorithmParameterException, CertPathBuilderException {
- try {
- CertPathBuilder.getInstance(null, mProv.getName());
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertPathBuilder.getInstance(invalidValues[i], mProv
- .getName());
- fail("NoSuchAlgorithmException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertPathBuilder.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (type: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- try {
- CertPathBuilder.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty (type: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- CertPathBuilder.getInstance(validValues[i],
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (type: "
- .concat(validValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- CertPathBuilder cerPB;
- for (int i = 0; i < validValues.length; i++) {
- cerPB = CertPathBuilder.getInstance(validValues[i], mProv
- .getName());
- assertEquals("Incorrect type", cerPB.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider", cerPB.getProvider().getName(),
- mProv.getName());
- checkResult(cerPB);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not correct
- * returns CertPathBuilder object
- */
- public void testGetInstance03() throws NoSuchAlgorithmException,
- IllegalArgumentException,
- InvalidAlgorithmParameterException, CertPathBuilderException {
- try {
- CertPathBuilder.getInstance(null, mProv);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertPathBuilder.getInstance(invalidValues[i], mProv);
- fail("NoSuchAlgorithmException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertPathBuilder.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (type: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- CertPathBuilder cerPB;
- for (int i = 0; i < validValues.length; i++) {
- cerPB = CertPathBuilder.getInstance(validValues[i], mProv);
- assertEquals("Incorrect type", cerPB.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider", cerPB.getProvider(), mProv);
- checkResult(cerPB);
- }
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderExceptionTest.java
deleted file mode 100644
index 417cc70..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderExceptionTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CertPathBuilderException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>CertPathBuilderException</code> class constructors and
- * methods.
- */
-public class CertPathBuilderExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertPathBuilderExceptionTests.
- *
- * @param arg0
- */
- public CertPathBuilderExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertPathBuilderException()</code> constructor Assertion:
- * constructs CertPathBuilderException with no detail message
- */
- public void testCertPathBuilderException01() {
- CertPathBuilderException tE = new CertPathBuilderException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertPathBuilderException(String)</code> constructor
- * Assertion: constructs CertPathBuilderException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testCertPathBuilderException02() {
- CertPathBuilderException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertPathBuilderException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertPathBuilderException(String)</code> constructor
- * Assertion: constructs CertPathBuilderException when <code>msg</code> is
- * null
- */
- public void testCertPathBuilderException03() {
- String msg = null;
- CertPathBuilderException tE = new CertPathBuilderException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertPathBuilderException(Throwable)</code> constructor
- * Assertion: constructs CertPathBuilderException when <code>cause</code>
- * is null
- */
- public void testCertPathBuilderException04() {
- Throwable cause = null;
- CertPathBuilderException tE = new CertPathBuilderException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertPathBuilderException(Throwable)</code> constructor
- * Assertion: constructs CertPathBuilderException when <code>cause</code>
- * is not null
- */
- public void testCertPathBuilderException05() {
- CertPathBuilderException tE = new CertPathBuilderException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CertPathBuilderException(String, Throwable)</code>
- * constructor Assertion: constructs CertPathBuilderException when
- * <code>cause</code> is null <code>msg</code> is null
- */
- public void testCertPathBuilderException06() {
- CertPathBuilderException tE = new CertPathBuilderException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertPathBuilderException(String, Throwable)</code>
- * constructor Assertion: constructs CertPathBuilderException when
- * <code>cause</code> is null <code>msg</code> is not null
- */
- public void testCertPathBuilderException07() {
- CertPathBuilderException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertPathBuilderException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertPathBuilderException(String, Throwable)</code>
- * constructor Assertion: constructs CertPathBuilderException when
- * <code>cause</code> is not null <code>msg</code> is null
- */
- public void testCertPathBuilderException08() {
- CertPathBuilderException tE = new CertPathBuilderException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CertPathBuilderException(String, Throwable)</code>
- * constructor Assertion: constructs CertPathBuilderException when
- * <code>cause</code> is not null <code>msg</code> is not null
- */
- public void testCertPathBuilderException09() {
- CertPathBuilderException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertPathBuilderException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderSpiTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderSpiTest.java
deleted file mode 100644
index 0067c2d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderSpiTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.cert.CertPathBuilderException;
-import java.security.cert.CertPathBuilderResult;
-import java.security.cert.CertPathBuilderSpi;
-import java.security.cert.CertPathParameters;
-
-import org.apache.harmony.security.tests.support.cert.MyCertPathBuilderSpi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertPathBuilderSpi</code> class constructors and methods.
- */
-
-public class CertPathBuilderSpiTest extends TestCase {
-
- /**
- * Constructor for CertPathBuilderSpiTest.
- *
- * @param arg0
- */
- public CertPathBuilderSpiTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>CertPathBuilderSpi</code> constructor Assertion:
- * constructs CertPathBuilderSpi
- */
- public void testCertPathBuilderSpi01() throws CertPathBuilderException,
- InvalidAlgorithmParameterException {
- CertPathBuilderSpi certPathBuilder = new MyCertPathBuilderSpi();
- CertPathParameters cpp = null;
- try {
- certPathBuilder.engineBuild(cpp);
- fail("CertPathBuilderException must be thrown");
- } catch (CertPathBuilderException e) {
- }
- CertPathBuilderResult cpbResult = certPathBuilder.engineBuild(cpp);
- assertNull("Not null CertPathBuilderResult", cpbResult);
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathTest.java
deleted file mode 100644
index a477de9..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CertPath;
-import java.security.cert.CertificateEncodingException;
-
-import org.apache.harmony.security.tests.support.cert.MyCertPath;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertPath</code> fields and methods
- */
-public class CertPathTest extends TestCase {
- /**
- * Meaningless cert path encoding just for testing purposes
- */
- private static final byte[] testEncoding = new byte[] {
- (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5
- };
-
- /**
- * Constructor for CertPathTest.
- *
- * @param name
- */
- public CertPathTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test for <code>hashCode()</code> method<br>
- * Assertion: returns hash of the <code>Certificate</code> instance
- */
- public final void testHashCode() {
- CertPath cp1 = new MyCertPath(testEncoding);
- CertPath cp2 = new MyCertPath(testEncoding);
-
- assertTrue(cp1.hashCode() == cp2.hashCode());
- }
-
- /**
- * Test for <code>hashCode()</code> method<br>
- * Assertion: hash code of equal objects should be the same
- */
- public final void testHashCodeEqualsObject() {
- CertPath cp1 = new MyCertPath(testEncoding);
- CertPath cp2 = new MyCertPath(testEncoding);
- assertTrue((cp1.hashCode() == cp2.hashCode()) && cp1.equals(cp2));
- }
-
- /**
- * Test for <code>getType()</code> method<br>
- * Assertion: returns cert path type
- */
- public final void testGetType() {
- assertEquals("MyEncoding", new MyCertPath(testEncoding).getType());
- }
-
- /**
- * Test #1 for <code>equals(Object)</code> method<br>
- * Assertion: object equals to itself
- */
- public final void testEqualsObject01() {
- CertPath cp1 = new MyCertPath(testEncoding);
- assertTrue(cp1.equals(cp1));
- }
-
- /**
- * Test for <code>equals(Object)</code> method<br>
- * Assertion: object equals to other <code>CertPath</code>
- * instance with the same state
- */
- public final void testEqualsObject02() {
- CertPath cp1 = new MyCertPath(testEncoding);
- CertPath cp2 = new MyCertPath(testEncoding);
- assertTrue(cp1.equals(cp2) && cp2.equals(cp1));
- }
-
- /**
- * Test for <code>equals(Object)</code> method<br>
- * Assertion: object not equals to <code>null</code>
- */
- public final void testEqualsObject03() {
- CertPath cp1 = new MyCertPath(testEncoding);
- assertFalse(cp1.equals(null));
- }
-
- /**
- * Test for <code>equals(Object)</code> method<br>
- * Assertion: object not equals to other which is not
- * instance of <code>CertPath</code>
- */
- public final void testEqualsObject04() {
- CertPath cp1 = new MyCertPath(testEncoding);
- assertFalse(cp1.equals("MyEncoding"));
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * Assertion: returns string representation of
- * <code>CertPath</code> object
- */
- public final void testToString() {
- CertPath cp1 = new MyCertPath(testEncoding);
- assertNotNull(cp1.toString());
- }
-
- //
- // the following tests just call methods
- // that are abstract in <code>CertPath</code>
- // (So they just like signature tests)
- //
-
- /**
- * This test just calls <code>getCertificates()</code> method<br>
- */
- public final void testGetCertificates() {
- CertPath cp1 = new MyCertPath(testEncoding);
- cp1.getCertificates();
- }
-
- /**
- * This test just calls <code>getEncoded()</code> method<br>
- *
- * @throws CertificateEncodingException
- */
- public final void testGetEncoded() throws CertificateEncodingException {
- CertPath cp1 = new MyCertPath(testEncoding);
- cp1.getEncoded();
- }
-
- /**
- * This test just calls <code>getEncoded(String)</code> method<br>
- *
- * @throws CertificateEncodingException
- */
- public final void testGetEncodedString() throws CertificateEncodingException {
- CertPath cp1 = new MyCertPath(testEncoding);
- cp1.getEncoded("MyEncoding");
- }
-
- /**
- * This test just calls <code>getEncodings()</code> method<br>
- */
- public final void testGetEncodings() {
- CertPath cp1 = new MyCertPath(testEncoding);
- cp1.getEncodings();
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator1Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator1Test.java
deleted file mode 100644
index b803544..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator1Test.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.cert.CertPathParameters;
-import java.security.cert.CertPathValidator;
-import java.security.cert.CertPathValidatorException;
-import java.security.cert.CertPathValidatorSpi;
-import java.security.cert.CertificateException;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.cert.MyCertPath;
-import org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertPathValidator</code> class constructors and
- * methods.
- */
-
-public class CertPathValidator1Test extends TestCase {
-
- /**
- * Constructor for CertPathValidatorTests.
- *
- * @param name
- */
- public CertPathValidator1Test(String name) {
- super(name);
- }
-
- public static final String srvCertPathValidator = "CertPathValidator";
-
- private static final String defaultType = "PKIX";
- public static final String[] validValues = {
- "PKIX", "pkix", "PkiX", "pKiX" };
-
- private static String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static boolean PKIXSupport = false;
-
- private static Provider defaultProvider;
- private static String defaultProviderName;
-
- private static String NotSupportMsg = "";
-
- static {
- defaultProvider = SpiEngUtils.isSupport(defaultType,
- srvCertPathValidator);
- PKIXSupport = (defaultProvider != null);
- defaultProviderName = (PKIXSupport ? defaultProvider.getName() : null);
- NotSupportMsg = defaultType.concat(" is not supported");
- }
-
-
- private static CertPathValidator[] createCPVs() {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return null;
- }
- try {
- CertPathValidator[] certPVs = new CertPathValidator[3];
- certPVs[0] = CertPathValidator.getInstance(defaultType);
- certPVs[1] = CertPathValidator.getInstance(defaultType,
- defaultProviderName);
- certPVs[2] = CertPathValidator.getInstance(defaultType,
- defaultProvider);
- return certPVs;
- } catch (Exception e) {
- return null;
- }
- }
-
-
- /**
- * Test for <code>getDefaultType()</code> method
- * Assertion: returns security property "certpathvalidator.type" or "PKIX"
- */
- public void testCertPathValidator01() {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- String propName = "certpathvalidator.type";
- String defCPV = Security.getProperty(propName);
-
- String dt = CertPathValidator.getDefaultType();
- String resType = defCPV;
- if (resType == null) {
- resType = defaultType;
- }
- assertNotNull("Default type have not be null", dt);
- assertEquals("Incorrect default type", dt, resType);
-
- if (defCPV == null) {
- Security.setProperty(propName, defaultType);
- dt = CertPathValidator.getDefaultType();
- resType = Security.getProperty(propName);
- assertNotNull("Incorrect default type", resType);
- assertNotNull("Default type have not be null", dt);
- assertEquals("Incorrect default type", dt, resType);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not available
- */
- public void testCertPathValidator02() {
- try {
- CertPathValidator.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertPathValidator.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion: returns CertPathValidator object
- */
- public void testCertPathValidator03() throws NoSuchAlgorithmException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- CertPathValidator certPV;
- for (int i = 0; i < validValues.length; i++) {
- certPV = CertPathValidator.getInstance(validValues[i]);
- assertEquals("Incorrect algorithm", certPV.getAlgorithm(), validValues[i]);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion: throws IllegalArgumentException when provider is null or empty
- * <p/>
- * FIXME: verify what exception will be thrown if provider is empty
- */
- public void testCertPathValidator04()
- throws NoSuchAlgorithmException, NoSuchProviderException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- String provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertPathValidator.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown thrown");
- } catch (IllegalArgumentException e) {
- }
- try {
- CertPathValidator.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
- * throws NoSuchProviderException when provider has invalid value
- */
- public void testCertPathValidator05() throws NoSuchAlgorithmException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- for (int t = 0; t < validValues.length; t++) {
- for (int i = 1; i < invalidValues.length; i++) {
- try {
- CertPathValidator.getInstance(validValues[t],
- invalidValues[i]);
- fail("NoSuchProviderException must be thrown");
- } catch (NoSuchProviderException e1) {
- }
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not available
- */
- public void testCertPathValidator06()
- throws NoSuchAlgorithmException, NoSuchProviderException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- try {
- CertPathValidator.getInstance(null, defaultProviderName);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertPathValidator.getInstance(invalidValues[i], defaultProviderName);
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e1) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion: returns CertPathValidator object
- */
- public void testCertPathValidator07() throws NoSuchAlgorithmException,
- NoSuchProviderException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- CertPathValidator certPV;
- for (int i = 0; i < validValues.length; i++) {
- certPV = CertPathValidator.getInstance(validValues[i],
- defaultProviderName);
- assertEquals("Incorrect algorithm", certPV.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider name", certPV.getProvider()
- .getName(), defaultProviderName);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code> method
- * Assertion: throws IllegalArgumentException when provider is null
- */
- public void testCertPathValidator08()
- throws NoSuchAlgorithmException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- Provider prov = null;
- for (int t = 0; t < validValues.length; t++) {
- try {
- CertPathValidator.getInstance(validValues[t], prov);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e1) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not available
- */
- public void testCertPathValidator09()
- throws NoSuchAlgorithmException, NoSuchProviderException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- try {
- CertPathValidator.getInstance(null, defaultProvider);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertPathValidator.getInstance(invalidValues[i], defaultProvider);
- fail("NoSuchAlgorithm must be thrown");
- } catch (NoSuchAlgorithmException e1) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion: returns CertPathValidator object
- */
- public void testCertPathValidator10() throws NoSuchAlgorithmException,
- NoSuchProviderException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- CertPathValidator certPV;
- for (int i = 0; i < invalidValues.length; i++) {
- certPV = CertPathValidator.getInstance(validValues[i],
- defaultProvider);
- assertEquals("Incorrect algorithm", certPV.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider name", certPV.getProvider(),
- defaultProvider);
- }
- }
-
- /**
- * Test for <code>validate(CertPath certpath, CertPathParameters params)</code> method
- * Assertion: throws InvalidAlgorithmParameterException params is not
- * instance of PKIXParameters or null
- */
- public void testCertPathValidator11()
- throws NoSuchAlgorithmException, NoSuchProviderException, CertPathValidatorException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- CertPathValidator[] certPV = createCPVs();
- assertNotNull("CertPathValidator objects were not created", certPV);
- MyCertPath mCP = new MyCertPath(new byte[0]);
- invalidParams mPar = new invalidParams();
- for (int i = 0; i < certPV.length; i++) {
- try {
- certPV[i].validate(mCP, mPar);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- try {
- certPV[i].validate(mCP, null);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
- }
-
- /**
- * Test for
- * <code>CertPathValidator</code> constructor
- * Assertion: returns CertPathValidator object
- */
- public void testCertPathValidator12()
- throws CertificateException, NoSuchProviderException, NoSuchAlgorithmException,
- CertPathValidatorException, InvalidAlgorithmParameterException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- CertPathValidatorSpi spi = new MyCertPathValidatorSpi();
- CertPathValidator certPV = new myCertPathValidator(spi,
- defaultProvider, defaultType);
- assertEquals("Incorrect algorithm", certPV.getAlgorithm(), defaultType);
- assertEquals("Incorrect provider", certPV.getProvider(), defaultProvider);
- certPV.validate(null, null);
- try {
- certPV.validate(null, null);
- fail("CertPathValidatorException must be thrown");
- } catch (CertPathValidatorException e) {
- }
- certPV = new myCertPathValidator(null, null, null);
- assertNull("Incorrect algorithm", certPV.getAlgorithm());
- assertNull("Incorrect provider", certPV.getProvider());
- try {
- certPV.validate(null, null);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- }
-}
-
-/**
- * Additional class to verify CertPathValidator constructor
- */
-class myCertPathValidator extends CertPathValidator {
-
- public myCertPathValidator(CertPathValidatorSpi spi, Provider prov, String type) {
- super(spi, prov, type);
- }
-}
-
-/**
- * Additional class to verify validate method
- */
-class invalidParams implements CertPathParameters {
- public Object clone() {
- return new invalidParams();
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator2Test.java
deleted file mode 100644
index 38734d4..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator2Test.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.cert.CertPathValidator;
-import java.security.cert.CertPathValidatorException;
-
-import org.apache.harmony.security.tests.java.security.cert.CertPathValidator1Test;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.SpiEngUtils.MyProvider;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for CertPathValidator class constructors and methods
- */
-
-public class CertPathValidator2Test extends TestCase {
- private static final String defaultAlg = "CertPB";
-
- public static final String CertPathValidatorProviderClass = "org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "CeRtPb";
- validValues[3] = "cERTpb";
- }
-
- Provider mProv;
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyCertPathValidatorProvider",
- "Provider for testing", CertPathValidator1Test.srvCertPathValidator
- .concat(".").concat(defaultAlg),
- CertPathValidatorProviderClass);
- Security.insertProviderAt(mProv, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- /**
- * Constructor for CertPathValidator2Test.
- *
- * @param arg0
- */
- public CertPathValidator2Test(String arg0) {
- super(arg0);
- }
-
- private void checkResult(CertPathValidator certV)
- throws CertPathValidatorException,
- InvalidAlgorithmParameterException {
- String dt = CertPathValidator.getDefaultType();
- String propName = "certpathvalidator.type";
- for (int i = 0; i < invalidValues.length; i++) {
- Security.setProperty(propName, invalidValues[i]);
- assertEquals("Incorrect default type", CertPathValidator.getDefaultType(),
- invalidValues[i]);
- }
- Security.setProperty(propName, dt);
- assertEquals("Incorrect default type", CertPathValidator.getDefaultType(),
- dt);
- certV.validate(null, null);
- try {
- certV.validate(null, null);
- } catch (CertPathValidatorException e) {
- }
- try {
- certV.validate(null, null);
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not available
- * returns CertPathValidator object
- */
- public void testGetInstance01() throws NoSuchAlgorithmException,
- InvalidAlgorithmParameterException, CertPathValidatorException {
- try {
- CertPathValidator.getInstance(null);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertPathValidator.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- CertPathValidator cerPV;
- for (int i = 0; i < validValues.length; i++) {
- cerPV = CertPathValidator.getInstance(validValues[i]);
- assertEquals("Incorrect type", cerPV.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider", cerPV.getProvider(), mProv);
- checkResult(cerPV);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not available
- * throws IllegalArgumentException when provider is null or empty;
- * throws NoSuchProviderException when provider is available;
- * returns CertPathValidator object
- */
- public void testGetInstance02() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidAlgorithmParameterException, CertPathValidatorException {
- try {
- CertPathValidator.getInstance(null, mProv.getName());
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertPathValidator.getInstance(invalidValues[i], mProv
- .getName());
- fail("NoSuchAlgorithmException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertPathValidator.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (type: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- try {
- CertPathValidator.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty (type: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- CertPathValidator.getInstance(validValues[i],
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (type: "
- .concat(validValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- CertPathValidator cerPV;
- for (int i = 0; i < validValues.length; i++) {
- cerPV = CertPathValidator.getInstance(validValues[i], mProv
- .getName());
- assertEquals("Incorrect type", cerPV.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider", cerPV.getProvider().getName(),
- mProv.getName());
- checkResult(cerPV);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is not available
- * throws IllegalArgumentException when provider is null;
- * returns CertPathValidator object
- */
- public void testGetInstance03() throws NoSuchAlgorithmException,
- IllegalArgumentException,
- InvalidAlgorithmParameterException, CertPathValidatorException {
- try {
- CertPathValidator.getInstance(null, mProv);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertPathValidator.getInstance(invalidValues[i], mProv);
- fail("NoSuchAlgorithmException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertPathValidator.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (type: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- CertPathValidator cerPV;
- for (int i = 0; i < validValues.length; i++) {
- cerPV = CertPathValidator.getInstance(validValues[i], mProv);
- assertEquals("Incorrect type", cerPV.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider", cerPV.getProvider(), mProv);
- checkResult(cerPV);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator3Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator3Test.java
deleted file mode 100644
index 34bdfbf..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator3Test.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.cert.CertPathParameters;
-import java.security.cert.CertPathValidator;
-import java.security.cert.CertPathValidatorException;
-import java.security.cert.PKIXParameters;
-
-import org.apache.harmony.security.tests.java.security.cert.CertPathBuilder1Test;
-import org.apache.harmony.security.tests.java.security.cert.CertPathValidator1Test;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.cert.MyCertPath;
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertPathValidator</code> class methods.
- */
-
-public class CertPathValidator3Test extends TestCase {
-
- /**
- * Constructor for CertPathValidatorTests.
- *
- * @param name
- */
- public CertPathValidator3Test(String name) {
- super(name);
- }
-
- private static final String defaultType = CertPathBuilder1Test.defaultType;
-
- private static boolean PKIXSupport = false;
-
- private static Provider defaultProvider;
- private static String defaultProviderName;
-
- private static String NotSupportMsg = "";
-
- static {
- defaultProvider = SpiEngUtils.isSupport(defaultType,
- CertPathValidator1Test.srvCertPathValidator);
- PKIXSupport = (defaultProvider != null);
- defaultProviderName = (PKIXSupport ? defaultProvider.getName() : null);
- NotSupportMsg = defaultType.concat(" is not supported");
- }
-
- private static CertPathValidator[] createCPVs() {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return null;
- }
- try {
- CertPathValidator[] certPVs = new CertPathValidator[3];
- certPVs[0] = CertPathValidator.getInstance(defaultType);
- certPVs[1] = CertPathValidator.getInstance(defaultType,
- defaultProviderName);
- certPVs[2] = CertPathValidator.getInstance(defaultType,
- defaultProvider);
- return certPVs;
- } catch (Exception e) {
- return null;
- }
- }
-
- /**
- * Test for <code>validate(CertPath certpath, CertPathParameters params)</code> method
- * Assertion: throws InvalidAlgorithmParameterException
- * when params is instance of PKIXParameters and
- * certpath is not X.509 type
- * <p/>
- * FIXME: jrockit-j2re1.4.2_04 throws NullPointerException when certPath is null
- */
- public void testValidate01()
- throws NoSuchAlgorithmException, NoSuchProviderException,
- CertPathValidatorException, InvalidAlgorithmParameterException {
- if (!PKIXSupport) {
- fail(NotSupportMsg);
- return;
- }
- MyCertPath mCP = new MyCertPath(new byte[0]);
- CertPathParameters params = new PKIXParameters(TestUtils.getTrustAnchorSet());
- CertPathValidator[] certPV = createCPVs();
- assertNotNull("CertPathValidator objects were not created", certPV);
- for (int i = 0; i < certPV.length; i++) {
- try {
- certPV[i].validate(mCP, null);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- try {
- certPV[i].validate(null, params);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- }
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorExceptionTest.java
deleted file mode 100644
index 0545d38..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorExceptionTest.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CertPathValidatorException;
-import java.security.cert.CertPath;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>CertPathValidatorException</code> class constructors and
- * methods.
- */
-public class CertPathValidatorExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertPathValidatorExceptionTests.
- *
- * @param arg0
- */
- public CertPathValidatorExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertPathValidatorException()</code> constructor
- * Assertion: constructs CertPathValidatorException with no detail message
- */
- public void testCertPathValidatorException01() {
- CertPathValidatorException tE = new CertPathValidatorException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertPathValidatorException(String)</code> constructor
- * Assertion: constructs CertPathValidatorException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testCertPathValidatorException02() {
- CertPathValidatorException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertPathValidatorException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertPathValidatorException(String)</code> constructor
- * Assertion: constructs CertPathValidatorException when <code>msg</code>
- * is null
- */
- public void testCertPathValidatorException03() {
- String msg = null;
- CertPathValidatorException tE = new CertPathValidatorException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertPathValidatorException(Throwable)</code> constructor
- * Assertion: constructs CertPathValidatorException when <code>cause</code>
- * is null
- */
- public void testCertPathValidatorException04() {
- Throwable cause = null;
- CertPathValidatorException tE = new CertPathValidatorException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertPathValidatorException(Throwable)</code> constructor
- * Assertion: constructs CertPathValidatorException when <code>cause</code>
- * is not null
- */
- public void testCertPathValidatorException05() {
- CertPathValidatorException tE = new CertPathValidatorException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CertPathValidatorException(String, Throwable)</code>
- * constructor Assertion: constructs CertPathValidatorException when
- * <code>cause</code> is null <code>msg</code> is null
- */
- public void testCertPathValidatorException06() {
- CertPathValidatorException tE = new CertPathValidatorException(null,
- null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertPathValidatorException(String, Throwable)</code>
- * constructor Assertion: constructs CertPathValidatorException when
- * <code>cause</code> is null <code>msg</code> is not null
- */
- public void testCertPathValidatorException07() {
- CertPathValidatorException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertPathValidatorException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertPathValidatorException(String, Throwable)</code>
- * constructor Assertion: constructs CertPathValidatorException when
- * <code>cause</code> is not null <code>msg</code> is null
- */
- public void testCertPathValidatorException08() {
- CertPathValidatorException tE = new CertPathValidatorException(null,
- tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CertPathValidatorException(String, Throwable)</code>
- * constructor Assertion: constructs CertPathValidatorException when
- * <code>cause</code> is not null <code>msg</code> is not null
- */
- public void testCertPathValidatorException09() {
- CertPathValidatorException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertPathValidatorException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-
- /**
- * Test for
- * <code>CertPathValidatorException(String, Throwable, CertPath, int)</code>
- * constructor Assertion: constructs CertPathValidatorException when
- * <code>cause</code> is null <code>msg</code> is null
- * <code>certPath</code> is null <code>index</code> is -1
- */
- public void testCertPathValidatorException10() {
- CertPathValidatorException tE = new CertPathValidatorException(null,
- null, null, -1);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- assertNull("getCertPath() must return null", tE.getCertPath());
- assertEquals("getIndex() must be -1", tE.getIndex(), -1);
- }
-
- /**
- * Test for
- * <code>CertPathValidatorException(String, Throwable, CertPath, int)</code>
- * constructor Assertion: constructs CertPathValidatorException when
- * <code>cause</code> is null <code>msg</code> is null
- * <code>certPath</code> is null <code>index</code> not -1 throws:
- * IllegalArgumentException
- */
- public void testCertPathValidatorException11() {
- int[] indx = { 0, 1, 100, Integer.MAX_VALUE, Integer.MIN_VALUE };
- for (int j = 0; j < indx.length; j++) {
- for (int i = 0; i < msgs.length; i++) {
- try {
- new CertPathValidatorException(msgs[i], tCause, null, indx[j]);
- fail("Error. IllegalArgumentException was not thrown as expected. "
- + " msg: "
- + msgs[i]
- + ", certPath is null and index is " + indx[j]);
- } catch (IllegalArgumentException e) {
- }
- }
- }
- }
-
- /**
- * Test for
- * <code>CertPathValidatorException(String, Throwable, CertPath, int)</code>
- * constructor Assertion: constructs CertPathValidatorException when
- * <code>cause</code> not null <code>msg</code> not null
- * <code>certPath</code> is null <code>index</code> is -1
- */
- public void testCertPathValidatorException12() {
- CertPathValidatorException tE;
-
- for (int i = 0; i < msgs.length; i++) {
- try {
- tE = new CertPathValidatorException(msgs[i], tCause, null, -1);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]),
- getM.indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS),
- getM.indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return "
- .concat(tCause.toString()), tE.getCause(), tCause);
- assertNull("getCertPath() must return null", tE.getCertPath());
- assertEquals("getIndex() must return -1", tE.getIndex(), -1);
- } catch (IndexOutOfBoundsException e) {
- fail("Unexpected exception: " + e.toString()
- + " Parameters: msg: " + msgs[i]
- + ", certPath is null and index is -1");
- }
- }
- }
-
- /**
- * Test for
- * <code>CertPathValidatorException(String, Throwable, CertPath, int)</code>
- * constructor Assertion: constructs CertPathValidatorException when
- * <code>cause</code> not null <code>msg</code> not null
- * <code>certPath</code> not null <code>index</code>< -1 || >=
- * certPath.getCertificates().size() throws: IndexOutOfBoundsException
- */
- public void testCertPathValidatorException13() {
- myCertPath mcp = new myCertPath("X.509", "");
- CertPath cp = mcp.get("X.509");
- int[] indx = { -2, -100, 0, 1, 100, Integer.MAX_VALUE,
- Integer.MIN_VALUE };
- for (int j = 0; j < indx.length; j++) {
- for (int i = 0; i < msgs.length; i++) {
- try {
- new CertPathValidatorException(msgs[i], tCause, cp, indx[j]);
- fail("IndexOutOfBoundsException was not thrown as expected. "
- + " msg: "
- + msgs[i]
- + ", certPath is null and index is " + indx[j]);
- } catch (IndexOutOfBoundsException e) {
- }
- }
- }
- }
-
- /**
- * Test for
- * <code>CertPathValidatorException(String, Throwable, CertPath, int)</code>
- * constructor Assertion: constructs CertPathValidatorException when
- * <code>cause</code> not null <code>msg</code> not null
- * <code>certPath</code> not null <code>index</code><
- * certPath.getCertificates().size()
- */
- public void testCertPathValidatorException14() {
- CertPathValidatorException tE;
- myCertPath mcp = new myCertPath("X.509", "");
- CertPath cp = mcp.get("X.509");
- for (int i = 0; i < msgs.length; i++) {
- try {
- tE = new CertPathValidatorException(msgs[i], tCause, cp, -1);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]),
- getM.indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS),
- getM.indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return "
- .concat(tCause.toString()), tE.getCause(), tCause);
- assertNotNull("getCertPath() must not return null", tE
- .getCertPath());
- assertEquals(
- "getCertPath() must return ".concat(cp.toString()), tE
- .getCertPath(), cp);
- assertEquals("getIndex() must return -1", tE.getIndex(), -1);
-
- } catch (IndexOutOfBoundsException e) {
- fail("Unexpected IndexOutOfBoundsException was thrown. "
- + e.toString());
- }
- }
- }
-
- class myCertPath extends CertPath {
-
- public List getCertificates() {
- return new Vector();
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public byte[] getEncoded(String s) {
- return new byte[0];
- }
-
- public Iterator getEncodings() {
- return (Iterator) (new StringTokenizer("ss ss ss ss"));
- }
-
- protected myCertPath(String s) {
- super(s);
- }
-
- public CertPath get(String s) {
- return new myCertPath(s);
- }
-
- public myCertPath(String s, String s1) {
- super(s);
- }
-
- }
-}
-
-
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorSpiTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorSpiTest.java
deleted file mode 100644
index db66090..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorSpiTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.cert.CertPath;
-import java.security.cert.CertPathParameters;
-import java.security.cert.CertPathValidatorException;
-import java.security.cert.CertPathValidatorResult;
-import java.security.cert.CertPathValidatorSpi;
-
-import org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertPathValidatorSpi</code> class constructors and methods.
- */
-
-public class CertPathValidatorSpiTest extends TestCase {
-
- /**
- * Constructor for CertPathValidatorSpiTest.
- *
- * @param arg0
- */
- public CertPathValidatorSpiTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>CertPathValidatorSpi</code> constructor Assertion:
- * constructs CertPathValidatorSpi
- */
- public void testCertPathValidatorSpi01() throws CertPathValidatorException,
- InvalidAlgorithmParameterException {
- CertPathValidatorSpi certPathValid = new MyCertPathValidatorSpi();
- CertPathParameters params = null;
- CertPath certPath = null;
- CertPathValidatorResult cpvResult = certPathValid.engineValidate(
- certPath, params);
- assertNull("Not null CertPathValidatorResult", cpvResult);
- try {
- certPathValid.engineValidate(certPath, params);
- fail("CertPathValidatorException must be thrown");
- } catch (CertPathValidatorException e) {
- }
- try {
- certPathValid.engineValidate(certPath, params);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStore1Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStore1Test.java
deleted file mode 100644
index e5f79dd..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStore1Test.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.cert.CertStore;
-import java.security.cert.CertStoreException;
-import java.security.cert.CertStoreParameters;
-import java.security.cert.CertStoreSpi;
-import java.security.cert.CollectionCertStoreParameters;
-import java.security.cert.LDAPCertStoreParameters;
-import java.util.Collection;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.cert.MyCertStoreParameters;
-import org.apache.harmony.security.tests.support.cert.MyCertStoreSpi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertStore</code> class constructors and
- * methods.
- */
-
-public class CertStore1Test extends TestCase {
-
- /**
- * Constructor for CertStoreTests.
- *
- * @param arg0
- */
- public CertStore1Test(String arg0) {
- super(arg0);
- }
-
- public static final String srvCertStore = "CertStore";
-
- private static final String defaultType = "LDAP";
- public static final String[] validValues = {
- "LDAP", "ldap", "Ldap", "lDAP", "lDaP" };
- public static String[] validValuesC = null;
-
- private static String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static boolean LDAPSupport = false;
- private static final String CollectionType = "Collection";
- private static boolean CollectionSupport = false;
-
- private static Provider defaultProvider;
- private static String defaultProviderName;
- private static Provider defaultProviderCol;
- private static String defaultProviderColName;
-
- private static String NotSupportMsg = "";
-
- static {
- defaultProvider = SpiEngUtils.isSupport(defaultType,
- srvCertStore);
- LDAPSupport = (defaultProvider != null);
- defaultProviderName = (LDAPSupport ? defaultProvider.getName() : null);
- NotSupportMsg = "LDAP and Collection algorithm are not supported";
-
- defaultProviderCol = SpiEngUtils.isSupport(CollectionType,
- srvCertStore);
- CollectionSupport = (defaultProviderCol != null);
- defaultProviderColName = (CollectionSupport ? defaultProviderCol.getName() : null);
- if (CollectionSupport) {
- validValuesC = new String[3];
- validValuesC[0] = CollectionType;
- validValuesC[1] = CollectionType.toUpperCase();
- validValuesC[2] = CollectionType.toLowerCase();
- }
- }
-
- private Provider dProv = null;
- private String dName = null;
- private String dType = null;
- private CertStoreParameters dParams = null;
- private String[] dValid;
-
- private boolean initParams() {
- if (!LDAPSupport && !CollectionSupport) {
- fail(NotSupportMsg);
- return false;
- }
- dParams = (CollectionSupport ? (CertStoreParameters) new CollectionCertStoreParameters() :
- (CertStoreParameters) new LDAPCertStoreParameters());
- dType = (CollectionSupport ? CollectionType : defaultType);
- dProv = (CollectionSupport ? defaultProviderCol : defaultProvider);
- dName = (CollectionSupport ? defaultProviderColName : defaultProviderName);
- dValid = (CollectionSupport ? validValuesC : validValues);
- return true;
- }
-
- private CertStore[] createCS() {
- if (!LDAPSupport && !CollectionSupport) {
- fail(NotSupportMsg);
- return null;
- }
- try {
- CertStore[] ss = new CertStore[3];
- ss[0] = CertStore.getInstance(dType, dParams);
- ss[1] = CertStore.getInstance(dType, dParams, dProv);
- ss[2] = CertStore.getInstance(dType, dParams, dName);
- return ss;
- } catch (Exception e) {
- return null;
- }
- }
-
-
- /**
- * Test for <code>getDefaultType()</code> method
- * Assertion: returns security property "certstore.type" or "LDAP"
- */
- public void testCertStore01() {
- if (!LDAPSupport) {
- return;
- }
- String dt = CertStore.getDefaultType();
- String sn = Security.getProperty("certstore.type");
- String def = "Proba.cert.store.type";
- if (sn == null) {
- sn = defaultType;
- }
- assertNotNull("Default type have not be null", dt);
- assertEquals("Incorrect default type", dt, sn);
-
- Security.setProperty("certstore.type", def);
- dt = CertStore.getDefaultType();
- assertEquals("Incorrect default type", dt, def);
- Security.setProperty("certstore.type", sn);
- assertEquals("Incorrect default type", Security.getProperty("certstore.type"), sn);
- }
-
- /**
- * Test for
- * <code>CertStore</code> constructor
- * Assertion: returns CertStore object
- */
-
- public void testCertStore02() throws NoSuchAlgorithmException,
- InvalidAlgorithmParameterException, CertStoreException {
- if (!initParams()) {
- return;
- }
- MyCertStoreParameters pp = new MyCertStoreParameters();
- CertStoreSpi spi = new MyCertStoreSpi(pp);
- CertStore certS = new myCertStore(spi, dProv, dType, pp);
- assertEquals("Incorrect algorithm", certS.getType(), dType);
- assertEquals("Incorrect provider", certS.getProvider(), dProv);
- assertTrue("Incorrect parameters", certS.getCertStoreParameters()
- instanceof MyCertStoreParameters);
- try {
- certS.getCertificates(null);
- fail("CertStoreException must be thrown");
- } catch (CertStoreException e) {
- }
- certS = new myCertStore(null, null, null, null);
- assertNull("Incorrect algorithm", certS.getType());
- assertNull("Incorrect provider", certS.getProvider());
- assertNull("Incorrect parameters", certS.getCertStoreParameters());
- try {
- certS.getCertificates(null);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test for <code>getInstance(String type, CertStoreParameters params)</code> method
- * Assertion:
- * throws NullPointerException when type is null
- * throws NoSuchAlgorithmException when type is incorrect;
- */
- public void testCertStore03() throws InvalidAlgorithmParameterException {
- if (!initParams()) {
- return;
- }
- try {
- CertStore.getInstance(null, dParams);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when type is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertStore.getInstance(invalidValues[i], dParams);
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String type, CertStoreParameters params)</code> method
- * Assertion: return CertStore object
- */
- public void testCertStore05()
- throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
- if (!initParams()) {
- return;
- }
- CertStore certS;
- for (int i = 0; i < dValid.length; i++) {
- certS = CertStore.getInstance(dValid[i], dParams);
- assertEquals("Incorrect type", certS.getType(), dValid[i]);
- certS.getCertStoreParameters();
- }
- }
-
- /**
- * Test for method
- * <code>getInstance(String type, CertStoreParameters params, String provider)</code>
- * Assertion: throws IllegalArgumentException when provider is null or empty
- * <p/>
- * FIXME: verify IllegalArgumentException when provider is empty
- */
- public void testCertStore06()
- throws InvalidAlgorithmParameterException, NoSuchAlgorithmException,
- NoSuchProviderException {
- if (!initParams()) {
- return;
- }
- String provider = null;
- for (int i = 0; i < dValid.length; i++) {
- try {
- CertStore.getInstance(dValid[i], dParams, provider);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- try {
- CertStore.getInstance(dValid[i], dParams, "");
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for method
- * <code>getInstance(String type, CertStoreParameters params, String provider)</code>
- * Assertion: throws NoSuchProviderException when provider has invalid value
- */
- public void testCertStore07()
- throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
- if (!initParams()) {
- return;
- }
- for (int i = 0; i < dValid.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- CertStore.getInstance(dValid[i], dParams, invalidValues[j]);
- fail("NoSuchProviderException must be thrown");
- } catch (NoSuchProviderException e) {
- }
- }
- }
- }
-
- /**
- * Test for method
- * <code>getInstance(String type, CertStoreParameters params, String provider)</code>
- * Assertion:
- * throws NullPointerException when type is null
- * throws NoSuchAlgorithmException when type is incorrect;
- */
- public void testCertStore08()
- throws InvalidAlgorithmParameterException, NoSuchProviderException,
- NoSuchAlgorithmException {
- if (!initParams()) {
- return;
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertStore.getInstance(invalidValues[i], dParams, dName);
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- try {
- CertStore.getInstance(null, dParams, dName);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when type is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- }
-
- /**
- * Test for method
- * <code>getInstance(String type, CertStoreParameters params, String provider)</code>
- * Assertion: return CertStore object
- */
- public void testCertStore10()
- throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException {
- if (!initParams()) {
- return;
- }
- CertStore certS;
- for (int i = 0; i < dValid.length; i++) {
- certS = CertStore.getInstance(dValid[i], dParams, dName);
- assertEquals("Incorrect type", certS.getType(), dValid[i]);
- certS.getCertStoreParameters();
- }
- }
-
- /**
- * Test for method
- * <code>getInstance(String type, CertStoreParameters params, Provider provider)</code>
- * Assertion: throws IllegalArgumentException when provider is null
- */
- public void testCertStore11()
- throws InvalidAlgorithmParameterException, NoSuchAlgorithmException,
- NoSuchProviderException {
- if (!initParams()) {
- return;
- }
- Provider provider = null;
- for (int i = 0; i < dValid.length; i++) {
- try {
- CertStore.getInstance(dValid[i], dParams, provider);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String type, CertStoreParameters params, Provider provider)</code> method
- * Assertion:
- * throws NullPointerException when type is null
- * throws NoSuchAlgorithmException when type is incorrect;
- */
- public void testCertStore12()
- throws InvalidAlgorithmParameterException,
- NoSuchAlgorithmException {
- if (!initParams()) {
- return;
- }
- try {
- CertStore.getInstance(null, dParams, dProv);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when type is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertStore.getInstance(invalidValues[i], dParams, dProv);
- fail("NoSuchAlgorithmException must be thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for method
- * <code>getInstance(String type, CertStoreParameters params, Provider provider)</code>
- * Assertion: return CertStore object
- */
- public void testCertStore14()
- throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
- if (!initParams()) {
- return;
- }
- CertStore certS;
- for (int i = 0; i < dValid.length; i++) {
- certS = CertStore.getInstance(dValid[i], dParams, dProv);
- assertEquals("Incorrect type", certS.getType(), dValid[i]);
- certS.getCertStoreParameters();
- }
- }
-
- /**
- * Test for methods
- * <code>getCertificates(CertSelector selector)</code>
- * <code>getCRLs(CRLSelector selector)</code>
- * Assertion: returns empty Collection when selector is null
- */
- public void testCertStore15()
- throws NoSuchAlgorithmException, InvalidAlgorithmParameterException,
- CertStoreException {
- if (!initParams()) {
- return;
- }
- CertStore[] certS = createCS();
- assertNotNull("CertStore object were not created", certS);
- Collection coll;
- for (int i = 0; i < certS.length; i++) {
- coll = certS[i].getCertificates(null);
- assertTrue("Result collection not empty", coll.isEmpty());
- coll = certS[i].getCRLs(null);
- assertTrue("Result collection not empty", coll.isEmpty());
- }
- }
-}
-
-/**
- * Additional class to verify CertStore constructor
- */
-class myCertStore extends CertStore {
- public myCertStore(CertStoreSpi spi, Provider prov, String type, CertStoreParameters params) {
- super(spi, prov, type, params);
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreExceptionTest.java
deleted file mode 100644
index 53312e5..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreExceptionTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CertStoreException;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertStoreException</code> class constructors and methods.
- */
-public class CertStoreExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertStoreExceptionTests.
- *
- * @param arg0
- */
- public CertStoreExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertStoreException()</code> constructor Assertion:
- * constructs CertStoreException with no detail message
- */
- public void testCertStoreException01() {
- CertStoreException tE = new CertStoreException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertStoreException(String)</code> constructor Assertion:
- * constructs CertStoreException with detail message msg. Parameter
- * <code>msg</code> is not null.
- */
- public void testCertStoreException02() {
- CertStoreException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertStoreException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertStoreException(String)</code> constructor Assertion:
- * constructs CertStoreException when <code>msg</code> is null
- */
- public void testCertStoreException03() {
- String msg = null;
- CertStoreException tE = new CertStoreException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertStoreException(Throwable)</code> constructor
- * Assertion: constructs CertStoreException when <code>cause</code> is
- * null
- */
- public void testCertStoreException04() {
- Throwable cause = null;
- CertStoreException tE = new CertStoreException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertStoreException(Throwable)</code> constructor
- * Assertion: constructs CertStoreException when <code>cause</code> is not
- * null
- */
- public void testCertStoreException05() {
- CertStoreException tE = new CertStoreException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CertStoreException(String, Throwable)</code> constructor
- * Assertion: constructs CertStoreException when <code>cause</code> is
- * null <code>msg</code> is null
- */
- public void testCertStoreException06() {
- CertStoreException tE = new CertStoreException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertStoreException(String, Throwable)</code> constructor
- * Assertion: constructs CertStoreException when <code>cause</code> is
- * null <code>msg</code> is not null
- */
- public void testCertStoreException07() {
- CertStoreException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertStoreException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertStoreException(String, Throwable)</code> constructor
- * Assertion: constructs CertStoreException when <code>cause</code> is not
- * null <code>msg</code> is null
- */
- public void testCertStoreException08() {
- CertStoreException tE = new CertStoreException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CertStoreException(String, Throwable)</code> constructor
- * Assertion: constructs CertStoreException when <code>cause</code> is not
- * null <code>msg</code> is not null
- */
- public void testCertStoreException09() {
- CertStoreException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertStoreException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreSpiTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreSpiTest.java
deleted file mode 100644
index 36e0bd7..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreSpiTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.cert.CRL;
-import java.security.cert.CRLSelector;
-import java.security.cert.CertSelector;
-import java.security.cert.CertStoreException;
-import java.security.cert.CertStoreSpi;
-import java.security.cert.Certificate;
-
-import org.apache.harmony.security.tests.support.cert.MyCertStoreSpi;
-import org.apache.harmony.security.tests.support.cert.MyCertStoreParameters;
-
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Tests for <code>CertStoreSpi</code> class constructors and methods.
- */
-
-public class CertStoreSpiTest extends TestCase {
-
- /**
- * Constructor for CertStoreSpiTest.
- *
- * @param arg0
- */
- public CertStoreSpiTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>CertStoreSpi</code> constructor Assertion: constructs
- * CertStoreSpi
- */
- public void testCertStoreSpi01() throws InvalidAlgorithmParameterException,
- CertStoreException {
- CertStoreSpi certStoreSpi = null;
- CertSelector certSelector = new tmpCertSelector();//new
- // X509CertSelector();
- CRLSelector crlSelector = new tmpCRLSelector();//new X509CRLSelector();
- try {
- certStoreSpi = new MyCertStoreSpi(null);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- certStoreSpi = new MyCertStoreSpi(new MyCertStoreParameters());
- assertNull("Not null collection", certStoreSpi
- .engineGetCertificates(certSelector));
- assertNull("Not null collection", certStoreSpi
- .engineGetCRLs(crlSelector));
- }
-
- public static Test suite() {
- return new TestSuite(CertStoreSpiTest.class);
- }
-
- /**
- * Additional classes for verification CertStoreSpi class
- */
- public static class tmpCRLSelector implements CRLSelector {
- public Object clone() {
- return null;
- }
-
- public boolean match(CRL crl) {
- return false;
- }
- }
-
- public static class tmpCertSelector implements CertSelector {
- public Object clone() {
- return null;
- }
-
- public boolean match(Certificate crl) {
- return true;
- }
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingExceptionTest.java
deleted file mode 100644
index aa6c959..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingExceptionTest.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CertificateEncodingException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>CertificateEncodingException</code> class constructors and
- * methods.
- */
-public class CertificateEncodingExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertificateEncodingExceptionTests.
- *
- * @param arg0
- */
- public CertificateEncodingExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertificateEncodingException()</code> constructor
- * Assertion: constructs CertificateEncodingException with no detail message
- */
- public void testCertificateEncodingException01() {
- CertificateEncodingException tE = new CertificateEncodingException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateEncodingException(String)</code> constructor
- * Assertion: constructs CertificateEncodingException with detail message
- * msg. Parameter <code>msg</code> is not null.
- */
- public void testCertificateEncodingException02() {
- CertificateEncodingException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateEncodingException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateEncodingException(String)</code> constructor
- * Assertion: constructs CertificateEncodingException when <code>msg</code>
- * is null
- */
- public void testCertificateEncodingException03() {
- String msg = null;
- CertificateEncodingException tE = new CertificateEncodingException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateEncodingException(Throwable)</code>
- * constructor Assertion: constructs CertificateEncodingException when
- * <code>cause</code> is null
- */
- public void testCertificateEncodingException04() {
- Throwable cause = null;
- CertificateEncodingException tE = new CertificateEncodingException(
- cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateEncodingException(Throwable)</code>
- * constructor Assertion: constructs CertificateEncodingException when
- * <code>cause</code> is not null
- */
- public void testCertificateEncodingException05() {
- CertificateEncodingException tE = new CertificateEncodingException(
- tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CertificateEncodingException(String, Throwable)</code>
- * constructor Assertion: constructs CertificateEncodingException when
- * <code>cause</code> is null <code>msg</code> is null
- */
- public void testCertificateEncodingException06() {
- CertificateEncodingException tE = new CertificateEncodingException(
- null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateEncodingException(String, Throwable)</code>
- * constructor Assertion: constructs CertificateEncodingException when
- * <code>cause</code> is null <code>msg</code> is not null
- */
- public void testCertificateEncodingException07() {
- CertificateEncodingException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateEncodingException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateEncodingException(String, Throwable)</code>
- * constructor Assertion: constructs CertificateEncodingException when
- * <code>cause</code> is not null <code>msg</code> is null
- */
- public void testCertificateEncodingException08() {
- CertificateEncodingException tE = new CertificateEncodingException(
- null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CertificateEncodingException(String, Throwable)</code>
- * constructor Assertion: constructs CertificateEncodingException when
- * <code>cause</code> is not null <code>msg</code> is not null
- */
- public void testCertificateEncodingException09() {
- CertificateEncodingException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateEncodingException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExceptionTest.java
deleted file mode 100644
index c50f0cf..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExceptionTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CertificateException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>CertificateException</code> class constructors and methods.
- */
-public class CertificateExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertificateExceptionTests.
- *
- * @param arg0
- */
- public CertificateExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertificateException()</code> constructor Assertion:
- * constructs CertificateException with no detail message
- */
- public void testCertificateException01() {
- CertificateException tE = new CertificateException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateException(String)</code> constructor
- * Assertion: constructs CertificateException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testCertificateException02() {
- CertificateException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateException(String)</code> constructor
- * Assertion: constructs CertificateException when <code>msg</code> is
- * null
- */
- public void testCertificateException03() {
- String msg = null;
- CertificateException tE = new CertificateException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateException(Throwable)</code> constructor
- * Assertion: constructs CertificateException when <code>cause</code> is
- * null
- */
- public void testCertificateException04() {
- Throwable cause = null;
- CertificateException tE = new CertificateException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateException(Throwable)</code> constructor
- * Assertion: constructs CertificateException when <code>cause</code> is
- * not null
- */
- public void testCertificateException05() {
- CertificateException tE = new CertificateException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CertificateException(String, Throwable)</code>
- * constructor Assertion: constructs CertificateException when
- * <code>cause</code> is null <code>msg</code> is null
- */
- public void testCertificateException06() {
- CertificateException tE = new CertificateException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateException(String, Throwable)</code>
- * constructor Assertion: constructs CertificateException when
- * <code>cause</code> is null <code>msg</code> is not null
- */
- public void testCertificateException07() {
- CertificateException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateException(String, Throwable)</code>
- * constructor Assertion: constructs CertificateException when
- * <code>cause</code> is not null <code>msg</code> is null
- */
- public void testCertificateException08() {
- CertificateException tE = new CertificateException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CertificateException(String, Throwable)</code>
- * constructor Assertion: constructs CertificateException when
- * <code>cause</code> is not null <code>msg</code> is not null
- */
- public void testCertificateException09() {
- CertificateException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExpiredExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExpiredExceptionTest.java
deleted file mode 100644
index db19b9b..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExpiredExceptionTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CertificateExpiredException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>DigestException</code> class constructors and methods.
- */
-public class CertificateExpiredExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertificateExpiredExceptionTests.
- *
- * @param arg0
- */
- public CertificateExpiredExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertificateExpiredException()</code> constructor
- * Assertion: constructs CertificateExpiredException with no detail message
- */
- public void testCertificateExpiredException01() {
- CertificateExpiredException tE = new CertificateExpiredException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateExpiredException(String)</code> constructor
- * Assertion: constructs CertificateExpiredException with detail message
- * msg. Parameter <code>msg</code> is not null.
- */
- public void testCertificateExpiredException02() {
- CertificateExpiredException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateExpiredException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateExpiredException(String)</code> constructor
- * Assertion: constructs CertificateExpiredException when <code>msg</code>
- * is null
- */
- public void testCertificateExpiredException03() {
- String msg = null;
- CertificateExpiredException tE = new CertificateExpiredException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory1Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory1Test.java
deleted file mode 100644
index 5f22603..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory1Test.java
+++ /dev/null
@@ -1,693 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectOutputStream;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.cert.CRL;
-import java.security.cert.CRLException;
-import java.security.cert.CertPath;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.CertificateFactorySpi;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.cert.MyCertPath;
-import org.apache.harmony.security.tests.support.cert.MyCertificate;
-import org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertificateFactory</code> class methods and constructor
- */
-
-public class CertificateFactory1Test extends TestCase {
-
- /**
- * Constructor for CertificateFactoryTests.
- *
- * @param arg0
- */
- public CertificateFactory1Test(String arg0) {
- super(arg0);
- }
-
- public static final String srvCertificateFactory = "CertificateFactory";
-
- private static String defaultProviderName = null;
-
- private static Provider defaultProvider = null;
-
- private static boolean X509Support = false;
-
- public static String defaultType = "X.509";
-
- public static final String[] validValues = {
- "X.509", "x.509" };
-
- private final static String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static String NotSupportMsg = "";
-
- static {
- defaultProvider = SpiEngUtils.isSupport(defaultType,
- srvCertificateFactory);
- X509Support = (defaultProvider != null);
- defaultProviderName = (X509Support ? defaultProvider.getName() : null);
- NotSupportMsg = defaultType.concat(" is not supported");
- }
-
- private static CertificateFactory[] initCertFs() {
- if (!X509Support) {
- fail(NotSupportMsg);
- return null;
- }
- try {
- CertificateFactory[] certFs = new CertificateFactory[3];
- certFs[0] = CertificateFactory.getInstance(defaultType);
- certFs[1] = CertificateFactory.getInstance(defaultType,
- defaultProviderName);
- certFs[2] = CertificateFactory.getInstance(defaultType,
- defaultProvider);
- return certFs;
- } catch (Exception e) {
- return null;
- }
- }
-
- private static MyCertificate createMC() {
- byte[] enc = { (byte) 0, (byte) 2, (byte) 3, (byte) 4, (byte) 5 };
- return new MyCertificate("Test_Test", enc);
- }
-
- /**
- * Test for <code>getInstance(String type)</code> method
- * Assertion: returns CertificateFactory if type is X.509
- */
- public void testCertificateFactory01() throws CertificateException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- for (int i = 0; i < validValues.length; i++) {
- CertificateFactory certF = CertificateFactory
- .getInstance(validValues[i]);
- assertEquals("Incorrect type: ", validValues[i], certF.getType());
- }
- }
-
- /**
- * Test for <code>getInstance(String type)</code> method
- * Assertion:
- * throws NullPointerException when type is null
- * throws CertificateException when type is not available
- */
- public void testCertificateFactory02() {
- try {
- CertificateFactory.getInstance(null);
- fail("NullPointerException or CertificateException must be thrown when type is null");
- } catch (CertificateException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertificateFactory.getInstance(invalidValues[i]);
- fail("CertificateException must be thrown when type: "
- .concat(invalidValues[i]));
- } catch (CertificateException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String type, String provider)</code> method
- * Assertion: throws IllegalArgumentException when provider is null or empty
- */
- public void testCertificateFactory03() throws CertificateException,
- NoSuchProviderException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- String provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertificateFactory.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- try {
- CertificateFactory.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String type, String provider)</code> method
- * Assertion:
- * throws NullPointerException when type is null
- * throws CertificateException when type is not available
- */
- public void testCertificateFactory04() throws CertificateException,
- NoSuchProviderException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- try {
- CertificateFactory.getInstance(null, defaultProviderName);
- fail("NullPointerException or CertificateException must be thrown when type is null");
- } catch (CertificateException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertificateFactory.getInstance(invalidValues[i],
- defaultProviderName);
- fail("CertificateException must be thrown (type: ".concat(
- invalidValues[i]).concat(" provider: ").concat(
- defaultProviderName).concat(")"));
- } catch (CertificateException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String type, String provider)</code> method
- * Assertion: returns CertificateFactory when type and provider have valid
- * values
- */
- public void testCertificateFactory05() throws CertificateException,
- NoSuchProviderException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- CertificateFactory certF;
- for (int i = 0; i < validValues.length; i++) {
- certF = CertificateFactory.getInstance(validValues[i],
- defaultProviderName);
- assertEquals("Incorrect type", certF.getType(), validValues[i]);
- assertEquals("Incorrect provider name", certF.getProvider()
- .getName(), defaultProviderName);
- }
- }
-
- /**
- * Test for <code>getInstance(String type, Provider provider)</code>
- * method
- * Assertion: throws IllegalArgumentException when provider is null
- */
- public void testCertificateFactory06() throws CertificateException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- Provider provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertificateFactory.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String type, Provider provider)</code>
- * method
- * Assertion:
- * throws NullPointerException when type is null
- * throws CertificateException when type is not available
- */
- public void testCertificateFactory07() throws CertificateException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- try {
- CertificateFactory.getInstance(null, defaultProvider);
- fail("NullPointerException or CertificateException must be thrown when type is null");
- } catch (CertificateException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertificateFactory.getInstance(invalidValues[i],
- defaultProvider);
- fail("CertificateException was not thrown as expected (type:"
- .concat(invalidValues[i]).concat(" provider: ").concat(
- defaultProvider.getName()).concat(")"));
- } catch (CertificateException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String type, Provider provider)</code>
- * method
- * Assertion: returns CertificateFactorythrows when type and provider
- * have valid values
- */
- public void testCertificateFactory08() throws CertificateException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- CertificateFactory certF;
- for (int i = 0; i < validValues.length; i++) {
- certF = CertificateFactory.getInstance(validValues[i],
- defaultProvider);
- assertEquals("Incorrect provider", certF.getProvider(),
- defaultProvider);
- assertEquals("Incorrect type", certF.getType(), validValues[i]);
- }
- }
-
- /**
- * Test for <code>getCertPathEncodings()</code> method
- * Assertion: returns encodings
- */
- public void testCertificateFactory09() throws CertificateException,
- NoSuchProviderException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- Iterator it1 = certFs[0].getCertPathEncodings();
- Iterator it2 = certFs[1].getCertPathEncodings();
- assertEquals("Incorrect encodings", it1.hasNext(), it2.hasNext());
- while (it1.hasNext()) {
- it2 = certFs[1].getCertPathEncodings();
- String s1 = (String) it1.next();
- boolean yesNo = false;
- while (it2.hasNext()) {
- if (s1.equals(it2.next())) {
- yesNo = true;
- break;
- }
- }
- assertTrue("Encoding: ".concat(s1).concat(
- " does not define for certF2 CertificateFactory"), yesNo);
- }
- it1 = certFs[0].getCertPathEncodings();
- it2 = certFs[2].getCertPathEncodings();
- assertEquals("Incorrect encodings", it1.hasNext(), it2.hasNext());
- while (it1.hasNext()) {
- it2 = certFs[2].getCertPathEncodings();
- String s1 = (String) it1.next();
- boolean yesNo = false;
- while (it2.hasNext()) {
- if (s1.equals(it2.next())) {
- yesNo = true;
- break;
- }
- }
- assertTrue("Encoding: ".concat(s1).concat(
- " does not define for certF3 CertificateFactory"), yesNo);
- }
- }
-
- /**
- * Test for <code>generateCertificate(InputStream inStream)</code>
- * <code>generateCertificates(InputStream inStream)</code>
- * <code>generateCRL(InputStream inStream)</code>
- * <code>generateCRLs(InputStream inStream)</code>
- * methods
- * Assertion: throw CertificateException and CRLException when
- * inStream is null or empty
- */
- public void testCertificateFactory10() throws CertificateException,
- NoSuchProviderException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- byte[] bb = { };
- InputStream is = new ByteArrayInputStream(bb);
- Collection colCer;
- Collection colCrl;
- for (int i = 0; i < certFs.length; i++) {
- try {
- certFs[i].generateCertificate(null);
- fail("generateCertificate must thrown CertificateException or NullPointerEXception when input stream is null");
- } catch (CertificateException e) {
- } catch (NullPointerException e) {
- }
- is = new ByteArrayInputStream(bb);
- try {
- certFs[i].generateCertificates(null);
- fail("generateCertificates must throw CertificateException or NullPointerException when input stream is null");
- } catch (CertificateException e) {
- } catch (NullPointerException e) {
- }
- is = new ByteArrayInputStream(bb);
- try {
- certFs[i].generateCertificate(is);
- } catch (CertificateException e) {
- }
- is = new ByteArrayInputStream(bb);
- try {
- colCer = certFs[i].generateCertificates(is);
- if (colCer != null) {
- assertTrue("Not empty certificate collection", colCer.isEmpty());
- }
- } catch (CertificateException e) {
- }
- }
- for (int i = 0; i < certFs.length; i++) {
- try {
- certFs[i].generateCRL(null);
- } catch (CRLException e) {
- } catch (NullPointerException e) {
- }
- try {
- colCrl = certFs[i].generateCRLs(null);
- if (colCrl != null) {
- assertTrue("Not empty CRL collection was returned from null stream", colCrl.isEmpty());
- }
- } catch (CRLException e) {
- } catch (NullPointerException e) {
- }
- is = new ByteArrayInputStream(bb);
- try {
- certFs[i].generateCRL(is);
- } catch (CRLException e) {
- }
- is = new ByteArrayInputStream(bb);
- try {
- certFs[i].generateCRLs(is);
- colCrl = certFs[i].generateCRLs(null);
- if (colCrl != null) {
- assertTrue("Not empty CRL collection was returned from empty stream", colCrl.isEmpty());
- }
- } catch (CRLException e) {
- }
- }
- }
-
- /*
- * Test for <code> generateCertificate(InputStream inStream) </code><code>
- * generateCertificates(InputStream inStream) </code><code>
- * generateCRL(InputStream inStream) </code><code>
- * generateCRLs(InputStream inStream) </code>
- * methods
- * Assertion: throw CertificateException and CRLException when inStream
- * contains incompatible datas
- */
- public void testCertificateFactory11() throws CertificateException,
- NoSuchProviderException, IOException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- MyCertificate mc = createMC();
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(os);
- oos.writeObject(mc);
- oos.flush();
- oos.close();
-
- Certificate cer;
- Collection colCer;
- CRL crl;
- Collection colCrl;
-
- byte[] arr = os.toByteArray();
- ByteArrayInputStream is;
- for (int i = 0; i < certFs.length; i++) {
- is = new ByteArrayInputStream(arr);
- try {
- cer = certFs[i].generateCertificate(is);
- assertNull("Not null certificate was created", cer);
- } catch (CertificateException e) {
- }
- is = new ByteArrayInputStream(arr);
- try {
- colCer = certFs[i].generateCertificates(is);
- if (colCer != null) {
- assertTrue("Not empty certificate Collection was created", colCer.isEmpty());
- }
- } catch (CertificateException e) {
- }
- is = new ByteArrayInputStream(arr);
- try {
- crl = certFs[i].generateCRL(is);
- assertNull("Not null CRL was created", crl);
- } catch (CRLException e) {
- }
- is = new ByteArrayInputStream(arr);
- try {
- colCrl = certFs[i].generateCRLs(is);
- if (colCrl != null) {
- assertTrue("Not empty CRL Collection was created", colCrl.isEmpty());
- }
- } catch (CRLException e) {
- }
- }
- }
-
- /**
- * Test for <code>generateCertPath(InputStream inStream)</code>
- * <code>generateCertPath(InputStream inStream, String encoding)</code>
- * methods
- * Assertion: throws CertificateException when inStream is null or
- * when isStream contains invalid datas
- */
- public void testCertificateFactory12() throws CertificateException,
- NoSuchProviderException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- InputStream is1 = null;
- InputStream is2 = new ByteArrayInputStream(new byte[10]);
-
- for (int i = 0; i < certFs.length; i++) {
- try {
- certFs[i].generateCertPath(is1);
- fail("generateCertificate must thrown CertificateException or NullPointerException when input stream is null");
- } catch (CertificateException e) {
- } catch (NullPointerException e) {
- }
- try {
- certFs[i].generateCertPath(is2);
- fail("generateCertificate must thrown CertificateException when input stream contains invalid datas");
- } catch (CertificateException e) {
- }
- Iterator it = certFs[i].getCertPathEncodings();
- while (it.hasNext()) {
- String enc = (String) it.next();
- try {
- certFs[i].generateCertPath(is1, enc);
- fail("generateCertificate must thrown CertificateException or NullPointerException when input stream is null and encodings "
- .concat(enc));
- } catch (CertificateException e) {
- } catch (NullPointerException e) {
- }
- try {
- certFs[i].generateCertPath(is2, enc);
- fail("generateCertificate must thrown CertificateException when input stream contains invalid datas and encodings "
- .concat(enc));
- } catch (CertificateException e) {
- }
- }
- }
- }
-
- /**
- * Test for <code>generateCertPath(InputStream inStream)</code>
- * <code>generateCertPath(InputStream inStream, String encoding)</code>
- * methods
- * Assertion: throw CertificateException when isStream contains invalid datas
- */
- public void testCertificateFactory13() throws IOException,
- CertificateException, NoSuchProviderException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- byte[] enc = { (byte) 0, (byte) 2, (byte) 3, (byte) 4, (byte) 5 };
- MyCertPath mc = new MyCertPath(enc);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
-
- ObjectOutputStream oos = new ObjectOutputStream(os);
- oos.writeObject(mc);
- oos.flush();
- oos.close();
-
- byte[] arr = os.toByteArray();
- ByteArrayInputStream is = new ByteArrayInputStream(arr);
-
- for (int i = 0; i < certFs.length; i++) {
- try {
- certFs[i].generateCertPath(is);
- fail("CertificateException must be thrown because input stream contains incorrect datas");
- } catch (CertificateException e) {
- }
- Iterator it = certFs[i].getCertPathEncodings();
- while (it.hasNext()) {
- try {
- certFs[i].generateCertPath(is, (String) it.next());
- fail("CertificateException must be thrown because input stream contains incorrect datas");
- } catch (CertificateException e) {
- }
- }
- }
- }
-
- /**
- * Test for <code>generateCertPath(List certificates)</code> method
- * Assertion: throw NullPointerException certificates is null
- */
- public void testCertificateFactory14() throws CertificateException,
- NoSuchProviderException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- List list = null;
- for (int i = 0; i < certFs.length; i++) {
- try {
- certFs[i].generateCertPath(list);
- fail("generateCertificate must thrown CertificateException when list is null");
- certFs[i].generateCertPath(list);
- fail("generateCertificates must throw CertificateException when list is null");
- } catch (NullPointerException e) {
- }
- }
- }
-
- /**
- * Test for <code>generateCertPath(List certificates)</code> method
- * Assertion: returns empty CertPath if certificates is empty
- */
- public void testCertificateFactory15() throws CertificateException,
- NoSuchProviderException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- List list = new Vector();
- for (int i = 0; i < certFs.length; i++) {
- CertPath cp = certFs[i].generateCertPath(list);
- List list1 = cp.getCertificates();
- assertTrue("List should be empty", list1.isEmpty());
- }
- }
-
- /**
- * Test for <code>generateCertPath(List certificates)</code> method
- * Assertion: throws CertificateException when certificates contains
- * incorrect Certificate
- */
- public void testCertificateFactory16() throws CertificateException,
- NoSuchProviderException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- MyCertificate ms = createMC();
- List list = new Vector();
- list.add(ms);
- for (int i = 0; i < certFs.length; i++) {
- try {
- certFs[i].generateCertPath(list);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- }
- }
-
- /**
- * Test for <code>CertificateFactory</code> constructor
- * Assertion: returns CertificateFactory object
- */
- public void testCertificateFactory17() throws CertificateException,
- NoSuchProviderException, NoSuchAlgorithmException, CRLException {
- if (!X509Support) {
- fail(NotSupportMsg);
- return;
- }
- CertificateFactorySpi spi = new MyCertificateFactorySpi();
- CertificateFactory cf = new myCertificateFactory(spi, defaultProvider,
- defaultType);
- assertEquals("Incorrect type", cf.getType(), defaultType);
- assertEquals("Incorrect provider", cf.getProvider(), defaultProvider);
- try {
- cf.generateCRLs(null);
- fail("CRLException must be thrown");
- } catch (CRLException e) {
- }
-
- cf = new myCertificateFactory(null, null, null);
- assertNull("Incorrect type", cf.getType());
- assertNull("Incorrect provider", cf.getProvider());
- try {
- cf.generateCRLs(null);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- }
-
-}
-
-/**
- * Additional class to verify CertificateFactory constructor
- */
-
-class myCertificateFactory extends CertificateFactory {
-
- public myCertificateFactory(CertificateFactorySpi spi, Provider prov,
- String type) {
- super(spi, prov, type);
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory2Test.java
deleted file mode 100644
index 2f25333..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory2Test.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.cert.CRL;
-import java.security.cert.CRLException;
-import java.security.cert.CertPath;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.SpiEngUtils.MyProvider;
-import org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for CertificateFactory class constructors and methods
- */
-
-public class CertificateFactory2Test extends TestCase {
- private static final String defaultAlg = "CertFac";
- private static final String CertificateFactoryProviderClass = "org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "CeRtFaC";
- validValues[3] = "cerTFac";
- }
-
- Provider mProv;
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyCFProvider",
- "Provider for testing", CertificateFactory1Test.srvCertificateFactory
- .concat(".").concat(defaultAlg),
- CertificateFactoryProviderClass);
- Security.insertProviderAt(mProv, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- /**
- * Constructor for CertificateFactory2Test.
- *
- * @param arg0
- */
- public CertificateFactory2Test(String arg0) {
- super(arg0);
- }
-
- private void checkResult(CertificateFactory certFactory, boolean mode)
- throws CertificateException, CRLException {
- MyCertificateFactorySpi.putMode(mode);
-
- ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
- DataInputStream dis = new DataInputStream(bais);
- try {
- certFactory.generateCertPath(bais);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- try {
- certFactory.generateCertPath(dis);
- if (!mode) {
- fail("CertificateException must be thrown because encodings list is empty");
- }
- } catch (CertificateException e) {
- if (mode) {
- fail("Unexpected CertificateFactoryException was thrown");
- }
- }
- try {
- certFactory.generateCertPath(bais, "aa");
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- try {
- certFactory.generateCertPath(dis, "");
- if (mode) {
- fail("IllegalArgumentException must be thrown");
- }
- } catch (IllegalArgumentException e) {
- if (!mode) {
- fail("Unexpected IllegalArgumentException was thrown");
- }
- }
- certFactory.generateCertPath(dis, "ss");
-
- try {
- certFactory.generateCertificate(bais);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- try {
- certFactory.generateCertificates(null);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- Certificate cert = certFactory.generateCertificate(dis);
- assertNull("Result must be null", cert);
- Collection col = certFactory.generateCertificates(dis);
- assertNull("Result must be null", col);
-
- try {
- certFactory.generateCRL(bais);
- fail("CRLException must be thrown");
- } catch (CRLException e) {
- }
- try {
- certFactory.generateCRLs(null);
- fail("CRLException must be thrown");
- } catch (CRLException e) {
- }
- CRL crl = certFactory.generateCRL(dis);
- assertNull("Result must be null", crl);
- col = certFactory.generateCRLs(dis);
- assertNull("Result must be null", col);
-
- List list = null;
- CertPath cp;
- try {
- cp = certFactory.generateCertPath(list);
- if (mode) {
- fail("NullPointerException must be thrown");
- } else {
- assertNull("Must be null", cp);
- }
- } catch (NullPointerException e) {
- if (!mode) {
- fail("Unexpected NullPointerException was thrown");
- }
- }
- Iterator it = certFactory.getCertPathEncodings();
- if (mode) {
- assertTrue(it.hasNext());
- } else {
- assertFalse(it.hasNext());
- }
- }
-
- /**
- * Test for <code>getInstance(String type)</code> method
- * Assertions:
- * throws NullPointerException when type is null
- * throws CertificateException when type is not available
- * returns CertificateFactory object
- */
- public void GetInstance01(boolean mode) throws CertificateException, CRLException {
- try {
- CertificateFactory.getInstance(null);
- fail("NullPointerException or CertificateException must be thrown when type is null");
- } catch (CertificateException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertificateFactory.getInstance(invalidValues[i]);
- fail("CertificateException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (CertificateException e) {
- }
- }
- CertificateFactory cerF;
- for (int i = 0; i < validValues.length; i++) {
- cerF = CertificateFactory.getInstance(validValues[i]);
- assertEquals("Incorrect type", cerF.getType(), validValues[i]);
- assertEquals("Incorrect provider", cerF.getProvider(), mProv);
- checkResult(cerF, mode);
- }
- }
-
- /**
- * Test for <code>getInstance(String type, String provider)</code> method
- * Assertions:
- * throws NullPointerException when type is null
- * throws CertificateException when type is not available
- * throws IllegalArgumentException when provider is null or empty;
- * throws NoSuchProviderException when provider is available;
- * returns CertificateFactory object
- */
- public void GetInstance02(boolean mode) throws CertificateException,
- NoSuchProviderException, IllegalArgumentException, CRLException {
- try {
- CertificateFactory.getInstance(null, mProv.getName());
- fail("NullPointerException or CertificateException must be thrown when type is null");
- } catch (CertificateException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertificateFactory.getInstance(invalidValues[i], mProv
- .getName());
- fail("CertificateException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (CertificateException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertificateFactory.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (type: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- try {
- CertificateFactory.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty (type: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- CertificateFactory.getInstance(validValues[i],
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (type: "
- .concat(validValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- CertificateFactory cerF;
- for (int i = 0; i < validValues.length; i++) {
- cerF = CertificateFactory.getInstance(validValues[i], mProv
- .getName());
- assertEquals("Incorrect type", cerF.getType(), validValues[i]);
- assertEquals("Incorrect provider", cerF.getProvider().getName(),
- mProv.getName());
- checkResult(cerF, mode);
- }
- }
-
- /**
- * Test for <code>getInstance(String type, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when type is null
- * throws CertificateException when type is not available
- * throws IllegalArgumentException when provider is null;
- * returns CertificateFactory object
- */
- public void GetInstance03(boolean mode) throws CertificateException,
- IllegalArgumentException, CRLException {
- try {
- CertificateFactory.getInstance(null, mProv);
- fail("NullPointerException or CertificateException must be thrown when type is null");
- } catch (CertificateException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertificateFactory.getInstance(invalidValues[i], mProv);
- fail("CertificateException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (CertificateException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertificateFactory.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (type: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- CertificateFactory cerF;
- for (int i = 0; i < validValues.length; i++) {
- cerF = CertificateFactory.getInstance(validValues[i], mProv);
- assertEquals("Incorrect type", cerF.getType(), validValues[i]);
- assertEquals("Incorrect provider", cerF.getProvider(), mProv);
- checkResult(cerF, mode);
- }
- }
-
- public void testGetInstance01() throws CertificateException, CRLException {
- GetInstance01(true);
- }
-
- public void testGetInstance02() throws CertificateException,
- NoSuchProviderException, IllegalArgumentException, CRLException {
- GetInstance02(true);
- }
-
- public void testGetInstance03() throws CertificateException,
- IllegalArgumentException, CRLException {
- GetInstance03(true);
- }
-
- public void testGetInstance04() throws CertificateException, CRLException {
- GetInstance01(false);
- }
-
- public void testGetInstance05() throws CertificateException,
- NoSuchProviderException, IllegalArgumentException, CRLException {
- GetInstance02(false);
- }
-
- public void testGetInstance06() throws CertificateException,
- IllegalArgumentException, CRLException {
- GetInstance03(false);
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory3Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory3Test.java
deleted file mode 100644
index 6a7fd8d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory3Test.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.security.Provider;
-import java.security.cert.CertPath;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateFactory;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import tests.support.resource.Support_Resources;
-
-/**
- * Tests for <code>CertificateFactory</code> class methods
- */
-
-public class CertificateFactory3Test extends TestCase {
-
- private static String defaultProviderName = null;
-
- private static Provider defaultProvider = null;
-
- private static String defaultType = CertificateFactory1Test.defaultType;
-
- public static String fileCertPathPki = "java/security/cert/CertPath.PkiPath";
-
- private static boolean X509Support = false;
-
- private static String NotSupportMsg = "";
-
- static {
- defaultProvider = SpiEngUtils.isSupport(defaultType,
- CertificateFactory1Test.srvCertificateFactory);
- X509Support = defaultProvider != null;
- defaultProviderName = X509Support ? defaultProvider.getName() : null;
-
- NotSupportMsg = defaultType.concat(" is not supported");
- }
-
- private static CertificateFactory[] initCertFs() throws Exception {
- if (!X509Support) {
- fail(NotSupportMsg);
- }
-
- CertificateFactory[] certFs = new CertificateFactory[3];
- certFs[0] = CertificateFactory.getInstance(defaultType);
- certFs[1] = CertificateFactory.getInstance(defaultType,
- defaultProviderName);
- certFs[2] = CertificateFactory
- .getInstance(defaultType, defaultProvider);
- return certFs;
- }
-
- /**
- * Test for <code>generateCertificate(InputStream inStream)</code> method
- * Assertion: returns Certificate
- */
- public void testGenerateCertificate() throws Exception {
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- Certificate[] certs = new Certificate[3];
- for (int i = 0; i < certFs.length; i++) {
- certs[i] = certFs[i].generateCertificate(new ByteArrayInputStream(
- TestUtils.getEncodedX509Certificate()));
- }
- assertEquals(certs[0], certs[1]);
- assertEquals(certs[0], certs[2]);
- }
-
- /**
- * Test for <code>generateCertificates(InputStream inStream)</code> method
- * Assertion: returns Collection which consists of 1 Certificate
- */
- public void testeGnerateCertificates() throws Exception {
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- Certificate cert = certFs[0]
- .generateCertificate(new ByteArrayInputStream(TestUtils
- .getEncodedX509Certificate()));
- for (int i = 0; i < certFs.length; i++) {
- Collection col = null;
- col = certFs[i].generateCertificates(new ByteArrayInputStream(
- TestUtils.getEncodedX509Certificate()));
- Iterator it = col.iterator();
- assertEquals("Incorrect Collection size", col.size(), 1);
- assertEquals("Incorrect Certificate in Collection", cert, it.next());
- }
- }
-
- /**
- * Test for <code>generateCertPath(List certificates)</code> method
- * Assertion: returns CertPath with 1 Certificate
- */
- public void testGenerateCertPath01() throws Exception {
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- // create list of certificates with one certificate
- Certificate cert = certFs[0]
- .generateCertificate(new ByteArrayInputStream(TestUtils
- .getEncodedX509Certificate()));
- List list = new Vector();
- list.add(cert);
- for (int i = 0; i < certFs.length; i++) {
- CertPath certPath = null;
- certPath = certFs[i].generateCertPath(list);
- assertEquals(cert.getType(), certPath.getType());
- List list1 = certPath.getCertificates();
- assertFalse("Result list is empty", list1.isEmpty());
- Iterator it = list1.iterator();
- assertEquals("Incorrect Certificate in CertPath", cert, it.next());
- }
- }
-
- /**
- * Test for
- * <code>generateCertPath(InputStream inStream, String encoding)</code>
- * method Assertion: returns CertPath with 1 Certificate
- */
- public void testGenerateCertPath02() throws Exception {
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- for (int i = 0; i < certFs.length; i++) {
- CertPath certPath = null;
- InputStream fis = Support_Resources
- .getResourceStream(fileCertPathPki);
- certPath = certFs[i].generateCertPath(fis, "PkiPath");
- fis.close();
- assertEquals(defaultType, certPath.getType());
-
- List list1 = certPath.getCertificates();
- assertFalse("Result list is empty", list1.isEmpty());
- }
- }
-
- /**
- * Test for <code>generateCertPath(InputStream inStream)</code> method
- * Assertion: returns CertPath with 1 Certificate
- */
- public void testGenerateCertPath03() throws Exception {
- String certPathEncoding = "PkiPath";
- CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
- for (int i = 0; i < certFs.length; i++) {
- Iterator it = certFs[0].getCertPathEncodings();
-
- assertTrue("no CertPath encodings", it.hasNext());
-
- assertEquals("Incorrect default encoding", certPathEncoding, it
- .next());
-
- CertPath certPath = null;
- InputStream fis = Support_Resources
- .getResourceStream(fileCertPathPki);
- certPath = certFs[i].generateCertPath(fis);
- fis.close();
- assertEquals(defaultType, certPath.getType());
-
- List list1 = certPath.getCertificates();
- assertFalse("Result list is empty", list1.isEmpty());
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory4Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory4Test.java
deleted file mode 100644
index adf5ae8..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory4Test.java
+++ /dev/null
@@ -1,611 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.cert.CRL;
-import java.security.cert.CRLException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.util.Collection;
-import java.util.List;
-
-import junit.framework.TestCase;
-import tests.support.Support_GetResource;
-import tests.support.resource.Support_Resources;
-
-public class CertificateFactory4Test extends TestCase {
-
- private static final String BASE_URL = Support_GetResource
- .getResourceURL("/../internalres/");
-
- private static final String[] CERTIFICATE_URLS = new String[] {
- "Bug93891-PEM.cer", "Bug93891-DER.cer", "Bug94404-PKCS7.cer" };
-
- private static final String[] CRL_URLS = new String[] { "Bug93893-1.crl",
- "Bug93893-2.crl", "Bug94404-DER.crl" };
-
- private static final String[] CRLCOLLECTION_URLS = new String[] { "Bug94404-PKCS7.crl" };
-
- /**
- * @tests java.security.cert.CertificateFactory#generateCertificate(java.io.InputStream)
- */
- public void test_generateCertificateLjava_io_InputStream() throws Exception {
- // Test 1
- // Test for method java.security.cert.Certificate
- // java.security.cert.CertificateFactory.generateCertificate(java.io.InputStream)
- CertificateFactory fact = CertificateFactory.getInstance("X.509");
- for (int i = 0; i < CERTIFICATES_ENCODED_X509.length; i++) {
- ByteArrayInputStream bais = new ByteArrayInputStream(
- CERTIFICATES_ENCODED_X509[i].getBytes("UTF-8"));
- fact.generateCertificate(bais);
-
- // try again with generateCertificates()
- bais = new ByteArrayInputStream(CERTIFICATES_ENCODED_X509[i]
- .getBytes("UTF-8"));
- fact.generateCertificate(bais);
- }
-
- // Test 2
- InputStream is = Support_Resources.getResourceStream("hyts_badpem.cer");
- try {
- fact.generateCertificate(is);
- fail("Test2: CertificateException not thrown");
- } catch (CertificateException e) {
- } finally {
- try {
- is.close();
- } catch (IOException ignore) {
- }
- }
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#generateCertificates(java.io.InputStream)
- */
- public void test_generateCertificatesLjava_io_InputStream()
- throws Exception {
- CertificateFactory fact = CertificateFactory.getInstance("X.509");
- for (int i = 0; i < CERTIFICATE_URLS.length; i++) {
- URL certUrl = new URL(BASE_URL + CERTIFICATE_URLS[i]);
- try {
- InputStream is = certUrl.openStream();
- Collection certs = fact.generateCertificates(is);
- assertNotNull("The certificates in \""
- + certUrl.toExternalForm()
- + "\" were not parsed correctly", certs);
- } catch (IOException e) {
- // the certificate could not be found, skip it
- } catch (CertificateException e) {
- fail("An exception was thrown while parsing \""
- + certUrl.toExternalForm() + "\": " + e.getMessage());
- }
- }
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#generateCRL(java.io.InputStream)
- */
- public void test_generateCRLLjava_io_InputStream() throws Exception {
- CertificateFactory fact = CertificateFactory.getInstance("X.509");
- for (int i = 0; i < CRL_URLS.length; i++) {
- URL certUrl = new URL(BASE_URL + CRL_URLS[i]);
- try {
- InputStream is = certUrl.openStream();
- CRL crl = fact.generateCRL(is);
- assertNotNull("The CRL in \"" + certUrl.toExternalForm()
- + "\" were not parsed correctly", crl);
- } catch (IOException e) {
- // the certificate could not be found, skip it
- } catch (CRLException e) {
- fail("An exception was thrown while parsing \""
- + certUrl.toExternalForm() + "\": " + e.getMessage());
- }
- }
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#generateCRLs(java.io.InputStream)
- */
- public void test_generateCRLsLjava_io_InputStream() throws Exception {
- CertificateFactory fact = CertificateFactory.getInstance("X.509");
- for (int i = 0; i < CRLCOLLECTION_URLS.length; i++) {
- URL certUrl = new URL(BASE_URL + CRLCOLLECTION_URLS[i]);
- try {
- InputStream is = certUrl.openStream();
- Collection crls = fact.generateCRLs(is);
- assertTrue("The CRLs in \"" + certUrl.toExternalForm()
- + "\" were not parsed correctly", crls != null
- && crls.size() > 0);
- } catch (IOException e) {
- // the certificate could not be found, skip it
- }
- }
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#getInstance(java.lang.String)
- */
- public void test_getInstanceLjava_lang_String() throws Exception {
- // Test for method java.security.cert.CertificateFactory
- // java.security.cert.CertificateFactory.getInstance(java.lang.String)
- CertificateFactory fact = CertificateFactory.getInstance("X.509");
- assertTrue("factory is null", fact != null);
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#getInstance(java.lang.String,
- *java.lang.String)
- */
- public void test_getInstanceLjava_lang_StringLjava_lang_String()
- throws Exception {
- // Test for method java.security.cert.CertificateFactory
- // java.security.cert.CertificateFactory.getInstance(java.lang.String,
- // java.lang.String)
- Provider[] providers = Security
- .getProviders("CertificateFactory.X.509");
-
- if (providers != null) {
- for (int i = 0; i < providers.length; i++) {
- CertificateFactory fact = CertificateFactory.getInstance(
- "X.509", providers[i].getName());
- assertNotNull("factory is null", fact);
- }// end for
- } else {
- fail("No providers support CertificateFactory.X.509");
- }
-
- // exception case
- try {
- CertificateFactory.getInstance("X.509", "IHaventBeenConfigured");
- fail("Should have thrown NoSuchProviderException");
- } catch (NoSuchProviderException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#getProvider()
- */
- public void test_getProvider() throws Exception {
- // Test for method java.security.Provider
- // java.security.cert.CertificateFactory.getProvider()
- Provider p = CertificateFactory.getInstance("X.509").getProvider();
- assertNotNull("provider is null", p);
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#generateCRLs(InputStream
- *inStream)
- */
- public void testGenerateCRLs2() throws Exception {
- // Regression for HARMONY-814
- try {
- CertificateFactory.getInstance("X.509").generateCRL(
- (InputStream) null);
- fail("CRLException was not thrown");
- } catch (CRLException e) {
- }
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#generateCertificate(InputStream
- *inStream)
- */
- public void testGenerateCertificate() throws Exception {
- // Regression for HARMONY-814
- try {
- CertificateFactory.getInstance("X.509").generateCertificate(null);
- fail("CertificateException was not thrown");
- } catch (CertificateException e) {
- }
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#generateCertificates(InputStream
- *inStream)
- */
- public void testGenerateCertificates2() throws Exception {
- // Regression for HARMONY-814
- try {
- CertificateFactory.getInstance("X.509").generateCertificates(null);
- fail("CertificateException was not thrown");
- } catch (CertificateException e) {
- }
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#generateCertPath(InputStream
- *inStream, String encoding)
- */
- public void testGenerateCertPath1() throws Exception {
- // Regression for HARMONY-814
- try {
- CertificateFactory.getInstance("X.509").generateCertPath(
- (InputStream) null, "PkiPath");
- fail("CertificateException was not thrown");
- } catch (CertificateException e) {
- }
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#generateCertPath(List<?
- * extends Certificate> certificates)
- */
- public void testGenerateCertPath2() throws Exception {
- // Regression for HARMONY-814
- try {
- CertificateFactory.getInstance("X.509").generateCertPath(
- (List) null);
- fail("NullPointerException was not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#generateCertPath(InputStream
- *inStream)
- */
- public void testGenerateCertPath3() throws Exception {
- // Regression for HARMONY-814
- try {
- CertificateFactory.getInstance("X.509").generateCertPath(
- (InputStream) null);
- fail("CertificateException was not thrown");
- } catch (CertificateException e) {
- }
- }
-
- /**
- * @tests java.security.cert.CertificateFactory#generateCRL(InputStream
- *inStream)
- */
- public void testGenerateCRL() throws Exception {
- // Regression for HARMONY-814
- try {
- CertificateFactory.getInstance("X.509").generateCRL(
- (InputStream) null);
- fail("CRLException was not thrown");
- } catch (CRLException e) {
- }
- }
-
- private static final String[] CERTIFICATES_ENCODED_X509 = {
- // CERTIFICATES_ENCODED_X509[0]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIICZTCCAdICBQL3AAC2MA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMSAw\n"
- + "HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJl\n"
- + "IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NzAyMjAwMDAwMDBa\n"
- + "Fw05ODAyMjAyMzU5NTlaMIGWMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZv\n"
- + "cm5pYTESMBAGA1UEBxMJUGFsbyBBbHRvMR8wHQYDVQQKExZTdW4gTWljcm9zeXN0\n"
- + "ZW1zLCBJbmMuMSEwHwYDVQQLExhUZXN0IGFuZCBFdmFsdWF0aW9uIE9ubHkxGjAY\n"
- + "BgNVBAMTEWFyZ29uLmVuZy5zdW4uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB\n"
- + "iQKBgQCofmdY+PiUWN01FOzEewf+GaG+lFf132UpzATmYJkA4AEA/juW7jSi+LJk\n"
- + "wJKi5GO4RyZoyimAL/5yIWDV6l1KlvxyKslr0REhMBaD/3Z3EsLTTEf5gVrQS6sT\n"
- + "WMoSZAyzB39kFfsB6oUXNtV8+UKKxSxKbxvhQn267PeCz5VX2QIDAQABMA0GCSqG\n"
- + "SIb3DQEBAgUAA34AXl3at6luiV/7I9MN5CXYoPJYI8Bcdc1hBagJvTMcmlqL2uOZ\n"
- + "H9T5hNMEL9Tk6aI7yZPXcw/xI2K6pOR/FrMp0UwJmdxX7ljV6ZtUZf7pY492UqwC\n"
- + "1777XQ9UEZyrKJvF5ntleeO0ayBqLGVKCWzWZX9YsXCpv47FNLZbupE=\n"
- + "-----END CERTIFICATE-----\n",
-
- // CERTIFICATES_ENCODED_X509[1]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIICZzCCAdCgAwIBAgIBGzANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJVUzEY\n"
- + "MBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsT\n"
- + "A1BLSTEcMBoGA1UEAxMTRG9EIFBLSSBNZWQgUm9vdCBDQTAeFw05ODA4MDMyMjAy\n"
- + "MjlaFw0wODA4MDQyMjAyMjlaMGExCzAJBgNVBAYTAlVTMRgwFgYDVQQKEw9VLlMu\n"
- + "IEdvdmVybm1lbnQxDDAKBgNVBAsTA0RvRDEMMAoGA1UECxMDUEtJMRwwGgYDVQQD\n"
- + "ExNEb0QgUEtJIE1lZCBSb290IENBMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n"
- + "gQDbrM/J9FrJSX+zxFUbsI9Vw5QbguVBIa95rwW/0M8+sM0r5gd+DY6iubm6wnXk\n"
- + "CSvbfQlFEDSKr4WYeeGp+d9WlDnQdtDFLdA45tCi5SHjnW+hGAmZnld0rz6wQekF\n"
- + "5xQaa5A6wjhMlLOjbh27zyscrorMJ1O5FBOWnEHcRv6xqQIDAQABoy8wLTAdBgNV\n"
- + "HQ4EFgQUVrmYR6m9701cHQ3r5kXyG7zsCN0wDAYDVR0TBAUwAwEB/zANBgkqhkiG\n"
- + "9w0BAQUFAAOBgQDVX1Y0YqC7vekeZjVxtyuC8Mnxbrz6D109AX07LEIRzNYzwZ0w\n"
- + "MTImSp9sEzWW+3FueBIU7AxGys2O7X0qmN3zgszPfSiocBuQuXIYQctJhKjF5KVc\n"
- + "VGQRYYlt+myhl2vy6yPzEVCjiKwMEb1Spu0irCf+lFW2hsdjvmSQMtZvOw==\n"
- + "-----END CERTIFICATE-----\n",
-
- // CERTIFICATES_ENCODED_X509[2]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIID6TCCA1KgAwIBAgIBGjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJVUzEY\n"
- + "MBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsT\n"
- + "A1BLSTEcMBoGA1UEAxMTRG9EIFBLSSBNZWQgUm9vdCBDQTAeFw05ODA4MDIxNjQ1\n"
- + "MzhaFw0wMzA4MDIxNjQ1MzhaMFYxCzAJBgNVBAYTAlVTMRgwFgYDVQQKEw9VLlMu\n"
- + "IEdvdmVybm1lbnQxDDAKBgNVBAsTA0RvRDEMMAoGA1UECxMDUEtJMREwDwYDVQQD\n"
- + "EwhNZWQgQ0EtMTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAyUcrw1k6QKdB\n"
- + "WjgtGOk1AVaqJNI8acDGglhqQQ94QYfqZKuo1wwdnYehrgo5QcGkw9XcjBYegLFs\n"
- + "v4NCCwZ2pgsfYJlvHcSGPhT/wROUYEpXKelfXiEeaGhFl8zGcqteI2+EBbOZnFpj\n"
- + "Y4y+25dQcjYnrRGMAQ98qGwQtogDiDcCAwEAAaOCAbowggG2MBYGA1UdIAQPMA0w\n"
- + "CwYJYIZIAWUCAQsDMB8GA1UdIwQYMBaAFFa5mEepve9NXB0N6+ZF8hu87AjdMAwG\n"
- + "A1UdJAQFMAOAAQAwHQYDVR0OBBYEFDM6FOgJZ2GIZSQg7HlwQtemkx72MA4GA1Ud\n"
- + "DwEB/wQEAwIBhjB+BgNVHRIEdzB1hnNsZGFwOi8vZHMtMS5jaGFtYi5kaXNhLm1p\n"
- + "bC9jbiUzZERvRCUyMFBLSSUyME1lZCUyMFJvb3QlMjBDQSUyY291JTNkUEtJJTIg\n"
- + "Y291JTNkRG9EJTJjbyUzZFUuUy4lMjBHb3Zlcm5tZW50JTJjYyUzZFVTMA8GA1Ud\n"
- + "EwEB/wQFMAMBAf8wgawGA1UdHwSBpDCBoTCBnqCBm6CBmIaBlWxkYXA6Ly9kcy0x\n"
- + "LmNoYW1iLmRpc2EubWlsL2NuJTNkRG9EJTIwUEtJJTIwTWVkJTIwUm9vdCUyMENB\n"
- + "JTJjb3UlM2RQS0klMmNvdSUzZERvRCUyY28lM2RVLlMuJTIwR292ZXJubWVudCUy\n"
- + "Y2MlM2RVUz9jZXJ0aWZpY2F0ZVJldm9jYXRpb25MaXN0JTNiYmluYXJ5MA0GCSqG\n"
- + "SIb3DQEBBQUAA4GBAFo5/Tu0dsy8tyhJVvxaKFNMfP3LLaspl+Or8oCpncKdpKyj\n"
- + "7ZO6uJ0n7oqvEaUThm8jgXSNgyttlYPwoNBxEsTq/lBDV3+y/c61psw3qM2boB1H\n"
- + "Oi3xXnRY+etG33TN9yydzrZ52XM0hnJZd4xIfoAgqs4T2rgqg8hx0ydU7o4o\n"
- + "-----END CERTIFICATE-----\n",
-
- // CERTIFICATES_ENCODED_X509[3]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIIDVjCCAr+gAwIBAgIBRTANBgkqhkiG9w0BAQUFADBWMQswCQYDVQQGEwJVUzEY\n"
- + "MBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsT\n"
- + "A1BLSTERMA8GA1UEAxMITWVkIENBLTEwHhcNOTgwODAyMTcxMzI5WhcNMDEwODAy\n"
- + "MTcxMzI5WjBwMQswCQYDVQQGEwJVUzEYMBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50\n"
- + "MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsTA1BLSTENMAsGA1UECxMEVVNBRjEcMBoG\n"
- + "A1UEAxMTZHMtMS5jaXN0dy5zYWljLmNvbTCBnTANBgkqhkiG9w0BAQEFAAOBiwAw\n"
- + "gYcCgYEA19oJsspSHnWDi1/NTthbLrnicDogg3c63ZHPedU1YD90L1ogkYzxSA2t\n"
- + "MgsVZpNejBglE972mXKPqEGDojnDgltRgRLtLqisIs0DSFQrJrhA8egMH/pHAo9H\n"
- + "fH0n9rQUYBI3dsLxQkGVUSbB4P83VHi0sQO0dWsq5mEZd9G+MfsCAQOjggEaMIIB\n"
- + "FjAWBgNVHSAEDzANMAsGCWCGSAFlAgELAzAfBgNVHSMEGDAWgBQzOhToCWdhiGUk\n"
- + "IOx5cELXppMe9jAdBgNVHQ4EFgQUcQaYO8EEjje+VI3vfBIlDC6HNj0wDgYDVR0P\n"
- + "AQH/BAQDAgUgMAwGA1UdEwEB/wQCMAAwgZ0GA1UdHwSBlTCBkjCBj6CBjKCBiYaB\n"
- + "hmxkYXA6Ly9kcy0xLmNoYW1iLmRpc2EubWlsL2NuJTNkTWVkJTIwQ0ElMmQxJTJj\n"
- + "b3UlM2RQS0klMmNvdSUzZERvRCUyY28lM2RVLlMuJTIwR292ZXJubWVudCUyY2Ml\n"
- + "M2RVUz9jZXJ0aWZpY2F0ZVJldm9jYXRpb25MaXN0JTNiYmluYXJ5MA0GCSqGSIb3\n"
- + "DQEBBQUAA4GBAEg7AC9bad2KZzyX4cqLU/mv2cbVg6tES2PIeST7nk8CQcv9a8IO\n"
- + "3K4uhrKoTsQfqs9p6+6s0VbgH3PKvOAIF4DAp5Yq1zz3fB+hsaFleHqtDNuldm1+\n"
- + "3XA2Oqa5aRFkb6Krut0EEOV4c/GEAPOrRGUTzYmOp4SEc8TEaD/75A7R\n"
- + "-----END CERTIFICATE-----\n",
-
- // CERTIFICATES_ENCODED_X509[4]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIIDXDCCAsWgAwIBAgIBSjANBgkqhkiG9w0BAQUFADBWMQswCQYDVQQGEwJVUzEY\n"
- + "MBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsT\n"
- + "A1BLSTERMA8GA1UEAxMITWVkIENBLTEwHhcNOTgwODAyMTgwMjQwWhcNMDEwODAy\n"
- + "MTgwMjQwWjB0MQswCQYDVQQGEwJVUzEYMBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50\n"
- + "MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsTA1BLSTENMAsGA1UECxMEVVNBRjEgMB4G\n"
- + "A1UEAxMXR3VtYnkuSm9zZXBoLjAwMDAwMDUwNDQwgZ8wDQYJKoZIhvcNAQEBBQAD\n"
- + "gY0AMIGJAoGBALT/R7bPqs1c1YqXAg5HNpZLgW2HuAc7RCaP06cE4R44GBLw/fQc\n"
- + "VRNLn5pgbTXsDnjiZVd8qEgYqjKFQka4/tNhaF7No2tBZB+oYL/eP0IWtP+h/W6D\n"
- + "KR5+UvIIdgmx7k3t9jp2Q51JpHhhKEb9WN54trCO9Yu7PYU+LI85jEIBAgMBAAGj\n"
- + "ggEaMIIBFjAWBgNVHSAEDzANMAsGCWCGSAFlAgELAzAfBgNVHSMEGDAWgBQzOhTo\n"
- + "CWdhiGUkIOx5cELXppMe9jAdBgNVHQ4EFgQUkLBJl+ayKgzOp/wwBX9M1lSkCg4w\n"
- + "DgYDVR0PAQH/BAQDAgbAMAwGA1UdEwEB/wQCMAAwgZ0GA1UdHwSBlTCBkjCBj6CB\n"
- + "jKCBiYaBhmxkYXA6Ly9kcy0xLmNoYW1iLmRpc2EubWlsL2NuJTNkTWVkJTIwQ0El\n"
- + "MmQxJTJjb3UlM2RQS0klMmNvdSUzZERvRCUyY28lM2RVLlMuJTIwR292ZXJubWVu\n"
- + "dCUyY2MlM2RVUz9jZXJ0aWZpY2F0ZVJldm9jYXRpb25MaXN0JTNiYmluYXJ5MA0G\n"
- + "CSqGSIb3DQEBBQUAA4GBAFjapuDHMvIdUeYRyEYdShBR1JZC20tJ3MQnyBQveddz\n"
- + "LGFDGpIkRAQU7T/5/ne8lMexyxViC21xOlK9LdbJCbVyywvb9uEm/1je9wieQQtr\n"
- + "kjykuB+WB6qTCIslAO/eUmgzfzIENvnH8O+fH7QTr2PdkFkiPIqBJYHvw7F3XDqy\n"
- + "-----END CERTIFICATE-----\n",
-
- // CERTIFICATES_ENCODED_X509[5]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIIDlDCCAv2gAwIBAgIBGTANBgkqhkiG9w0BAQUFADBcMQswCQYDVQQGEwJVUzEY\n"
- + "MBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsT\n"
- + "A1BLSTEXMBUGA1UEAxMOTWVkIEVtYWlsIENBLTEwHhcNOTgwODAyMTgwNjM0WhcN\n"
- + "MDAwODAyMTgwNjM0WjCBmTELMAkGA1UEBhMCVVMxGDAWBgNVBAoTD1UuUy4gR292\n"
- + "ZXJubWVudDEMMAoGA1UECxMDRG9EMQwwCgYDVQQLEwNQS0kxDTALBgNVBAsTBFVT\n"
- + "QUYxIDAeBgNVBAMTF0d1bWJ5Lkpvc2VwaC4wMDAwMDA1MDQ0MSMwIQYJKoZIhvcN\n"
- + "AQkBFhRndW1ieUBjaXN0dy5zYWljLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw\n"
- + "gYkCgYEAvU4LMoOnF9bmhHvxZz8wCc9eRJ0j4RB0SmVYoq9iPrSJBwROeuxuU8VS\n"
- + "JBL/u+RB5t6UJVNjXFmB1wS0foxpOHFQBFWyvWmuOiRUNaRxTVCrO4eG+nmM/U89\n"
- + "DKAc9FV4bZ8dPE9PlK9oq0J8Y2DIKz1+gIeM1sTPMnDtFgfGyH8CAwEAAaOCASYw\n"
- + "ggEiMBYGA1UdIAQPMA0wCwYJYIZIAWUCAQsDMB8GA1UdIwQYMBaAFJcrSHN/a+aN\n"
- + "L5DK1NpJUIvX+bVnMB0GA1UdDgQWBBR50N97AxK0G6U17EP1iu38LiLTBzAOBgNV\n"
- + "HQ8BAf8EBAMCBaAwDAYDVR0TAQH/BAIwADCBqQYDVR0fBIGhMIGeMIGboIGYoIGV\n"
- + "hoGSbGRhcDovL2RzLTEuY2hhbWIuZGlzYS5taWw6MzkwL2NuJTNkTWVkJTIwRW1h\n"
- + "aWwlMjBDQSUyZDElMmNvdSUzZFBLSSUyY291JTNkRG9EJTJjbyUzZFUuUy4lMjBH\n"
- + "b3Zlcm5tZW50JTJjYyUzZFVTP2NlcnRpZmljYXRlUmV2b2NhdGlvbkxpc3QlM2Ji\n"
- + "aW5hcnkwDQYJKoZIhvcNAQEFBQADgYEAA9z8h7K4v0CuOyvmALNl8TQt0inf0w52\n"
- + "JJUvw/3FLA622IHe/vC9VHyIF0ibSEljWeOBuRjoMELAZGXCwRu43o2LDRqHr4Pc\n"
- + "WlG0uUtgHTPxbZpaUwueIZCBZg57f7Zhlub7Ag+AjeOybFj3FYqDB7TYqWJgAs/7\n"
- + "g5WfNEVAEwc=\n" + "-----END CERTIFICATE-----\n",
-
- // CERTIFICATES_ENCODED_X509[6]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIIEEjCCA7ygAwIBAgIIEt4r4gAAAlIwDQYJKoZIhvcNAQEEBQAwgZMxCzAJBgNV\n"
- + "BAYTAlVTMQswCQYDVQQIEwJXQTEQMA4GA1UEBxMHUmVkbW9uZDETMBEGA1UEChMK\n"
- + "V2luZG93cyBOVDEbMBkGA1UECxMSRGlzdHJpYnV0ZWQgU3lzdGVtMTMwMQYDVQQD\n"
- + "EypNaWNyb3NvZnQgQ2VydGlmaWNhdGUgU2VydmVyIFRlc3QgR3JvdXAgQ0EwHhcN\n"
- + "OTcxMTI1MTkwNDIyWhcNOTgxMDE0MTgxMTI4WjBuMQswCQYDVQQGEwJVUzELMAkG\n"
- + "A1UECBMCV0ExEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBD\n"
- + "b3Jwb3JhdGlvbjENMAsGA1UECxMERFNZUzERMA8GA1UEAxMIQ2VydFRlc3QwWzAN\n"
- + "BgkqhkiG9w0BAQEFAANKADBHAkB6hKgbYme8gtCf1Vy74KVNLf2o/R1kQVDSZiNm\n"
- + "lBSEsHAJSLXuuVdYsKo/hzarr9gGmI/gUzmargY1xJGQYbazAgMBAAGjggIXMIIC\n"
- + "EzCBzwYDVR0jBIHHMIHEgBS3hTIRuBZaOibht1DZjnTUg/IiRaGBmaSBljCBkzEL\n"
- + "MAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdSZWRtb25kMRMwEQYD\n"
- + "VQQKEwpXaW5kb3dzIE5UMRswGQYDVQQLExJEaXN0cmlidXRlZCBTeXN0ZW0xMzAx\n"
- + "BgNVBAMTKk1pY3Jvc29mdCBDZXJ0aWZpY2F0ZSBTZXJ2ZXIgVGVzdCBHcm91cCBD\n"
- + "QYIQERNhAKoA/oUR0US54igUYzCBvQYDVR0fBIG1MIGyMFagVKBShlBodHRwOi8v\n"
- + "Q0VSVFNSVi9DZXJ0U3J2L0NlcnRFbnJvbGwvTWljcm9zb2Z0IENlcnRpZmljYXRl\n"
- + "IFNlcnZlciBUZXN0IEdyb3VwIENBLmNybDBYoFagVIZSZmlsZTovL1xcQ0VSVFNS\n"
- + "VlxDZXJ0U3J2XENlcnRFbnJvbGxcTWljcm9zb2Z0IENlcnRpZmljYXRlIFNlcnZl\n"
- + "ciBUZXN0IEdyb3VwIENBLmNybDAJBgNVHRMEAjAAMHQGCCsGAQUFBwEBBGgwZjBk\n"
- + "BggrBgEFBQcwAoZYaHR0cDovL0NFUlRTUlYvQ2VydFNydi9DZXJ0RW5yb2xsL0NF\n"
- + "UlRTUlZfTWljcm9zb2Z0IENlcnRpZmljYXRlIFNlcnZlciBUZXN0IEdyb3VwIENB\n"
- + "LmNydDANBgkqhkiG9w0BAQQFAANBAFbEj4j/3Nv6WcAvq24C7yw8L0FcyE4dtLLX\n"
- + "U+04P0POe/doyTT6UngXNXp9RXpqDSiIHBRTshpvR+N2vweR5qA=\n"
- + "-----END CERTIFICATE-----\n",
-
- // CERTIFICATES_ENCODED_X509[7]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIIEYTCCBAugAwIBAgIIFViWmwAAAlowDQYJKoZIhvcNAQEEBQAwgZMxCzAJBgNV\n"
- + "BAYTAlVTMQswCQYDVQQIEwJXQTEQMA4GA1UEBxMHUmVkbW9uZDETMBEGA1UEChMK\n"
- + "V2luZG93cyBOVDEbMBkGA1UECxMSRGlzdHJpYnV0ZWQgU3lzdGVtMTMwMQYDVQQD\n"
- + "EypNaWNyb3NvZnQgQ2VydGlmaWNhdGUgU2VydmVyIFRlc3QgR3JvdXAgQ0EwHhcN\n"
- + "OTcxMTI2MDYzNzE4WhcNOTgxMDE0MTgxMTI4WjCBmjEjMCEGCSqGSIb3DQEJARYU\n"
- + "YWxsYW5jQG1pY3Jvc29mdC5jb20xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJXQTEQ\n"
- + "MA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u\n"
- + "MQ0wCwYDVQQLEwREU1lTMRgwFgYDVQQDEw9BbGxhbiBKLiBDb29wZXIwWzANBgkq\n"
- + "hkiG9w0BAQEFAANKADBHAkB1951uZLyJXjSZTc8Z1QnuXvKBAqm2WT4OFaFySF/F\n"
- + "WnMbIlAE0pvszDkKZ+N7hBzcc5pVIjezPfZ8cPh//jVPAgMBAAGjggI5MIICNTAL\n"
- + "BgNVHQ8EBAMCADgwEwYDVR0lBAwwCgYIKwYBBQUHAwQwgc8GA1UdIwSBxzCBxIAU\n"
- + "t4UyEbgWWjom4bdQ2Y501IPyIkWhgZmkgZYwgZMxCzAJBgNVBAYTAlVTMQswCQYD\n"
- + "VQQIEwJXQTEQMA4GA1UEBxMHUmVkbW9uZDETMBEGA1UEChMKV2luZG93cyBOVDEb\n"
- + "MBkGA1UECxMSRGlzdHJpYnV0ZWQgU3lzdGVtMTMwMQYDVQQDEypNaWNyb3NvZnQg\n"
- + "Q2VydGlmaWNhdGUgU2VydmVyIFRlc3QgR3JvdXAgQ0GCEBETYQCqAP6FEdFEueIo\n"
- + "FGMwgb0GA1UdHwSBtTCBsjBWoFSgUoZQaHR0cDovL0NFUlRTUlYvQ2VydFNydi9D\n"
- + "ZXJ0RW5yb2xsL01pY3Jvc29mdCBDZXJ0aWZpY2F0ZSBTZXJ2ZXIgVGVzdCBHcm91\n"
- + "cCBDQS5jcmwwWKBWoFSGUmZpbGU6Ly9cXENFUlRTUlZcQ2VydFNydlxDZXJ0RW5y\n"
- + "b2xsXE1pY3Jvc29mdCBDZXJ0aWZpY2F0ZSBTZXJ2ZXIgVGVzdCBHcm91cCBDQS5j\n"
- + "cmwwCQYDVR0TBAIwADB0BggrBgEFBQcBAQRoMGYwZAYIKwYBBQUHMAKGWGh0dHA6\n"
- + "Ly9DRVJUU1JWL0NlcnRTcnYvQ2VydEVucm9sbC9DRVJUU1JWX01pY3Jvc29mdCBD\n"
- + "ZXJ0aWZpY2F0ZSBTZXJ2ZXIgVGVzdCBHcm91cCBDQS5jcnQwDQYJKoZIhvcNAQEE\n"
- + "BQADQQA1TYsk07tW0dhU6bHPK7NXHUFFiZ2fAtC0epLY9G6yuYb1lozPv5sDnCl1\n"
- + "A2fZPgawvAqCvK9xkv5L4j2F+v4U\n"
- + "-----END CERTIFICATE-----\n",
-
- // CERTIFICATES_ENCODED_X509[8]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIIEYjCCBAygAwIBAgIIFVsHaQAAAlwwDQYJKoZIhvcNAQEEBQAwgZMxCzAJBgNV\n"
- + "BAYTAlVTMQswCQYDVQQIEwJXQTEQMA4GA1UEBxMHUmVkbW9uZDETMBEGA1UEChMK\n"
- + "V2luZG93cyBOVDEbMBkGA1UECxMSRGlzdHJpYnV0ZWQgU3lzdGVtMTMwMQYDVQQD\n"
- + "EypNaWNyb3NvZnQgQ2VydGlmaWNhdGUgU2VydmVyIFRlc3QgR3JvdXAgQ0EwHhcN\n"
- + "OTcxMTI2MDYzOTU4WhcNOTgxMDE0MTgxMTI4WjCBmjEjMCEGCSqGSIb3DQEJARYU\n"
- + "YWxsYW5jQG1pY3Jvc29mdC5jb20xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJXQTEQ\n"
- + "MA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u\n"
- + "MQ0wCwYDVQQLEwREU1lTMRgwFgYDVQQDEw9BbGxhbiBKLiBDb29wZXIwXDANBgkq\n"
- + "hkiG9w0BAQEFAANLADBIAkEA0T1td8kfsJgwm8Qj+jtrq29tqc/DIkIbAPcyygKG\n"
- + "1XEUvzQEQumVQx5lCD2LOOJs0eOuv4h6ngvLW+goDaidNQIDAQABo4ICOTCCAjUw\n"
- + "CwYDVR0PBAQDAgDAMBMGA1UdJQQMMAoGCCsGAQUFBwMIMIHPBgNVHSMEgccwgcSA\n"
- + "FLeFMhG4Flo6JuG3UNmOdNSD8iJFoYGZpIGWMIGTMQswCQYDVQQGEwJVUzELMAkG\n"
- + "A1UECBMCV0ExEDAOBgNVBAcTB1JlZG1vbmQxEzARBgNVBAoTCldpbmRvd3MgTlQx\n"
- + "GzAZBgNVBAsTEkRpc3RyaWJ1dGVkIFN5c3RlbTEzMDEGA1UEAxMqTWljcm9zb2Z0\n"
- + "IENlcnRpZmljYXRlIFNlcnZlciBUZXN0IEdyb3VwIENBghARE2EAqgD+hRHRRLni\n"
- + "KBRjMIG9BgNVHR8EgbUwgbIwVqBUoFKGUGh0dHA6Ly9DRVJUU1JWL0NlcnRTcnYv\n"
- + "Q2VydEVucm9sbC9NaWNyb3NvZnQgQ2VydGlmaWNhdGUgU2VydmVyIFRlc3QgR3Jv\n"
- + "dXAgQ0EuY3JsMFigVqBUhlJmaWxlOi8vXFxDRVJUU1JWXENlcnRTcnZcQ2VydEVu\n"
- + "cm9sbFxNaWNyb3NvZnQgQ2VydGlmaWNhdGUgU2VydmVyIFRlc3QgR3JvdXAgQ0Eu\n"
- + "Y3JsMAkGA1UdEwQCMAAwdAYIKwYBBQUHAQEEaDBmMGQGCCsGAQUFBzAChlhodHRw\n"
- + "Oi8vQ0VSVFNSVi9DZXJ0U3J2L0NlcnRFbnJvbGwvQ0VSVFNSVl9NaWNyb3NvZnQg\n"
- + "Q2VydGlmaWNhdGUgU2VydmVyIFRlc3QgR3JvdXAgQ0EuY3J0MA0GCSqGSIb3DQEB\n"
- + "BAUAA0EAUPXt2pOY3YwRUHzD7Dtgyx5G7KxKtLan1wFBFjhv406v2Utb+2+wTQlS\n"
- + "ulWemcm8eOdG64nspv0oqSJnA8f4xg==\n"
- + "-----END CERTIFICATE-----\n",
-
- // CERTIFICATES_ENCODED_X509[9]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIICiTCCAfICAQAwDQYJKoZIhvcNAQEEBQAwgYwxCzAJBgNVBAYTAlVTMRUwEwYD\n"
- + "VQQIEwxOb3J0aCBEYWtvdGExFDASBgNVBAcTC0dyYW5kIEZvcmtzMRYwFAYDVQQK\n"
- + "Ew1VTkQgQWVyb3NwYWNlMRgwFgYDVQQDFA9yb290QGNzLnVuZC5lZHUxHjAcBgkq\n"
- + "hkiG9w0BCQEWD3Jvb3RAY3MudW5kLmVkdTAeFw05OTAzMDIyMDU4NDRaFw0wOTAy\n"
- + "MjcyMDU4NDRaMIGMMQswCQYDVQQGEwJVUzEVMBMGA1UECBMMTm9ydGggRGFrb3Rh\n"
- + "MRQwEgYDVQQHEwtHcmFuZCBGb3JrczEWMBQGA1UEChMNVU5EIEFlcm9zcGFjZTEY\n"
- + "MBYGA1UEAxQPcm9vdEBjcy51bmQuZWR1MR4wHAYJKoZIhvcNAQkBFg9yb290QGNz\n"
- + "LnVuZC5lZHUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALmlQJg5Nl2VsQZ1\n"
- + "/B8fW4YDdk09SlVc7vyWcbcmbWRBJee0jcH448XdRP/m/MXIRsVKyhLA5f01+VPy\n"
- + "E2aDkx2WiU4DpqbMbGGAytuXBNudJQmBXjWEFiAGe7dYgDNGKK7Yo1k49Q6qGg9q\n"
- + "5did3+ppsyfzbeaiDCH0LO5gegNvAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAJnok\n"
- + "1gvj4KC9HeUX/R4Q/f5tbJ2jLeQATIHtUx9QSKSq7IsdY0zz9EnKOsc9pr8JfBTL\n"
- + "cAwrxqvl5QuoCFVR2tQq8DtBQY8vp7bEF2CZVoxZJXMIKKiD/Hjb0oypbq5wF0SY\n"
- + "xN5DUfG5sShi+vPIAwE62tZ1P1I1N8DQpDYiXkw=\n"
- + "-----END CERTIFICATE-----\n",
-
- // CERTIFICATES_ENCODED_X509[10]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIICWDCCAgICAQAwDQYJKoZIhvcNAQEEBQAwgbYxCzAJBgNVBAYTAlpBMRUwEwYD\n"
- + "VQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsGA1UEChMU\n"
- + "VGhhd3RlIENvbnN1bHRpbmcgY2MxHzAdBgNVBAsTFkNlcnRpZmljYXRpb24gU2Vy\n"
- + "dmljZXMxFzAVBgNVBAMTDnd3dy50aGF3dGUuY29tMSMwIQYJKoZIhvcNAQkBFhR3\n"
- + "ZWJtYXN0ZXJAdGhhd3RlLmNvbTAeFw05NjExMTQxNzE1MjVaFw05NjEyMTQxNzE1\n"
- + "MjVaMIG2MQswCQYDVQQGEwJaQTEVMBMGA1UECBMMV2VzdGVybiBDYXBlMRIwEAYD\n"
- + "VQQHEwlDYXBlIFRvd24xHTAbBgNVBAoTFFRoYXd0ZSBDb25zdWx0aW5nIGNjMR8w\n"
- + "HQYDVQQLExZDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzMRcwFQYDVQQDEw53d3cudGhh\n"
- + "d3RlLmNvbTEjMCEGCSqGSIb3DQEJARYUd2VibWFzdGVyQHRoYXd0ZS5jb20wXDAN\n"
- + "BgkqhkiG9w0BAQEFAANLADBIAkEAmpIl7aR3aSPUUwUrHzpVMrsm3gpI2PzIwMh3\n"
- + "9l1h/RszI0/0qC2WRMlfwm5FapohoyjTJ6ZyGUUenICllKyKZwIDAQABMA0GCSqG\n"
- + "SIb3DQEBBAUAA0EAfI57WLkOKEyQqyCDYZ6reCukVDmAe7nZSbOyKv6KUvTCiQ5c\n"
- + "e5L4y3c/ViKdlou5BcQYAbxA7rwO/vz4m51w4w==\n"
- + "-----END CERTIFICATE-----\n",
-
- // CERTIFICATES_ENCODED_X509[11]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIIDGjCCAtgCBDaRW4swCwYHKoZIzjgEAwUAMHMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdGbG9y\n"
- + "aWRhMRQwEgYDVQQHEwtHYWluZXN2aWxsZTEQMA4GA1UEChMHVW5rbm93bjEQMA4GA1UECxMHVW5r\n"
- + "bm93bjEYMBYGA1UEAxMPUm9iZXJ0IEx5YmFyZ2VyMB4XDTk5MDEwNTAwMjMzOVoXDTk5MDQwNTAw\n"
- + "MjMzOVowczELMAkGA1UEBhMCVVMxEDAOBgNVBAgTB0Zsb3JpZGExFDASBgNVBAcTC0dhaW5lc3Zp\n"
- + "bGxlMRAwDgYDVQQKEwdVbmtub3duMRAwDgYDVQQLEwdVbmtub3duMRgwFgYDVQQDEw9Sb2JlcnQg\n"
- + "THliYXJnZXIwggG3MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11EilS30qcLuzk5/YRt1I870QA\n"
- + "wx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZgt2uZUKWkn5/oBHsQIsJPu6nX\n"
- + "/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/yIgMZndFIAccCFQCXYFCPFSML\n"
- + "zLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o66oL5V0wLPQeCZ1FZV4661FlP\n"
- + "5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7OmdZFuo38L+iE1YvH7YnoBJDvM\n"
- + "pPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhAACgYBMhs/XcF0LAjbuhoAY4EOmxd4U\n"
- + "U0w4nSJQ2vKcgpyHU1Sv/tbUr3xEm6Yyx49j1eNp9jVwM1a6NYX8BO8fCSHIiUVvJVFlCcoO7Qb8\n"
- + "Px7drfbFAFt8mFE1mjYCuj21ePHhs1DlZKJwu2ElC6GaRwtBk3+oCMDAnLuySd0+fAohdDALBgcq\n"
- + "hkjOOAQDBQADLwAwLAIUddbqC3woMcABg/r1GPW9eVNStGwCFCBGySvdXK0i4aLVC4Ptbc3PQFjp\n"
- + "-----END CERTIFICATE-----\n",
-
- //CERTIFICATES_ENCODED_X509[12]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIICyzCCAjQCAQAwDQYJKoZIhvcNAQEEBQAwga0xCzAJBgNVBAYTAlVTMREwDwYD\n"
- + "VQQIEwhOZXcgWW9yazEWMBQGA1UEBxMNTmV3IFlvcmsgQ2l0eTEcMBoGA1UEChMT\n"
- + "Q29sdW1iaWEgVW5pdmVyc2l0eTENMAsGA1UECxMEQWNJUzEfMB0GA1UEAxMWQ29s\n"
- + "dW1iaWEgVW5pdmVyc2l0eSBDQTElMCMGCSqGSIb3DQEJARYWY2VydC1hdXRoQGNv\n"
- + "bHVtYmlhLmVkdTAeFw05NzA0MjgxNDQxMDNaFw0wMDA0MjgxNDQxMDNaMIGtMQsw\n"
- + "CQYDVQQGEwJVUzERMA8GA1UECBMITmV3IFlvcmsxFjAUBgNVBAcTDU5ldyBZb3Jr\n"
- + "IENpdHkxHDAaBgNVBAoTE0NvbHVtYmlhIFVuaXZlcnNpdHkxDTALBgNVBAsTBEFj\n"
- + "SVMxHzAdBgNVBAMTFkNvbHVtYmlhIFVuaXZlcnNpdHkgQ0ExJTAjBgkqhkiG9w0B\n"
- + "CQEWFmNlcnQtYXV0aEBjb2x1bWJpYS5lZHUwgZ8wDQYJKoZIhvcNAQEBBQADgY0A\n"
- + "MIGJAoGBANiod6flzM72CbsK/3gzHzcdjpoozRDD/wgq31jEeDdfKY+ljAwxaZS9\n"
- + "mt7S1g7lL+55fx7FjfJxvJRXvS9UbDU46PDDyJloWYobg84bK5ZcV5UnIPZmGHW/\n"
- + "/xVDUtIGhc4T+Xm5p4F+4AcgewF2s4TbKWxfC98FJfepc31KjkGbAgMBAAEwDQYJ\n"
- + "KoZIhvcNAQEEBQADgYEAI/e6xC+osVM4eMkSUUWgihuocQlRL9ixTlGqW9fvNlI1\n"
- + "q58fELU5bcFko7d02S9Egac/9ckkt/sbHMv9zQhfnvpol8BN+LivGu+09IiOW4yq\n"
- + "c9xT58Pv9gwZ/Ei5VS+FXvzHIr91yWIlwLsnKfgYDrmQowG5FkHSG1ZotUdl7Oo=\n"
- + "-----END CERTIFICATE-----\n",
-
- //CERTIFICATES_ENCODED_X509[13]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIICnjCCAgcCAQMwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAklUMR4wHAYD\n"
- + "VQQKExVQb2xpdGVjbmljbyBkaSBUb3Jpbm8xIzAhBgNVBAsTGklDRS1URUwgSXRh\n"
- + "bGlhbiBDQSBmb3IgV1dXMSAwHgYDVQQDExdDZXJ0aWZpY2F0aW9uIEF1dGhvcml0\n"
- + "eTEqMCgGCSqGSIb3DQEJARYbd3d3LWNhLWl0QGljZS10ZWwucG9saXRvLml0MB4X\n"
- + "DTk2MTAwMjExNDQ0NFoXDTk3MTIwMTExNDQ0NFowgY0xCzAJBgNVBAYTAklUMQ8w\n"
- + "DQYDVQQHEwZUb3Jpbm8xHjAcBgNVBAoTFVBvbGl0ZWNuaWNvIGRpIFRvcmlubzEO\n"
- + "MAwGA1UECxMFQ2VTSVQxGTAXBgNVBAMTEHVsaXNzZS5wb2xpdG8uaXQxIjAgBgkq\n"
- + "hkiG9w0BCQEWE3dlYm1hc3RlckBwb2xpdG8uaXQwgZ8wDQYJKoZIhvcNAQEBBQAD\n"
- + "gY0AMIGJAoGBAMUq/FdrxbSfGtGZq/FTTgC1JqxO4iiHiyxtgRT1oEvJIUjajVRN\n"
- + "dtBVUhW6JmhHje/qnMop09XcF7b89a9ahtG9jM70S03biXVmg66pWOpy6P7znAQj\n"
- + "VFPoCRR7BqUiGq0419a101Acaqkxi/4DdqiTPee4H7mcDZYu+fDPNQaHAgMBAAEw\n"
- + "DQYJKoZIhvcNAQEEBQADgYEAt15bzk0XO+ZM+Q6275VTQIon6KQQHnv9NflIFOoW\n"
- + "fgGRmoyiJFrjU1sIS8ctF03DH2xR20CuKd98fBpKnoOLd7eTKAGzGFPml36TPVj+\n"
- + "YYWdrWqnIzQn6F0OKR/U3Y+ot5fUNuqN36Q1wsVvpPJlOMx8D8OQy8ainHgG3YYA\n"
- + "TJk=\n" + "-----END CERTIFICATE-----\n",
-
- //CERTIFICATES_ENCODED_X509[14]
- "-----BEGIN CERTIFICATE-----\n"
- + "MIIC1TCCAj6gAwIBAgIBBDANBgkqhkiG9w0BAQQFADBZMQswCQYDVQQGEwJVUzEf\n"
- + "MB0GA1UEChMWVW5pdmVyc2l0eSBvZiBDb2xvcmFkbzEWMBQGA1UECxMNU3lzdGVt\n"
- + "IE9mZmljZTERMA8GA1UEAxMIVU1TIENBLTEwHhcNOTgwNTExMjEwMjU0WhcNMDgw\n"
- + "NTEwMjEwMjU0WjBZMQswCQYDVQQGEwJVUzEfMB0GA1UEChMWVW5pdmVyc2l0eSBv\n"
- + "ZiBDb2xvcmFkbzEWMBQGA1UECxMNU3lzdGVtIE9mZmljZTERMA8GA1UEAxMIVU1T\n"
- + "IENBLTEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALGf8Ny+kHlXqLTi3uIf\n"
- + "mkxxwDJd14sOg+hv85pxsqzCRJEgOx5YDUt05hJ7N0s4rJ/gNUcJaKR6ul+qLGbW\n"
- + "+Zb4S1YFbnKaO16zggvgckwpLGYRBbmee9+E47W8VEOZWrJXUkpJ/ZV8GAnesrvn\n"
- + "XTEKfm7bX9s6R7FQfDoHNnQfAgMBAAGjgawwgakwEQYJYIZIAYb4QgEBBAQDAgD2\n"
- + "MB8GA1UdIwQYMBaAFOqlID9Er6dI09n9Lvnby+FISi7oMFQGCWCGSAGG+EIBDQRH\n"
- + "FkVFeHRlbmRlZCBDQSBDZXJ0aWZpY2F0ZSBmcm9tIDI0IE1vbnRocyB0byAxMjAg\n"
- + "TW9udGhzLiAgRFRHID0gMDUxMTE5OTgwHQYDVR0OBBYEFOqlID9Er6dI09n9Lvnb\n"
- + "y+FISi7oMA0GCSqGSIb3DQEBBAUAA4GBAFNFo27JeeIgsMqS7Na//6gJQRilxwVS\n"
- + "Bfx6J43YX47EgNDLn4J7B9Tst+2bDZDAk1lZyu4y2WCLrnfg/e6B1KYBhCt/Srsc\n"
- + "r+WomFcw19k1jBtBaYxVwh/9N4ppZGdKILACciXbxfoLbbNgSDx5+KbE2c2m9is7\n"
- + "MIZgRexTvnJa\n" + "-----END CERTIFICATE-----\n" };
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactorySpiTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactorySpiTest.java
deleted file mode 100644
index 9df2882..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactorySpiTest.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.InputStream;
-import java.security.cert.CRL;
-import java.security.cert.CRLException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactorySpi;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertificateFactorySpi</code> class constructors and methods
- */
-
-public class CertificateFactorySpiTest extends TestCase {
- /**
- * Constructor for CertStoreSpiTest.
- *
- * @param arg0
- */
- public CertificateFactorySpiTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>CertificateFactorySpi</code> constructor
- * Assertion: constructs CertificateFactorySpi
- */
- public void testCertificateFactorySpi01() throws CertificateException,
- CRLException {
- CertificateFactorySpi certFactorySpi = new extCertificateFactorySpi();
- ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
- try {
- certFactorySpi.engineGenerateCertPath(bais);
- fail("UnsupportedOperationException must be thrown");
- } catch (UnsupportedOperationException e) {
- }
- try {
- certFactorySpi.engineGenerateCertPath(bais, "");
- fail("UnsupportedOperationException must be thrown");
- } catch (UnsupportedOperationException e) {
- }
- try {
- List list = null;
- certFactorySpi.engineGenerateCertPath(list);
- fail("UnsupportedOperationException must be thrown");
- } catch (UnsupportedOperationException e) {
- }
- try {
- certFactorySpi.engineGetCertPathEncodings();
- fail("UnsupportedOperationException must be thrown");
- } catch (UnsupportedOperationException e) {
- }
- Certificate cc = certFactorySpi
- .engineGenerateCertificate(bais);
- assertNull("Not null Cerificate", cc);
- try {
- certFactorySpi.engineGenerateCertificate(null);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- Collection col = certFactorySpi
- .engineGenerateCertificates(bais);
- assertNull("Not null Collection", col);
- try {
- certFactorySpi.engineGenerateCertificates(null);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
-
- CRL ccCRL = certFactorySpi.engineGenerateCRL(bais);
- assertNull("Not null CRL", ccCRL);
- try {
- certFactorySpi.engineGenerateCRL(null);
- fail("CRLException must be thrown");
- } catch (CRLException e) {
- }
-
- Collection colCRL = certFactorySpi
- .engineGenerateCRLs(bais);
- assertNull("Not null CRL", colCRL);
- try {
- certFactorySpi.engineGenerateCRLs(null);
- fail("CRLException must be thrown");
- } catch (CRLException e) {
- }
- }
-
- /**
- * Test for <code>CertificateFactorySpi</code> constructor
- * Assertion: constructs CertificateFactorySpi
- */
- public void testCertificateFactorySpi02() throws CertificateException,
- CRLException {
- CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi();
- MyCertificateFactorySpi.putMode(true);
- ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
- DataInputStream dis = new DataInputStream(bais);
- try {
- certFactorySpi.engineGenerateCertPath(bais);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- certFactorySpi.engineGenerateCertPath(dis);
- try {
- certFactorySpi.engineGenerateCertPath(bais, "aa");
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- try {
- certFactorySpi.engineGenerateCertPath(dis, "");
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- certFactorySpi.engineGenerateCertPath(dis, "ss");
-
- try {
- certFactorySpi.engineGenerateCertificate(bais);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- try {
- certFactorySpi.engineGenerateCertificates(null);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- Certificate cert = certFactorySpi
- .engineGenerateCertificate(dis);
- assertNull("Result must be null", cert);
- Collection col = certFactorySpi
- .engineGenerateCertificates(dis);
- assertNull("Result must be null", col);
-
- try {
- certFactorySpi.engineGenerateCRL(bais);
- fail("CRLException must be thrown");
- } catch (CRLException e) {
- }
- try {
- certFactorySpi.engineGenerateCRLs(null);
- fail("CRLException must be thrown");
- } catch (CRLException e) {
- }
- CRL crl = certFactorySpi.engineGenerateCRL(dis);
- assertNull("Result must be null", crl);
- col = certFactorySpi.engineGenerateCRLs(dis);
- assertNull("Result must be null", col);
-
- List list = null;
- try {
- certFactorySpi.engineGenerateCertPath(list);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- Iterator enc = certFactorySpi.engineGetCertPathEncodings();
- assertTrue("Incorrect Iterator", enc.hasNext());
- }
-
- /**
- * Test for <code>CertificateFactorySpi</code> constructor
- * Assertion: constructs CertificateFactorySpi
- */
- public void testCertificateFactorySpi03() throws CertificateException,
- CRLException {
- CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi();
- MyCertificateFactorySpi.putMode(false);
- ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
- DataInputStream dis = new DataInputStream(bais);
- try {
- certFactorySpi.engineGenerateCertPath(bais);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- try {
- certFactorySpi.engineGenerateCertPath(dis);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- try {
- certFactorySpi.engineGenerateCertPath(bais, "aa");
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- certFactorySpi.engineGenerateCertPath(dis, "");
- certFactorySpi.engineGenerateCertPath(dis, "ss");
-
- try {
- certFactorySpi.engineGenerateCertificate(bais);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- try {
- certFactorySpi.engineGenerateCertificates(null);
- fail("CertificateException must be thrown");
- } catch (CertificateException e) {
- }
- Certificate cert = certFactorySpi
- .engineGenerateCertificate(dis);
- assertNull("Result must be null", cert);
- Collection col = certFactorySpi
- .engineGenerateCertificates(dis);
- assertNull("Result must be null", col);
-
- try {
- certFactorySpi.engineGenerateCRL(bais);
- fail("CRLException must be thrown");
- } catch (CRLException e) {
- }
- try {
- certFactorySpi.engineGenerateCRLs(null);
- fail("CRLException must be thrown");
- } catch (CRLException e) {
- }
- CRL crl = certFactorySpi.engineGenerateCRL(dis);
- assertNull("Result must be null", crl);
- col = certFactorySpi.engineGenerateCRLs(dis);
- assertNull("Result must be null", col);
-
- List list = null;
- certFactorySpi.engineGenerateCertPath(list);
- Iterator enc = certFactorySpi.engineGetCertPathEncodings();
- assertFalse("Incorrect Iterator", enc.hasNext());
- }
-
-
- private static class extCertificateFactorySpi extends CertificateFactorySpi {
- public Certificate engineGenerateCertificate(InputStream inStream)
- throws CertificateException {
- if (inStream == null) {
- throw new CertificateException("InputStream null");
- }
- return null;
- }
-
- public Collection engineGenerateCertificates(InputStream inStream)
- throws CertificateException {
- if (inStream == null) {
- throw new CertificateException("InputStream null");
- }
- return null;
- }
-
- public CRL engineGenerateCRL(InputStream inStream) throws CRLException {
- if (inStream == null) {
- throw new CRLException("InputStream null");
- }
- return null;
- }
-
- public Collection engineGenerateCRLs(InputStream inStream)
- throws CRLException {
- if (inStream == null) {
- throw new CRLException("InputStream null");
- }
- return null;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateNotYetValidExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateNotYetValidExceptionTest.java
deleted file mode 100644
index d3e6a70..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateNotYetValidExceptionTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CertificateNotYetValidException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>DigestException</code> class constructors and methods.
- */
-public class CertificateNotYetValidExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertificateNotYetValidExceptionTests.
- *
- * @param arg0
- */
- public CertificateNotYetValidExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertificateNotYetValidException()</code> constructor
- * Assertion: constructs CertificateNotYetValidException with no detail
- * message
- */
- public void testCertificateNotYetValidException01() {
- CertificateNotYetValidException tE = new CertificateNotYetValidException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateNotYetValidException(String)</code>
- * constructor Assertion: constructs CertificateNotYetValidException with
- * detail message msg. Parameter <code>msg</code> is not null.
- */
- public void testCertificateNotYetValidException02() {
- CertificateNotYetValidException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateNotYetValidException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateNotYetValidException(String)</code>
- * constructor Assertion: constructs CertificateNotYetValidException when
- * <code>msg</code> is null
- */
- public void testCertificateNotYetValidException03() {
- String msg = null;
- CertificateNotYetValidException tE = new CertificateNotYetValidException(
- msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateParsingExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateParsingExceptionTest.java
deleted file mode 100644
index e35512f..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateParsingExceptionTest.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CertificateParsingException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>CertificateParsingException</code> class constructors and
- * methods.
- */
-public class CertificateParsingExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertificateParsingExceptionTests.
- *
- * @param arg0
- */
- public CertificateParsingExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertificateParsingException()</code> constructor
- * Assertion: constructs CertificateParsingException with no detail message
- */
- public void testCertificateParsingException01() {
- CertificateParsingException tE = new CertificateParsingException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateParsingException(String)</code> constructor
- * Assertion: constructs CertificateParsingException with detail message
- * msg. Parameter <code>msg</code> is not null.
- */
- public void testCertificateParsingException02() {
- CertificateParsingException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateParsingException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateParsingException(String)</code> constructor
- * Assertion: constructs CertificateParsingException when <code>msg</code>
- * is null
- */
- public void testCertificateParsingException03() {
- String msg = null;
- CertificateParsingException tE = new CertificateParsingException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateParsingException(Throwable)</code>
- * constructor Assertion: constructs CertificateParsingException when
- * <code>cause</code> is null
- */
- public void testCertificateParsingException04() {
- Throwable cause = null;
- CertificateParsingException tE = new CertificateParsingException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateParsingException(Throwable)</code>
- * constructor Assertion: constructs CertificateParsingException when
- * <code>cause</code> is not null
- */
- public void testCertificateParsingException05() {
- CertificateParsingException tE = new CertificateParsingException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CertificateParsingException(String, Throwable)</code>
- * constructor Assertion: constructs CertificateParsingException when
- * <code>cause</code> is null <code>msg</code> is null
- */
- public void testCertificateParsingException06() {
- CertificateParsingException tE = new CertificateParsingException(null,
- null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateParsingException(String, Throwable)</code>
- * constructor Assertion: constructs CertificateParsingException when
- * <code>cause</code> is null <code>msg</code> is not null
- */
- public void testCertificateParsingException07() {
- CertificateParsingException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateParsingException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateParsingException(String, Throwable)</code>
- * constructor Assertion: constructs CertificateParsingException when
- * <code>cause</code> is not null <code>msg</code> is null
- */
- public void testCertificateParsingException08() {
- CertificateParsingException tE = new CertificateParsingException(null,
- tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>CertificateParsingException(String, Throwable)</code>
- * constructor Assertion: constructs CertificateParsingException when
- * <code>cause</code> is not null <code>msg</code> is not null
- */
- public void testCertificateParsingException09() {
- CertificateParsingException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateParsingException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateTest.java
deleted file mode 100644
index 4740a9d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateTest.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.SignatureException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-
-import org.apache.harmony.security.tests.support.cert.MyCertificate;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>Certificate</code> fields and methods
- */
-public class CertificateTest extends TestCase {
- /**
- * Meaningless cert encoding just for testing purposes
- */
- private static final byte[] testEncoding = new byte[] {
- (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5
- };
-
-
- /**
- * Constructor for CertificateTest.
- *
- * @param name
- */
- public CertificateTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test for <code>hashCode()</code> method<br>
- * Assertion: returns hash of the <code>Certificate</code> instance
- */
- public final void testHashCode() {
- Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
- Certificate c2 = new MyCertificate("TEST_TYPE", testEncoding);
-
- assertTrue(c1.hashCode() == c2.hashCode());
- }
-
- /**
- * Test for <code>hashCode()</code> method<br>
- * Assertion: hash code of equal objects should be the same
- */
- public final void testHashCodeEqualsObject() {
- Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
- Certificate c2 = new MyCertificate("TEST_TYPE", testEncoding);
-
- assertTrue((c1.hashCode() == c2.hashCode()) && c1.equals(c2));
- }
-
-
- /**
- * Test for <code>getType()</code> method<br>
- * Assertion: returns this certificate type
- */
- public final void testGetType() {
- Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
- assertEquals("TEST_TYPE", c1.getType());
- }
-
- /**
- * Test #1 for <code>equals(Object)</code> method<br>
- * Assertion: object equals to itself
- */
- public final void testEqualsObject01() {
- Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
- assertTrue(c1.equals(c1));
- }
-
- /**
- * Test for <code>equals(Object)</code> method<br>
- * Assertion: object equals to other <code>Certificate</code>
- * instance with the same state
- */
- public final void testEqualsObject02() {
- Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
- Certificate c2 = new MyCertificate("TEST_TYPE", testEncoding);
- assertTrue(c1.equals(c2) && c2.equals(c1));
- }
-
- /**
- * Test for <code>equals(Object)</code> method<br>
- * Assertion: object not equals to <code>null</code>
- */
- public final void testEqualsObject03() {
- Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
- assertFalse(c1.equals(null));
- }
-
- /**
- * Test for <code>equals(Object)</code> method<br>
- * Assertion: object not equals to other which is not
- * instance of <code>Certificate</code>
- */
- public final void testEqualsObject04() {
- Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
- assertFalse(c1.equals("TEST_TYPE"));
- }
-
- //
- // the following tests just call methods
- // that are abstract in <code>Certificate</code>
- // (So they just like signature tests)
- //
-
- /**
- * This test just calls <code>getEncoded()</code> method<br>
- *
- * @throws CertificateEncodingException
- */
- public final void testGetEncoded() throws CertificateEncodingException {
- Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
- c1.getEncoded();
- }
-
- /**
- * This test just calls <code>verify(PublicKey)</code> method<br>
- *
- * @throws InvalidKeyException
- * @throws CertificateException
- * @throws NoSuchAlgorithmException
- * @throws NoSuchProviderException
- * @throws SignatureException
- */
- public final void testVerifyPublicKey()
- throws InvalidKeyException,
- CertificateException,
- NoSuchAlgorithmException,
- NoSuchProviderException,
- SignatureException {
- Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
- c1.verify(null);
- }
-
- /**
- * This test just calls <code>verify(PublicKey,String)</code> method<br>
- *
- * @throws InvalidKeyException
- * @throws CertificateException
- * @throws NoSuchAlgorithmException
- * @throws NoSuchProviderException
- * @throws SignatureException
- */
- public final void testVerifyPublicKeyString()
- throws InvalidKeyException,
- CertificateException,
- NoSuchAlgorithmException,
- NoSuchProviderException,
- SignatureException {
- Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
- c1.verify(null, null);
- }
-
- /**
- * This test just calls <code>toString()</code> method<br>
- */
- public final void testToString() {
- Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
- c1.toString();
- }
-
- /**
- * This test just calls <code>testGetPublicKey()</code> method<br>
- */
- public final void testGetPublicKey() {
- Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
- c1.getPublicKey();
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CollectionCertStoreParametersTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CollectionCertStoreParametersTest.java
deleted file mode 100644
index e401c77..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CollectionCertStoreParametersTest.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CertStoreParameters;
-import java.security.cert.CollectionCertStoreParameters;
-import java.util.Collection;
-import java.util.Vector;
-
-import org.apache.harmony.security.tests.support.cert.MyCertificate;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CollectionCertStoreParameters</code>
- */
-public class CollectionCertStoreParametersTest extends TestCase {
-
- /**
- * Constructor for CollectionCertStoreParametersTest.
- *
- * @param name
- */
- public CollectionCertStoreParametersTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>CollectionCertStoreParameters()</code> constructor<br>
- * Assertion: Creates an instance of CollectionCertStoreParameters
- * with the default parameter values (an empty and immutable Collection)
- */
- public final void testCollectionCertStoreParameters01() {
- CertStoreParameters cp = new CollectionCertStoreParameters();
- assertTrue("isCollectionCertStoreParameters",
- cp instanceof CollectionCertStoreParameters);
- }
-
- /**
- * Test #2 for <code>CollectionCertStoreParameters</code> constructor<br>
- * Assertion: Creates an instance of CollectionCertStoreParameters
- * with the default parameter values (an empty and immutable Collection)
- */
- public final void testCollectionCertStoreParameters02() {
- CollectionCertStoreParameters cp = new CollectionCertStoreParameters();
- Collection c = cp.getCollection();
- assertTrue("isEmpty", c.isEmpty());
-
- // check that empty collection is immutable
- try {
- // try to modify it
- c.add(new Object());
- fail("empty collection must be immutable");
- } catch (Exception e) {
- }
- }
-
- /**
- * Test #1 for <code>CollectionCertStoreParameters(Collection)</code>
- * constructor<br>
- * Assertion: Creates an instance of CollectionCertStoreParameters
- */
- public final void testCollectionCertStoreParametersCollection01() {
- Vector certificates = new Vector();
- certificates.add(new MyCertificate("TEST", new byte[] { }));
- new CollectionCertStoreParameters(certificates);
- }
-
- /**
- * Test #2 for <code>CollectionCertStoreParameters(Collection)</code>
- * constructor<br>
- * Assertion: If the specified <code>Collection</code> contains an object
- * that is not a <code>Certificate</code> or <code>CRL</code>, that object
- * will be ignored by the Collection <code>CertStore</code>.
- */
- public final void testCollectionCertStoreParametersCollection02() {
- // just check that we able to create CollectionCertStoreParameters
- // object passing Collection containing Object which is not
- // a Certificate or CRL
- Vector certificates = new Vector();
- certificates.add(new String("Not a Certificate"));
- new CollectionCertStoreParameters(certificates);
- }
-
- /**
- * Test #3 for <code>CollectionCertStoreParameters(Collection)</code>
- * constructor<br>
- * Assertion: The Collection is not copied. Instead, a reference is used.
- * This allows the caller to subsequently add or remove Certificates or
- * CRLs from the Collection, thus changing the set of Certificates or CRLs
- * available to the Collection CertStore. The Collection CertStore will
- * not modify the contents of the Collection
- */
- public final void testCollectionCertStoreParametersCollection03() {
- Vector certificates = new Vector();
- // create using empty collection
- CollectionCertStoreParameters cp =
- new CollectionCertStoreParameters(certificates);
- // check that the reference is used
- assertTrue("isRefUsed_1", certificates == cp.getCollection());
- // check that collection still empty
- assertTrue("isEmpty", cp.getCollection().isEmpty());
- // modify our collection
- certificates.add(new MyCertificate("TEST", new byte[] { (byte) 1 }));
- certificates.add(new MyCertificate("TEST", new byte[] { (byte) 2 }));
- // check that internal state has been changed accordingly
- assertTrue("isRefUsed_2", certificates.equals(cp.getCollection()));
- }
-
- /**
- * Test #4 for <code>CollectionCertStoreParameters(Collection)</code>
- * constructor<br>
- * Assertion: <code>NullPointerException</code> - if
- * <code>collection</code> is <code>null</code>
- */
- public final void testCollectionCertStoreParametersCollection04() {
- try {
- new CollectionCertStoreParameters(null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #1 for <code>clone()</code> method<br>
- * Assertion: Returns a copy of this object
- */
- public final void testClone01() {
- Vector certificates = new Vector();
- certificates.add(new MyCertificate("TEST", new byte[] { (byte) 4 }));
- CollectionCertStoreParameters cp1 =
- new CollectionCertStoreParameters(certificates);
- CollectionCertStoreParameters cp2 =
- (CollectionCertStoreParameters) cp1.clone();
- // check that that we have new object
- assertTrue(cp1 != cp2);
- }
-
- /**
- * Test #2 for <code>clone()</code> method<br>
- * Assertion: ...only a reference to the <code>Collection</code>
- * is copied, and not the contents
- */
- public final void testClone02() {
- Vector certificates = new Vector();
- certificates.add(new MyCertificate("TEST", new byte[] { (byte) 4 }));
- CollectionCertStoreParameters cp1 =
- new CollectionCertStoreParameters(certificates);
- CollectionCertStoreParameters cp2 =
- (CollectionCertStoreParameters) cp1.clone();
- // check that both objects hold the same reference
- assertTrue(cp1.getCollection() == cp2.getCollection());
- }
-
- /**
- * Test #3 for <code>clone()</code> method<br>
- * Assertion: ...only a reference to the <code>Collection</code>
- * is copied, and not the contents
- */
- public final void testClone03() {
- CollectionCertStoreParameters cp1 =
- new CollectionCertStoreParameters();
- CollectionCertStoreParameters cp2 =
- (CollectionCertStoreParameters) cp1.clone();
- CollectionCertStoreParameters cp3 =
- (CollectionCertStoreParameters) cp2.clone();
- // check that all objects hold the same reference
- assertTrue(cp1.getCollection() == cp2.getCollection() &&
- cp3.getCollection() == cp2.getCollection());
- }
-
- /**
- * Test #1 for <code>toString()</code> method<br>
- * Assertion: returns the formatted string describing parameters
- */
- public final void testToString01() {
- CollectionCertStoreParameters cp =
- new CollectionCertStoreParameters();
- String s = cp.toString();
- assertNotNull(s);
- }
-
- /**
- * Test #2 for <code>toString()</code> method<br>
- * Assertion: returns the formatted string describing parameters
- */
- public final void testToString02() {
- Vector certificates = new Vector();
- certificates.add(new MyCertificate("TEST", new byte[] { (byte) 4 }));
- CollectionCertStoreParameters cp =
- new CollectionCertStoreParameters(certificates);
-
- assertNotNull(cp.toString());
- }
-
- /**
- * Test #1 for <code>getCollection()</code> method<br>
- * Assertion: returns the Collection (never null)
- */
- public final void testGetCollection01() {
- CollectionCertStoreParameters cp = new CollectionCertStoreParameters();
- assertNotNull(cp.getCollection());
- }
-
- /**
- * Test #2 for <code>getCollection()</code> method<br>
- * Assertion: returns the Collection (never null)
- */
- public final void testGetCollection02() {
- Vector certificates = new Vector();
- CollectionCertStoreParameters cp =
- new CollectionCertStoreParameters(certificates);
- assertNotNull(cp.getCollection());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/LDAPCertStoreParametersTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/LDAPCertStoreParametersTest.java
deleted file mode 100644
index 5499a1a..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/LDAPCertStoreParametersTest.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CertStoreParameters;
-import java.security.cert.LDAPCertStoreParameters;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>java.security.cert.LDAPCertStoreParameters</code>
- * fields and methods
- */
-public class LDAPCertStoreParametersTest extends TestCase {
-
- /**
- * Constructor for LDAPCertStoreParametersTest.
- *
- * @param name
- */
- public LDAPCertStoreParametersTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>LDAPCertStoreParameters()</code> constructor<br>
- * Assertion: Creates an instance of <code>LDAPCertStoreParameters</code>
- * with the default parameter values (server name "localhost", port 389)
- */
- public final void testLDAPCertStoreParameters01() {
- CertStoreParameters cp = new LDAPCertStoreParameters();
- assertTrue("isLDAPCertStoreParameters",
- cp instanceof LDAPCertStoreParameters);
- }
-
- /**
- * Test #2 for <code>LDAPCertStoreParameters()</code> constructor<br>
- * Assertion: Creates an instance of <code>LDAPCertStoreParameters</code>
- * with the default parameter values (server name "localhost", port 389)
- */
- public final void testLDAPCertStoreParameters02() {
- LDAPCertStoreParameters cp = new LDAPCertStoreParameters();
- assertEquals("host", "localhost", cp.getServerName());
- assertEquals("port", 389, cp.getPort());
- }
-
- /**
- * Test #1 for <code>LDAPCertStoreParameters(String)</code> constructor<br>
- * Assertion: Creates an instance of <code>LDAPCertStoreParameters</code>
- * with the specified server name and a default port of 389
- */
- public final void testLDAPCertStoreParametersString01() {
- CertStoreParameters cp = new LDAPCertStoreParameters("myhost");
- assertTrue("isLDAPCertStoreParameters",
- cp instanceof LDAPCertStoreParameters);
- }
-
- /**
- * Test #2 for <code>LDAPCertStoreParameters(String)</code> constructor<br>
- * Assertion: Creates an instance of <code>LDAPCertStoreParameters</code>
- * with the specified server name and a default port of 389
- */
- public final void testLDAPCertStoreParametersString02() {
- String serverName = "myhost";
- LDAPCertStoreParameters cp = new LDAPCertStoreParameters(serverName);
- assertTrue("host", serverName.equals(cp.getServerName()));
- assertEquals("port", 389, cp.getPort());
- }
-
- /**
- * Test #3 for <code>LDAPCertStoreParameters(String)</code> constructor<br>
- * Assertion: throws <code>NullPointerException</code> -
- * if <code>serverName</code> is <code>null</code>
- */
- public final void testLDAPCertStoreParametersString03() {
- try {
- new LDAPCertStoreParameters(null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #1 for <code>LDAPCertStoreParameters(String, int)</code> constructor<br>
- * Assertion: Creates an instance of <code>LDAPCertStoreParameters</code>
- * with the specified parameter values
- */
- public final void testLDAPCertStoreParametersStringint01() {
- CertStoreParameters cp = new LDAPCertStoreParameters("myhost", 1098);
- assertTrue("isLDAPCertStoreParameters",
- cp instanceof LDAPCertStoreParameters);
- }
-
- /**
- * Test #2 for <code>LDAPCertStoreParameters(String, int)</code> constructor<br>
- * Assertion: Creates an instance of <code>LDAPCertStoreParameters</code>
- * with the specified parameter values
- */
- public final void testLDAPCertStoreParametersStringint02() {
- String serverName = "myhost";
- int portNumber = 1099;
- LDAPCertStoreParameters cp =
- new LDAPCertStoreParameters(serverName, portNumber);
- assertTrue("host", serverName.equals(cp.getServerName()));
- assertTrue("port", cp.getPort() == portNumber);
- }
-
- /**
- * Test #3 for <code>LDAPCertStoreParameters(String, int)</code> constructor<br>
- * Assertion: throws <code>NullPointerException</code> -
- * if <code>serverName</code> is <code>null</code>
- */
- public final void testLDAPCertStoreParametersStringint03() {
- try {
- new LDAPCertStoreParameters(null, 0);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test for <code>clone()</code> method<br>
- * Assertion: Returns a copy of this object
- */
- public final void testClone() {
- LDAPCertStoreParameters cp1 =
- new LDAPCertStoreParameters("myhost", 1100);
- LDAPCertStoreParameters cp2 = (LDAPCertStoreParameters) cp1.clone();
- // check that that we have new object
- assertTrue("newObject", cp1 != cp2);
- assertTrue("hostsTheSame",
- cp1.getServerName().equals(cp2.getServerName()));
- assertTrue("portsTheSame", cp1.getPort() == cp2.getPort());
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * Assertion: returns the formatted string describing parameters
- */
- public final void testToString() {
- LDAPCertStoreParameters cp1 =
- new LDAPCertStoreParameters("myhost", 1101);
-
- assertNotNull(cp1.toString());
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * Assertion: returns the port number
- */
- public final void testGetPort() {
- int portNumber = -1099;
- LDAPCertStoreParameters cp =
- new LDAPCertStoreParameters("serverName", portNumber);
- assertTrue(cp.getPort() == portNumber);
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * Assertion: returns the server name (never <code>null</code>)
- */
- public final void testGetServerName() {
- LDAPCertStoreParameters cp =
- new LDAPCertStoreParameters("serverName");
- assertNotNull(cp.getServerName());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParametersTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParametersTest.java
deleted file mode 100644
index da46778..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParametersTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.cert.PKIXBuilderParameters;
-import java.security.cert.PKIXParameters;
-import java.security.cert.X509CertSelector;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>PKIXBuilderParameters</code> fields and methods
- */
-public class PKIXBuilderParametersTest extends TestCase {
- private static final int DEFAULT_MAX_PATH_LEN = 5;
-
- /**
- * Constructor for PKIXBuilderParametersTest.
- *
- * @param name
- */
- public PKIXBuilderParametersTest(String name) {
- super(name);
- }
-
- /**
- * Test #1 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
- * constructor<br>
- * Assertion: creates an instance of <code>PKIXBuilderParameters</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testPKIXBuilderParametersSetCertSelector01()
- throws InvalidAlgorithmParameterException {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
- // both parameters are valid and non-null
- PKIXParameters p =
- new PKIXBuilderParameters(taSet, new X509CertSelector());
- assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
- assertNotNull("certSelector", p.getTargetCertConstraints());
- }
-
- /**
- * Test #2 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
- * constructor<br>
- * Assertion: creates an instance of <code>PKIXBuilderParameters</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testPKIXBuilderParametersSetCertSelector02()
- throws InvalidAlgorithmParameterException {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
- // both parameters are valid but CertSelector is null
- PKIXParameters p = new PKIXBuilderParameters(taSet, null);
- assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
- assertNull("certSelector", p.getTargetCertConstraints());
- }
-
- /**
- * Test #3 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
- * constructor<br>
- * Assertion: ... the <code>Set</code> is copied to protect against
- * subsequent modifications
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testPKIXBuilderParametersSetCertSelector03()
- throws InvalidAlgorithmParameterException {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
- HashSet originalSet = (HashSet) taSet;
- HashSet originalSetCopy = (HashSet) originalSet.clone();
- // create test object using originalSet
- PKIXBuilderParameters pp =
- new PKIXBuilderParameters(originalSetCopy, null);
- // modify originalSet
- originalSetCopy.clear();
- // check that test object's internal state
- // has not been affected by the above modification
- Set returnedSet = pp.getTrustAnchors();
- assertEquals(originalSet, returnedSet);
- }
-
- /**
- * Test #4 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
- * constructor<br>
- * Assertion: <code>NullPointerException</code> -
- * if the specified <code>Set</code> is null
- */
- public final void testPKIXBuilderParametersSetCertSelector04() throws Exception {
- try {
- // pass null
- new PKIXBuilderParameters((Set) null, null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #5 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
- * constructor<br>
- * Assertion: <code>InvalidAlgorithmParameterException</code> -
- * if the specified <code>Set</code> is empty
- * (<code>trustAnchors.isEmpty() == true</code>)
- */
- public final void testPKIXBuilderParametersSetCertSelector05() {
- try {
- // use empty set
- new PKIXBuilderParameters(new HashSet(), null);
- fail("InvalidAlgorithmParameterException expected");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- /**
- * Test #6 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
- * constructor<br>
- * Assertion: <code>ClassCastException</code> -
- * if any of the elements in the <code>Set</code> are not of type
- * <code>java.security.cert.TrustAnchor</code>
- */
- public final void testPKIXBuilderParametersSetCertSelector06() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- // add wrong object to valid set
- assertTrue(taSet.add(new Object()));
-
- try {
- new PKIXBuilderParameters(taSet, null);
- fail("ClassCastException expected");
- } catch (ClassCastException e) {
- }
- }
-
- /**
- * Test #4 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
- * constructor<br>
- * Assertion: <code>NullPointerException</code> -
- * if the <code>keystore</code> is <code>null</code>
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector04() throws Exception {
- try {
- // pass null
- new PKIXBuilderParameters((KeyStore) null, null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java
deleted file mode 100644
index 5ea699c..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.PublicKey;
-import java.security.cert.CertPath;
-import java.security.cert.CertPathBuilderResult;
-import java.security.cert.PKIXCertPathBuilderResult;
-import java.security.cert.TrustAnchor;
-import java.security.spec.InvalidKeySpecException;
-
-import org.apache.harmony.security.tests.support.cert.MyCertPath;
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>PKIXCertPathBuilderResult</code>
- */
-public class PKIXCertPathBuilderResultTest extends TestCase {
- /**
- * Cert path encoding stub
- */
- private static final byte[] testEncoding = new byte[] {
- (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5
- };
-
- /**
- * PublicKey stub
- */
- private static PublicKey testPublicKey = new PublicKey() {
- public String getAlgorithm() {
- return "NeverMind";
- }
-
- public String getFormat() {
- return "NeverMind";
- }
-
- public byte[] getEncoded() {
- return new byte[] { };
- }
- };
-
-
- /**
- * Constructor for PKIXCertPathBuilderResultTest.
- *
- * @param name
- */
- public PKIXCertPathBuilderResultTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: Creates an instance of <code>PKIXCertPathBuilderResult</code>
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testPKIXCertPathBuilderResult01()
- throws InvalidKeySpecException,
- NoSuchAlgorithmException {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
- CertPathBuilderResult r =
- new PKIXCertPathBuilderResult(
- new MyCertPath(testEncoding),
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
- assertTrue(r instanceof PKIXCertPathBuilderResult);
- }
-
- /**
- * Test #2 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: policy tree parameter may be <code>null</code>
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testPKIXCertPathBuilderResult02()
- throws InvalidKeySpecException,
- NoSuchAlgorithmException {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
- CertPathBuilderResult r =
- new PKIXCertPathBuilderResult(
- new MyCertPath(testEncoding),
- ta,
- null,
- testPublicKey);
- assertTrue(r instanceof PKIXCertPathBuilderResult);
- }
-
- /**
- * Test #3 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: <code>NullPointerException</code>
- * if certPath is <code>null</code>
- */
- public final void testPKIXCertPathBuilderResult03() {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- try {
- // pass null
- new PKIXCertPathBuilderResult(
- null,
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #4 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: <code>NullPointerException</code>
- * if trustAnchor is <code>null</code>
- */
- public final void testPKIXCertPathBuilderResult04() {
- try {
- // pass null
- new PKIXCertPathBuilderResult(
- new MyCertPath(testEncoding),
- null,
- TestUtils.getPolicyTree(),
- testPublicKey);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #5 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: <code>NullPointerException</code>
- * if publicKey is <code>null</code>
- */
- public final void testPKIXCertPathBuilderResult05() {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- try {
- // pass null
- new PKIXCertPathBuilderResult(
- new MyCertPath(testEncoding),
- ta,
- TestUtils.getPolicyTree(),
- null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- public final void test_clone() {
-
- // Regression for HARMONY-2786.
- TrustAnchor ta = TestUtils.getTrustAnchor();
- assertNotNull(getName()
- + ": not performed (could not create test TrustAnchor)", ta);
-
- PKIXCertPathBuilderResult init = new PKIXCertPathBuilderResult(
- new MyCertPath(testEncoding), ta, TestUtils.getPolicyTree(),
- testPublicKey);
-
- PKIXCertPathBuilderResult clone = (PKIXCertPathBuilderResult) init
- .clone();
- assertSame(init.getCertPath(), clone.getCertPath());
- assertSame(init.getPolicyTree(), clone.getPolicyTree());
- assertSame(init.getPublicKey(), clone.getPublicKey());
- assertSame(init.getTrustAnchor(), clone.getTrustAnchor());
- }
-
- /**
- * Test for <code>getCertPath()</code> method<br>
- * Assertion: the built and validated <code>CertPath</code>
- * (never <code>null</code>)
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testGetCertPath() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- CertPath cp = new MyCertPath(testEncoding);
- CertPathBuilderResult r =
- new PKIXCertPathBuilderResult(
- cp,
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
-
- // must return the same reference
- // as passed to the constructor
- assertSame(cp, r.getCertPath());
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * Assertion: the printable representation of this object
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testToString()
- throws InvalidKeySpecException,
- NoSuchAlgorithmException {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
- CertPathBuilderResult r =
- new PKIXCertPathBuilderResult(
- new MyCertPath(testEncoding),
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
-
- assertNotNull(r.toString());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathCheckerTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathCheckerTest.java
deleted file mode 100644
index e0ec291..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathCheckerTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.cert.CertPathValidatorException;
-import java.security.cert.PKIXCertPathChecker;
-import java.util.HashSet;
-
-import org.apache.harmony.security.tests.support.cert.MyCertificate;
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>PKIXCertPathChecker</code>
- */
-public class PKIXCertPathCheckerTest extends TestCase {
-
- /**
- * Constructor for PKIXCertPathCheckerTest.
- *
- * @param name
- */
- public PKIXCertPathCheckerTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- public final void testClone() {
- PKIXCertPathChecker pc1 = TestUtils.getTestCertPathChecker();
- PKIXCertPathChecker pc2 = (PKIXCertPathChecker) pc1.clone();
- assertNotSame("notSame", pc1, pc2);
- }
-
- //
- // the following tests just call methods
- // that are abstract in <code>PKIXCertPathChecker</code>
- // (So they just like signature tests)
- //
-
- public final void testIsForwardCheckingSupported() {
- PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
- pc.isForwardCheckingSupported();
- }
-
- public final void testInit()
- throws CertPathValidatorException {
- PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
- pc.init(true);
- }
-
- public final void testGetSupportedExtensions() {
- PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
- pc.getSupportedExtensions();
- }
-
- public final void testCheck()
- throws CertPathValidatorException {
- PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
- pc.check(new MyCertificate("", null), new HashSet());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java
deleted file mode 100644
index c2b2484..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.PublicKey;
-import java.security.cert.PKIXCertPathValidatorResult;
-import java.security.cert.PolicyNode;
-import java.security.cert.TrustAnchor;
-import java.security.spec.InvalidKeySpecException;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-/**
- * Tests for <code>PKIXCertPathValidatorResult</code>
- */
-public class PKIXCertPathValidatorResultTest extends TestCase {
- /**
- * PublicKey stub
- */
- private static PublicKey testPublicKey = new PublicKey() {
- public String getAlgorithm() {
- return "NeverMind";
- }
-
- public String getFormat() {
- return "NeverMind";
- }
-
- public byte[] getEncoded() {
- return new byte[] { };
- }
- };
-
- /**
- * Constructor for PKIXCertPathValidatorResultTest.
- *
- * @param name
- */
- public PKIXCertPathValidatorResultTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>PKIXCertPathValidatorResult(TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: creates an instance of
- * <code>PKIXCertPathValidatorResult</code>
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testPKIXCertPathValidatorResult01()
- throws InvalidKeySpecException,
- NoSuchAlgorithmException {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
- new PKIXCertPathValidatorResult(
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
- }
-
- /**
- * Test #2 for <code>PKIXCertPathValidatorResult(TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: <code>NullPointerException</code> if
- * <code>TrustAnchor</code> parameter is <code>null</code>
- */
- public final void testPKIXCertPathValidatorResult02() {
- try {
- // pass null
- new PKIXCertPathValidatorResult(
- null,
- TestUtils.getPolicyTree(),
- testPublicKey);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #3 for <code>PKIXCertPathValidatorResult(TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: <code>NullPointerException</code> if
- * <code>PublicKey</code> parameter is <code>null</code>
- */
- public final void testPKIXCertPathValidatorResult03() {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
- try {
- // pass null
- new PKIXCertPathValidatorResult(
- ta,
- TestUtils.getPolicyTree(),
- null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #4 for <code>PKIXCertPathValidatorResult(TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: <code>PolicyNode</code>can be <code>null</code>
- */
- public final void testPKIXCertPathValidatorResult04() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- new PKIXCertPathValidatorResult(
- ta,
- null,
- testPublicKey);
- }
-
- /**
- * Test for <code>getTrustAnchor()</code> method<br>
- * Assertion: returns <code>TrustAnchor</code> (never <code>null</code>)
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testGetTrustAnchor() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- PKIXCertPathValidatorResult vr =
- new PKIXCertPathValidatorResult(
- ta,
- null,
- testPublicKey);
-
- // must return the same reference passed
- // as a parameter to the constructor
- assertSame(ta, vr.getTrustAnchor());
- }
-
- /**
- * Test for <code>getPublicKey()</code> method<br>
- * Assertion: returns the subject's public key (never <code>null</code>)
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testGetPublicKey() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- PublicKey pk = testPublicKey;
- PKIXCertPathValidatorResult vr =
- new PKIXCertPathValidatorResult(
- ta,
- null,
- pk);
-
- // must return the same reference passed
- // as a parameter to the constructor
- assertSame(pk, vr.getPublicKey());
- }
-
- /**
- * Test for <code>getPolicyTree()</code> method<br>
- * Assertion: returns the root node of the valid
- * policy tree or <code>null</code> if there are
- * no valid policies
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testGetPolicyTree01() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- // valid policy tree case;
- PolicyNode pn = TestUtils.getPolicyTree();
- PKIXCertPathValidatorResult vr =
- new PKIXCertPathValidatorResult(
- ta,
- pn,
- testPublicKey);
-
- // must return the same reference passed
- // as a parameter to the constructor
- assertSame(pn, vr.getPolicyTree());
- }
-
- /**
- * Test for <code>getPolicyTree()</code> method<br>
- * Assertion: returns the root node of the valid
- * policy tree or <code>null</code> if there are
- * no valid policies
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testGetPolicyTree02() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- // no valid policy tree case (null)
- PKIXCertPathValidatorResult vr =
- new PKIXCertPathValidatorResult(
- ta,
- null,
- testPublicKey);
-
- // must return the same reference passed
- // as a parameter to the constructor
- assertNull(vr.getPolicyTree());
- }
-
- /**
- * Test for <code>clone()</code> method<br>
- * Assertion: returns a copy of this object
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testClone() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- PKIXCertPathValidatorResult vr1 =
- new PKIXCertPathValidatorResult(
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
-
- PKIXCertPathValidatorResult vr2 =
- (PKIXCertPathValidatorResult) vr1.clone();
-
- // check that method makes shallow copy
- assertNotSame("notSame", vr1, vr2);
- assertSame("trustAncor", vr1.getTrustAnchor(), vr2.getTrustAnchor());
- assertSame("policyTree", vr1.getPolicyTree(), vr2.getPolicyTree());
- assertSame("publicKey", vr1.getPublicKey(), vr2.getPublicKey());
-
- // Regression for HARMONY-2786.
- byte[] encoding = { 0x01 };
- MyPKIXCertPathBuilderResult my = new MyPKIXCertPathBuilderResult(ta,
- TestUtils.getPolicyTree(), testPublicKey, encoding);
- MyPKIXCertPathBuilderResult myClone = (MyPKIXCertPathBuilderResult) my
- .clone();
- assertSame(my.getPolicyTree(), myClone.getPolicyTree());
- assertSame(my.getPublicKey(), myClone.getPublicKey());
- assertSame(my.getTrustAnchor(), myClone.getTrustAnchor());
- assertSame(my.enc, myClone.enc);
- }
-
- class MyPKIXCertPathBuilderResult extends PKIXCertPathValidatorResult {
-
- public byte[] enc; // byte array is cloneable
-
- public MyPKIXCertPathBuilderResult(TrustAnchor trustAnchor,
- PolicyNode policyTree, PublicKey subjectPublicKey, byte[] enc) {
- super(trustAnchor, policyTree, subjectPublicKey);
-
- this.enc = enc;
- }
- }
-
- /**
- * Test #1 for <code>toString()</code> method<br>
- * Assertion: Returns a formatted string describing this object
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testToString01() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- PKIXCertPathValidatorResult vr =
- new PKIXCertPathValidatorResult(
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
-
- assertNotNull(vr.toString());
- }
-
- /**
- * Test #2 for <code>toString()</code> method<br>
- * Assertion: Returns a formatted string describing this object
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testToString02() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- PKIXCertPathValidatorResult vr =
- new PKIXCertPathValidatorResult(
- ta,
- null,
- testPublicKey);
-
- assertNotNull(vr.toString());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXParametersTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXParametersTest.java
deleted file mode 100644
index a944802..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXParametersTest.java
+++ /dev/null
@@ -1,1359 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertPathParameters;
-import java.security.cert.CertPathValidatorException;
-import java.security.cert.CertStore;
-import java.security.cert.CollectionCertStoreParameters;
-import java.security.cert.PKIXCertPathChecker;
-import java.security.cert.PKIXParameters;
-import java.security.cert.X509CertSelector;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>PKIXParameters</code> fields and methods
- */
-public class PKIXParametersTest extends TestCase {
- /**
- * Some valid issuer name
- */
- private final static String testIssuer =
- "CN=VM,OU=DRL Security,O=Intel,L=Novosibirsk,ST=NSO,C=RU";
-
- /**
- * Constructor for PKIXParametersTest.
- *
- * @param name
- */
- public PKIXParametersTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>PKIXParameters(Set)</code> constructor<br>
- * Assertion: Creates an instance of <code>PKIXParameters</code> with the
- * specified <code>Set</code> of most-trusted CAs. Each element of the set
- * is a <code>TrustAnchor</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testPKIXParametersSet01()
- throws InvalidAlgorithmParameterException {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
- // use valid parameter
- CertPathParameters cpp = new PKIXParameters(taSet);
- assertTrue(cpp instanceof PKIXParameters);
- }
-
- /**
- * Test #2 for <code>PKIXParameters(Set)</code> constructor<br>
- * Assertion: ... the <code>Set</code> is copied to protect against
- * subsequent modifications
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testPKIXParametersSet02()
- throws InvalidAlgorithmParameterException {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
- HashSet originalSet = (HashSet) taSet;
- HashSet originalSetCopy = (HashSet) originalSet.clone();
- // create test object using originalSet
- PKIXParameters pp = new PKIXParameters(originalSetCopy);
- // modify originalSet
- originalSetCopy.clear();
- // check that test object's internal state
- // has not been affected by the above modification
- Set returnedSet = pp.getTrustAnchors();
- assertEquals(originalSet, returnedSet);
- }
-
- /**
- * Test #3 for <code>PKIXParameters(Set)</code> constructor<br>
- * Assertion: <code>NullPointerException</code> -
- * if the specified <code>Set</code> is null
- */
- public final void testPKIXParametersSet03() throws Exception {
- try {
- // pass null
- new PKIXParameters((Set) null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #4 for <code>PKIXParameters(Set)</code> constructor<br>
- * Assertion: <code>InvalidAlgorithmParameterException</code> -
- * if the specified <code>Set</code> is empty
- * (<code>trustAnchors.isEmpty() == true</code>)
- */
- public final void testPKIXParametersSet04() {
- try {
- // use empty set
- new PKIXParameters(new HashSet());
- fail("InvalidAlgorithmParameterException expected");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- /**
- * Test #5 for <code>PKIXParameters(Set)</code> constructor<br>
- * Assertion: <code>ClassCastException</code> -
- * if any of the elements in the <code>Set</code> are not of type
- * <code>java.security.cert.TrustAnchor</code>
- */
- public final void testPKIXParametersSet05() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- // add wrong object to valid set
- assertTrue(taSet.add(new Object()));
- try {
- new PKIXParameters(taSet);
- fail("ClassCastException expected");
- } catch (ClassCastException e) {
- }
- }
-
- /**
- * Test #3 for <code>PKIXParameters(KeyStore)</code> constructor<br>
- * Assertion: <code>NullPointerException</code> -
- * if the <code>keystore</code> is <code>null</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws KeyStoreException
- */
- public final void testPKIXParametersKeyStore03() throws Exception {
- try {
- // pass null
- new PKIXParameters((KeyStore) null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #1 for <code>getPolicyQualifiersRejected()</code> method<br>
- * Assertion: When a <code>PKIXParameters</code> object is created,
- * this flag is set to <code>true</code><br>
- * Assertion: returns the current value of the PolicyQualifiersRejected flag
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetPolicyQualifiersRejected() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- assertTrue(p.getPolicyQualifiersRejected());
- }
-
- /**
- * Test for <code>setPolicyQualifiersRejected()</code> method<br>
- * Assertion: set the new value of the
- * <code>PolicyQualifiersRejected</code> flag
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetPolicyQualifiersRejected() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- p.setPolicyQualifiersRejected(false);
- assertFalse("setFalse", p.getPolicyQualifiersRejected());
- p.setPolicyQualifiersRejected(true);
- assertTrue("setTrue", p.getPolicyQualifiersRejected());
- }
-
- /**
- * Test for <code>isAnyPolicyInhibited()</code> method<br>
- * Assertion: returns <code>true</code> if the any policy
- * OID is inhibited, <code>false</code> otherwise<br>
- * Assertion: By default, the any policy OID is not inhibited
- * (<code>isAnyPolicyInhibited()</code> returns false).
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testIsAnyPolicyInhibited() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- assertFalse(p.isAnyPolicyInhibited());
- }
-
- /**
- * Test for <code>setAnyPolicyInhibited()</code> method<br>
- * Assertion: sets state to determine if the any policy OID
- * should be processed if it is included in a certificate
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetAnyPolicyInhibited() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- p.setAnyPolicyInhibited(true);
- assertTrue("setTrue", p.isAnyPolicyInhibited());
- p.setAnyPolicyInhibited(false);
- assertFalse("setFalse", p.isAnyPolicyInhibited());
- }
-
- /**
- * Test for <code>isExplicitPolicyRequired()</code> method<br>
- * Assertion: returns <code>true</code> if explicit policy is required,
- * <code>false</code> otherwise<br>
- * Assertion: by default, the ExplicitPolicyRequired flag is false
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testIsExplicitPolicyRequired() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- assertFalse(p.isExplicitPolicyRequired());
- }
-
- /**
- * Test for <code>setExplicitPolicyRequired()</code> method<br>
- * Assertion: sets the ExplicitPolicyRequired flag
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetExplicitPolicyRequired() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- p.setExplicitPolicyRequired(true);
- assertTrue("setTrue", p.isExplicitPolicyRequired());
- p.setExplicitPolicyRequired(false);
- assertFalse("setFalse", p.isExplicitPolicyRequired());
- }
-
- /**
- * Test for <code>isPolicyMappingInhibited()</code> method<br>
- * Assertion: returns true if policy mapping is inhibited, false otherwise
- * Assertion: by default, policy mapping is not inhibited (the flag is false)
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testIsPolicyMappingInhibited() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- assertFalse(p.isPolicyMappingInhibited());
- }
-
- /**
- * Test for <code>setPolicyMappingInhibited()</code> method<br>
- * Assertion: sets the PolicyMappingInhibited flag
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetPolicyMappingInhibited() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- p.setPolicyMappingInhibited(true);
- assertTrue("setTrue", p.isPolicyMappingInhibited());
- p.setPolicyMappingInhibited(false);
- assertFalse("setFalse", p.isPolicyMappingInhibited());
- }
-
- /**
- * Test for <code>isPolicyMappingInhibited()</code> method<br>
- * Assertion: returns the current value of the RevocationEnabled flag
- * Assertion: when a <code>PKIXParameters</code> object is created,
- * this flag is set to true
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testIsRevocationEnabled() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- assertTrue(p.isRevocationEnabled());
- }
-
- /**
- * Test for <code>isPolicyMappingInhibited()</code> method<br>
- * Assertion: sets the RevocationEnabled flag
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetRevocationEnabled() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- p.setRevocationEnabled(false);
- assertFalse("setFalse", p.isRevocationEnabled());
- p.setRevocationEnabled(true);
- assertTrue("setTrue", p.isRevocationEnabled());
- }
-
- /**
- * Test for <code>getSigProvider()</code> method<br>
- * Assertion: returns the signature provider's name,
- * or null if not set
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetSigProvider() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- assertNull("not set", p.getSigProvider());
- p.setSigProvider("Some Provider");
- assertNotNull("set", p.getSigProvider());
- }
-
- /**
- * Test for <code>setSigProvider(String)</code> method<br>
- * Assertion: sets the signature provider's name
- */
- public final void testSetSigProvider() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- String sigProviderName = "Some Provider";
- p.setSigProvider(sigProviderName);
- assertTrue("set", sigProviderName.equals(p.getSigProvider()));
- p.setSigProvider(null);
- assertNull("unset", p.getSigProvider());
- }
-
- /**
- * Test #1 for <code>getTargetCertConstraints()</code> method<br>
- * Assertion: returns a <code>CertSelector</code> specifying
- * the constraints on the target certificate (or <code>null</code>)
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetTargetCertConstraints01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- assertNull(p.getTargetCertConstraints());
- }
-
- /**
- * Test #2 for <code>getTargetCertConstraints()</code> method<br>
- * Assertion: note that the <code>CertSelector</code> returned
- * is cloned to protect against subsequent modifications
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws IOException
- */
- public final void testGetTargetCertConstraints02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- X509CertSelector x509cs = new X509CertSelector();
- PKIXParameters p = new PKIXParameters(taSet);
- p.setTargetCertConstraints(x509cs);
- // get cert selector
- X509CertSelector cs1 = (X509CertSelector) p.getTargetCertConstraints();
- // modify returned selector
- cs1.setIssuer(testIssuer);
- // get cert selector again
- X509CertSelector cs2 = (X509CertSelector) p.getTargetCertConstraints();
- // check that selector is not the same
- assertNotSame("notTheSame", cs1, cs2);
- // check that selector's internal state has
- // not been changed by above modification
- assertFalse("stateNotChanged", testIssuer.equals(cs2.getIssuerAsString()));
- }
-
- /**
- * Test for <code>setTargetCertConstraints(CertSelector)</code> method<br>
- * Assertion: sets the required constraints on the target certificate.
- * The constraints are specified as an instance of CertSelector<br>
- * Assertion: ... If <code>null</code>, no constraints are defined
- *
- * @throws IOException
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetTargetCertConstraints01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- X509CertSelector x509cs = new X509CertSelector();
- x509cs.setIssuer(testIssuer);
- PKIXParameters p = new PKIXParameters(taSet);
- p.setTargetCertConstraints(x509cs);
- assertEquals("set",
- testIssuer,
- ((X509CertSelector) p.getTargetCertConstraints()).getIssuerAsString());
- p.setTargetCertConstraints(null);
- assertNull("unset", p.getTargetCertConstraints());
- }
-
- /**
- * Test #2 for <code>setTargetCertConstraints(CertSelector)</code> method<br>
- * Assertion: ... the CertSelector specified is cloned to protect against
- * subsequent modifications
- *
- * @throws IOException
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetTargetCertConstraints02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- X509CertSelector x509cs = new X509CertSelector();
- PKIXParameters p = new PKIXParameters(taSet);
- p.setTargetCertConstraints(x509cs);
- // modify selector
- x509cs.setIssuer(testIssuer);
- // get selector
- X509CertSelector x509cs1 = (X509CertSelector) p.getTargetCertConstraints();
- // check that selector's internal state has
- // not been changed by above modification
- assertFalse(testIssuer.equals(x509cs1.getIssuerAsString()));
- }
-
- /**
- * Test #1 for <code>getCertStores()</code> method<br>
- * Assertion: list ... (may be empty, but never <code>null</code>)
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetCertStores01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- assertNotNull("notNull", p.getCertStores());
- assertTrue("isEmpty", p.getCertStores().isEmpty());
- }
-
- /**
- * Test #2 for <code>getCertStores()</code> method<br>
- * Assertion: returns an immutable <code>List</code>
- * of <code>CertStores</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetCertStores02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- List cs = p.getCertStores();
-
- try {
- // try to modify returned list
- cs.add(new Object());
- fail("must be immutable");
- } catch (Exception e) {
- }
- }
-
- /**
- * Test #1 for <code>setCertStores(List)</code> method<br>
- * Assertion: Sets the list of CertStores ...
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetCertStores01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- p.setCertStores(TestUtils.getCollectionCertStoresList());
- // check that list has been set
- assertFalse(p.getCertStores().isEmpty());
- }
-
- /**
- * Test #2 for <code>setCertStores(List)</code> method<br>
- * Assertion: list ... may be <code>null</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetCertStores02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- // add null
- p.setCertStores(null);
- // check that we have non null empty list now
- assertNotNull("notNull1", p.getCertStores());
- assertTrue("isEmpty1", p.getCertStores().isEmpty());
- // add empty
- p.setCertStores(new ArrayList());
- assertNotNull("notNull2", p.getCertStores());
- assertTrue("isEmpty2", p.getCertStores().isEmpty());
- }
-
- /**
- * Test #3 for <code>setCertStores(List)</code> method<br>
- * Assertion: list is copied to protect against subsequent modifications
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetCertStores03() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- List l = TestUtils.getCollectionCertStoresList();
- p.setCertStores(l);
- // modify list just set
- l.clear();
- // check that list maintained internally has
- // not been changed by the above modification
- assertFalse(p.getCertStores().isEmpty());
- }
-
- /**
- * Test #4 for <code>setCertStores(List)</code> method<br>
- * Assertion: <code>ClassCastException</code> -
- * if any of the elements in the list are not of type
- * <code>java.security.cert.CertStore</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws NoSuchAlgorithmException
- */
- public final void testSetCertStores04() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- List l = TestUtils.getCollectionCertStoresList();
- // add wrong object to valid set
- assertTrue(l.add(new Object()));
-
- try {
- p.setCertStores(l);
- fail("ClassCastException expected");
- } catch (ClassCastException e) {
- }
- }
-
- /**
- * Test #1 for <code>addCertStore(CertStore)</code> method<br>
- * Assertion: adds a <code>CertStore</code> to the end of the
- * list of <code>CertStores</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws NoSuchAlgorithmException
- */
- public final void testAddCertStore01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- p.addCertStore(CertStore.getInstance("Collection",
- new CollectionCertStoreParameters()));
- assertFalse(p.getCertStores().isEmpty());
- }
-
- /**
- * Test #2 for <code>addCertStore(CertStore)</code> method<br>
- * Assertion: if <code>null</code>, the store is ignored (not added to list)
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testAddCertStore02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- p.addCertStore(null);
- assertTrue(p.getCertStores().isEmpty());
- }
-
- /**
- * Test #1 for <code>getCertPathCheckers()</code> method<br>
- * Assertion: list ... may be empty, but not <code>null</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetCertPathCheckers01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- List l = p.getCertPathCheckers();
- assertNotNull("notNull", l);
- assertTrue("isEmpty", l.isEmpty());
- }
-
- /**
- * Test #2 for <code>getCertPathCheckers()</code> method<br>
- * Assertion: returns an immutable <code>List</code>
- * of <code>PKIXCertPathChecker</code>s
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetCertPathCheckers02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- List l = p.getCertPathCheckers();
-
- try {
- // try to modify returned list
- l.add(new Object());
- fail("must be immutable");
- } catch (Exception e) {
- }
- }
-
- /**
- * Test #3 for <code>getCertPathCheckers()</code> method<br>
- * Assertion: The returned List is immutable, and each
- * <code>PKIXCertPathChecker</code> in the <code>List</code>
- * is cloned to protect against subsequent modifications
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws CertPathValidatorException
- */
- public final void testGetCertPathCheckers03() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
- List l = new ArrayList();
- assertTrue("addedOk", l.add(cpc));
- p.setCertPathCheckers(l);
- // retrieve checker and modify it
- PKIXCertPathChecker cpc1 = p.getCertPathCheckers().get(0);
- cpc1.init(true);
- assertTrue("modifiedOk", cpc1.isForwardCheckingSupported());
- // retrieve checker again and check
- // that its state has not been changed
- // by the above modification
- PKIXCertPathChecker cpc2 = p.getCertPathCheckers().get(0);
- assertFalse("isCloned", cpc2.isForwardCheckingSupported());
- }
-
- /**
- * Test #1 for <code>setCertPathCheckers(List)</code> method<br>
- * Assertion: sets a <code>List</code> of additional
- * certification path checkers
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetCertPathCheckers01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
- List l = new ArrayList();
- assertTrue("addedOk", l.add(cpc));
- p.setCertPathCheckers(l);
- List l1 = p.getCertPathCheckers();
- assertNotNull("notNull", l1);
- assertFalse("isNotEmpty", l1.isEmpty());
- }
-
- /**
- * Test #2 for <code>setCertPathCheckers(List)</code> method<br>
- * Assertion: <code>List</code> ... may be null
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetCertPathCheckers02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- p.setCertPathCheckers(null);
- List l1 = p.getCertPathCheckers();
- assertNotNull("notNull1", l1);
- assertTrue("isEmpty1", l1.isEmpty());
- p.setCertPathCheckers(new ArrayList());
- List l2 = p.getCertPathCheckers();
- assertNotNull("notNull2", l2);
- assertTrue("isEmpty2", l2.isEmpty());
- }
-
- /**
- * Test #3 for <code>setCertPathCheckers(List)</code> method<br>
- * Assertion: <code>List</code> supplied here is copied and each
- * <code>PKIXCertPathChecker</code> in the list is cloned to protect
- * against subsequent modifications
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetCertPathCheckers03() throws Exception {
- // checks that list copied
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
- List l = new ArrayList();
- assertTrue("addedOk", l.add(cpc));
- p.setCertPathCheckers(l);
- // modify list
- l.clear();
- // retrieve list and check
- // that its state has not been changed
- // by the above modification
- assertFalse("isCopied", p.getCertPathCheckers().isEmpty());
- }
-
- /**
- * Test #4 for <code>setCertPathCheckers(List)</code> method<br>
- * Assertion: <code>List</code> supplied here is copied and each
- * <code>PKIXCertPathChecker</code> in the list is cloned to protect
- * against subsequent modifications
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws CertPathValidatorException
- */
- public final void testSetCertPathCheckers04() throws Exception {
- // checks that checkers cloned
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
- List l = new ArrayList();
- assertTrue("addedOk", l.add(cpc));
- p.setCertPathCheckers(l);
- // modify checker
- cpc.init(true);
- // retrieve list and check that CertPathChecker's
- // state it contains has not been changed by the
- // above modification
- PKIXCertPathChecker cpc1 = p.getCertPathCheckers().get(0);
- assertFalse("isCopied", cpc1.isForwardCheckingSupported());
- }
-
- /**
- * Test #5 for <code>setCertPathCheckers(List)</code> method<br>
- * Assertion: <code>ClassCastException</code> -
- * if any of the elements in the list are not of type
- * <code>java.security.cert.PKIXCertPathChecker</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetCertPathCheckers05() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
- List l = new ArrayList();
- assertTrue("addedOk", l.add(cpc));
- // add wrong object to the list
- assertTrue("addedOk", l.add(new Object()));
-
- try {
- p.setCertPathCheckers(l);
- fail("ClassCastException expected");
- } catch (ClassCastException e) {
- }
- }
-
- /**
- * Test #1 for <code>addCertPathChecker(PKIXCertPathChecker)</code> method<br>
- * Assertion: adds a <code>CertPathChecker</code> to the end of the
- * list of <code>CertPathChecker</code>s
- *
- * @throws CertPathValidatorException
- */
- public final void testAddCertPathChecker01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
- List l = new ArrayList();
- assertTrue("addedOk", l.add(cpc));
- p.setCertPathCheckers(l);
- // create one more PKIXCertPathChecker
- PKIXCertPathChecker cpc1 = TestUtils.getTestCertPathChecker();
- cpc1.init(true);
- p.addCertPathChecker(cpc1);
- // check that we have two PKIXCertPathCheckers and
- // they are in right order
- List l1 = p.getCertPathCheckers();
- assertEquals("listSize", 2, l1.size());
- assertFalse("order1",
- ((PKIXCertPathChecker) l1.get(0)).isForwardCheckingSupported());
- assertTrue("order2",
- ((PKIXCertPathChecker) l1.get(1)).isForwardCheckingSupported());
- }
-
- /**
- * Test #2 for <code>addCertPathChecker(PKIXCertPathChecker)</code> method<br>
- * Assertion: if null, the checker is ignored (not added to list).
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testAddCertPathChecker02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
- List l = new ArrayList();
- assertTrue("addedOk", l.add(cpc));
- p.setCertPathCheckers(l);
- // try to add null
- p.addCertPathChecker(null);
- // check that we have one PKIXCertPathChecker
- List l1 = p.getCertPathCheckers();
- assertEquals("listSize", 1, l1.size());
- }
-
- /**
- * Test #3 for <code>addCertPathChecker(PKIXCertPathChecker)</code> method<br>
- * Assertion: <code>PKIXCertPathChecker</code> is cloned to protect
- * against subsequent modifications
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws CertPathValidatorException
- */
- public final void testAddCertPathChecker03() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- // checks that checkers cloned
- PKIXParameters p = new PKIXParameters(taSet);
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
-
- p.addCertPathChecker(cpc);
- // modify checker
- cpc.init(true);
- // retrieve list and check that CertPathChecker's
- // state it contains has not been changed by the
- // above modification
- List l = p.getCertPathCheckers();
- PKIXCertPathChecker cpc1 = (PKIXCertPathChecker) l.get(0);
- assertEquals("listSize", 1, l.size());
- assertFalse("isCopied", cpc1.isForwardCheckingSupported());
- }
-
- /**
- * Test #1 for <code>getDate()</code> method<br>
- * Assertion: the <code>Date</code>, or <code>null</code> if not set
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetDate01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- // the Date has not been set
- // the method must return null
- assertNull("null", p.getDate());
- Date currentDate = new Date();
- p.setDate(currentDate);
- // the Date returned must match
- assertEquals("notNull", currentDate, p.getDate());
- }
-
- /**
- * Test #2 for <code>getDate()</code> method<br>
- * Assertion: <code>Date</code> returned is copied to protect
- * against subsequent modifications
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetDate02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- Date currentDate = new Date();
- p.setDate((Date) currentDate.clone());
- Date ret1 = p.getDate();
- // modify Date returned
- ret1.setTime(0L);
- // check that internal Date has not been
- // changed by the above modification
- assertEquals(currentDate, p.getDate());
- }
-
- /**
- * @tests java.security.cert.PKIXParameters#setDate(Date)
- */
- public final void test_setDateLjava_util_Date() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- assertNotNull("could not create test TrustAnchor set", taSet);
-
- // test: 'date' is unset and param is null
- PKIXParameters p = new PKIXParameters(taSet);
- p.setDate(null);
- assertNull(p.getDate());
-
- // test: 'date' is not null
- p = new PKIXParameters(taSet);
- Date toBeSet = new Date(555L);
- p.setDate(toBeSet);
- assertEquals(555L, p.getDate().getTime());
- // modify initial 'date' - it should be copied by constructor
- toBeSet.setTime(0L);
- // check that internal 'date' has not been
- // changed by the above modification
- assertEquals(555L, p.getDate().getTime());
- // set another 'date'
- p.setDate(new Date(333L));
- assertEquals(333L, p.getDate().getTime());
-
- // Regression for HARMONY-2882 (non-bug difference from RI)
- p = new PKIXParameters(taSet);
- p.setDate(new Date(555L));
- p.setDate(null); // reset 'date' back to current time
- assertNull(p.getDate());
- }
-
- /**
- * Test #1 for <code>getInitialPolicies()</code> method<br>
- * Assertion: The default return value is an empty <code>Set</code>
- * Assertion: Never returns <code>null</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetInitialPolicies01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- assertNotNull("notNull", p.getInitialPolicies());
- assertTrue("isEmpty", p.getInitialPolicies().isEmpty());
- }
-
- /**
- * Test #2 for <code>getInitialPolicies()</code> method<br>
- * Assertion: returns an immutable <code>Set</code> of initial
- * policy OIDs in <code>String</code> format<br>
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetInitialPolicies02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- Set s = p.getInitialPolicies();
- try {
- // try to modify returned set
- s.add(new Object());
- fail("must be immutable");
- } catch (Exception e) {
- }
- }
-
- /**
- * Test #1 for <code>setInitialPolicies(Set)</code> method<br>
- * Assertion: sets the <code>Set</code> of initial policy
- * identifiers (OID strings)
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetInitialPolicies01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- Set s = new HashSet();
- s.add("1.2.3.4.5.6.7");
- PKIXParameters p = new PKIXParameters(taSet);
- p.setInitialPolicies(s);
- assertEquals(1, p.getInitialPolicies().size());
- }
-
- /**
- * Test #2 for <code>setInitialPolicies(Set)</code> method<br>
- * Assertion: <code>Set</code> may be <code>null</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetInitialPolicies02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- p.setInitialPolicies(null);
- assertTrue(p.getInitialPolicies().isEmpty());
- }
-
- /**
- * Test #3 for <code>setInitialPolicies(Set)</code> method<br>
- * Assertion: <code>Set</code> may be empty
- */
- public final void testSetInitialPolicies03() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- p.setInitialPolicies(new HashSet());
- assertTrue(p.getInitialPolicies().isEmpty());
- }
-
- /**
- * Test #4 for <code>setInitialPolicies(Set)</code> method<br>
- * Assertion: <code>Set</code> is copied to protect against
- * subsequent modifications
- */
- public final void testSetInitialPolicies04() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- Set s = new HashSet();
- s.add("1.2.3.4.5.6.7");
- s.add("1.2.3.4.5.6.8");
- PKIXParameters p = new PKIXParameters(taSet);
- p.setInitialPolicies(s);
- // modify original set
- s.clear();
- // check that set maintained internally has
- // not been changed by the above modification
- assertEquals(2, p.getInitialPolicies().size());
- }
-
- /**
- * Test #5 for <code>setInitialPolicies(Set)</code> method<br>
- * Assertion: <code>ClassCastException</code> -
- * if any of the elements in the set are not of type <code>String</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetInitialPolicies05() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- Set s = new HashSet();
- s.add("1.2.3.4.5.6.7");
- s.add(new Object());
- PKIXParameters p = new PKIXParameters(taSet);
- try {
- p.setInitialPolicies(s);
- fail("ClassCastException expected");
- } catch (ClassCastException e) {
- }
- }
-
- /**
- * Test #1 for <code>getTrustAnchors()</code> method<br>
- * Assertion: an immutable <code>Set</code> of <code>TrustAnchors</code>
- * (never <code>null</code>)
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetTrustAnchors01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- assertNotNull("notNull", p.getTrustAnchors());
- }
-
- /**
- * Test #2 for <code>getTrustAnchors()</code> method<br>
- * Assertion: an immutable <code>Set</code> of <code>TrustAnchors</code>
- * (never <code>null</code>)
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetTrustAnchors02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- Set s = p.getTrustAnchors();
- try {
- // try to modify returned set
- s.add(new Object());
- fail("must be immutable");
- } catch (Exception e) {
- }
- }
-
- /**
- * Test #1 for <code>setTrustAnchors(Set)</code> method<br>
- * Assertion: Sets the <code>Set</code> of most-trusted CAs
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetTrustAnchors01() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- Set taSet1 = TestUtils.getTrustAnchorSet();
- PKIXParameters p = new PKIXParameters(taSet);
- p.setTrustAnchors(taSet1);
- assertFalse(p.getTrustAnchors().isEmpty());
- }
-
- /**
- * Test #2 for <code>setTrustAnchors(Set)</code> method<br>
- * Assertion: <code>InvalidAlgorithmParameterException</code> -
- * if the specified <code>Set</code> is empty
- * (<code>trustAnchors.isEmpty() == true</code>)
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetTrustAnchors02() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- try {
- // use empty set
- p.setTrustAnchors(new HashSet());
- fail("InvalidAlgorithmParameterException expected");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- /**
- * Test #3 for <code>setTrustAnchors(Set)</code> method<br>
- * Assertion: <code>NullPointerException</code> -
- * if the specified <code>Set</code> is <code>null</code>)
- */
- public final void testSetTrustAnchors03() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- try {
- // use null
- p.setTrustAnchors(null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #4 for <code>setTrustAnchors(Set)</code> method<br>
- * Assertion: <code>ClassCastException</code> -
- * if any of the elements in the set are not of type
- * <code>java.security.cert.TrustAnchor</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetTrustAnchors04() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- PKIXParameters p = new PKIXParameters(taSet);
- Set s = new HashSet(p.getTrustAnchors());
- s.add(new Object());
- try {
- p.setTrustAnchors(s);
- fail("ClassCastException expected");
- } catch (ClassCastException e) {
- }
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PolicyQualifierInfoTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PolicyQualifierInfoTest.java
deleted file mode 100644
index 5444017..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PolicyQualifierInfoTest.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.IOException;
-import java.security.cert.PolicyQualifierInfo;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * PolicyQualifierInfo test
- */
-public class PolicyQualifierInfoTest extends TestCase {
-
- /**
- * Constructor for PolicyQualifierInfoTest.
- *
- * @param name
- */
- public PolicyQualifierInfoTest(String name) {
- super(name);
- }
-
- /**
- * Test #1 for <code>PolicyQualifierInfo</code> constructor<br>
- * Assertion: throws <code>IOException</code> if byte array
- * parameter does not represent a valid and parsable policy
- * qualifier info
- */
- public final void test_Ctor() throws IOException {
- try {
- // pass null
- new PolicyQualifierInfo(null);
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- try {
- // pass empty array
- new PolicyQualifierInfo(new byte[0]);
- fail("IOE expected");
- } catch (IOException e) {
- }
-
-
- try {
- // pass invalid array
- new PolicyQualifierInfo(
- new byte[] { (byte) 0x06, (byte) 0x03,
- (byte) 0x81, (byte) 0x34, (byte) 0x03 });
- fail("IOE expected");
- } catch (IOException e) {
- }
- }
-
- /**
- * Test #2 for <code>PolicyQualifierInfo</code> constructor<br>
- * Assertion: throws <code>IOException</code> if byte array
- * parameter does not represent a valid and parsable policy
- * qualifier info
- */
- public final void testPolicyQualifierInfo02() {
- // get valid encoding
- byte[] encoding = getDerEncoding();
- // corrupt root seq length
- encoding[1] = (byte) 0x27;
-
- try {
- // pass invalid array
- new PolicyQualifierInfo(encoding);
- fail("IOE expected");
- } catch (IOException e) {
- }
-
-
- // get valid encoding
- encoding = getDerEncoding();
- // corrupt policy qualifier ID:
- // - change OID to the Relative OID
- encoding[2] = (byte) 13;
- try {
- // pass invalid array
- new PolicyQualifierInfo(encoding);
- fail("IOE expected");
- } catch (IOException e) {
- }
- }
-
- /**
- * Test #3 for <code>PolicyQualifierInfo</code> constructor<br>
- * Assertion: Creates an instance of <code>PolicyQualifierInfo</code>
- * from the encoded bytes
- *
- * @throws IOException
- */
- public final void testPolicyQualifierInfo03() throws IOException {
- // get valid encoding
- byte[] encoding = getDerEncoding();
- // pass valid array
- new PolicyQualifierInfo(encoding);
- }
-
- /**
- * Test #4 for <code>PolicyQualifierInfo</code> constructor<br>
- * Assertion: The encoded byte array is copied on construction
- *
- * @throws IOException
- */
- public final void testPolicyQualifierInfo04() throws IOException {
- // get valid encoding
- byte[] encoding = getDerEncoding();
- byte[] encodingCopy = encoding.clone();
- // pass valid array
- PolicyQualifierInfo i = new PolicyQualifierInfo(encodingCopy);
- // get encoding
- byte[] encodingRet = i.getEncoded();
- // check returned array
- assertTrue(Arrays.equals(encoding, encodingRet));
- // modify input
- encodingCopy[0] = (byte) 0;
- // get encoding again
- byte[] encodingRet1 = i.getEncoded();
- // check that above modification did not change
- // internal state of the PolicyQualifierInfo instance
- assertTrue(Arrays.equals(encoding, encodingRet1));
- }
-
- /**
- * Test #1 for <code>getEncoded()</code> method
- * Assertion: Returns the ASN.1 DER encoded form of
- * this <code>PolicyQualifierInfo</code>
- *
- * @throws IOException
- */
- public final void testGetEncoded01() throws IOException {
- // get valid encoding
- byte[] encoding = getDerEncoding();
- // pass valid array
- PolicyQualifierInfo i = new PolicyQualifierInfo(encoding);
- // get encoding
- byte[] encodingRet = i.getEncoded();
- // check returned array
- assertTrue(Arrays.equals(encoding, encodingRet));
- }
-
- /**
- * Test #2 for <code>getEncoded()</code> method
- * Assertion: a copy is returned each time
- *
- * @throws IOException
- */
- public final void testGetEncoded02() throws IOException {
- // get valid encoding
- byte[] encoding = getDerEncoding();
- byte[] encodingCopy = encoding.clone();
- // pass valid array
- PolicyQualifierInfo i = new PolicyQualifierInfo(encodingCopy);
- // get encoding
- byte[] encodingRet = i.getEncoded();
- // modify returned array
- encodingRet[0] = (byte) 0;
- // get encoding again
- byte[] encodingRet1 = i.getEncoded();
- // check that above modification did not change
- // internal state of the PolicyQualifierInfo instance
- assertTrue(Arrays.equals(encoding, encodingRet1));
- }
-
- /**
- * Test #1 for <code>getPolicyQualifier()</code> method
- * Assertion: Returns the ASN.1 DER encoded form of
- * this <code>PolicyQualifierInfo</code>
- *
- * @throws IOException
- */
- public final void testGetPolicyQualifier01() throws IOException {
- // get valid encoding
- byte[] encoding = getDerEncoding();
- // get policy qualifier encoding
- byte[] pqEncoding = new byte[28];
- System.arraycopy(encoding, 12, pqEncoding, 0, pqEncoding.length);
- // pass valid array
- PolicyQualifierInfo i = new PolicyQualifierInfo(encoding);
- // get encoding
- byte[] pqEncodingRet = i.getPolicyQualifier();
- // check returned array
- assertTrue(Arrays.equals(pqEncoding, pqEncodingRet));
- }
-
- /**
- * Test #2 for <code>getPolicyQualifier()</code> method
- * Assertion: a copy is returned each time
- *
- * @throws IOException
- */
- public final void testGetPolicyQualifier02() throws IOException {
- // get valid encoding
- byte[] encoding = getDerEncoding();
- // get policy qualifier encoding
- byte[] pqEncoding = new byte[28];
- System.arraycopy(encoding, 12, pqEncoding, 0, pqEncoding.length);
- // pass valid array
- PolicyQualifierInfo i = new PolicyQualifierInfo(encoding);
- // get encoding
- byte[] pqEncodingRet = i.getPolicyQualifier();
- // modify returned array
- pqEncodingRet[0] = (byte) 0;
- // get encoding again
- byte[] pqEncodingRet1 = i.getPolicyQualifier();
- //
- assertNotSame(pqEncodingRet, pqEncodingRet1);
- // check that above modification did not change
- // internal state of the PolicyQualifierInfo instance
- assertTrue(Arrays.equals(pqEncoding, pqEncodingRet1));
- }
-
- /**
- * Test for <code>getPolicyQualifierId()</code> method
- * Assertion: Returns the <code>policyQualifierId</code>
- * field of this <code>PolicyQualifierInfo</code>.
- * The <code>policyQualifierId</code> is an Object Identifier (OID)
- * represented by a set of nonnegative integers separated by periods
- *
- * @throws IOException
- */
- public final void testGetPolicyQualifierId() throws IOException {
- // get valid encoding
- byte[] encoding = getDerEncoding();
- // pass valid array
- PolicyQualifierInfo i = new PolicyQualifierInfo(encoding);
- // get OID as String and check it
- assertEquals("1.3.6.1.5.5.7.2.1", i.getPolicyQualifierId());
-
- // get valid encoding
- encoding = getDerEncoding();
- // change OID to 1.3.98437.82818.1
- encoding[5] = (byte) 0x86;
- encoding[6] = (byte) 0x81;
- encoding[8] = (byte) 0x85;
- encoding[9] = (byte) 0x87;
- i = new PolicyQualifierInfo(encoding);
- // get OID as String and check it
- assertEquals("1.3.98437.82818.1", i.getPolicyQualifierId());
- }
-
- /**
- * Test for <code>toString()</code> method
- * Assertion: returns description of the contents of this
- * <code>PolicyQualifierInfo</code> as printable <code>String</code>
- *
- * @throws IOException
- * @throws IOException
- */
- public final void testToString() throws IOException {
- // get valid encoding
- byte[] encoding = getDerEncoding();
- // pass valid array
- PolicyQualifierInfo i = new PolicyQualifierInfo(encoding);
-
- assertNotNull(i.toString());
- }
-
- //
- // Private stuff
- //
-
- /**
- * Returns valid DER encoding for the following ASN.1 definition
- * (as specified in RFC 3280 -
- * Internet X.509 Public Key Infrastructure.
- * Certificate and Certificate Revocation List (CRL) Profile.
- * http://www.ietf.org/rfc/rfc3280.txt):
- * <p/>
- * PolicyQualifierInfo ::= SEQUENCE {
- * policyQualifierId PolicyQualifierId,
- * qualifier ANY DEFINED BY policyQualifierId
- * }
- * <p/>
- * where policyQualifierId (OID) is
- * 1.3.6.1.5.5.7.2.1
- * and qualifier (IA5String) is
- * "http://www.qq.com/stmt.txt"
- * <p/>
- * (data generated by own encoder during test development)
- */
- private static final byte[] getDerEncoding() {
- // DO NOT MODIFY!
- return new byte[] {
- (byte) 0x30, (byte) 0x26, // tag Seq, length
- (byte) 0x06, (byte) 0x08, // tag OID, length
- (byte) 0x2b, (byte) 0x06, (byte) 0x01, (byte) 0x05, // oid value
- (byte) 0x05, (byte) 0x07, (byte) 0x02, (byte) 0x01, // oid value
- (byte) 0x16, (byte) 0x1a, // tag IA5String, length
- (byte) 0x68, (byte) 0x74, (byte) 0x74, (byte) 0x70, // IA5String value
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x77, // IA5String value
- (byte) 0x77, (byte) 0x77, (byte) 0x2e, (byte) 0x71, // IA5String value
- (byte) 0x71, (byte) 0x2e, (byte) 0x63, (byte) 0x6f, // IA5String value
- (byte) 0x6d, (byte) 0x2f, (byte) 0x73, (byte) 0x74, // IA5String value
- (byte) 0x6d, (byte) 0x74, (byte) 0x2e, (byte) 0x74, // IA5String value
- (byte) 0x78, (byte) 0x74 // IA5String value
- };
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchorTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchorTest.java
deleted file mode 100644
index 25d145a..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchorTest.java
+++ /dev/null
@@ -1,557 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.PublicKey;
-import java.security.cert.TrustAnchor;
-import java.security.cert.X509Certificate;
-import java.security.spec.InvalidKeySpecException;
-import java.util.Arrays;
-
-import javax.security.auth.x500.X500Principal;
-
-import org.apache.harmony.security.tests.support.TestKeyPair;
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for <code>TrustAnchor</code>
- */
-public class TrustAnchorTest extends TestCase {
- private static final String keyAlg = "DSA";
- // Sample of some valid CA name
- private static final String validCaNameRfc2253 =
- "CN=Test CA," +
- "OU=Testing Division," +
- "O=Test It All," +
- "L=Test Town," +
- "ST=Testifornia," +
- "C=Testland";
-
- /**
- * Test #1 for <code>TrustAnchor(String, PublicKey, byte[])</code> constructor<br>
- * Assertion: creates <code>TrustAnchor</code> instance<br>
- * Test preconditions: valid parameters passed<br>
- * Expected: must pass without any exceptions
- *
- * @throws InvalidKeySpecException
- */
- public final void testTrustAnchorStringPublicKeybyteArray01()
- throws Exception {
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
- // sub testcase 1
- new TrustAnchor(validCaNameRfc2253, pk, getFullEncoding());
- // sub testcase 2
- new TrustAnchor(validCaNameRfc2253, pk, getEncodingPSOnly());
- // sub testcase 3
- new TrustAnchor(validCaNameRfc2253, pk, getEncodingESOnly());
- // sub testcase 4
- new TrustAnchor(validCaNameRfc2253, pk, getEncodingNoMinMax());
- }
-
- /**
- * Test #2 for <code>TrustAnchor(String, PublicKey, byte[])</code> constructor<br>
- * Assertion: creates <code>TrustAnchor</code> instance<br>
- * Test preconditions: <code>null</code> as nameConstraints passed<br>
- * Expected: must pass without any exceptions
- *
- * @throws InvalidKeySpecException
- */
- public final void testTrustAnchorStringPublicKeybyteArray02()
- throws Exception {
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
- new TrustAnchor(validCaNameRfc2253, pk, null);
- }
-
- /**
- * Test #3 for <code>TrustAnchor(String, PublicKey, byte[])</code> constructor<br>
- * Assertion: nameConstraints cloned by the constructor<br>
- * Test preconditions: modify passed nameConstraints<br>
- * Expected: modification must not change object internal state
- *
- * @throws InvalidKeySpecException
- */
- public final void testTrustAnchorStringPublicKeybyteArray03()
- throws Exception {
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
- byte[] nc = getEncodingPSOnly();
- byte[] ncCopy = nc.clone();
- // sub testcase 5 - nameConstraints can be null
- TrustAnchor ta = new TrustAnchor(validCaNameRfc2253, pk, ncCopy);
- // modify
- ncCopy[0] = (byte) 0;
- // check that above modification did not change
- // object internal state
- assertTrue(Arrays.equals(nc, ta.getNameConstraints()));
- }
-
- /**
- * Test #4 for <code>TrustAnchor(String, PublicKey, byte[])</code> constructor<br>
- * Assertion: <code>NullPointerException</code> if <code>caName</code>
- * or <code>caPublicKey</code> parameter is <code>null</code><br>
- * Test preconditions: pass <code>null</code> as mentioned parameter<br>
- * Expected: NullPointerException
- */
- public final void testTrustAnchorStringPublicKeybyteArray04()
- throws Exception {
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
- // sub testcase 1: 'caName' param is null
- try {
- new TrustAnchor((String) null, pk, getEncodingPSOnly());
- fail("NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
-
- // sub testcase 2: 'caPublicKey' param is null
- try {
- new TrustAnchor(validCaNameRfc2253, null, getEncodingPSOnly());
- fail("NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
-
- // sub testcase 3: 'caName' and 'caPublicKey' params are null
- try {
- new TrustAnchor((String) null, null, getEncodingPSOnly());
- fail("NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
-
- // sub testcase 4: 'caName' param is empty
- try {
- new TrustAnchor("", pk, getEncodingPSOnly());
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 5: 'caName' param is incorrect distinguished name
- try {
- new TrustAnchor("AID.11.12=A", pk, getEncodingPSOnly());
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test #1 for <code>TrustAnchor(X500Principal, PublicKey, byte[])</code> constructor<br>
- * Assertion: creates <code>TrustAnchor</code> instance<br>
- * Test preconditions: valid parameters passed<br>
- * Expected: must pass without any exceptions
- *
- * @throws InvalidKeySpecException
- */
- public final void testTrustAnchorX500PrincipalPublicKeybyteArray01()
- throws Exception {
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
- X500Principal x500p = new X500Principal(validCaNameRfc2253);
- // sub testcase 1
- new TrustAnchor(x500p, pk, getFullEncoding());
- // sub testcase 2
- new TrustAnchor(x500p, pk, getEncodingPSOnly());
- // sub testcase 3
- new TrustAnchor(x500p, pk, getEncodingESOnly());
- // sub testcase 4
- new TrustAnchor(x500p, pk, getEncodingNoMinMax());
- }
-
- /**
- * Test #2 for <code>TrustAnchor(X500Principal, PublicKey, byte[])</code> constructor<br>
- * Assertion: creates <code>TrustAnchor</code> instance<br>
- * Test preconditions: <code>null</code> as nameConstraints passed<br>
- * Expected: must pass without any exceptions
- *
- * @throws InvalidKeySpecException
- */
- public final void testTrustAnchorX500PrincipalPublicKeybyteArray02()
- throws Exception {
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
- X500Principal x500p = new X500Principal(validCaNameRfc2253);
-
- new TrustAnchor(x500p, pk, null);
- }
-
- /**
- * Test #3 for <code>TrustAnchor(X500Principal, PublicKey, byte[])</code> constructor<br>
- * Assertion: nameConstraints cloned by the constructor<br>
- * Test preconditions: modify passed nameConstraints<br>
- * Expected: modification must not change object internal state
- *
- * @throws InvalidKeySpecException
- */
- public final void testTrustAnchorX500PrincipalPublicKeybyteArray03()
- throws Exception {
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
- byte[] nc = getEncodingPSOnly();
- byte[] ncCopy = nc.clone();
- // sub testcase 5 - nameConstraints can be null
- TrustAnchor ta = new TrustAnchor(new X500Principal(validCaNameRfc2253),
- pk, ncCopy);
- // modify
- ncCopy[0] = (byte) 0;
- // check that above modification did not change
- // object internal state
- assertTrue(Arrays.equals(nc, ta.getNameConstraints()));
- }
-
- /**
- * Test #4 for <code>TrustAnchor(X500Principal, PublicKey, byte[])</code> constructor<br>
- * Assertion: <code>NullPointerException</code> if <code>caPrincipal</code>
- * or <code>caPublicKey</code> parameter is <code>null</code><br>
- * Test preconditions: pass <code>null</code> as mentioned parameter<br>
- * Expected: NullPointerException
- *
- * @throws InvalidKeySpecException
- */
- public final void testTrustAnchorX500PrincipalPublicKeybyteArray04()
- throws Exception {
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
- X500Principal x500p = new X500Principal(validCaNameRfc2253);
- // sub testcase 1
- try {
- new TrustAnchor((X500Principal) null,
- pk, getEncodingPSOnly());
- fail("NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
-
- // sub testcase 2
- try {
- new TrustAnchor(x500p, null, getEncodingPSOnly());
- fail("NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
-
- // sub testcase 3
- try {
- new TrustAnchor((X500Principal) null, null,
- getEncodingPSOnly());
- fail("NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
-
- }
-
- /**
- * Test #1 for <code>getCAPublicKey()</code> method<br>
- * <p/>
- * Assertion: returns most trusted CA public key</code><br>
- * Test preconditions: valid name passed to the constructor<br>
- * Expected: the same name must be returned by the method<br>
- */
- public final void testGetCAPublicKey01() throws Exception {
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
- // sub testcase 1
- TrustAnchor ta =
- new TrustAnchor(validCaNameRfc2253, pk, null);
- assertEquals("equals1", pk, ta.getCAPublicKey());
- // sub testcase 2
- X500Principal x500p = new X500Principal(validCaNameRfc2253);
- ta = new TrustAnchor(x500p, pk, null);
- assertEquals("equals2", pk, ta.getCAPublicKey());
- }
-
-
- /**
- * Test #1 for <code>getCAName()</code> method<br>
- * <p/>
- * Assertion: returns most trusted CA name as <code>String</code><br>
- * Test preconditions: valid name passed to the constructor<br>
- * Expected: the same name must be returned by the method<br>
- *
- * @throws InvalidKeySpecException
- */
- public final void testGetCAName01() throws Exception {
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
- // sub testcase 1
- TrustAnchor ta =
- new TrustAnchor(validCaNameRfc2253, pk, null);
- assertEquals("equals1", validCaNameRfc2253, ta.getCAName());
- // sub testcase 2
- X500Principal x500p = new X500Principal(validCaNameRfc2253);
- ta = new TrustAnchor(x500p, pk, null);
- assertEquals("equals2", validCaNameRfc2253, ta.getCAName());
- }
-
- /**
- * Test #2 for <code>getCAName()</code> method<br>
- * <p/>
- * Assertion: returns ... <code>null</code> if <code>TrustAnchor</code>
- * was not specified as trusted certificate<br>
- * Test preconditions: test object is not specified as trusted certificate<br>
- * Expected: <code>null</code> as return value<br>
- *
- * @throws InvalidKeySpecException
- */
- public final void testGetTrustedCer02() throws Exception {
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
- // sub testcase 1
- TrustAnchor ta =
- new TrustAnchor(validCaNameRfc2253, pk, null);
- assertNull("null1", ta.getTrustedCert());
- // sub testcase 2
- X500Principal x500p = new X500Principal(validCaNameRfc2253);
- ta = new TrustAnchor(x500p, pk, null);
- assertNull("null2", ta.getTrustedCert());
- }
-
-
- /**
- * Test #1 for <code>getCA()</code> method<br>
- * <p/>
- * Assertion: returns most trusted CA<br>
- * Test preconditions: valid CA or CA name passed to the constructor<br>
- * Expected: the same CA ot the CA with the same name must be returned
- * by the method<br>
- *
- * @throws InvalidKeySpecException
- */
- public final void testGetCA01() throws Exception {
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
- // sub testcase 1
- TrustAnchor ta =
- new TrustAnchor(validCaNameRfc2253, pk, null);
- X500Principal ca = ta.getCA();
- assertEquals("equals1", validCaNameRfc2253, ca.getName());
- // sub testcase 2
- X500Principal x500p = new X500Principal(validCaNameRfc2253);
- ta = new TrustAnchor(x500p, pk, null);
- assertEquals("equals2", x500p, ta.getCA());
- }
-
- //
- // Private stuff
- //
-
- /*
- * The following methods return valid DER encoding
- * for the following ASN.1 definition (as specified in RFC 3280 -
- * Internet X.509 Public Key Infrastructure.
- * Certificate and Certificate Revocation List (CRL) Profile.
- * http://www.ietf.org/rfc/rfc3280.txt):
- *
- * NameConstraints ::= SEQUENCE {
- * permittedSubtrees [0] GeneralSubtrees OPTIONAL,
- * excludedSubtrees [1] GeneralSubtrees OPTIONAL }
- *
- * GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree
- *
- * GeneralSubtree ::= SEQUENCE {
- * base GeneralName,
- * minimum [0] BaseDistance DEFAULT 0,
- * maximum [1] BaseDistance OPTIONAL }
- *
- * BaseDistance ::= INTEGER (0..MAX)
- *
- * GeneralName ::= CHOICE {
- * otherName [0] OtherName,
- * rfc822Name [1] IA5String,
- * dNSName [2] IA5String,
- * x400Address [3] ORAddress,
- * directoryName [4] Name,
- * ediPartyName [5] EDIPartyName,
- * uniformResourceIdentifier [6] IA5String,
- * iPAddress [7] OCTET STRING,
- * registeredID [8] OBJECT IDENTIFIER}
- */
-
- //
- // Full NameConstraints encoding
- // (generated by own encoder class created during test development)
- //
- // @return Full NameConstraints encoding
- // with all OPTIONAL values presented.
- //
- private static final byte[] getFullEncoding() {
- // DO NOT MODIFY!
- return new byte[] {
- (byte) 0x30, (byte) 0x81, (byte) 0x8c, (byte) 0xa0,
- (byte) 0x44, (byte) 0x30, (byte) 0x16, (byte) 0x86,
- (byte) 0x0e, (byte) 0x66, (byte) 0x69, (byte) 0x6c,
- (byte) 0x65, (byte) 0x3a, (byte) 0x2f, (byte) 0x2f,
- (byte) 0x66, (byte) 0x6f, (byte) 0x6f, (byte) 0x2e,
- (byte) 0x63, (byte) 0x6f, (byte) 0x6d, (byte) 0x80,
- (byte) 0x01, (byte) 0x00, (byte) 0x81, (byte) 0x01,
- (byte) 0x01, (byte) 0x30, (byte) 0x16, (byte) 0x86,
- (byte) 0x0e, (byte) 0x66, (byte) 0x69, (byte) 0x6c,
- (byte) 0x65, (byte) 0x3a, (byte) 0x2f, (byte) 0x2f,
- (byte) 0x62, (byte) 0x61, (byte) 0x72, (byte) 0x2e,
- (byte) 0x63, (byte) 0x6f, (byte) 0x6d, (byte) 0x80,
- (byte) 0x01, (byte) 0x00, (byte) 0x81, (byte) 0x01,
- (byte) 0x01, (byte) 0x30, (byte) 0x12, (byte) 0x86,
- (byte) 0x0a, (byte) 0x66, (byte) 0x69, (byte) 0x6c,
- (byte) 0x65, (byte) 0x3a, (byte) 0x2f, (byte) 0x2f,
- (byte) 0x6d, (byte) 0x75, (byte) 0x75, (byte) 0x80,
- (byte) 0x01, (byte) 0x00, (byte) 0x81, (byte) 0x01,
- (byte) 0x01, (byte) 0xa1, (byte) 0x44, (byte) 0x30,
- (byte) 0x16, (byte) 0x86, (byte) 0x0e, (byte) 0x68,
- (byte) 0x74, (byte) 0x74, (byte) 0x70, (byte) 0x3a,
- (byte) 0x2f, (byte) 0x2f, (byte) 0x66, (byte) 0x6f,
- (byte) 0x6f, (byte) 0x2e, (byte) 0x63, (byte) 0x6f,
- (byte) 0x6d, (byte) 0x80, (byte) 0x01, (byte) 0x00,
- (byte) 0x81, (byte) 0x01, (byte) 0x01, (byte) 0x30,
- (byte) 0x16, (byte) 0x86, (byte) 0x0e, (byte) 0x68,
- (byte) 0x74, (byte) 0x74, (byte) 0x70, (byte) 0x3a,
- (byte) 0x2f, (byte) 0x2f, (byte) 0x62, (byte) 0x61,
- (byte) 0x72, (byte) 0x2e, (byte) 0x63, (byte) 0x6f,
- (byte) 0x6d, (byte) 0x80, (byte) 0x01, (byte) 0x00,
- (byte) 0x81, (byte) 0x01, (byte) 0x01, (byte) 0x30,
- (byte) 0x12, (byte) 0x86, (byte) 0x0a, (byte) 0x68,
- (byte) 0x74, (byte) 0x74, (byte) 0x70, (byte) 0x3a,
- (byte) 0x2f, (byte) 0x2f, (byte) 0x6d, (byte) 0x75,
- (byte) 0x75, (byte) 0x80, (byte) 0x01, (byte) 0x00,
- (byte) 0x81, (byte) 0x01, (byte) 0x01
- };
- }
-
- //
- // NameConstraints encoding without excludedSubtrees
- // (generated by own encoder class created during test development)
- //
- // @return NameConstraints encoding with
- // permittedSubtrees only; all OPTIONAL
- // values in permittedSubtrees are presented.
- //
- private static final byte[] getEncodingPSOnly() {
- // DO NOT MODIFY!
- return new byte[] {
- (byte) 0x30, (byte) 0x46, (byte) 0xa0, (byte) 0x44,
- (byte) 0x30, (byte) 0x16, (byte) 0x86, (byte) 0x0e,
- (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x66,
- (byte) 0x6f, (byte) 0x6f, (byte) 0x2e, (byte) 0x63,
- (byte) 0x6f, (byte) 0x6d, (byte) 0x80, (byte) 0x01,
- (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x01,
- (byte) 0x30, (byte) 0x16, (byte) 0x86, (byte) 0x0e,
- (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x62,
- (byte) 0x61, (byte) 0x72, (byte) 0x2e, (byte) 0x63,
- (byte) 0x6f, (byte) 0x6d, (byte) 0x80, (byte) 0x01,
- (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x01,
- (byte) 0x30, (byte) 0x12, (byte) 0x86, (byte) 0x0a,
- (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x6d,
- (byte) 0x75, (byte) 0x75, (byte) 0x80, (byte) 0x01,
- (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x01,
- };
- }
-
- //
- // NameConstraints encoding without permittedSubtrees
- // (generated by own encoder class created during test development)
- //
- // @return NameConstraints encoding with
- // excludedSubtrees only; all OPTIONAL
- // values in excludedSubtrees are presented.
- //
- private static final byte[] getEncodingESOnly() {
- // DO NOT MODIFY!
- return new byte[] {
- (byte) 0x30, (byte) 0x46, (byte) 0xa1, (byte) 0x44,
- (byte) 0x30, (byte) 0x16, (byte) 0x86, (byte) 0x0e,
- (byte) 0x68, (byte) 0x74, (byte) 0x74, (byte) 0x70, // http
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x66, // ://f
- (byte) 0x6f, (byte) 0x6f, (byte) 0x2e, (byte) 0x63, // oo.c
- (byte) 0x6f, (byte) 0x6d, (byte) 0x80, (byte) 0x01, // om
- (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x01,
- (byte) 0x30, (byte) 0x16, (byte) 0x86, (byte) 0x0e,
- (byte) 0x68, (byte) 0x74, (byte) 0x74, (byte) 0x70,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x62,
- (byte) 0x61, (byte) 0x72, (byte) 0x2e, (byte) 0x63,
- (byte) 0x6f, (byte) 0x6d, (byte) 0x80, (byte) 0x01,
- (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x01,
- (byte) 0x30, (byte) 0x12, (byte) 0x86, (byte) 0x0a,
- (byte) 0x68, (byte) 0x74, (byte) 0x74, (byte) 0x70,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x6d,
- (byte) 0x75, (byte) 0x75, (byte) 0x80, (byte) 0x01,
- (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x01,
- };
- }
-
- //
- // NameConstraints full encoding with all (OPTIONAL)
- // minimum/maximum GeneralSubtree fields OMITTED
- // (generated by own encoder class created during test development)
- //
- // @return Full NameConstraints encoding
- // with all (OPTIONAL) minimum/maximum
- // GeneralSubtree fields OMITTED
- //
- private static final byte[] getEncodingNoMinMax() {
- // DO NOT MODIFY!
- return new byte[] {
- (byte) 0x30, (byte) 0x68, (byte) 0xa0, (byte) 0x32,
- (byte) 0x30, (byte) 0x10, (byte) 0x86, (byte) 0x0e,
- (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x66,
- (byte) 0x6f, (byte) 0x6f, (byte) 0x2e, (byte) 0x63,
- (byte) 0x6f, (byte) 0x6d, (byte) 0x30, (byte) 0x10,
- (byte) 0x86, (byte) 0x0e, (byte) 0x66, (byte) 0x69,
- (byte) 0x6c, (byte) 0x65, (byte) 0x3a, (byte) 0x2f,
- (byte) 0x2f, (byte) 0x62, (byte) 0x61, (byte) 0x72,
- (byte) 0x2e, (byte) 0x63, (byte) 0x6f, (byte) 0x6d,
- (byte) 0x30, (byte) 0x0c, (byte) 0x86, (byte) 0x0a,
- (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x6d,
- (byte) 0x75, (byte) 0x75, (byte) 0xa1, (byte) 0x32,
- (byte) 0x30, (byte) 0x10, (byte) 0x86, (byte) 0x0e,
- (byte) 0x68, (byte) 0x74, (byte) 0x74, (byte) 0x70,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x66,
- (byte) 0x6f, (byte) 0x6f, (byte) 0x2e, (byte) 0x63,
- (byte) 0x6f, (byte) 0x6d, (byte) 0x30, (byte) 0x10,
- (byte) 0x86, (byte) 0x0e, (byte) 0x68, (byte) 0x74,
- (byte) 0x74, (byte) 0x70, (byte) 0x3a, (byte) 0x2f,
- (byte) 0x2f, (byte) 0x62, (byte) 0x61, (byte) 0x72,
- (byte) 0x2e, (byte) 0x63, (byte) 0x6f, (byte) 0x6d,
- (byte) 0x30, (byte) 0x0c, (byte) 0x86, (byte) 0x0a,
- (byte) 0x68, (byte) 0x74, (byte) 0x74, (byte) 0x70,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x6d,
- (byte) 0x75, (byte) 0x75,
- };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRL2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRL2Test.java
deleted file mode 100644
index 4685c3b..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRL2Test.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.InputStream;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.Iterator;
-import java.util.Vector;
-
-import tests.support.resource.Support_Resources;
-
-import junit.framework.TestCase;
-
-public class X509CRL2Test extends junit.framework.TestCase {
-
- private X509Certificate pemCert = null;
-
- protected void setUp() throws Exception {
-
- InputStream is = Support_Resources
- .getResourceStream("hyts_certificate_PEM.txt");
-
- CertificateFactory certFact = CertificateFactory.getInstance("X509");
- pemCert = (X509Certificate) certFact.generateCertificate(is);
- }
-
- /**
- * @tests java.security.cert.X509CRL#getExtensionValue(java.lang.String)
- */
- public void test_getExtensionValueLjava_lang_String() {
- if (pemCert != null) {
- Vector extensionOids = new Vector();
- extensionOids.addAll(pemCert.getCriticalExtensionOIDs());
- extensionOids.addAll(pemCert.getNonCriticalExtensionOIDs());
- Iterator i = extensionOids.iterator();
- while (i.hasNext()) {
- String oid = (String) i.next();
- byte[] value = pemCert.getExtensionValue(oid);
- if (value != null && value.length > 0) {
- // check that it is an encoded as a OCTET STRING
- assertTrue("The extension value for the oid " + oid
- + " was not encoded as an OCTET STRING",
- value[0] == 0x04);
- }
- }// end while
- } else {
- fail("Unable to obtain X509Certificate");
- }
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntry2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntry2Test.java
deleted file mode 100644
index d32c1fd..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntry2Test.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.InputStream;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.Iterator;
-import java.util.Vector;
-
-import tests.support.resource.Support_Resources;
-
-import junit.framework.TestCase;
-
-public class X509CRLEntry2Test extends junit.framework.TestCase {
-
- private X509Certificate pemCert = null;
-
- protected void setUp() throws Exception {
-
- InputStream is = Support_Resources
- .getResourceStream("hyts_certificate_PEM.txt");
-
- CertificateFactory certFact = CertificateFactory.getInstance("X509");
- pemCert = (X509Certificate) certFact.generateCertificate(is);
- }
-
- /**
- * @tests java.security.cert.X509CRLEntry#getExtensionValue(java.lang.String)
- */
- public void test_getExtensionValueLjava_lang_String() {
- if (pemCert != null) {
- Vector extensionOids = new Vector();
- extensionOids.addAll(pemCert.getCriticalExtensionOIDs());
- extensionOids.addAll(pemCert.getNonCriticalExtensionOIDs());
- Iterator i = extensionOids.iterator();
- while (i.hasNext()) {
- String oid = (String) i.next();
- byte[] value = pemCert.getExtensionValue(oid);
- if (value != null && value.length > 0) {
- // check that it is an encoded as a OCTET STRING
- assertTrue("The extension value for the oid " + oid
- + " was not encoded as an OCTET STRING",
- value[0] == 0x04);
- }
- }// end while
- } else {
- fail("Unable to obtain X509Certificate");
- }
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntryTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntryTest.java
deleted file mode 100644
index 6e7257d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntryTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.math.BigInteger;
-import java.security.cert.CRLException;
-import java.security.cert.X509CRLEntry;
-import java.util.Date;
-import java.util.Set;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class X509CRLEntryTest extends TestCase {
-
- X509CRLEntry tbt_crlentry;
-
- /**
- * The stub class used for testing of non abstract methods.
- */
- private class TBTCRLEntry extends X509CRLEntry {
- public Set getNonCriticalExtensionOIDs() {
- return null;
- }
-
- public Set getCriticalExtensionOIDs() {
- return null;
- }
-
- public byte[] getExtensionValue(String oid) {
- return null;
- }
-
- public boolean hasUnsupportedCriticalExtension() {
- return false;
- }
-
- public byte[] getEncoded() throws CRLException {
- return null;
- }
-
- public BigInteger getSerialNumber() {
- return null;
- }
-
- public Date getRevocationDate() {
- return null;
- }
-
- public boolean hasExtensions() {
- return false;
- }
-
- public String toString() {
- return null;
- }
- }
-
- public X509CRLEntryTest() {
- tbt_crlentry = new TBTCRLEntry() {
- public byte[] getEncoded() throws CRLException {
- return new byte[] { 1, 2, 3 };
- }
- };
- }
-
- /**
- * equals(Object other) method testing. Tests the correctness of equal
- * operation: it should be reflexive, symmetric, transitive, consistent
- * and should be false on null object.
- */
- public void testEquals() {
- TBTCRLEntry tbt_crlentry_1 = new TBTCRLEntry() {
- public byte[] getEncoded() {
- return new byte[] { 1, 2, 3 };
- }
- };
-
- TBTCRLEntry tbt_crlentry_2 = new TBTCRLEntry() {
- public byte[] getEncoded() {
- return new byte[] { 1, 2, 3 };
- }
- };
-
- TBTCRLEntry tbt_crlentry_3 = new TBTCRLEntry() {
- public byte[] getEncoded() {
- return new byte[] { 3, 2, 1 };
- }
- };
-
- // checking for reflexive law:
- assertTrue("The equivalence relation should be reflexive.",
- tbt_crlentry.equals(tbt_crlentry));
-
- assertEquals("The CRL Entries with equals encoded form should be equal",
- tbt_crlentry, tbt_crlentry_1);
- // checking for symmetric law:
- assertTrue("The equivalence relation should be symmetric.",
- tbt_crlentry_1.equals(tbt_crlentry));
-
- assertEquals("The CRL Entries with equals encoded form should be equal",
- tbt_crlentry_1, tbt_crlentry_2);
- // checking for transitive law:
- assertTrue("The equivalence relation should be transitive.",
- tbt_crlentry.equals(tbt_crlentry_2));
-
- assertFalse("Should not be equal to null object.",
- tbt_crlentry.equals(null));
-
- assertFalse("The CRL Entries with differing encoded form "
- + "should not be equal.",
- tbt_crlentry.equals(tbt_crlentry_3));
- assertFalse("The CRL Entries should not be equals to the object "
- + "which is not an instance of X509CRLEntry.",
- tbt_crlentry.equals(new Object()));
- }
-
- /**
- * hashCode() method testing. Tests that for equal objects hash codes
- * are equal.
- */
- public void testHashCode() {
- TBTCRLEntry tbt_crlentry_1 = new TBTCRLEntry() {
- public byte[] getEncoded() {
- return new byte[] { 1, 2, 3 };
- }
- };
- assertTrue("Equal objects should have the same hash codes.",
- tbt_crlentry.hashCode() == tbt_crlentry_1.hashCode());
- }
-
- /**
- * getCertificateIssuer() method testing. Tests if the method throws
- * appropriate exception.
- */
- public void testGetCertificateIssuer() {
- assertNull("The default implementation should return null.",
- tbt_crlentry.getCertificateIssuer());
- }
-
- public static Test suite() {
- return new TestSuite(X509CRLEntryTest.class);
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLSelectorTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLSelectorTest.java
deleted file mode 100644
index 4770267..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLSelectorTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.IOException;
-import java.security.cert.X509CRLSelector;
-import java.util.Iterator;
-import java.util.TreeSet;
-
-import javax.security.auth.x500.X500Principal;
-
-import junit.framework.TestCase;
-
-/**
- */
-
-public class X509CRLSelectorTest extends TestCase {
-
- /**
- * @tests java.security.cert.X509CRLSelector#addIssuer(javax.security.auth.x500.X500Principal)
- */
- public void test_addIssuerLjavax_security_auth_x500_X500Principal()
- throws Exception {
- //Regression for HARMONY-465
- X509CRLSelector obj = new X509CRLSelector();
- try {
- obj.addIssuer((X500Principal) null);
- fail("NullPointerException expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- /**
- * @tests java.security.cert.X509CRLSelector#addIssuerName(java.lang.String)
- */
- public void test_addIssuerNameLjava_lang_String() throws Exception {
- //Regression for HARMONY-465
- X509CRLSelector obj = new X509CRLSelector();
- try {
- obj.addIssuerName("234");
- fail("IOException expected");
- } catch (IOException e) {
- // expected
- }
-
- // Regression for HARMONY-1076
- try {
- new X509CRLSelector().addIssuerName("w=y");
- fail("IOException expected");
- } catch (IOException e) {
- // expected
- }
- }
-
- /**
- * @tests java.security.cert.X509CRLSelector#addIssuerName(byte[])
- */
- public void test_addIssuerName$B_3() throws Exception {
- //Regression for HARMONY-465
- X509CRLSelector obj = new X509CRLSelector();
- try {
- obj.addIssuerName(new byte[] { (byte) 2, (byte) 3, (byte) 4 });
- fail("IOException expected");
- } catch (IOException e) {
- // expected
- }
- }
-
- /**
- * @tests java.security.cert.X509CRLSelector#addIssuerName(byte[])
- */
- public void test_addIssuerName$B_4() throws Exception {
- //Regression for HARMONY-465
- X509CRLSelector obj = new X509CRLSelector();
- try {
- obj.addIssuerName((byte[]) null);
- fail("NullPointerException expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- /**
- * @tests addIssuerName(String name)
- */
- public void testAddIssuerName() throws IOException {
- //Regression for HARMONY-736
- X509CRLSelector selector = new X509CRLSelector();
- try {
- selector.addIssuerName("a");
- fail("IOException expected");
- } catch (IOException e) {
- }
-
- //no exception for null
- selector.addIssuerName((String) null);
- }
-
- /**
- * @tests setIssuerNames(Collection <?> names)
- */
- public void testSetIssuerNames1() throws IOException {
- // Regression for HARMONY-737
- X509CRLSelector selector = new X509CRLSelector();
- selector.setIssuerNames(new TreeSet() {
- public Iterator iterator() {
- return null;
- }
- });
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLTest.java
deleted file mode 100644
index 284bcff..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLTest.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Principal;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.cert.CRLException;
-import java.security.cert.Certificate;
-import java.security.cert.X509CRL;
-import java.security.cert.X509CRLEntry;
-import java.security.cert.X509Certificate;
-import java.util.Date;
-import java.util.Set;
-
-import javax.security.auth.x500.X500Principal;
-
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class X509CRLTest extends TestCase {
-
- private X509CRL tbt_crl;
-
- /**
- * The stub class used for testing of non abstract methods.
- */
- private class TBTCRL extends X509CRL {
- public String toString() {
- return null;
- }
-
- public boolean isRevoked(Certificate cert) {
- return true;
- }
-
- public Set getNonCriticalExtensionOIDs() {
- return null;
- }
-
- public Set getCriticalExtensionOIDs() {
- return null;
- }
-
- public byte[] getExtensionValue(String oid) {
- return null;
- }
-
- public boolean hasUnsupportedCriticalExtension() {
- return false;
- }
-
- public byte[] getEncoded() {
- return null;
- }
-
- public void verify(PublicKey key)
- throws CRLException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- }
-
- public void verify(PublicKey key, String sigProvider)
- throws CRLException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- }
-
- public int getVersion() {
- return 2;
- }
-
- public Principal getIssuerDN() {
- return null;
- }
-
- public Date getThisUpdate() {
- return null;
- }
-
- public Date getNextUpdate() {
- return null;
- }
-
- public X509CRLEntry getRevokedCertificate(BigInteger serialNumber) {
- return null;
- }
-
- public Set getRevokedCertificates() {
- return null;
- }
-
- public byte[] getTBSCertList() {
- return null;
- }
-
- public byte[] getSignature() {
- return null;
- }
-
- public String getSigAlgName() {
- return null;
- }
-
- public String getSigAlgOID() {
- return null;
- }
-
- public byte[] getSigAlgParams() {
- return null;
- }
- }
-
-
- public X509CRLTest() {
- tbt_crl = new TBTCRL() {
- public byte[] getEncoded() {
- return new byte[] { 1, 2, 3 };
- }
- };
- }
-
- /**
- * getType() method testing. Tests that getType() method returns
- * the value "X.509"
- */
- public void testGetType() {
- assertEquals("The type of X509CRL should be X.509",
- tbt_crl.getType(), "X.509");
- }
-
- /**
- * equals(Object other) method testing. Tests the correctness of equal
- * operation: it should be reflexive, symmetric, transitive, consistent
- * and should be false on null object.
- */
- public void testEquals() {
- TBTCRL tbt_crl_1 = new TBTCRL() {
- public byte[] getEncoded() {
- return new byte[] { 1, 2, 3 };
- }
- };
-
- TBTCRL tbt_crl_2 = new TBTCRL() {
- public byte[] getEncoded() {
- return new byte[] { 1, 2, 3 };
- }
- };
-
- TBTCRL tbt_crl_3 = new TBTCRL() {
- public byte[] getEncoded() {
- return new byte[] { 3, 2, 1 };
- }
- };
-
- // checking for reflexive law:
- assertTrue("The equivalence relation should be reflexive.",
- tbt_crl.equals(tbt_crl));
-
- assertEquals("The CRLs with equal encoded form should be equal",
- tbt_crl, tbt_crl_1);
- // checking for symmetric law:
- assertTrue("The equivalence relation should be symmetric.",
- tbt_crl_1.equals(tbt_crl));
-
- assertEquals("The CRLs with equal encoded form should be equal",
- tbt_crl_1, tbt_crl_2);
- // checking for transitive law:
- assertTrue("The equivalence relation should be transitive.",
- tbt_crl.equals(tbt_crl_2));
-
- assertFalse("Should not be equal to null object.",
- tbt_crl.equals(null));
-
- assertFalse("The CRLs with differing encoded form should not be equal",
- tbt_crl.equals(tbt_crl_3));
- assertFalse("The CRL should not be equals to the object which is not "
- + "an instance of X509CRL", tbt_crl.equals(new Object()));
- }
-
- /**
- * hashCode() method testing. Tests that for equal objects hash codes
- * are equal.
- */
- public void testHashCode() {
- TBTCRL tbt_crl_1 = new TBTCRL() {
- public byte[] getEncoded() {
- return new byte[] { 1, 2, 3 };
- }
- };
- assertTrue("Equal objects should have the same hash codes.",
- tbt_crl.hashCode() == tbt_crl_1.hashCode());
- }
-
- /**
- * @tests java.security.cert.X509CRL#getIssuerX500Principal()
- */
- public void testGetIssuerX500Principal() {
- // return valid encoding
- TBTCRL crl = new TBTCRL() {
- public byte[] getEncoded() {
- return TestUtils.getX509CRL_v1();
- }
-
- ;
- };
-
- assertEquals(new X500Principal("CN=Z"), crl.getIssuerX500Principal());
- }
-
- /**
- * getRevokedCertificate(X509Certificate certificate) method testing.
- * Check if the default implementation throws NullPointerException
- * on null input data.
- */
- public void testGetRevokedCertificate() {
- try {
- tbt_crl.getRevokedCertificate((X509Certificate) null);
- fail("NullPointerException should be thrown "
- + "in the case of null input data.");
- } catch (NullPointerException e) {
- }
- }
-
- public static Test suite() {
- return new TestSuite(X509CRLTest.class);
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CertSelectorTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CertSelectorTest.java
deleted file mode 100644
index c2d8366..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CertSelectorTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.IOException;
-import java.security.PublicKey;
-import java.security.cert.X509CertSelector;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * X509CertSelectorTest
- */
-public class X509CertSelectorTest extends TestCase {
-
- /**
- * @tests java.security.cert.X509CertSelector#addSubjectAlternativeName(int, byte[])
- */
- public void test_addSubjectAlternativeNameLintLbyte_array() throws IOException {
- // Regression for HARMONY-2487
- int[] types = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
- for (int i = 0; i < types.length; i++) {
- try {
- new X509CertSelector().addSubjectAlternativeName(types[i],
- (byte[]) null);
- fail("No expected NullPointerException for type: " + types[i]);
- } catch (NullPointerException e) {
- }
- }
- }
-
- /**
- * @tests java.security.cert.X509CertSelector#addSubjectAlternativeName(int, String)
- */
- public void test_addSubjectAlternativeNameLintLjava_lang_String() throws IOException {
- // Regression for HARMONY-727
- int[] types = { 0, 3, 4, 5, 6, 7, 8 };
- for (int i = 0; i < types.length; i++) {
- try {
- new X509CertSelector().addSubjectAlternativeName(types[i],
- "0xDFRF");
- fail("IOException expected for type: " + types[i]);
- } catch (IOException e) {
- }
- }
- // Tests for DNSGeneralName
- // Legal DNS names
- new X509CertSelector().addSubjectAlternativeName(2, "0xDFRF");
- new X509CertSelector().addSubjectAlternativeName(2, "");
- new X509CertSelector().addSubjectAlternativeName(2, "foo.example.com");
- new X509CertSelector().addSubjectAlternativeName(2, "3g.example.com");
- new X509CertSelector().addSubjectAlternativeName(2, "*.example.com");
- // Illegal DNS names
- String[] names = new String[] { "*", "*.", "%anything" };
- for (String badName : names) {
- try {
- new X509CertSelector().addSubjectAlternativeName(2, badName);
- fail("IOException expected for DNS name " + badName);
- } catch (IOException e) {
- // Expected
- }
- }
- }
-
- /**
- * @tests java.security.cert.X509CertSelector#addPathToName(int, byte[])
- */
- public void test_addPathToNameLintLbyte_array() throws IOException {
- // Regression for HARMONY-2487
- int[] types = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
- for (int i = 0; i < types.length; i++) {
- try {
- new X509CertSelector().addPathToName(types[i], (byte[]) null);
- fail("No expected NullPointerException for type: " + types[i]);
- } catch (NullPointerException e) {
- }
- }
- }
-
- /**
- * @tests java.security.cert.X509CertSelector#addPathToName(int, String)
- */
- public void test_addPathToNameLintLjava_lang_String() {
- // Regression for HARMONY-724
- for (int type = 0; type <= 8; type++) {
- try {
- new X509CertSelector().addPathToName(type, (String) null);
- fail("IOException expected for type: " + type);
- } catch (IOException ioe) {
- // expected
- }
- }
- }
-
- /**
- * @tests java.security.cert.X509CertSelector#setSubjectPublicKey(byte[])
- */
- public void test_setSubjectPublicKeyLB$() throws Exception {
-
- //SubjectPublicKeyInfo ::= SEQUENCE {
- // algorithm AlgorithmIdentifier,
- // subjectPublicKey BIT STRING }
- byte[] enc = { 0x30, 0x0E, // SEQUENCE
- 0x30, 0x07, // SEQUENCE
- 0x06, 0x02, 0x03, 0x05,//OID
- 0x01, 0x01, 0x07, //ANY
- 0x03, 0x03, 0x01, 0x01, 0x06, // subjectPublicKey
- };
-
- X509CertSelector selector = new X509CertSelector();
-
- selector.setSubjectPublicKey(enc);
- PublicKey key = selector.getSubjectPublicKey();
- assertEquals("0.3.5", key.getAlgorithm());
- assertEquals("X.509", key.getFormat());
- assertTrue(Arrays.equals(enc, key.getEncoded()));
- assertNotNull(key.toString());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509Certificate2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509Certificate2Test.java
deleted file mode 100644
index 156b532..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509Certificate2Test.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import tests.support.resource.Support_Resources;
-
-public class X509Certificate2Test extends junit.framework.TestCase {
-
- /**
- * @tests java.security.cert.X509Certificate#getExtensionValue(java.lang.String)
- */
- public void test_getExtensionValueLjava_lang_String() throws Exception {
-
- InputStream is = Support_Resources
- .getResourceStream("hyts_certificate_PEM.txt");
-
- CertificateFactory certFact = CertificateFactory.getInstance("X509");
- X509Certificate pemCert = (X509Certificate) certFact
- .generateCertificate(is);
-
- Vector<String> extensionOids = new Vector<String>();
- extensionOids.addAll(pemCert.getCriticalExtensionOIDs());
- extensionOids.addAll(pemCert.getNonCriticalExtensionOIDs());
- Iterator i = extensionOids.iterator();
- while (i.hasNext()) {
- String oid = (String) i.next();
- byte[] value = pemCert.getExtensionValue(oid);
- if (value != null && value.length > 0) {
- // check that it is an encoded as a OCTET STRING
- assertEquals("The extension value for the oid " + oid
- + " was not encoded as an OCTET STRING", 0x04, value[0]);
- }
- }
- }
-
- /**
- * Test for X.509 Certificate provider
- */
- public void test_toString() throws Exception {
-
- // Regression for HARMONY-3384
- CertificateFactory certFact = CertificateFactory.getInstance("X509");
- X509Certificate pemCert = (X509Certificate) certFact
- .generateCertificate(new ByteArrayInputStream(TestUtils
- .getX509Certificate_v3()));
-
- // extension value is empty sequence
- byte[] extnValue = pemCert.getExtensionValue("2.5.29.35");
- assertTrue(Arrays.equals(new byte[] { 0x04, 0x02, 0x30, 0x00 },
- extnValue));
- assertNotNull(pemCert.toString());
- // End regression for HARMONY-3384
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.java
deleted file mode 100644
index 003e2a6..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert.serialization;
-
-import java.security.cert.CRLException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CRLException serialization
- */
-
-public class CRLExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- CRLException dExc = new CRLException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new CRLException(), new CRLException(msg),
- new CRLException(msgs[1]),
- new CRLException(new Throwable()), new CRLException(th),
- new CRLException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.java
deleted file mode 100644
index 887a91e..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert.serialization;
-
-import java.security.cert.CertPathBuilderException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertPathBuilderException serialization
- */
-
-public class CertPathBuilderExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- CertPathBuilderException dExc = new CertPathBuilderException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new CertPathBuilderException(), new CertPathBuilderException(msg),
- new CertPathBuilderException(msgs[1]),
- new CertPathBuilderException(new Throwable()), new CertPathBuilderException(th),
- new CertPathBuilderException(msgs[1], dExc) };
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.java
deleted file mode 100644
index a324e8c..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert.serialization;
-
-import java.io.ObjectStreamException;
-import java.security.cert.CertPath;
-import java.security.cert.CertificateFactory;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.cert.MyCertPath;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-import tests.support.resource.Support_Resources;
-
-/**
- * Tests for <code>CertPath</code> serialization
- */
-public class CertPathTest extends TestCase {
-
- //Certificate/CertPath type to be created during testing
- private static final String certType = "X.509";
-
- //Input file name used for <code>CertPath</code> instance generation
- private static final String certPathFileName = "java/security/cert/CertPath.PkiPath";
-
- //
- // Tests
- //
-
- /**
- * @tests serialization/deserialization.
- */
- public void testSerializationSelf() throws Exception {
-
- CertificateFactory cf = CertificateFactory.getInstance(certType);
-
- CertPath certPath = cf.generateCertPath(Support_Resources
- .getResourceStream(certPathFileName));
-
- SerializationTest.verifySelf(certPath);
- }
-
- /**
- * @tests serialization/deserialization compatibility with RI.
- */
- public void testSerializationCompatibility() throws Exception {
-
- CertificateFactory cf = CertificateFactory.getInstance(certType);
-
- CertPath certPath = cf.generateCertPath(Support_Resources
- .getResourceStream(certPathFileName));
-
- SerializationTest.verifyGolden(this, certPath);
- }
-
- /**
- * Test for <code>CertPath.CertPathRep.readResolve()</code> method<br>
- * <p/>
- * Assertion: ObjectStreamException if a <code>CertPath</code>
- * could not be constructed
- */
- public final void testCertPathRep_readResolve() throws Exception {
-
- // Create object to be serialized
- CertPath cp1 = new MyCertPath(new byte[] { (byte) 0, (byte) 1 });
-
- // try to serialize/deserialize cert
- try {
- SerializationTest.copySerializable(cp1);
- fail("No expected ObjectStreamException");
- } catch (ObjectStreamException e) {
- }
- }
-
- /**
- * Test for <code>writeReplace()</code> method<br>
- * ByteArray streams used.
- */
- public final void testWriteReplace() throws Exception {
- // Create object to be serialized
- // set encoded form to null
- CertPath cp1 = new MyCertPath(null);
- // Try to serialize cert
- // writeReplace() must fail with exception
- // (both OSE and NPE are possible)
- try {
- SerializationTest.copySerializable(cp1);
- fail("No exception");
- } catch (ObjectStreamException e) {
- } catch (NullPointerException e) {
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.java
deleted file mode 100644
index a9997f5..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert.serialization;
-
-import java.io.Serializable;
-import java.security.cert.CertPath;
-import java.security.cert.CertPathValidatorException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertPathValidatorException serialization
- */
-
-public class CertPathValidatorExceptionTest extends SerializationTest implements
- SerializationTest.SerializableAssert {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- CertPathValidatorException dExc = new CertPathValidatorException(
- msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new CertPathValidatorException(),
- new CertPathValidatorException(msg),
- new CertPathValidatorException(msgs[1]),
- new CertPathValidatorException(new Throwable()),
- new CertPathValidatorException(th),
- new CertPathValidatorException(msgs[1], dExc),
- new CertPathValidatorException(msgs[1], dExc, null, -1) };
- }
-
- public void assertDeserialized(Serializable oref, Serializable otest) {
-
- // common checks
- THROWABLE_COMPARATOR.assertDeserialized(oref, otest);
-
- // class specific checks
- CertPathValidatorException ref = (CertPathValidatorException) oref;
- CertPathValidatorException test = (CertPathValidatorException) otest;
- CertPath cp = ref.getCertPath();
- int ind = ref.getIndex();
- assertEquals("Incorrect index", test.getIndex(), ind);
- if (cp == null) {
- assertNull("getCertPath() must return null", test.getCertPath());
- } else {
- CertPath res = test.getCertPath();
- assertEquals("Incorrect CertPath", res.getClass(), cp.getClass());
- }
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.java
deleted file mode 100644
index 3538077..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert.serialization;
-
-import java.security.cert.CertStoreException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertStoreException serialization
- */
-
-public class CertStoreExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- CertStoreException dExc = new CertStoreException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new CertStoreException(), new CertStoreException(msg),
- new CertStoreException(msgs[1]),
- new CertStoreException(new Throwable()), new CertStoreException(th),
- new CertStoreException(msgs[1], dExc) };
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.java
deleted file mode 100644
index 469b9a6..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert.serialization;
-
-import java.security.cert.CertificateEncodingException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertificateEncodingException serialization
- */
-
-public class CertificateEncodingExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- CertificateEncodingException dExc = new CertificateEncodingException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new CertificateEncodingException(), new CertificateEncodingException(msg),
- new CertificateEncodingException(msgs[1]),
- new CertificateEncodingException(new Throwable()), new CertificateEncodingException(th),
- new CertificateEncodingException(msgs[1], dExc) };
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.java
deleted file mode 100644
index db2332a..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert.serialization;
-
-import java.security.cert.CertificateException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertificateException serialization
- */
-
-public class CertificateExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- CertificateException dExc = new CertificateException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new CertificateException(), new CertificateException(msg),
- new CertificateException(msgs[1]),
- new CertificateException(new Throwable()), new CertificateException(th),
- new CertificateException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.java
deleted file mode 100644
index 2e2025c..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert.serialization;
-
-import java.security.cert.CertificateExpiredException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertificateExpiredException serialization
- */
-
-public class CertificateExpiredExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
-
- return new Object[] { new CertificateExpiredException(),
- new CertificateExpiredException(null),
- new CertificateExpiredException(msgs[1]) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.java
deleted file mode 100644
index 024328b..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert.serialization;
-
-import java.security.cert.CertificateNotYetValidException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertificateNotYetValidException serialization
- */
-
-public class CertificateNotYetValidExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new CertificateNotYetValidException(),
- new CertificateNotYetValidException(null),
- new CertificateNotYetValidException(msgs[1]) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.java
deleted file mode 100644
index 25eb225..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert.serialization;
-
-import java.security.cert.CertificateParsingException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertificateParsingException serialization
- */
-
-public class CertificateParsingExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- CertificateParsingException dExc = new CertificateParsingException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new CertificateParsingException(), new CertificateParsingException(msg),
- new CertificateParsingException(msgs[1]),
- new CertificateParsingException(new Throwable()), new CertificateParsingException(th),
- new CertificateParsingException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java
deleted file mode 100644
index b25ec4d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert.serialization;
-
-import java.io.ByteArrayInputStream;
-import java.io.ObjectStreamException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateFactory;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.cert.MyCertificate;
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-/**
- * Tests for <code>Certificate</code> serialization
- */
-public class CertificateTest extends TestCase {
-
- // certificate type to be created during testing
- private static final String certType = "X.509";
-
- /**
- * @tests serialization/deserialization.
- */
- public void testSerializationSelf() throws Exception {
-
- CertificateFactory cf = CertificateFactory.getInstance(certType);
-
- Certificate cert = cf.generateCertificate(new ByteArrayInputStream(
- TestUtils.getEncodedX509Certificate()));
-
- SerializationTest.verifySelf(cert);
- }
-
- /**
- * @tests serialization/deserialization compatibility with RI.
- */
- public void testSerializationCompatibility() throws Exception {
-
- CertificateFactory cf = CertificateFactory.getInstance(certType);
-
- Certificate cert = cf.generateCertificate(new ByteArrayInputStream(
- TestUtils.getEncodedX509Certificate()));
-
- SerializationTest.verifyGolden(this, cert);
- }
-
- /**
- * Test for <code>Certificate.CertificateRep.readResolve()</code> method<br>
- * <p/>
- * Assertion: ObjectStreamException if a <code>CertPath</code> could not
- * be constructed
- */
- public final void testCertificateRep_readResolve() throws Exception {
- // Create object to be serialized
- Certificate c1 = new MyCertificate("DUMMY", new byte[] { (byte) 0, (byte) 1 });
-
- // try to serialize/deserialize cert
- try {
- SerializationTest.copySerializable(c1);
- fail("No expected ObjectStreamException");
- } catch (ObjectStreamException e) {
- }
- }
-
- /**
- * Test for <code>writeReplace()</code> method<br>
- * ByteArray streams used.
- */
- public final void testWriteReplace() throws Exception {
- // Create object to be serialized
- Certificate c1 = new MyCertificate("DUMMY", null);
-
- // Try to serialize cert
- try {
- SerializationTest.copySerializable(c1);
- fail("No exception");
- } catch (ObjectStreamException e) {
- } catch (NullPointerException e) {
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPrivateKeyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPrivateKeyTest.java
deleted file mode 100644
index 27adcb9..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPrivateKeyTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.interfaces;
-
-
-import java.math.BigInteger;
-import java.security.interfaces.DSAParams;
-import java.security.interfaces.DSAPrivateKey;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>DSAPrivateKey</code> class field
- */
-public class DSAPrivateKeyTest extends TestCase {
-
- /**
- * Constructor for DSAPrivateKeyTest.
- *
- * @param arg0
- */
- public DSAPrivateKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkDSAPrivateKey k = new checkDSAPrivateKey();
- assertEquals("Incorrect serialVersionUID",
- k.getSerVerUID(), //DSAPrivateKey.serialVersionUID
- 7776497482533790279L);
- }
-
- public class checkDSAPrivateKey implements DSAPrivateKey {
- public String getAlgorithm() {
- return "DSAPrivateKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
-
- public BigInteger getX() {
- return null;
- }
-
- public DSAParams getParams() {
- return null;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPublicKeyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPublicKeyTest.java
deleted file mode 100644
index aa6a270..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPublicKeyTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.interfaces;
-
-
-import java.math.BigInteger;
-import java.security.interfaces.DSAParams;
-import java.security.interfaces.DSAPublicKey;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>DSAPublicKey</code> class field
- */
-public class DSAPublicKeyTest extends TestCase {
-
- /**
- * Constructor for DSAPublicKeyTest.
- *
- * @param arg0
- */
- public DSAPublicKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkDSAPublicKey k = new checkDSAPublicKey();
- assertEquals("Incorrect serialVersionUID",
- k.getSerVerUID(), //DSAPublicKey.serialVersionUID
- 1234526332779022332L);
- }
-
- public class checkDSAPublicKey implements DSAPublicKey {
- public String getAlgorithm() {
- return "DSAPublicKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
-
- public BigInteger getY() {
- return null;
- }
-
- public DSAParams getParams() {
- return null;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPrivateKeyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPrivateKeyTest.java
deleted file mode 100644
index 259ca81..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPrivateKeyTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.interfaces;
-
-
-import java.math.BigInteger;
-import java.security.interfaces.ECPrivateKey;
-import java.security.spec.ECParameterSpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ECPrivateKey</code> class field
- */
-public class ECPrivateKeyTest extends TestCase {
-
- /**
- * Constructor for ECPrivateKeyTest.
- *
- * @param arg0
- */
- public ECPrivateKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkECPrivateKey k = new checkECPrivateKey();
- assertEquals("Incorrect serialVersionUID",
- k.getSerVerUID(), //ECPrivateKey.serialVersionUID
- -7896394956925609184L);
- }
-
- public class checkECPrivateKey implements ECPrivateKey {
- public String getAlgorithm() {
- return "ECPrivateKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public BigInteger getS() {
- return null;
- }
-
- public ECParameterSpec getParams() {
- return null;
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPublicKeyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPublicKeyTest.java
deleted file mode 100644
index dcc1949..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPublicKeyTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.interfaces;
-
-
-import java.security.spec.ECPoint;
-import java.security.interfaces.ECPublicKey;
-import java.security.spec.ECParameterSpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ECPublicKey</code> class field
- */
-public class ECPublicKeyTest extends TestCase {
-
- /**
- * Constructor for ECPublicKeyTest.
- *
- * @param arg0
- */
- public ECPublicKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkECPublicKey key = new checkECPublicKey();
- assertEquals("Incorrect serialVersionUID",
- key.getSerVerUID(), // ECPublicKey.serialVersionUID
- -3314988629879632826L);
- }
-
- public class checkECPublicKey implements ECPublicKey {
- public String getAlgorithm() {
- return "ECPublicKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public ECPoint getW() {
- return null;
- }
-
- public ECParameterSpec getParams() {
- return null;
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAMultiPrimePrivateCrtKeyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAMultiPrimePrivateCrtKeyTest.java
deleted file mode 100644
index 10d132e..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAMultiPrimePrivateCrtKeyTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.interfaces;
-
-
-import java.math.BigInteger;
-import java.security.interfaces.RSAMultiPrimePrivateCrtKey;
-import java.security.spec.RSAOtherPrimeInfo;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>RSAMultiPrimePrivateCrtKey</code> class field
- */
-public class RSAMultiPrimePrivateCrtKeyTest extends TestCase {
-
- /**
- * Constructor for RSAMultiPrimePrivateCrtKeyTest.
- *
- * @param arg0
- */
- public RSAMultiPrimePrivateCrtKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkCrtKey k = new checkCrtKey();
- assertEquals("Incorrect serialVersionUID",
- k.getSerVerUID(), //RSAMultiPrimePrivateCrtKey.serialVersionUID
- 618058533534628008L);
- }
-
- public class checkCrtKey implements RSAMultiPrimePrivateCrtKey {
- public BigInteger getModulus() {
- return null;
- }
-
- public BigInteger getPrivateExponent() {
- return null;
- }
-
- public BigInteger getCrtCoefficient() {
- return null;
- }
-
- public RSAOtherPrimeInfo[] getOtherPrimeInfo() {
- return null;
- }
-
- public BigInteger getPrimeP() {
- return null;
- }
-
- public BigInteger getPrimeQ() {
- return null;
- }
-
- public BigInteger getPrimeExponentP() {
- return null;
- }
-
- public BigInteger getPrimeExponentQ() {
- return null;
- }
-
- public BigInteger getPublicExponent() {
- return null;
- }
-
- public String getAlgorithm() {
- return "ECPublicKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateCrtKeyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateCrtKeyTest.java
deleted file mode 100644
index 83b3926..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateCrtKeyTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.interfaces;
-
-
-import java.math.BigInteger;
-import java.security.interfaces.RSAPrivateCrtKey;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>RSAPrivateCrtKey</code> class field
- */
-public class RSAPrivateCrtKeyTest extends TestCase {
-
- /**
- * Constructor for RSAPrivateCrtKeyTest.
- *
- * @param arg0
- */
- public RSAPrivateCrtKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkRSAPrivateCrtKey key = new checkRSAPrivateCrtKey();
- assertEquals("Incorrect serialVersionUID",
- key.getSerVerUID(), //RSAPrivateCrtKey.serialVersionUID
- -5682214253527700368L);
- }
-
- public class checkRSAPrivateCrtKey implements RSAPrivateCrtKey {
- public String getAlgorithm() {
- return "RSAPrivateCrtKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
-
- public BigInteger getCrtCoefficient() {
- return null;
- }
-
- public BigInteger getPrimeP() {
- return null;
- }
-
- public BigInteger getPrimeQ() {
- return null;
- }
-
- public BigInteger getPrimeExponentP() {
- return null;
- }
-
- public BigInteger getPrimeExponentQ() {
- return null;
- }
-
- public BigInteger getPublicExponent() {
- return null;
- }
-
- public BigInteger getModulus() {
- return null;
- }
-
- public BigInteger getPrivateExponent() {
- return null;
- }
-
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateKeyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateKeyTest.java
deleted file mode 100644
index 807d96e..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateKeyTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.interfaces;
-
-
-import java.math.BigInteger;
-import java.security.interfaces.RSAPrivateKey;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>RSAPrivateKey</code> class field
- */
-public class RSAPrivateKeyTest extends TestCase {
-
- /**
- * Constructor for RSAPrivateKeyTest.
- *
- * @param arg0
- */
- public RSAPrivateKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkRSAPrivateKey key = new checkRSAPrivateKey();
- assertEquals("Incorrect serialVersionUID",
- key.getSerVerUID(), //RSAPrivateKey.serialVersionUID,
- 5187144804936595022L);
- }
-
- public class checkRSAPrivateKey implements RSAPrivateKey {
- public String getAlgorithm() {
- return "RSAPrivateKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
-
- public BigInteger getPrivateExponent() {
- return null;
- }
-
- public BigInteger getModulus() {
- return null;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPublicKeyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPublicKeyTest.java
deleted file mode 100644
index 8d52c1d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPublicKeyTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.interfaces;
-
-
-import java.math.BigInteger;
-import java.security.interfaces.RSAPublicKey;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>RSAPublicKey</code> class field
- */
-public class RSAPublicKeyTest extends TestCase {
-
- /**
- * Constructor for RSAPublicKeyTest.
- *
- * @param arg0
- */
- public RSAPublicKeyTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>serialVersionUID</code> field
- */
- public void testField() {
- checkRSAPublicKey key = new checkRSAPublicKey();
- assertEquals("Incorrect serialVersionUID",
- key.getSerVerUID(), //RSAPublicKey.serialVersionUID
- -8727434096241101194L);
- }
-
- public class checkRSAPublicKey implements RSAPublicKey {
- public String getAlgorithm() {
- return "RSAPublicKey";
- }
-
- public String getFormat() {
- return "Format";
- }
-
- public byte[] getEncoded() {
- return new byte[0];
- }
-
- public long getSerVerUID() {
- return serialVersionUID;
- }
-
- public BigInteger getModulus() {
- return null;
- }
-
- public BigInteger getPublicExponent() {
- return null;
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.java
deleted file mode 100644
index 3fdc806..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.io.Serializable;
-import java.security.AccessControlException;
-import java.security.AllPermission;
-import java.security.Permission;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Serialization tests for <code>AccessControlException</code>
- */
-
-public class AccessControlExceptionTest extends SerializationTest implements
- SerializationTest.SerializableAssert {
-
- protected Object[] getData() {
- AllPermission allperms = new AllPermission();
- return new Object[] { new AccessControlException(null),
- new AccessControlException("string1"),
- new AccessControlException(null, null),
- new AccessControlException("string2", allperms) };
- }
-
- public void assertDeserialized(Serializable oref, Serializable otest) {
-
- // common checks
- THROWABLE_COMPARATOR.assertDeserialized(oref, otest);
-
- // class specific checks
- AccessControlException ref = (AccessControlException) oref;
- AccessControlException test = (AccessControlException) otest;
- Permission p = ref.getPermission();
- if (p == null) {
- assertNull(test.getPermission());
- } else {
- assertEquals(p, test.getPermission());
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.java
deleted file mode 100644
index d793445..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.CodeSigner;
-import java.security.Timestamp;
-import java.security.cert.CertPath;
-import java.util.Date;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.security.tests.support.TestCertUtils;
-
-
-/**
- * Serialization tests for <code>CodeSigner</code>
- */
-
-public class CodeSignerTest extends SerializationTest {
-
- /**
- * @see com.intel.drl.test.SerializationTest#getData()
- */
- protected Object[] getData() {
- CertPath cpath = TestCertUtils.getCertPath();
- Timestamp ts = new Timestamp(new Date(1146633204309L), cpath);
- return new Object[] { new CodeSigner(cpath, ts),
- new CodeSigner(cpath, null) };
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.java
deleted file mode 100644
index 6f583ad..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.DigestException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Tests for DigestException serialization
- */
-
-public class DigestExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- DigestException dExc = new DigestException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new DigestException(), new DigestException(msg),
- new DigestException(msgs[1]),
- new DigestException(new Throwable()), new DigestException(th),
- new DigestException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.java
deleted file mode 100644
index 88578fc..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.GeneralSecurityException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for GeneralSecurityException serialization
- */
-
-public class GeneralSecurityExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- GeneralSecurityException dExc = new GeneralSecurityException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new GeneralSecurityException(), new GeneralSecurityException(msg),
- new GeneralSecurityException(msgs[1]),
- new GeneralSecurityException(new Throwable()), new GeneralSecurityException(th),
- new GeneralSecurityException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.java
deleted file mode 100644
index ca9f81e..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexey V. Varlamov
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.io.Serializable;
-import java.security.GuardedObject;
-
-import org.apache.harmony.security.tests.support.MyGuard;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-/**
- * Serialization tests for <code>GuardedObject</code>
- */
-
-public class GuardedObjectTest extends SerializationTest implements
- SerializationTest.SerializableAssert {
-
- /**
- * @see com.intel.drl.test.SerializationTest#getData()
- */
- protected Object[] getData() {
- return new Object[] { new GuardedObject(null, null),
- new GuardedObject("dsgdfg", null),
- new GuardedObject(new Integer(76547), new MyGuard(true)), };
- }
-
- public void assertDeserialized(Serializable golden, Serializable test) {
- assertSame(golden.getClass(), test.getClass());
- assertEquals(((GuardedObject) golden).getObject(),
- ((GuardedObject) test).getObject());
- }
-
- public void testDisableGuard() throws Throwable {
- try {
- copySerializable(new GuardedObject(null, new MyGuard(false)));
- fail("Should not serialize if guard denies access");
- } catch (SecurityException ok) {
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.java
deleted file mode 100644
index 5261878..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.InvalidAlgorithmParameterException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for InvalidAlgorithmParameterException serialization
- */
-
-public class InvalidAlgorithmParameterExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- InvalidAlgorithmParameterException dExc = new InvalidAlgorithmParameterException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new InvalidAlgorithmParameterException(), new InvalidAlgorithmParameterException(msg),
- new InvalidAlgorithmParameterException(msgs[1]),
- new InvalidAlgorithmParameterException(new Throwable()), new InvalidAlgorithmParameterException(th),
- new InvalidAlgorithmParameterException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.java
deleted file mode 100644
index ade2b7a..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.InvalidKeyException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for InvalidKeyException serialization
- */
-
-public class InvalidKeyExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- InvalidKeyException dExc = new InvalidKeyException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new InvalidKeyException(), new InvalidKeyException(msg),
- new InvalidKeyException(msgs[1]),
- new InvalidKeyException(new Throwable()), new InvalidKeyException(th),
- new InvalidKeyException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.java
deleted file mode 100644
index a0d7092..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.InvalidParameterException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for InvalidParameterException serialization
- */
-
-public class InvalidParameterExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] {
- new InvalidParameterException(),
- new InvalidParameterException(null),
- new InvalidParameterException(msgs[1])
- };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.java
deleted file mode 100644
index a44d364..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.KeyException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for KeyException serialization
- */
-
-public class KeyExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- KeyException dExc = new KeyException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new KeyException(), new KeyException(msg),
- new KeyException(msgs[1]),
- new KeyException(new Throwable()), new KeyException(th),
- new KeyException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.java
deleted file mode 100644
index 4fef270..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.KeyManagementException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for KeyManagementException serialization
- */
-
-public class KeyManagementExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- KeyManagementException dExc = new KeyManagementException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new KeyManagementException(), new KeyManagementException(msg),
- new KeyManagementException(msgs[1]),
- new KeyManagementException(new Throwable()), new KeyManagementException(th),
- new KeyManagementException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyPairTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyPairTest.java
deleted file mode 100644
index 6038ac2..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyPairTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.io.Serializable;
-import java.security.Key;
-import java.security.KeyPair;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.PrivateKeyStub;
-import org.apache.harmony.security.tests.support.PublicKeyStub;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-
-/**
- * Tests for <code>KeyPair</code> serialization
- */
-public class KeyPairTest extends TestCase {
-
- // key pair for testing
- private KeyPair keyPair;
-
- protected void setUp() throws Exception {
- PrivateKeyStub privateKey = new PrivateKeyStub("privateAlgorithm",
- "privateFormat", new byte[] { 0x00, 0x05, 0x10 });
- PublicKeyStub publicKey = new PublicKeyStub("publicAlgorithm",
- "publicFormat", new byte[] { 0x01, 0x02, 0x12 });
-
- keyPair = new KeyPair(publicKey, privateKey);
- }
-
- /**
- * Tests serialization compatibility
- */
- public void testSerializationCompatibility() throws Exception {
-
- SerializationTest.verifyGolden(this, keyPair, comparator);
- }
-
- /**
- * Tests serialization/deserialization
- */
- public void testSerializationSelf() throws Exception {
-
- SerializationTest.verifySelf(keyPair, comparator);
- }
-
-
- // comparator for KeyPair objects
- private static SerializableAssert comparator = new SerializableAssert() {
- public void assertDeserialized(Serializable reference, Serializable test) {
-
- // check result: compare public keys
- Key key1 = ((KeyPair) test).getPublic();
- Key key2 = ((KeyPair) reference).getPublic();
-
- assertEquals("PublicKey class", key1.getClass(), key2.getClass());
- assertEquals("PublicKey algorithm", key1.getAlgorithm(), key2
- .getAlgorithm());
- assertEquals("PublicKey format", key1.getFormat(), key2.getFormat());
- assertTrue("PublicKey encoded", Arrays.equals(key1.getEncoded(),
- key2.getEncoded()));
-
- // check result: compare private keys
- key1 = ((KeyPair) test).getPrivate();
- key2 = ((KeyPair) reference).getPrivate();
-
- assertEquals("PrivateKey class", key1.getClass(), key2.getClass());
- assertEquals("PrivateKey algorithm", key1.getAlgorithm(), key2
- .getAlgorithm());
- assertEquals("PrivateKey format", key1.getFormat(), key2.getFormat());
- assertTrue("PrivateKey encoded", Arrays.equals(key1.getEncoded(),
- key2.getEncoded()));
- }
- };
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.java
deleted file mode 100644
index 7e10af2..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.KeyStoreException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for KeyStoreException serialization
- */
-
-public class KeyStoreExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- KeyStoreException dExc = new KeyStoreException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new KeyStoreException(), new KeyStoreException(msg),
- new KeyStoreException(msgs[1]),
- new KeyStoreException(new Throwable()), new KeyStoreException(th),
- new KeyStoreException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.java
deleted file mode 100644
index 43fa5a0..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.NoSuchAlgorithmException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for NoSuchAlgorithmException serialization
- */
-
-public class NoSuchAlgorithmExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- NoSuchAlgorithmException dExc = new NoSuchAlgorithmException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new NoSuchAlgorithmException(), new NoSuchAlgorithmException(msg),
- new NoSuchAlgorithmException(msgs[1]),
- new NoSuchAlgorithmException(new Throwable()), new NoSuchAlgorithmException(th),
- new NoSuchAlgorithmException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.java
deleted file mode 100644
index 4a6c2cb..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.NoSuchProviderException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for NoSuchProviderException serialization
- */
-
-public class NoSuchProviderExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new NoSuchProviderException(),
- new NoSuchProviderException(null),
- new NoSuchProviderException(msgs[1]) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.java
deleted file mode 100644
index 40234d8..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.io.Serializable;
-import java.security.PrivilegedActionException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Serialization testing for PrivilegedActionException.
- */
-
-public class PrivilegedActionExceptionTest extends SerializationTest implements
- SerializationTest.SerializableAssert {
-
- protected Object[] getData() {
- Exception ex = new Exception();
- PrivilegedActionException ex1 = new PrivilegedActionException(ex);
- return new PrivilegedActionException[] {
- new PrivilegedActionException(null),
- new PrivilegedActionException(ex),
- new PrivilegedActionException(ex1)
- };
- }
-
- public void assertDeserialized(Serializable reference, Serializable otest) {
-
- // common checks
- THROWABLE_COMPARATOR.assertDeserialized(reference, otest);
-
- // class specific checks
- PrivilegedActionException ref = (PrivilegedActionException) reference;
- PrivilegedActionException test = (PrivilegedActionException) otest;
- if (ref.getException() == null) {
- assertNull(test.getException());
- } else {
- THROWABLE_COMPARATOR.assertDeserialized(ref.getException(), test
- .getException());
- }
- }
-
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.java
deleted file mode 100644
index 13e44f3..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.ProviderException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for ProviderException serialization
- */
-
-public class ProviderExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- ProviderException dExc = new ProviderException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new ProviderException(), new ProviderException(msg),
- new ProviderException(msgs[1]),
- new ProviderException(new Throwable()), new ProviderException(th),
- new ProviderException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.java
deleted file mode 100644
index 7b2b989..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.SignatureException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for SignatureException serialization
- */
-
-public class SignatureExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- SignatureException dExc = new SignatureException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new SignatureException(), new SignatureException(msg),
- new SignatureException(msgs[1]),
- new SignatureException(new Throwable()), new SignatureException(th),
- new SignatureException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignedObjectTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignedObjectTest.java
deleted file mode 100644
index f84f26f..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignedObjectTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.Signature;
-import java.security.SignatureException;
-import java.security.SignedObject;
-import java.security.spec.InvalidKeySpecException;
-import java.util.Properties;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.security.tests.support.TestKeyPair;
-
-
-/**
- * Tests for SignedObject serialization
- */
-public class SignedObjectTest extends SerializationTest implements
- SerializationTest.SerializableAssert {
-
- private Signature sig;
- private TestKeyPair tkp = null;
- private Properties prop;
-
- protected Object[] getData() {
- try {
- sig = Signature.getInstance("SHA1withDSA");
- } catch (NoSuchAlgorithmException e) {
- fail(e.toString());
- }
- try {
- tkp = new TestKeyPair("DSA");
- } catch (NoSuchAlgorithmException e1) {
- fail(e1.toString());
- }
- prop = new Properties();
- prop.put("aaa", "bbb");
- Object o = null;
- try {
- o = new SignedObject(prop, tkp.getPrivate(), sig);
- } catch (IOException e) {
- fail(e.toString());
- } catch (SignatureException e) {
- fail(e.toString());
- } catch (InvalidKeyException e) {
- fail(e.toString());
- } catch (InvalidKeySpecException e) {
- fail(e.toString());
- }
- return new Object[] { o };
- }
-
- public void assertDeserialized(Serializable oref, Serializable otest) {
- SignedObject ref = (SignedObject) oref;
- SignedObject test = (SignedObject) otest;
-
- assertEquals(test.getAlgorithm(), ref.getAlgorithm());
-
- try {
- assertEquals(test.getObject(), prop);
- } catch (ClassNotFoundException e) {
- fail(e.toString());
- } catch (IOException e) {
- fail(e.toString());
- }
- try {
- if (!test.verify(tkp.getPublic(), sig)) {
- fail("verify() failed");
- }
- } catch (SignatureException e) {
- fail(e.toString());
- } catch (InvalidKeyException e) {
- fail(e.toString());
- } catch (InvalidKeySpecException e) {
- fail(e.toString());
- }
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/TimestampTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/TimestampTest.java
deleted file mode 100644
index 8a3887d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/TimestampTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.Timestamp;
-import java.security.cert.CertPath;
-import java.util.Date;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.security.tests.support.TestCertUtils;
-
-
-/**
- * Serialization tests for <code>Timestamp</code>
- */
-
-public class TimestampTest extends SerializationTest {
-
- /**
- * @see com.intel.drl.test.SerializationTest#getData()
- */
- protected Object[] getData() {
- CertPath cpath = TestCertUtils.getCertPath();
- return new Object[] { new Timestamp(new Date(1146633251341L), cpath) };
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.java
deleted file mode 100644
index 73c81a0..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.UnrecoverableEntryException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for UnrecoverableEntryException serialization
- */
-
-public class UnrecoverableEntryExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new UnrecoverableEntryException(),
- new UnrecoverableEntryException(null),
- new UnrecoverableEntryException(msgs[1]) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.java
deleted file mode 100644
index a05e3cb..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.UnrecoverableKeyException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for UnrecoverableKeyException serialization
- */
-
-public class UnrecoverableKeyExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new UnrecoverableKeyException(),
- new UnrecoverableKeyException(null),
- new UnrecoverableKeyException(msgs[1]) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAParameterSpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAParameterSpecTest.java
deleted file mode 100644
index b76ead5..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAParameterSpecTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.DSAParameterSpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>DSAParameterSpec</code>
- */
-public class DSAParameterSpecTest extends TestCase {
-
- /**
- * Constructor for DSAParameterSpecTest.
- *
- * @param name
- */
- public DSAParameterSpecTest(String name) {
- super(name);
- }
-
- /**
- * Ctor test
- */
- public final void testDSAParameterSpec() {
- AlgorithmParameterSpec aps = new DSAParameterSpec(
- new BigInteger("1"),
- new BigInteger("2"),
- new BigInteger("3"));
-
- assertTrue(aps instanceof DSAParameterSpec);
- }
-
- /**
- * getG() test
- */
- public final void testGetG() {
- DSAParameterSpec dps = new DSAParameterSpec(
- new BigInteger("1"),
- new BigInteger("2"),
- new BigInteger("3"));
-
- assertEquals(3, dps.getG().intValue());
- }
-
- /**
- * getP() test
- */
- public final void testGetP() {
- DSAParameterSpec dps = new DSAParameterSpec(
- new BigInteger("1"),
- new BigInteger("2"),
- new BigInteger("3"));
-
- assertEquals(1, dps.getP().intValue());
- }
-
- /**
- * getQ() test
- */
- public final void testGetQ() {
- DSAParameterSpec dps = new DSAParameterSpec(
- new BigInteger("1"),
- new BigInteger("2"),
- new BigInteger("3"));
-
- assertEquals(2, dps.getQ().intValue());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPrivateKeySpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPrivateKeySpecTest.java
deleted file mode 100644
index ce2af09..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPrivateKeySpecTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.DSAPrivateKeySpec;
-import java.security.spec.KeySpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>DSAPrivateKeySpec</code>
- */
-public class DSAPrivateKeySpecTest extends TestCase {
-
- /**
- * Constructor for DSAPrivateKeySpecTest.
- *
- * @param name
- */
- public DSAPrivateKeySpecTest(String name) {
- super(name);
- }
-
- /**
- * Test for constructor
- */
- public final void testDSAPrivateKeySpec() {
- KeySpec ks = new DSAPrivateKeySpec(
- new BigInteger("1"),
- new BigInteger("2"),
- new BigInteger("3"),
- new BigInteger("4"));
-
- assertTrue(ks instanceof DSAPrivateKeySpec);
- }
-
- /**
- * getG() test
- */
- public final void testGetG() {
- DSAPrivateKeySpec dpks = new DSAPrivateKeySpec(
- new BigInteger("1"),
- new BigInteger("2"),
- new BigInteger("3"),
- new BigInteger("4"));
-
- assertEquals(4, dpks.getG().intValue());
- }
-
- /**
- * getP() test
- */
- public final void testGetP() {
- DSAPrivateKeySpec dpks = new DSAPrivateKeySpec(
- new BigInteger("1"),
- new BigInteger("2"),
- new BigInteger("3"),
- new BigInteger("4"));
-
- assertEquals(2, dpks.getP().intValue());
- }
-
- /**
- * getQ() test
- */
- public final void testGetQ() {
- DSAPrivateKeySpec dpks = new DSAPrivateKeySpec(
- new BigInteger("1"),
- new BigInteger("2"),
- new BigInteger("3"),
- new BigInteger("4"));
-
- assertEquals(3, dpks.getQ().intValue());
- }
-
- /**
- * getX() test
- */
- public final void testGetX() {
- DSAPrivateKeySpec dpks = new DSAPrivateKeySpec(
- new BigInteger("1"),
- new BigInteger("2"),
- new BigInteger("3"),
- new BigInteger("4"));
-
- assertEquals(1, dpks.getX().intValue());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPublicKeySpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPublicKeySpecTest.java
deleted file mode 100644
index 7e2c195..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPublicKeySpecTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.DSAPublicKeySpec;
-import java.security.spec.KeySpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>DSAPublicKeySpec</code>
- */
-public class DSAPublicKeySpecTest extends TestCase {
-
- /**
- * Constructor for DSAPublicKeySpecTest.
- *
- * @param name
- */
- public DSAPublicKeySpecTest(String name) {
- super(name);
- }
-
- /**
- * Test for <code>DSAPublicKeySpec</code> ctor
- */
- public final void testDSAPublicKeySpec() {
- KeySpec ks = new DSAPublicKeySpec(
- new BigInteger("1"), // y
- new BigInteger("2"), // p
- new BigInteger("3"), // q
- new BigInteger("4"));// g
-
- assertTrue(ks instanceof DSAPublicKeySpec);
- }
-
- /**
- * Test for <code>getG</code> method
- */
- public final void testGetG() {
- DSAPublicKeySpec dpks = new DSAPublicKeySpec(
- new BigInteger("1"), // y
- new BigInteger("2"), // p
- new BigInteger("3"), // q
- new BigInteger("4"));// g
-
- assertEquals(4, dpks.getG().intValue());
- }
-
- /**
- * Test for <code>getP</code> method
- */
- public final void testGetP() {
- DSAPublicKeySpec dpks = new DSAPublicKeySpec(
- new BigInteger("1"), // y
- new BigInteger("2"), // p
- new BigInteger("3"), // q
- new BigInteger("4"));// g
-
- assertEquals(2, dpks.getP().intValue());
- }
-
- /**
- * Test for <code>getQ</code> method
- */
- public final void testGetQ() {
- DSAPublicKeySpec dpks = new DSAPublicKeySpec(
- new BigInteger("1"), // y
- new BigInteger("2"), // p
- new BigInteger("3"), // q
- new BigInteger("4"));// g
-
- assertEquals(3, dpks.getQ().intValue());
- }
-
- /**
- * Test for <code>getY</code> method
- */
- public final void testGetY() {
- DSAPublicKeySpec dpks = new DSAPublicKeySpec(
- new BigInteger("1"), // y
- new BigInteger("2"), // p
- new BigInteger("3"), // q
- new BigInteger("4"));// g
-
- assertEquals(1, dpks.getY().intValue());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2mTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2mTest.java
deleted file mode 100644
index db487fb..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2mTest.java
+++ /dev/null
@@ -1,539 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.ECFieldF2m;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ECFieldF2m</code> class fields and methods.
- */
-public class ECFieldF2mTest extends TestCase {
-
- /**
- * Support class for this test.
- * Encapsulates <code>ECFieldF2m</code> testing
- * domain parameters.
- */
- private static final class ECFieldF2mDomainParams {
-
- /**
- * <code>NPE</code> reference object of class NullPointerException.
- * NullPointerException must be thrown by <code>ECFieldF2m</code>
- * ctors in some circumstances
- */
- static final NullPointerException NPE = new NullPointerException();
- /**
- * <code>IArgE</code> reference object of class IllegalArgumentException.
- * IllegalArgumentException must be thrown by <code>ECFieldF2m</code>
- * ctors in some circumstances
- */
- static final IllegalArgumentException IArgE = new IllegalArgumentException();
-
- /**
- * The <code>m</code> parameter for <code>ECFieldF2m</code>
- * ctor for the current test.
- */
- final int m;
- /**
- * The <code>rp</code> parameter for <code>ECFieldF2m</code>
- * ctor for the current test.
- */
- final BigInteger rp;
- /**
- * The <code>ks</code> parameter for <code>ECFieldF2m</code>
- * ctor for the current test.
- */
- final int[] ks;
-
-
- /**
- * Exception expected with this parameters set or <code>null</code>
- * if no exception expected.
- */
- final Exception x;
-
- /**
- * Constructs ECFieldF2mDomainParams
- *
- * @param m
- * @param rp
- * @param ks
- * @param expectedException
- */
- ECFieldF2mDomainParams(final int m,
- final BigInteger rp,
- final int[] ks,
- final Exception expectedException) {
- this.m = m;
- this.rp = rp;
- this.ks = ks;
- this.x = expectedException;
- }
- }
-
- /**
- * Constructor for ECFieldF2mTest.
- *
- * @param name
- */
- public ECFieldF2mTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Set of parameters used for <code>ECFieldF2m(int)</code>
- * constructor tests.
- */
- private final ECFieldF2mDomainParams[] intCtorTestParameters =
- new ECFieldF2mDomainParams[] {
- // set 0: valid m
- new ECFieldF2mDomainParams(1, null, null, null),
- // set 1: valid m
- new ECFieldF2mDomainParams(Integer.MAX_VALUE, null, null, null),
- // set 2: invalid m
- new ECFieldF2mDomainParams(0, null, null, ECFieldF2mDomainParams.IArgE),
- // set 3: invalid m
- new ECFieldF2mDomainParams(-1, null, null, ECFieldF2mDomainParams.IArgE)
- };
-
- /**
- * Tests for constructor <code>ECFieldF2m(int)</code><br>
- * <p/>
- * Assertion: constructs new <code>ECFieldF2m</code> object
- * using valid parameter m.
- * <p/>
- * Assertion: IllegalArgumentException if m is not positive.
- */
- public final void testECFieldF2mint() {
- for (int i = 0; i < intCtorTestParameters.length; i++) {
- ECFieldF2mDomainParams tp = intCtorTestParameters[i];
- try {
- // perform test
- new ECFieldF2m(tp.m);
-
- if (tp.x != null) {
- // exception has been expected
- fail(getName() + ", set " + i +
- " FAILED: expected exception has not been thrown");
- }
- } catch (Exception e) {
- if (tp.x == null || !e.getClass().isInstance(tp.x)) {
- // exception: failure
- // if it has not been expected
- // or wrong one has been thrown
- fail(getName() + ", set " + i +
- " FAILED: unexpected " + e);
- }
- }
- }
- }
-
- /**
- * Set of parameters used for <code>ECFieldF2m(int, BigInteger)</code>
- * constructor tests.
- */
- private final ECFieldF2mDomainParams[] intIntArrayCtorTestParameters =
- new ECFieldF2mDomainParams[] {
- // set 0: valid m and ks - trinomial basis params
- new ECFieldF2mDomainParams(
- 1999,
- null,
- new int[] { 367 },
- null),
- // set 1: valid m and ks - pentanomial basis params
- new ECFieldF2mDomainParams(
- 2000,
- null,
- new int[] { 981, 2, 1 },
- null),
- // set 2: valid m, invalid (null) ks
- new ECFieldF2mDomainParams(
- 1963,
- null,
- null,
- ECFieldF2mDomainParams.NPE),
- // set 3: valid m, invalid ks - wrong length
- new ECFieldF2mDomainParams(
- 1963,
- null,
- new int[] { 981, 2 },
- ECFieldF2mDomainParams.IArgE),
- // set 4: valid m, invalid ks - wrong length
- new ECFieldF2mDomainParams(
- 1963,
- null,
- new int[] { 981, 124, 2, 1 },
- ECFieldF2mDomainParams.IArgE),
- // set 5: valid m, invalid ks - wrong value
- new ECFieldF2mDomainParams(
- 1999,
- null,
- new int[] { 1999 },
- ECFieldF2mDomainParams.IArgE),
- // set 6: valid m, invalid ks - wrong value
- new ECFieldF2mDomainParams(
- 1999,
- null,
- new int[] { 0 },
- ECFieldF2mDomainParams.IArgE),
- // set 7: valid m, invalid ks - wrong values
- new ECFieldF2mDomainParams(
- 2000,
- null,
- new int[] { 2000, 2, 1 },
- ECFieldF2mDomainParams.IArgE),
- // set 8: valid m, invalid ks - wrong values
- new ECFieldF2mDomainParams(
- 2000,
- null,
- new int[] { 981, 2, 0 },
- ECFieldF2mDomainParams.IArgE),
- // set 9: invalid m
- new ECFieldF2mDomainParams(
- -5,
- null,
- new int[] { 981, 2, 1 },
- ECFieldF2mDomainParams.IArgE),
- // set 10: valid m, invalid ks - wrong order
- new ECFieldF2mDomainParams(
- 2000,
- null,
- new int[] { 981, 1, 2 },
- ECFieldF2mDomainParams.IArgE),
- // set 11: valid m, invalid ks - no content
- new ECFieldF2mDomainParams(
- 2000,
- null,
- new int[3],
- ECFieldF2mDomainParams.IArgE),
- // set 12: valid m, invalid ks - length is 0
- new ECFieldF2mDomainParams(
- 2000,
- null,
- new int[0],
- ECFieldF2mDomainParams.IArgE),
- };
-
- /**
- * Tests for constructor <code>ECFieldF2m(int m, int[] ks)</code><br>
- * <p/>
- * Assertion: constructs new <code>ECFieldF2m</code> object
- * using valid parameters m and rp. ks represents trinomial basis.
- * <p/>
- * Assertion: constructs new <code>ECFieldF2m</code> object
- * using valid parameters m and ks. ks represents pentanomial basis.
- * <p/>
- * Assertion: IllegalArgumentException if m is not positive.
- * <p/>
- * Assertion: NullPointerException if ks is null.
- * <p/>
- * Assertion: IllegalArgumentException if ks is invalid.
- */
- public final void testECFieldF2mintintArray() {
- for (int i = 0; i < intIntArrayCtorTestParameters.length; i++) {
- ECFieldF2mDomainParams tp = intIntArrayCtorTestParameters[i];
- try {
- // perform test
- new ECFieldF2m(tp.m, tp.ks);
-
- if (tp.x != null) {
- // exception has been expected
- fail(getName() + ", set " + i +
- " FAILED: expected exception has not been thrown");
- }
- } catch (Exception e) {
- if (tp.x == null || !e.getClass().isInstance(tp.x)) {
- // exception: failure
- // if it has not been expected
- // or wrong one has been thrown
- fail(getName() + ", set " + i +
- " FAILED: unexpected " + e);
- }
- }
- }
- }
-
- /**
- * Test #1 for <code>hashCode()</code> method.<br>
- * <p/>
- * Assertion: must return the same value if invoked
- * repeatedly on the same object.
- */
- public final void testHashCode01() {
- ECFieldF2m f = new ECFieldF2m(2000);
- int hc = f.hashCode();
- assertTrue(hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode());
- }
-
- /**
- * Test #2 for <code>hashCode()</code> method.<br>
- * <p/>
- * Assertion: must return the same value if invoked
- * repeatedly on the same object.
- */
- public final void testHashCode02() {
- ECFieldF2m f = new ECFieldF2m(2000, new int[] { 981, 2, 1 });
- int hc = f.hashCode();
- assertTrue(hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode());
- }
-
- /**
- * Test #3 for <code>hashCode()</code> method.<br>
- * <p/>
- * Assertion: must return the same value if invoked
- * on equal (according to the <code>equals(Object)</code> method) objects.
- */
- public final void testHashCode03() {
- assertTrue(new ECFieldF2m(111).hashCode() ==
- new ECFieldF2m(111).hashCode());
- }
-
- /**
- * Test #4 for <code>hashCode()</code> method.<br>
- * <p/>
- * Assertion: must return the same value if invoked
- * on equal (according to the <code>equals(Object)</code> method) objects.
- */
- public final void testHashCode04() {
- assertTrue(new ECFieldF2m(2000, new int[] { 981, 2, 1 }).hashCode() ==
- new ECFieldF2m(2000, new int[] { 981, 2, 1 }).hashCode());
- }
-
- /**
- * Test #5 for <code>hashCode()</code> method.<br>
- * <p/>
- * Assertion: must return the same value if invoked
- * on equal (according to the <code>equals(Object)</code> method) objects.
- */
- public final void testHashCode05() {
- assertTrue(new ECFieldF2m(2000, new int[] { 981, 2, 1 }).hashCode() ==
- new ECFieldF2m(2000, BigInteger.valueOf(0L).
- setBit(0).setBit(1).setBit(2).
- setBit(981).setBit(2000)).hashCode());
- }
-
- /**
- * Test #1 for <code>equals()</code> method.<br>
- * <p/>
- * Assertion: object equals to itself.
- */
- public final void testEqualsObject01() {
- ECFieldF2m obj = new ECFieldF2m(1999, new int[] { 367 });
- assertTrue(obj.equals(obj));
- }
-
- /**
- * Test #2 for <code>equals()</code> method.<br>
- * <p/>
- * Assertion: normal basis - objects equal if their m are equal.
- */
- public final void testEqualsObject02() {
- assertTrue(new ECFieldF2m(43).equals(new ECFieldF2m(43)));
- }
-
- /**
- * Test #3 for <code>equals()</code> method.<br>
- * <p/>
- * Assertion: trinomial basis - objects equal if their m, and rp
- * are mutually equal.
- */
- public final void testEqualsObject03() {
- assertTrue(new ECFieldF2m(1999, new int[] { 367 }).equals(
- new ECFieldF2m(1999, BigInteger.valueOf(0L).
- setBit(0).setBit(367).setBit(1999))));
- }
-
- /**
- * Test #4 for <code>equals()</code> method.<br>
- * <p/>
- * Assertion: pentanomial basis - objects equal if their m, and rp
- * are mutually equal.
- */
- public final void testEqualsObject04() {
- ECFieldF2m f1 = new ECFieldF2m(2000, new int[] { 981, 2, 1 });
- ECFieldF2m f2 = new ECFieldF2m(2000, BigInteger.valueOf(0L).
- setBit(0).setBit(1).setBit(2).
- setBit(981).setBit(2000));
- assertTrue(f1.equals(f2) && f2.equals(f1));
- }
-
- /**
- * Test #5 for <code>equals()</code> method.<br>
- * <p/>
- * Assertion: objects equal if their m, and rp are mutually equal.
- */
- public final void testEqualsObject05() {
- ECFieldF2m f1 = new ECFieldF2m(2000);
- ECFieldF2m f2 = new ECFieldF2m(2000, BigInteger.valueOf(0L).
- setBit(0).setBit(1).setBit(2).
- setBit(981).setBit(2000));
- assertFalse(f1.equals(f2) || f2.equals(f1));
- }
-
- /**
- * Test #6 for <code>equals(Object obj)</code> method.<br>
- * <p/>
- * Assertion: returns false if obj is <code>null</code>
- */
- public final void testEqualsObject06() {
- assertFalse(new ECFieldF2m(2000).equals(null));
- }
-
- /**
- * Test #7 for <code>equals(Object obj)</code> method.<br>
- * <p/>
- * Assertion: returns false if obj is not instance of <code>ECFieldF2m</code>
- */
- public final void testEqualsObject07() {
- assertFalse(new ECFieldF2m(2000).equals(new Object()));
- }
-
- /**
- * Test for <code>getFieldSize()</code> method.<br>
- * <p/>
- * Assertion: returns m value for <code>ECFieldF2m</code>
- */
- public final void testGetFieldSize() {
- assertEquals(2000, new ECFieldF2m(2000).getFieldSize());
- }
-
- /**
- * Test for <code>getM()</code> method.<br>
- * <p/>
- * Assertion: returns m value for <code>ECFieldF2m</code>
- */
- public final void testGetM() {
- assertEquals(2000, new ECFieldF2m(2000).getM());
- }
-
- /**
- * Test #1 for <code>getMidTermsOfReductionPolynomial()</code> method.<br>
- * <p/>
- * Assertion: returns mid terms of reduction polynomial
- */
- public final void testGetMidTermsOfReductionPolynomial01() {
- int[] a = new int[] { 981, 2, 1 };
- int[] b = new ECFieldF2m(2000,
- BigInteger.valueOf(0L).setBit(0).setBit(1).
- setBit(2).setBit(981).setBit(2000)).
- getMidTermsOfReductionPolynomial();
- assertTrue(Arrays.equals(a, b));
- }
-
- /**
- * Test #2 for <code>getMidTermsOfReductionPolynomial()</code> method.<br>
- * <p/>
- * Assertion: returns null for normal basis
- */
- public final void testGetMidTermsOfReductionPolynomial02() {
- assertNull(new ECFieldF2m(2000).getMidTermsOfReductionPolynomial());
- }
-
- /**
- * Test #3 for <code>getMidTermsOfReductionPolynomial()</code> method.<br>
- * <p/>
- * Assertion: returns mid terms of reduction polynomial
- */
- public final void testGetMidTermsOfReductionPolynomial03() {
- int[] a = new int[] { 367 };
- int[] b = new ECFieldF2m(1999, a).getMidTermsOfReductionPolynomial();
- assertTrue(Arrays.equals(a, b));
- }
-
- /**
- * Test #1 for <code>getReductionPolynomial()</code> method.<br>
- * <p/>
- * Assertion: returns reduction polynomial
- */
- public final void testGetReductionPolynomial01() {
- BigInteger rp = BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).
- setBit(981).setBit(2000);
- assertTrue(new ECFieldF2m(2000, rp).getReductionPolynomial().equals(rp));
- }
-
- /**
- * Test #2 for <code>getReductionPolynomial()</code> method.<br>
- * <p/>
- * Assertion: returns null for normal basis
- */
- public final void testGetReductionPolynomial02() {
- assertNull(new ECFieldF2m(2000).getReductionPolynomial());
- }
-
- /**
- * Tests that object state is preserved against modifications
- * through array reference passed to the constructor.
- */
- public final void testIsStatePreserved01() {
- // reference array
- int[] a = new int[] { 367 };
- // reference array copy
- int[] aCopy = a.clone();
- // create obj using copy
- ECFieldF2m f = new ECFieldF2m(1999, aCopy);
- // modify copy
- aCopy[0] = 5;
- // compare reference with returned array
- assertTrue(Arrays.equals(a, f.getMidTermsOfReductionPolynomial()));
- }
-
- /**
- * Tests that object state is preserved against
- * modifications through array reference returned by
- * <code>getMidTermsOfReductionPolynomial()</code> method.
- */
- public final void testIsStatePreserved02() {
- // reference array
- int[] a = new int[] { 981, 2, 1 };
- // reference array copy
- int[] aCopy = a.clone();
- // create obj using copy
- ECFieldF2m f = new ECFieldF2m(2000, aCopy);
- // get array reference and modify returned array
- f.getMidTermsOfReductionPolynomial()[0] = 1532;
- // compare reference with returned for the second time array
- assertTrue(Arrays.equals(a, f.getMidTermsOfReductionPolynomial()));
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldFpTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldFpTest.java
deleted file mode 100644
index 46821b3..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldFpTest.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.ECFieldFp;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ECFieldFp</code> class fields and methods.
- */
-public class ECFieldFpTest extends TestCase {
-
- /**
- * Constructor for ECFieldFpTest.
- *
- * @param name
- */
- public ECFieldFpTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>ECFieldFp</code> constructor
- * <p/>
- * Assertion: creates new object of <code>ECFieldFp</code> class
- * using valid <code>p</code> (odd prime)
- */
- public final void testECFieldFp01() {
- new ECFieldFp(BigInteger.valueOf(23L));
- }
-
- /**
- * Test #2 for <code>ECFieldFp</code> constructor
- * <p/>
- * Assertion: creates new object of <code>ECFieldFp</code> class
- * using valid <code>p</code> (odd but not prime)
- */
- public final void testECFieldFp02() {
- new ECFieldFp(BigInteger.valueOf(21L));
- }
-
- /**
- * Test #3 for <code>ECFieldFp</code> constructor
- * <p/>
- * Assertion: IllegalArgumentException if <code>p</code> is not positive
- */
- public final void testECFieldFp03() {
- try {
- new ECFieldFp(BigInteger.valueOf(-1L));
- fail(getName() +
- " FAILED: expected exception has not been thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Test #4 for <code>ECFieldFp</code> constructor
- * <p/>
- * Assertion: IllegalArgumentException if <code>p</code> is not positive
- */
- public final void testECFieldFp04() {
- try {
- new ECFieldFp(BigInteger.valueOf(0L));
- fail(getName() +
- " FAILED: expected exception has not been thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Test #4 for <code>ECFieldFp</code> constructor
- * <p/>
- * Assertion: NullPointerException if <code>p</code> is null
- */
- public final void testECFieldFp05() {
- try {
- new ECFieldFp(null);
- fail(getName() +
- " FAILED: expected exception has not been thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #1 for <code>hashCode()</code> method.<br>
- * <p/>
- * Assertion: must return the same value if invoked
- * repeatedly on the same object.
- */
- public final void testHashCode01() {
- ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
- int hc = f.hashCode();
- assertTrue(hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode());
- }
-
- /**
- * Test #2 for <code>hashCode()</code> method.<br>
- * <p/>
- * Assertion: must return the same value if invoked
- * on equal (according to the <code>equals(Object)</code> method) objects.
- */
- public final void testHashCode02() {
- assertTrue(new ECFieldFp(BigInteger.valueOf(23L)).hashCode() ==
- new ECFieldFp(BigInteger.valueOf(23L)).hashCode());
- }
-
- /**
- * Test for <code>getFieldSize()()</code> method.<br>
- * <p/>
- * Assertion: returns field size in bits which is prime size
- */
- public final void testGetFieldSize() {
- assertEquals(5, new ECFieldFp(BigInteger.valueOf(23L)).getFieldSize());
- }
-
- /**
- * Test for <code>getP()</code> method.<br>
- * <p/>
- * Assertion: returns prime
- */
- public final void testGetP() {
- BigInteger p = BigInteger.valueOf(23L);
- assertTrue(p.equals(new ECFieldFp(p).getP()));
- }
-
- /**
- * Test #1 for <code>equals()</code> method.<br>
- * <p/>
- * Assertion: object equals to itself.
- */
- public final void testEqualsObject01() {
- ECFieldFp obj = new ECFieldFp(BigInteger.valueOf(23L));
- assertTrue(obj.equals(obj));
- }
-
- /**
- * Test #2 for <code>equals(Object obj)</code> method.<br>
- * <p/>
- * Assertion: returns false if <code>obj</code> is <code>null</code>
- */
- public final void testEqualsObject02() {
- assertFalse(new ECFieldFp(BigInteger.valueOf(23L)).equals(null));
- }
-
- /**
- * Test #3 for <code>equals(Object obj)</code> method.<br>
- * <p/>
- * Assertion: returns false if <code>obj</code>
- * is not instance of <code>ECFieldFp</code>
- */
- public final void testEqualsObject03() {
- assertFalse(new ECFieldFp(BigInteger.valueOf(23L)).equals(new Object()));
- }
-
- /**
- * Test #4 for <code>equals()</code> method.<br>
- * <p/>
- * Assertion: true if prime values match.
- */
- public final void testEqualsObject04() {
- assertTrue(new ECFieldFp(BigInteger.valueOf(23L)).equals(
- new ECFieldFp(BigInteger.valueOf(23L))));
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECGenParameterSpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECGenParameterSpecTest.java
deleted file mode 100644
index b79ee54..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECGenParameterSpecTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.security.spec.ECGenParameterSpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ECGenParameterSpec</code> class fields and methods.
- */
-public class ECGenParameterSpecTest extends TestCase {
-
- /**
- * Constructor for ECGenParameterSpecTest.
- *
- * @param name
- */
- public ECGenParameterSpecTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>ECGenParameterSpec</code> constructor<br>
- * <p/>
- * Assertion: creates new object of <code>ECGenParameterSpec</code> class
- * using valid <code>name</code>
- */
- public final void testECGenParameterSpec01() {
- new ECGenParameterSpec("someName");
- }
-
- /**
- * Test #2 for <code>ECGenParameterSpec</code> constructor<br>
- * <p/>
- * Assertion: throws NullPointerException
- * if <code>name</code> is <code>null</code>
- */
- public final void testECGenParameterSpec02() {
- try {
- new ECGenParameterSpec(null);
- fail("NPE expected");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test for <code>getName()</code> method<br>
- * <p/>
- * Assertion: returns the <code>name</code>
- */
- public final void testGetName() {
- String name = "someName";
- ECGenParameterSpec ps = new ECGenParameterSpec(name);
- assertEquals(name, ps.getName());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECPointTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECPointTest.java
deleted file mode 100644
index 2766f3a..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECPointTest.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.ECPoint;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ECPoint</code> class fields and methods.
- */
-public class ECPointTest extends TestCase {
-
- /**
- * Constructor for ECPointTest.
- *
- * @param name
- */
- public ECPointTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>ECPoint(BigInteger, BigInteger)</code> constructor<br>
- * Assertion: creates <code>ECPoint</code> instance<br>
- * Test preconditions: valid parameters passed<br>
- * Expected: must pass without any exceptions
- */
- public final void testECPoint01() {
- new ECPoint(BigInteger.ZERO, BigInteger.ZERO);
- new ECPoint(BigInteger.valueOf(-23456L), BigInteger.valueOf(-23456L));
- new ECPoint(BigInteger.valueOf(123456L), BigInteger.valueOf(123456L));
- new ECPoint(BigInteger.valueOf(-56L), BigInteger.valueOf(234L));
- new ECPoint(BigInteger.valueOf(3456L), BigInteger.valueOf(-2344L));
- }
-
- /**
- * Test #2 for <code>ECPoint(BigInteger x, BigInteger y)</code> constructor<br>
- * Assertion: throws <code>NullPointerException</code> if <code>x</code>or
- * <code>y</code> is <code>null</code><br>
- * Test preconditions: pass <code>null</code> as mentioned parameters<br>
- * Expected: must throw <code>NullPointerException</code>
- */
- public final void testECPoint02() {
- // test case 1: x is null
- try {
- new ECPoint(null, BigInteger.ZERO);
- fail("#1: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // test case 2: y is null
- try {
- new ECPoint(BigInteger.ZERO, null);
- fail("#2: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // test case 3: both : x and y are null
- try {
- new ECPoint(null, null);
- fail("#3: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test #1 for <code>getAffineX()</code> method<br>
- * Assertion: returns affine <code>x</code> coordinate<br>
- * Test preconditions: <code>ECPoint</code> instance
- * created using valid parameters<br>
- * Expected: must return affine <code>x</code> coordinate
- * which is equal to the one passed to the constructor;
- * (both must refer the same object)
- */
- public final void testGetAffineX01() {
- BigInteger x = BigInteger.valueOf(-23456L);
- ECPoint p = new ECPoint(x, BigInteger.valueOf(23456L));
- BigInteger xRet = p.getAffineX();
- assertEquals(x, xRet);
- assertSame(x, xRet);
- }
-
- /**
- * Test #2 for <code>getAffineX()</code> method<br>
- * Assertion: returns <code>null</code> for <code>ECPoint.POINT_INFINITY</code><br>
- * Test preconditions: none<br>
- * Expected: must return <code>null</code> for
- * <code>ECPoint.POINT_INFINITY</code>
- */
- public final void testGetAffineX02() {
- assertNull(ECPoint.POINT_INFINITY.getAffineX());
- }
-
- /**
- * Test #1 for <code>getAffineY()</code> method<br>
- * Assertion: returns affine <code>y</code> coordinate<br>
- * Test preconditions: <code>ECPoint</code> instance
- * created using valid parameters<br>
- * Expected: must return affine <code>y</code> coordinate
- * which is equal to the one passed to the constructor;
- * (both must refer the same object)
- */
- public final void testGetAffineY01() {
- BigInteger y = BigInteger.valueOf(23456L);
- ECPoint p = new ECPoint(BigInteger.valueOf(-23456L), y);
- BigInteger yRet = p.getAffineY();
- assertEquals(y, yRet);
- assertSame(y, yRet);
- }
-
- /**
- * Test #2 for <code>getAffineX()</code> method<br>
- * Assertion: returns <code>null</code> for <code>ECPoint.POINT_INFINITY</code><br>
- * Test preconditions: none<br>
- * Expected: must return <code>null</code> for
- * <code>ECPoint.POINT_INFINITY</code>
- */
- public final void testGetAffineY02() {
- assertNull(ECPoint.POINT_INFINITY.getAffineY());
- }
-
- /**
- * Test #1 for <code>equals(Object other)</code> method<br>
- * Assertion: return true if this and other objects are equal<br>
- * Test preconditions: see test comments<br>
- * Expected: all objects in this test must be equal
- */
- public final void testEqualsObject01() {
- // test case 1: must be equal to itself
- ECPoint p2 = null, p1 =
- new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ONE);
- assertTrue(p1.equals(p1));
-
- // test case 2: equal objects
- p1 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ONE);
- p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.valueOf(1L));
- assertTrue(p1.equals(p2) && p2.equals(p1));
-
- // test case 3: equal POINT_INFINITY object(s)
- p1 = ECPoint.POINT_INFINITY;
- p2 = ECPoint.POINT_INFINITY;
- assertTrue(p1.equals(p2) && p2.equals(p1));
- }
-
- /**
- * Test #2 for <code>equals(Object other)</code> method<br>
- * Assertion: return false if this and other objects are not equal<br>
- * Test preconditions: see test comments<br>
- * Expected: all objects in this test must be not equal
- */
- public final void testEqualsObject02() {
- // test case 1: must be not equal to null
- ECPoint p2 = null, p1 =
- new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ONE);
- assertFalse(p1.equals(p2));
-
- // test case 2: not equal objects - x
- p1 = new ECPoint(BigInteger.valueOf(-23457L), BigInteger.ONE);
- p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.valueOf(1L));
- assertFalse(p1.equals(p2) || p2.equals(p1));
-
- // test case 3: not equal objects - y
- p1 = new ECPoint(BigInteger.valueOf(-23457L), BigInteger.ONE);
- p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ZERO);
- assertFalse(p1.equals(p2) || p2.equals(p1));
-
- // test case 4: not equal - some point and POINT_INFINITY
- p1 = ECPoint.POINT_INFINITY;
- p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ZERO);
- assertFalse(p1.equals(p2) || p2.equals(p1));
- }
-
- /**
- * Test #1 for <code>hashCode()</code> method.<br>
- * <p/>
- * Assertion: must return the same value if invoked
- * repeatedly on the same object.
- */
- public final void testHashCode01() {
- ECPoint f = new ECPoint(BigInteger.valueOf(-23457L), BigInteger.ONE);
- int hc = f.hashCode();
- assertTrue(hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode() &&
- hc == f.hashCode());
-
-
- // the same for POINT_INFINITY
- hc = ECPoint.POINT_INFINITY.hashCode();
- assertTrue(hc == ECPoint.POINT_INFINITY.hashCode() &&
- hc == ECPoint.POINT_INFINITY.hashCode() &&
- hc == ECPoint.POINT_INFINITY.hashCode() &&
- hc == ECPoint.POINT_INFINITY.hashCode() &&
- hc == ECPoint.POINT_INFINITY.hashCode() &&
- hc == ECPoint.POINT_INFINITY.hashCode() &&
- hc == ECPoint.POINT_INFINITY.hashCode() &&
- hc == ECPoint.POINT_INFINITY.hashCode());
- }
-
- /**
- * Test #2 for <code>hashCode()</code> method.<br>
- * <p/>
- * Assertion: must return the same value if invoked
- * on equal (according to the <code>equals(Object)</code> method) objects.
- */
- public final void testHashCode02() {
- ECPoint p1 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.ONE);
- ECPoint p2 = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.valueOf(1L));
- assertEquals(p1.hashCode(), p2.hashCode());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurveTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurveTest.java
deleted file mode 100644
index f402cb7..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurveTest.java
+++ /dev/null
@@ -1,666 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.ECField;
-import java.security.spec.ECFieldF2m;
-import java.security.spec.ECFieldFp;
-import java.security.spec.EllipticCurve;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>EllipticCurve</code> class fields and methods.
- */
-public class EllipticCurveTest extends TestCase {
-
- /**
- * Test #1 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
- * constructor<br>
- * Assertion: creates instance of EllipticCurve<br>
- * Test preconditions: valid parameters passed<br>
- * Expected: must pass without any exceptions
- */
- public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray01() {
- // test case 1 parameters set
- ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
- BigInteger a = BigInteger.ONE;
- BigInteger b = BigInteger.valueOf(19L);
- byte[] seed = new byte[24];
- // perform test case 1
- new EllipticCurve(f, a, b, seed);
-
- // test case 2 parameters set
- ECFieldF2m f1 = new ECFieldF2m(5);
- a = BigInteger.ZERO;
- b = BigInteger.valueOf(23L);
- // perform test case 2
- new EllipticCurve(f1, a, b, seed);
-
- // test case 3 parameters set,
- // the seed parameter may be null
- f = new ECFieldFp(BigInteger.valueOf(23L));
- a = BigInteger.ONE;
- b = BigInteger.valueOf(19L);
- seed = null;
- // perform test case 3
- new EllipticCurve(f, a, b, seed);
- }
-
- /**
- * Test #2 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
- * constructor<br>
- * Assertion: throws <code>NullPointerException</code> if <code>field</code>,
- * <code>a</code> or <code>b</code> is <code>null</code><br>
- * Test preconditions: pass <code>null</code> as mentioned parameters<br>
- * Expected: must throw <code>NullPointerException</code>
- */
- public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray02() {
- // test case 1 parameters set
- ECFieldFp f = null;
- BigInteger a = BigInteger.ONE;
- BigInteger b = BigInteger.valueOf(19L);
- byte[] seed = new byte[24];
-
- // perform test case 1
- try {
- new EllipticCurve(f, a, b, seed);
- fail("#1: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
- // test case 2 parameters set,
- f = new ECFieldFp(BigInteger.valueOf(23L));
- a = null;
- b = BigInteger.valueOf(19L);
- seed = new byte[24];
- // perform test case 2
- try {
- new EllipticCurve(f, a, b, seed);
- fail("#2: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
- // test case 3 parameters set,
- f = new ECFieldFp(BigInteger.valueOf(23L));
- a = BigInteger.ONE;
- b = null;
- seed = new byte[24];
- // perform test case 2
- try {
- new EllipticCurve(f, a, b, seed);
- fail("#3: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test #3 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
- * constructor<br>
- * Assertion: throws <code>IllegalArgumentException</code> if
- * <code>a</code> or <code>b</code> is not <code>null</code> and not in
- * the <code>field</code><br>
- * Test preconditions: pass <code>a</code>, <code>b</code> which are
- * not in the <code>field</code> of type <code>ECFieldFp</code><br>
- * Expected: must throw <code>IllegalArgumentException</code>
- */
- public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray03() {
- // test case 1 parameters set,
- // a is not in field
- ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
- BigInteger a = BigInteger.valueOf(24L);
- BigInteger b = BigInteger.valueOf(19L);
- byte[] seed = new byte[24];
-
- // perform test case 1
- try {
- new EllipticCurve(f, a, b, seed);
- fail("#1: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // test case 1.1 parameters set,
- // b is not in field
- f = new ECFieldFp(BigInteger.valueOf(23L));
- a = BigInteger.valueOf(1L);
- b = BigInteger.valueOf(23L);
- seed = new byte[24];
- // perform test case 1.1
- try {
- new EllipticCurve(f, a, b, seed);
- fail("#1.1: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // test case 2 parameters set,
- // b is not in field
- f = new ECFieldFp(BigInteger.valueOf(23L));
- a = BigInteger.valueOf(19L);
- b = BigInteger.valueOf(24L);
- seed = new byte[24];
- // perform test case 2
- try {
- new EllipticCurve(f, a, b, seed);
- fail("#2: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // test case 3 parameters set,
- // both a and b are not in field
- f = new ECFieldFp(BigInteger.valueOf(23L));
- a = BigInteger.valueOf(25L);
- b = BigInteger.valueOf(240L);
- seed = new byte[24];
- // perform test case 3
- try {
- new EllipticCurve(f, a, b, seed);
- fail("#3: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test #4 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
- * constructor<br>
- * Assertion: throws <code>IllegalArgumentException</code> if
- * <code>a</code> or <code>b</code> is not <code>null</code> and not in
- * the <code>field</code><br>
- * Test preconditions: pass <code>a</code>, <code>b</code> which are
- * not in the <code>field</code> of type <code>ECFieldF2m</code><br>
- * Expected: must throw <code>IllegalArgumentException</code>
- */
- public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray04() {
- // test case 1 parameters set,
- // a is not in field
- ECFieldF2m f = new ECFieldF2m(5);
- BigInteger a = BigInteger.valueOf(32L);
- BigInteger b = BigInteger.valueOf(19L);
- byte[] seed = new byte[24];
-
- // perform test case 1
- try {
- new EllipticCurve(f, a, b, seed);
- fail("#1: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // test case 2 parameters set,
- // b is not in field
- f = new ECFieldF2m(5);
- a = BigInteger.valueOf(19L);
- b = BigInteger.valueOf(32L);
- seed = new byte[24];
- // perform test case 2
- try {
- new EllipticCurve(f, a, b, seed);
- fail("#2: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // test case 3 parameters set,
- // both a and b are not in field
- f = new ECFieldF2m(5);
- a = BigInteger.valueOf(32L);
- b = BigInteger.valueOf(43L);
- seed = new byte[24];
- // perform test case 3
- try {
- new EllipticCurve(f, a, b, seed);
- fail("#3: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test #5 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
- * constructor<br>
- * Assertion: array <code>seed</code> is copied to prevent subsequent modification<br>
- * Test preconditions: pass <code>seed</code> to the ctor then modify it<br>
- * Expected: getSeed() must return unmodified array
- */
- public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray05() {
- ECFieldF2m f = new ECFieldF2m(5);
- BigInteger a = BigInteger.valueOf(0L);
- BigInteger b = BigInteger.valueOf(19L);
- byte[] seed = new byte[24];
- byte[] seedCopy = seed.clone();
- EllipticCurve c = new EllipticCurve(f, a, b, seedCopy);
- // modify array passed
- seedCopy[0] = (byte) 1;
- // check that above modification did not changed
- // internal state of test object
- assertTrue(Arrays.equals(seed, c.getSeed()));
- }
-
- /**
- * Test #1 for <code>EllipticCurve(ECField, BigInteger, BigInteger)</code>
- * constructor<br>
- * Assertion: creates instance of EllipticCurve<br>
- * Test preconditions: valid parameters passed, field type is ECFieldFp<br>
- * Expected: must pass without any exceptions
- */
- public final void testEllipticCurveECFieldBigIntegerBigInteger01() {
- // test case 1 parameters set
- ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
- BigInteger a = BigInteger.ONE;
- BigInteger b = BigInteger.valueOf(19L);
- // perform test case 1
- new EllipticCurve(f, a, b);
-
- // test case 2 parameters set
- ECFieldF2m f1 = new ECFieldF2m(5);
- a = BigInteger.ZERO;
- b = BigInteger.valueOf(23L);
- // perform test case 2
- new EllipticCurve(f1, a, b);
-
- // test case 3 parameters set,
- // the seed parameter may be null
- f = new ECFieldFp(BigInteger.valueOf(23L));
- a = BigInteger.ONE;
- b = BigInteger.valueOf(19L);
- // perform test case 3
- new EllipticCurve(f, a, b);
- }
-
- /**
- * Test #2 for <code>EllipticCurve(ECField, BigInteger, BigInteger)</code>
- * constructor<br>
- * Assertion: throws <code>NullPointerException</code> if <code>field</code>,
- * <code>a</code> or <code>b</code> is <code>null</code><br>
- * Test preconditions: pass <code>null</code> as mentioned parameters<br>
- * Expected: must throw <code>NullPointerException</code>
- */
- public final void testEllipticCurveECFieldBigIntegerBigInteger02() {
- // test case 1 parameters set
- ECFieldFp f = null;
- BigInteger a = BigInteger.ONE;
- BigInteger b = BigInteger.valueOf(19L);
-
- // perform test case 1
- try {
- new EllipticCurve(f, a, b);
- fail("#1: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
- // test case 2 parameters set,
- f = new ECFieldFp(BigInteger.valueOf(23L));
- a = null;
- b = BigInteger.valueOf(19L);
- // perform test case 2
- try {
- new EllipticCurve(f, a, b);
- fail("#2: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
- // test case 3 parameters set,
- f = new ECFieldFp(BigInteger.valueOf(23L));
- a = BigInteger.ONE;
- b = null;
- // perform test case 3
- try {
- new EllipticCurve(f, a, b);
- fail("#3: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test #3 for <code>EllipticCurve(ECField, BigInteger, BigInteger)</code>
- * constructor<br>
- * Assertion: throws <code>IllegalArgumentException</code> if
- * <code>a</code> or <code>b</code> is not <code>null</code> and not in
- * the <code>field</code><br>
- * Test preconditions: pass <code>a</code>, <code>b</code> which are
- * not in the <code>field</code> of type <code>ECFieldFp</code><br>
- * Expected: must throw <code>IllegalArgumentException</code>
- */
- public final void testEllipticCurveECFieldBigIntegerBigInteger03() {
- // test case 1 parameters set,
- // a is not in field
- ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
- BigInteger a = BigInteger.valueOf(24L);
- BigInteger b = BigInteger.valueOf(19L);
-
- // perform test case 1
- try {
- new EllipticCurve(f, a, b);
- fail("#1: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // test case 1.1 parameters set,
- // a is not in field
- f = new ECFieldFp(BigInteger.valueOf(23L));
- a = BigInteger.valueOf(23L);
- b = BigInteger.valueOf(19L);
- // perform test case 1.1
- try {
- new EllipticCurve(f, a, b);
- fail("#1.1: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // test case 2 parameters set,
- // b is not in field
- f = new ECFieldFp(BigInteger.valueOf(23L));
- a = BigInteger.valueOf(19L);
- b = BigInteger.valueOf(24L);
- // perform test case 2
- try {
- new EllipticCurve(f, a, b);
- fail("#2: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // test case 3 parameters set,
- // both a and b are not in field
- f = new ECFieldFp(BigInteger.valueOf(23L));
- a = BigInteger.valueOf(25L);
- b = BigInteger.valueOf(240L);
- // perform test case 3
- try {
- new EllipticCurve(f, a, b);
- fail("#3: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test #4 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
- * constructor<br>
- * Assertion: throws <code>IllegalArgumentException</code> if
- * <code>a</code> or <code>b</code> is not <code>null</code> and not in
- * the <code>field</code><br>
- * Test preconditions: pass <code>a</code>, <code>b</code> which are
- * not in the <code>field</code> of type <code>ECFieldF2m</code><br>
- * Expected: must throw <code>IllegalArgumentException</code>
- */
- public final void testEllipticCurveECFieldBigIntegerBigInteger04() {
- // test case 1 parameters set,
- // a is not in field
- ECFieldF2m f = new ECFieldF2m(5);
- BigInteger a = BigInteger.valueOf(32L);
- BigInteger b = BigInteger.valueOf(19L);
- // perform test case 1
- try {
- new EllipticCurve(f, a, b);
- fail("#1: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // test case 2 parameters set,
- // b is not in field
- f = new ECFieldF2m(5);
- a = BigInteger.valueOf(19L);
- b = BigInteger.valueOf(32L);
- // perform test case 2
- try {
- new EllipticCurve(f, a, b);
- fail("#2: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // test case 3 parameters set,
- // both a and b are not in field
- f = new ECFieldF2m(5);
- a = BigInteger.valueOf(32L);
- b = BigInteger.valueOf(43L);
- // perform test case 3
- try {
- new EllipticCurve(f, a, b);
- fail("#3: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test for <code>getA()</code> method<br>
- * Assertion: returns coefficient <code>a</code><br>
- * Test preconditions: <code>ECFieldF2m</code> instance
- * created using valid parameters<br>
- * Expected: must return coefficient <code>a</code> which is equal
- * to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetA() {
- ECFieldF2m f = new ECFieldF2m(5);
- BigInteger a = BigInteger.valueOf(5L);
- BigInteger b = BigInteger.valueOf(19L);
- EllipticCurve c = new EllipticCurve(f, a, b);
- assertEquals(a, c.getA());
- assertSame(a, c.getA());
- }
-
- /**
- * @tests java/security/spec/EllipticCurve#EllipticCurve(EcField,BigInteger,BigInteger)
- */
- public final void testEllipticCurveECFieldBigIntegerBigInteger05() {
- // Regression for Harmony-731
- EllipticCurve ec = new EllipticCurve(new testECField(), BigInteger
- .valueOf(4L), BigInteger.ONE);
- assertEquals("incorrect a", ec.getA(), BigInteger.valueOf(4L));
- assertEquals("incorrect b", ec.getB(), BigInteger.ONE);
- assertEquals("incorrect size", ec.getField().getFieldSize(), 2);
- }
-
- /**
- * Test for <code>getB()</code> method<br>
- * Assertion: returns coefficient <code>b</code><br>
- * Test preconditions: <code>ECFieldF2m</code> instance
- * created using valid parameters<br>
- * Expected: must return coefficient <code>b</code> which is equal
- * to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetB() {
- ECFieldF2m f = new ECFieldF2m(5);
- BigInteger a = BigInteger.valueOf(5L);
- BigInteger b = BigInteger.valueOf(19L);
- EllipticCurve c = new EllipticCurve(f, a, b);
- assertEquals(b, c.getB());
- assertSame(b, c.getB());
- }
-
- /**
- * Test for <code>getField()</code> method<br>
- * Assertion: returns <code>field</code><br>
- * Test preconditions: <code>ECFieldF2m</code> instance
- * created using valid parameters<br>
- * Expected: must return <code>field</code> which is equal
- * to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetField() {
- ECFieldF2m f = new ECFieldF2m(5);
- BigInteger a = BigInteger.valueOf(5L);
- BigInteger b = BigInteger.valueOf(19L);
- EllipticCurve c = new EllipticCurve(f, a, b);
- assertEquals(f, c.getField());
- assertSame(f, c.getField());
- }
-
- /**
- * Test #1 for <code>getSeed()</code> method<br>
- * Assertion: returns <code>seed</code><br>
- * Test preconditions: <code>ECFieldF2m</code> instance
- * created using valid parameters<br>
- * Expected: must return <code>seed</code> which is equal
- * to the one passed to the constructor
- */
- public final void testGetSeed01() {
- ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
- BigInteger a = BigInteger.ONE;
- BigInteger b = BigInteger.valueOf(19L);
- byte[] seed = new byte[24];
- EllipticCurve c = new EllipticCurve(f, a, b, seed);
- byte[] seedRet = c.getSeed();
- assertNotNull(seedRet);
- assertTrue(Arrays.equals(seed, seedRet));
- }
-
- /**
- * Test #2 for <code>getSeed()</code> method<br>
- * Assertion: returned array is copied to prevent subsequent modification<br>
- * Test preconditions: <code>ECFieldF2m</code> instance
- * created using valid parameters; <code>getSeed()</code>
- * called and then returned array modified<br>
- * Expected: internal state must not be affected by the modification
- */
- public final void testGetSeed02() {
- ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
- BigInteger a = BigInteger.ONE;
- BigInteger b = BigInteger.valueOf(19L);
- byte[] seed = new byte[24];
- EllipticCurve c = new EllipticCurve(f, a, b, seed.clone());
- byte[] seedRet = c.getSeed();
- // modify returned array
- seedRet[0] = (byte) 1;
- // check that above modification did not changed
- // internal state of test object
- assertTrue(Arrays.equals(seed, c.getSeed()));
- }
-
- /**
- * Test #3 for <code>getSeed()</code> method<br>
- * Assertion: returned array is copied to prevent subsequent modification<br>
- * Test preconditions: <code>ECFieldF2m</code> instance
- * created using valid parameters<br>
- * Expected: repeated method calls must return different refs
- */
- public final void testGetSeed03() {
- ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
- BigInteger a = BigInteger.ONE;
- BigInteger b = BigInteger.valueOf(19L);
- byte[] seed = new byte[24];
- EllipticCurve c = new EllipticCurve(f, a, b, seed);
- c.getSeed();
- assertNotSame(c.getSeed(), c.getSeed());
- }
-
- /**
- * @tests java.security.spec.EllipticCurve#getSeed()
- * Assertion: null if not specified
- */
- public final void testGetSeed04() {
- //Regression for HARMONY-732
- ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
- BigInteger a = BigInteger.ONE;
- assertNull(new EllipticCurve(f, a, a).getSeed());
- }
-
- /**
- * Test #1 for <code>equals(Object other)</code> method<br>
- * Assertion: return true if this and other objects are equal<br>
- * Test preconditions: see test comments<br>
- * Expected: all objects in this test must be equal
- */
- public final void testEqualsObject01() {
- // test case 1: must be equal to itself
- EllipticCurve c2 = null, c1 = new EllipticCurve(new ECFieldFp(
- BigInteger.valueOf(23L)), BigInteger.ONE, BigInteger
- .valueOf(19L));
- assertTrue(c1.equals(c1));
-
- // test case 2: equal objects
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE, BigInteger.valueOf(19L));
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.valueOf(1L), BigInteger.valueOf(19L));
- assertTrue(c1.equals(c2) && c2.equals(c1));
-
- // test case 3: equal objects with seed not null
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE, BigInteger.valueOf(19L), new byte[24]);
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.valueOf(1L), BigInteger.valueOf(19L), new byte[24]);
- assertTrue(c1.equals(c2) && c2.equals(c1));
-
- // test case 4: equal object and subclass object
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE, BigInteger.valueOf(19L), new byte[24]);
- MyEllipticCurve c3 = new MyEllipticCurve(new ECFieldFp(BigInteger
- .valueOf(23L)), BigInteger.ONE, BigInteger.valueOf(19L),
- new byte[24]);
- assertTrue(c1.equals(c3) && c3.equals(c1));
-
- // test case 5: equal objects
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE, BigInteger.valueOf(19L));
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.valueOf(1L), BigInteger.valueOf(19L), null);
- assertTrue(c1.equals(c2) && c2.equals(c1));
- }
-
- /**
- * Test #1 for <code>hashCode()</code> method.<br>
- * <p/>
- * Assertion: must return the same value if invoked
- * repeatedly on the same object.
- */
- public final void testHashCode01() {
- int hc = 0;
- EllipticCurve f = new EllipticCurve(new ECFieldFp(BigInteger
- .valueOf(23L)), BigInteger.ONE, BigInteger.valueOf(19L),
- new byte[24]);
- hc = f.hashCode();
- assertTrue(hc == f.hashCode() && hc == f.hashCode()
- && hc == f.hashCode() && hc == f.hashCode()
- && hc == f.hashCode() && hc == f.hashCode()
- && hc == f.hashCode() && hc == f.hashCode());
- }
-
- /**
- * Test #2 for <code>hashCode()</code> method.<br>
- * <p/>
- * Assertion: must return the same value if invoked
- * on equal (according to the <code>equals(Object)</code> method) objects.
- */
- public final void testHashCode02() {
- assertEquals(new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE, BigInteger.valueOf(19L), new byte[24])
- .hashCode(), new EllipticCurve(new ECFieldFp(BigInteger
- .valueOf(23L)), BigInteger.ONE, BigInteger.valueOf(19L),
- new byte[24]).hashCode());
- }
-
- //
- // Private stuff
- //
-
- class testECField implements ECField {
-
- public int getFieldSize() {
- return 2;
- }
- }
-
- /**
- * EllipticCurve subclass for testing purposes
- */
- private static class MyEllipticCurve extends EllipticCurve {
-
- MyEllipticCurve(ECField f, BigInteger a, BigInteger b, byte[] seed) {
- super(f, a, b, seed);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpec2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpec2Test.java
deleted file mode 100644
index cd9dde4..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpec2Test.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.security.Key;
-import java.security.KeyFactory;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.interfaces.DSAPrivateKey;
-import java.security.interfaces.DSAPublicKey;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.security.spec.X509EncodedKeySpec;
-
-import junit.framework.TestCase;
-
-public class EncodedKeySpec2Test extends TestCase {
-
- /**
- * @tests java.security.spec.EncodedKeySpec#getEncoded()
- */
- public void test_getEncoded() throws Exception {
-
- KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
-
- keyGen.initialize(1024);
- KeyPair keys = keyGen.generateKeyPair();
-
-
- KeyFactory fact = KeyFactory.getInstance("DSA");
-
-
- // check public key encoding
- byte[] encoded = keys.getPublic().getEncoded();
- Key key = fact.generatePublic(new X509EncodedKeySpec(encoded));
-
- assertTrue("public key encodings were different",
- isEqual(key, keys.getPublic()));
-
- // check private key encoding
- encoded = keys.getPrivate().getEncoded();
- key = fact.generatePrivate(new PKCS8EncodedKeySpec(encoded));
-
- assertTrue("private key encodings were different",
- isEqual(key, keys.getPrivate()));
- }
-
- private boolean isEqual(Key key1, Key key2) {
- if (key1 instanceof DSAPublicKey && key2 instanceof DSAPublicKey) {
- DSAPublicKey dsa1 = ((DSAPublicKey) key1);
- DSAPublicKey dsa2 = ((DSAPublicKey) key2);
- return dsa1.getY().equals(dsa2.getY())
- && dsa1.getParams().getG().equals(dsa2.getParams().getG())
- && dsa1.getParams().getP().equals(dsa2.getParams().getP())
- && dsa1.getParams().getQ().equals(dsa2.getParams().getQ());
-
- } else if (key1 instanceof DSAPrivateKey
- && key2 instanceof DSAPrivateKey) {
- DSAPrivateKey dsa1 = ((DSAPrivateKey) key1);
- DSAPrivateKey dsa2 = ((DSAPrivateKey) key2);
- return dsa1.getX().equals(dsa2.getX())
- && dsa1.getParams().getG().equals(dsa2.getParams().getG())
- && dsa1.getParams().getP().equals(dsa2.getParams().getP())
- && dsa1.getParams().getQ().equals(dsa2.getParams().getQ());
- } else {
- return false;
- }
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpecTest.java
deleted file mode 100644
index e45e824..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpecTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.security.spec.EncodedKeySpec;
-
-import org.apache.harmony.security.tests.support.spec.MyEncodedKeySpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>EncodedKeySpec</code> class fields and methods.
- */
-
-public class EncodedKeySpecTest extends TestCase {
-
- /**
- * Constructor for EncodedKeySpecTest.
- *
- * @param name
- */
- public EncodedKeySpecTest(String name) {
- super(name);
- }
-
- /**
- * Tests that <code>getEncoded()</code> method
- * returns valid byte array
- */
- public final void testGetEncoded() {
-
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
- EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
-
- /* Get encoded key */
- byte[] ek = meks.getEncoded();
-
- /* Check returned array */
- boolean result = true;
- for (int i = 0; i < encodedKey.length; i++) {
- if (encodedKey[i] != ek[i]) {
- /* indicate failure */
- result = false;
- }
- }
- /* passed */
- assertTrue(result);
- }
-
- /**
- * Tests that internal state of the object
- * can not be modified by modifying initial array value
- */
- public final void testIsStatePreserved1() {
- /* Create initial byte array */
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
-
- EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
-
- /* Modify initial array's value */
- encodedKey[3] = (byte) 5;
-
- /* Get encoded key */
- byte[] ek = meks.getEncoded();
-
- /* Check that byte value has not been changed */
- assertTrue(ek[3] == (byte) 4);
- }
-
- /**
- * Tests that internal state of the object
- * can not be modified using returned value
- * of <code>getEncoded()</code> method
- */
- public final void testIsStatePreserved2() {
-
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
- EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
-
- /* Get encoded key */
- byte[] ek = meks.getEncoded();
- /* Modify returned value */
- ek[3] = (byte) 5;
- /* Get encoded key again */
- byte[] ek1 = meks.getEncoded();
-
- /* Check that byte value has not been changed */
- assertTrue(ek1[3] == (byte) 4);
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidKeySpecExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidKeySpecExceptionTest.java
deleted file mode 100644
index 7ea8e23..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidKeySpecExceptionTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.security.spec.InvalidKeySpecException;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>InvalidKeySpecException</code> class constructors and
- * methods.
- */
-public class InvalidKeySpecExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for InvalidKeySpecExceptionTests.
- *
- * @param arg0
- */
- public InvalidKeySpecExceptionTest(String arg0) {
- super(arg0);
- }
-
- private static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- private static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>InvalidKeySpecException()</code> constructor Assertion:
- * constructs InvalidKeySpecException with no detail message
- */
- public void testInvalidKeySpecException01() {
- InvalidKeySpecException tE = new InvalidKeySpecException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidKeySpecException(String)</code> constructor
- * Assertion: constructs InvalidKeySpecException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testInvalidKeySpecException02() {
- InvalidKeySpecException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new InvalidKeySpecException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>InvalidKeySpecException(String)</code> constructor
- * Assertion: constructs InvalidKeySpecException when <code>msg</code> is
- * null
- */
- public void testInvalidKeySpecException03() {
- String msg = null;
- InvalidKeySpecException tE = new InvalidKeySpecException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidKeySpecException(Throwable)</code> constructor
- * Assertion: constructs InvalidKeySpecException when <code>cause</code>
- * is null
- */
- public void testInvalidKeySpecException04() {
- Throwable cause = null;
- InvalidKeySpecException tE = new InvalidKeySpecException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidKeySpecException(Throwable)</code> constructor
- * Assertion: constructs InvalidKeySpecException when <code>cause</code>
- * is not null
- */
- public void testInvalidKeySpecException05() {
- InvalidKeySpecException tE = new InvalidKeySpecException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>InvalidKeySpecException(String, Throwable)</code>
- * constructor Assertion: constructs InvalidKeySpecException when
- * <code>cause</code> is null <code>msg</code> is null
- */
- public void testInvalidKeySpecException06() {
- InvalidKeySpecException tE = new InvalidKeySpecException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidKeySpecException(String, Throwable)</code>
- * constructor Assertion: constructs InvalidKeySpecException when
- * <code>cause</code> is null <code>msg</code> is not null
- */
- public void testInvalidKeySpecException07() {
- InvalidKeySpecException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new InvalidKeySpecException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>InvalidKeySpecException(String, Throwable)</code>
- * constructor Assertion: constructs InvalidKeySpecException when
- * <code>cause</code> is not null <code>msg</code> is null
- */
- public void testInvalidKeySpecException08() {
- InvalidKeySpecException tE = new InvalidKeySpecException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()), tE
- .getCause(), tCause);
- }
-
- /**
- * Test for <code>InvalidKeySpecException(String, Throwable)</code>
- * constructor Assertion: constructs InvalidKeySpecException when
- * <code>cause</code> is not null <code>msg</code> is not null
- */
- public void testInvalidKeySpecException09() {
- InvalidKeySpecException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new InvalidKeySpecException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidParameterSpecExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidParameterSpecExceptionTest.java
deleted file mode 100644
index eaa1997..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidParameterSpecExceptionTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.security.spec.InvalidParameterSpecException;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>InvalidParameterSpecException</code> class constructors and
- * methods.
- */
-public class InvalidParameterSpecExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for InvalidParameterSpecExceptionTests.
- *
- * @param arg0
- */
- public InvalidParameterSpecExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>InvalidParameterSpecException()</code> constructor
- * Assertion: constructs InvalidParameterSpecException with no detail
- * message
- */
- public void testInvalidParameterSpecException01() {
- InvalidParameterSpecException tE = new InvalidParameterSpecException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>InvalidParameterSpecException(String)</code> constructor
- * Assertion: constructs InvalidParameterSpecException with detail message
- * msg. Parameter <code>msg</code> is not null.
- */
- public void testInvalidParameterSpecException02() {
- InvalidParameterSpecException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new InvalidParameterSpecException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>InvalidParameterSpecException(String)</code> constructor
- * Assertion: constructs InvalidParameterSpecException when <code>msg</code>
- * is null
- */
- public void testInvalidParameterSpecException03() {
- String msg = null;
- InvalidParameterSpecException tE = new InvalidParameterSpecException(
- msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/MGF1ParameterSpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/MGF1ParameterSpecTest.java
deleted file mode 100644
index 149479f..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/MGF1ParameterSpecTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.security.spec.MGF1ParameterSpec;
-
-import junit.framework.TestCase;
-
-/**
- * Test for MGF1ParameterSpec class
- */
-public class MGF1ParameterSpecTest extends TestCase {
-
- /**
- * Meaningless algorithm name just for testing purposes
- */
- private static final String testAlgName = "TEST";
-
- /**
- * Constructor for MGF1ParameterSpecTest.
- *
- * @param arg0
- */
- public MGF1ParameterSpecTest(String arg0) {
- super(arg0);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>MGF1ParameterSpec</code> constructor<br>
- * Assertion: constructs new <code>MGF1ParameterSpec</code>
- * object using valid parameter
- */
- public final void testMGF1ParameterSpec01() {
- new MGF1ParameterSpec(testAlgName);
- }
-
- /**
- * Test #2 for <code>MGF1ParameterSpec</code> constructor<br>
- * Assertion: <code>NullPointerException</code> if parameter is <code>null</code>
- */
- public final void testMGF1ParameterSpec02() {
- try {
- new MGF1ParameterSpec(null);
- fail("NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test for <code>getDigestAlgorithm</code> method<br>
- * Assertion: returns the algorithm name of the message
- * digest used by the mask generation function
- */
- public final void testGetDigestAlgorithm() {
- MGF1ParameterSpec aps = new MGF1ParameterSpec(testAlgName);
- assertTrue(testAlgName.equals(aps.getDigestAlgorithm()));
- }
-
- /**
- * Test for public static fields and <code>getDigestAlgorithm</code> method<br>
- * Assertion: returns the algorithm name of the message
- * digest used by the mask generation function
- */
- public final void testFieldsGetDigestAlgorithm() {
- assertEquals("SHA-1", MGF1ParameterSpec.SHA1.getDigestAlgorithm());
- assertEquals("SHA-256", MGF1ParameterSpec.SHA256.getDigestAlgorithm());
- assertEquals("SHA-384", MGF1ParameterSpec.SHA384.getDigestAlgorithm());
- assertEquals("SHA-512", MGF1ParameterSpec.SHA512.getDigestAlgorithm());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PKCS8EncodedKeySpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PKCS8EncodedKeySpecTest.java
deleted file mode 100644
index e11e135..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PKCS8EncodedKeySpecTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.security.spec.EncodedKeySpec;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>PKCS8EncodedKeySpec</code> class fields and methods.
- */
-public class PKCS8EncodedKeySpecTest extends TestCase {
-
- /**
- * Constructor for PKCS8EncodedKeySpecTest.
- *
- * @param name
- */
- public PKCS8EncodedKeySpecTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test for <code>PKCS8EncodedKeySpec</code> constructor<br>
- * Assertion: constructs new <code>PKCS8EncodedKeySpec</code>
- * object using valid parameter
- */
- public final void testPKCS8EncodedKeySpec() {
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
-
- EncodedKeySpec eks = new PKCS8EncodedKeySpec(encodedKey);
-
- assertTrue(eks instanceof PKCS8EncodedKeySpec);
- }
-
- /**
- * Test for <code>getEncoded()</code> method<br>
- * Assertion: returns encoded key
- */
- public final void testGetEncoded() {
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
-
- PKCS8EncodedKeySpec meks = new PKCS8EncodedKeySpec(encodedKey);
-
- byte[] ek = meks.getEncoded();
-
- assertTrue(Arrays.equals(encodedKey, ek));
- }
-
- /**
- * Test for <code>getFormat()</code> method
- * Assertion: returns format name (always "PKCS#8")
- */
- public final void testGetFormat() {
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
-
- PKCS8EncodedKeySpec meks = new PKCS8EncodedKeySpec(encodedKey);
-
- assertEquals("PKCS#8", meks.getFormat());
- }
-
- /**
- * Tests that internal state of the object
- * can not be changed by modifying initial
- * array value
- */
- public final void testIsStatePreserved1() {
- // Reference array
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
- // Reference array's copy will be used for test
- byte[] encodedKeyCopy = encodedKey.clone();
-
- PKCS8EncodedKeySpec meks = new PKCS8EncodedKeySpec(encodedKeyCopy);
-
- // Modify initial array's value
- encodedKeyCopy[3] = (byte) 5;
-
- // Get encoded key
- byte[] ek = meks.getEncoded();
-
- // Check using reference array that
- // byte value has not been changed
- assertTrue(Arrays.equals(encodedKey, ek));
- }
-
- /**
- * Tests that internal state of the object
- * can not be modified using returned value
- * of <code>getEncoded()</code> method
- */
- public final void testIsStatePreserved2() {
- // Reference array
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
- // Reference array's copy will be used for test
- byte[] encodedKeyCopy = encodedKey.clone();
-
- PKCS8EncodedKeySpec meks = new PKCS8EncodedKeySpec(encodedKeyCopy);
-
- byte[] ek = meks.getEncoded();
-
- // Modify returned array
- ek[3] = (byte) 5;
-
- // Get encoded key again
- byte[] ek1 = meks.getEncoded();
-
- // Check using reference array that
- // byte value has not been changed
- assertTrue(Arrays.equals(encodedKey, ek1));
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PSSParameterSpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PSSParameterSpecTest.java
deleted file mode 100644
index 78a5393..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PSSParameterSpecTest.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.MGF1ParameterSpec;
-import java.security.spec.PSSParameterSpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>PSSParameterSpec</code> class (1.5)
- */
-public class PSSParameterSpecTest extends TestCase {
-
- /**
- * Constructor for PSSParameterSpecTest.
- *
- * @param name
- */
- public PSSParameterSpecTest(String name) {
- super(name);
- }
-
- /**
- * Test #1 for <code>PSSParameterSpec(int)</code> ctor<br>
- * Assertion: constructs using valid parameter
- * <code>PSSParameterSpec<code> object
- */
- public final void testPSSParameterSpec0101() {
- AlgorithmParameterSpec aps = new PSSParameterSpec(20);
- assertTrue(aps instanceof PSSParameterSpec);
- }
-
- /**
- * Test #2 for <code>PSSParameterSpec(int)</code> ctor<br>
- * Assertion:
- * throws <code>IllegalArgumentException</code>
- * if <code>saltLen</code> less than 0
- */
- public final void testPSSParameterSpec0102() {
- try {
- new PSSParameterSpec(-1);
- fail("Expected IAE not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Test #1 for
- * <code>
- * PSSParameterSpec(String,String,AlgorithmParameterSpec,int,int)
- * </code> ctor<br>
- * Assertion: constructs using valid parameters
- * <code>PSSParameterSpec<code> object
- */
- public final void testPSSParameterSpec0201() {
- AlgorithmParameterSpec aps = new PSSParameterSpec("SHA-1", "MGF1",
- MGF1ParameterSpec.SHA1, 20, 1);
- assertTrue(aps instanceof PSSParameterSpec);
- }
-
- /**
- * Test #2 for
- * <code>
- * PSSParameterSpec(String,String,AlgorithmParameterSpec,int,int)
- * </code> ctor<br>
- * Assertion:
- * throws <code>NullPointerException</code>
- * if <code>mdName</code> is null
- */
- public final void testPSSParameterSpec0202() {
- try {
- new PSSParameterSpec(null, "MGF1", MGF1ParameterSpec.SHA1, 20, 1);
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #3 for
- * <code>
- * PSSParameterSpec(String,String,AlgorithmParameterSpec,int,int)
- * </code> ctor<br>
- * Assertion:
- * throws <code>NullPointerException</code>
- * if <code>mgfName</code> is null
- */
- public final void testPSSParameterSpec0203() {
- try {
- new PSSParameterSpec("SHA-1", null, MGF1ParameterSpec.SHA1, 20, 1);
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #4 for
- * <code>
- * PSSParameterSpec(String,String,AlgorithmParameterSpec,int,int)
- * </code> ctor<br>
- * Assertion:
- * throws <code>IllegalArgumentException<code>
- * if <code>saltLen<code> less than 0
- */
- public final void testPSSParameterSpec0204() {
- try {
- new PSSParameterSpec("SHA-1", "MGF1",
- MGF1ParameterSpec.SHA1, -20, 1);
- fail("Expected IAE not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Test #5 for
- * <code>
- * PSSParameterSpec(String,String,AlgorithmParameterSpec,int,int)
- * </code> ctor<br>
- * Assertion:
- * throws <code>IllegalArgumentException</code>
- * if <code>trailerField</code> less than 0
- */
- public final void testPSSParameterSpec0205() {
- try {
- new PSSParameterSpec("SHA-1", "MGF1",
- MGF1ParameterSpec.SHA1, 20, -1);
- fail("Expected IAE not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Test #6 for
- * <code>
- * PSSParameterSpec(String,String,AlgorithmParameterSpec,int,int)
- * </code> ctor<br>
- * Assertion: <code>AlgorithmParameterSpec</code> can be null
- */
- public final void testPSSParameterSpec0206() {
- new PSSParameterSpec("SHA-1", "MGF1", null, 20, 1);
- }
-
- /**
- * Test for <code>getDigestAlgorithm()</code> method
- * Assertion: returns message digest algorithm name
- */
- public final void testGetDigestAlgorithm() {
- PSSParameterSpec pssps = new PSSParameterSpec("SHA-1", "MGF1",
- MGF1ParameterSpec.SHA1, 20, 1);
- assertEquals("SHA-1", pssps.getDigestAlgorithm());
- }
-
- /**
- * Test for <code>getMGFAlgorithm()</code> method
- * Assertion: returns mask generation function algorithm name
- */
- public final void testGetMGFAlgorithm() {
- PSSParameterSpec pssps = new PSSParameterSpec("SHA-1", "MGF1",
- MGF1ParameterSpec.SHA1, 20, 1);
- assertEquals("MGF1", pssps.getMGFAlgorithm());
- }
-
- /**
- * Test #1 for <code>getMGFParameters()</code> method
- * Assertion: returns mask generation function parameters
- */
- public final void testGetMGFParameters01() {
- PSSParameterSpec pssps = new PSSParameterSpec("SHA-1", "MGF1",
- MGF1ParameterSpec.SHA1, 20, 1);
- assertTrue(MGF1ParameterSpec.SHA1.equals(pssps.getMGFParameters()));
- }
-
- /**
- * Test #2 for <code>getMGFParameters()</code> method
- * Assertion: returns <code>null</code>
- * if <code>null</code> had been passed as
- * AlgorithmParameterSpec parameter to the ctor
- */
- public final void testGetMGFParameters02() {
- PSSParameterSpec pssps = new PSSParameterSpec("SHA-1", "MGF1",
- null, 20, 1);
- assertNull(pssps.getMGFParameters());
- }
-
-
- /**
- * Test for <code>getSaltLength()</code> method<br>
- * Assertion: returns salt length value
- */
- public final void testGetSaltLength() {
- PSSParameterSpec pssps = new PSSParameterSpec(20);
- assertEquals(20, pssps.getSaltLength());
- }
-
- /**
- * Test for <code>getTrailerField()</code> method<br>
- * Assertion: returns trailer field value
- */
- public final void testGetTrailerField() {
- PSSParameterSpec pssps = new PSSParameterSpec("SHA-1", "MGF1",
- MGF1ParameterSpec.SHA1, 20, 1);
- assertEquals(1, pssps.getTrailerField());
- }
-
- /**
- * Test for <code>DEFAULT</code> field<br>
- * Assertion: default message digest algorithm name is "SHA-1"
- */
- public final void testDEFAULTmdName() {
- assertEquals("SHA-1", PSSParameterSpec.DEFAULT.getDigestAlgorithm());
- }
-
- /**
- * Test for <code>DEFAULT</code> field<br>
- * Assertion: default mask generation function algorithm name is "MGF1"
- */
- public final void testDEFAULTmgfName() {
- assertEquals("MGF1", PSSParameterSpec.DEFAULT.getMGFAlgorithm());
- }
-
- /**
- * Test for <code>DEFAULT</code> field<br>
- * Assertion: default algorithm parameters for mask
- * generation function are <code>MGF1ParameterSpec.SHA1</code>
- */
- public final void testDEFAULTmgfSpec() {
- assertTrue(MGF1ParameterSpec.SHA1.equals(PSSParameterSpec.DEFAULT.getMGFParameters()));
- }
-
- /**
- * Test for <code>DEFAULT</code> field<br>
- * Assertion: default salt length value is 20
- */
- public final void testDEFAULTsaltLen() {
- assertEquals(20, PSSParameterSpec.DEFAULT.getSaltLength());
- }
-
- /**
- * Test for <code>DEFAULT</code> field<br>
- * Assertion: default trailer field value is 1
- */
- public final void testDEFAULTtrailerField() {
- assertEquals(1, PSSParameterSpec.DEFAULT.getTrailerField());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAKeyGenParameterSpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAKeyGenParameterSpecTest.java
deleted file mode 100644
index d166f13..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAKeyGenParameterSpecTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.RSAKeyGenParameterSpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>RSAKeyGenParameterSpec</code> class fields and methods.
- */
-public class RSAKeyGenParameterSpecTest extends TestCase {
-
- /**
- * Constructor for RSAKeyGenParameterSpecTest.
- *
- * @param name
- */
- public RSAKeyGenParameterSpecTest(String name) {
- super(name);
- }
-
- /**
- * Test for <code>RSAKeyGenParameterSpec(int,BigInteger)</code> ctor
- * Assertion: constructs <code>RSAKeyGenParameterSpec</code>
- * object using valid parameters
- */
- public final void testRSAKeyGenParameterSpec() {
- AlgorithmParameterSpec aps =
- new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L));
- assertTrue(aps instanceof RSAKeyGenParameterSpec);
- }
-
- /**
- * Test for <code>getKeySize()</code> method<br>
- * Assertion: returns key size value
- */
- public final void testGetKeysize() {
- RSAKeyGenParameterSpec rkgps =
- new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L));
- assertEquals(512, rkgps.getKeysize());
- }
-
- /**
- * Test for <code>getPublicExponent()</code> method<br>
- * Assertion: returns public exponent value
- */
- public final void testGetPublicExponent() {
- RSAKeyGenParameterSpec rkgps =
- new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L));
- assertEquals(0, rkgps.getPublicExponent().intValue());
- }
-
- /**
- * Test for <code>F0</code> field<br>
- * Assertion: the public exponent value F0 = 3
- */
- public final void testF0Value() {
- assertEquals(3, RSAKeyGenParameterSpec.F0.intValue());
- }
-
- /**
- * Test for <code>F4</code> field<br>
- * Assertion: the public exponent value F0 = 65537
- */
- public final void testF4Value() {
- assertEquals(65537, RSAKeyGenParameterSpec.F4.intValue());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java
deleted file mode 100644
index 72fd03e..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java
+++ /dev/null
@@ -1,708 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.KeySpec;
-import java.security.spec.RSAMultiPrimePrivateCrtKeySpec;
-import java.security.spec.RSAOtherPrimeInfo;
-import java.security.spec.RSAPrivateKeySpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>RSAMultiPrimePrivateCrtKeySpec</code> class fields and methods.
- */
-public class RSAMultiPrimePrivateCrtKeySpecTest extends TestCase {
- /**
- * Reference array of RSAOtherPrimeInfo. DO NOT MODIFY
- */
- private static final RSAOtherPrimeInfo[] opi = new RSAOtherPrimeInfo[] {
- new RSAOtherPrimeInfo(BigInteger.ONE, BigInteger.ONE, BigInteger.ONE),
- new RSAOtherPrimeInfo(BigInteger.ONE, BigInteger.ONE, BigInteger.ONE),
- new RSAOtherPrimeInfo(BigInteger.ONE, BigInteger.ONE, BigInteger.ONE)
- };
-
- /**
- * Constructor for RSAMultiPrimePrivateCrtKeySpecTest.
- *
- * @param name
- */
- public RSAMultiPrimePrivateCrtKeySpecTest(String name) {
- super(name);
- }
-
- // Test-cases:
-
- /**
- * Test #1 for
- * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
- * BigInteger publicExponent,
- * BigInteger privateExponent,
- * BigInteger primeP,
- * BigInteger primeQ,
- * BigInteger primeExponentP,
- * BigInteger primeExponentQ,
- * BigInteger crtCoefficient,
- * RSAOtherPrimeInfo[] otherPrimeInfo)
- * </code> ctor<br>
- * Assertion: constructs <code>RSAMultiPrimePrivateCrtKeySpec</code>
- * object using valid parameters
- */
- public final void testRSAMultiPrimePrivateCrtKeySpec01() {
- KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- assertTrue(ks instanceof RSAMultiPrimePrivateCrtKeySpec);
- }
-
- /**
- * Test #2 for
- * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
- * BigInteger publicExponent,
- * BigInteger privateExponent,
- * BigInteger primeP,
- * BigInteger primeQ,
- * BigInteger primeExponentP,
- * BigInteger primeExponentQ,
- * BigInteger crtCoefficient,
- * RSAOtherPrimeInfo[] otherPrimeInfo)
- * </code> ctor<br>
- * Assertion: NullPointerException if modulus is null
- */
- public final void testRSAMultiPrimePrivateCrtKeySpec02() {
- try {
- new RSAMultiPrimePrivateCrtKeySpec(
- null,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #3 for
- * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
- * BigInteger publicExponent,
- * BigInteger privateExponent,
- * BigInteger primeP,
- * BigInteger primeQ,
- * BigInteger primeExponentP,
- * BigInteger primeExponentQ,
- * BigInteger crtCoefficient,
- * RSAOtherPrimeInfo[] otherPrimeInfo)
- * </code> ctor<br>
- * Assertion: NullPointerException if publicExponent is null
- */
- public final void testRSAMultiPrimePrivateCrtKeySpec03() {
- try {
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- null,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #4 for
- * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
- * BigInteger publicExponent,
- * BigInteger privateExponent,
- * BigInteger primeP,
- * BigInteger primeQ,
- * BigInteger primeExponentP,
- * BigInteger primeExponentQ,
- * BigInteger crtCoefficient,
- * RSAOtherPrimeInfo[] otherPrimeInfo)
- * </code> ctor<br>
- * Assertion: NullPointerException if privateExponent is null
- */
- public final void testRSAMultiPrimePrivateCrtKeySpec04() {
- try {
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- null,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #5 for
- * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
- * BigInteger publicExponent,
- * BigInteger privateExponent,
- * BigInteger primeP,
- * BigInteger primeQ,
- * BigInteger primeExponentP,
- * BigInteger primeExponentQ,
- * BigInteger crtCoefficient,
- * RSAOtherPrimeInfo[] otherPrimeInfo)
- * </code> ctor<br>
- * Assertion: NullPointerException if primeP is null
- */
- public final void testRSAMultiPrimePrivateCrtKeySpec05() {
- try {
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- null,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #6 for
- * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
- * BigInteger publicExponent,
- * BigInteger privateExponent,
- * BigInteger primeP,
- * BigInteger primeQ,
- * BigInteger primeExponentP,
- * BigInteger primeExponentQ,
- * BigInteger crtCoefficient,
- * RSAOtherPrimeInfo[] otherPrimeInfo)
- * </code> ctor<br>
- * Assertion: NullPointerException if primeQ is null
- */
- public final void testRSAMultiPrimePrivateCrtKeySpec06() {
- try {
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- null,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #7 for
- * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
- * BigInteger publicExponent,
- * BigInteger privateExponent,
- * BigInteger primeP,
- * BigInteger primeQ,
- * BigInteger primeExponentP,
- * BigInteger primeExponentQ,
- * BigInteger crtCoefficient,
- * RSAOtherPrimeInfo[] otherPrimeInfo)
- * </code> ctor<br>
- * Assertion: NullPointerException if primeExponentP is null
- */
- public final void testRSAMultiPrimePrivateCrtKeySpec07() {
- try {
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- null,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #8 for
- * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
- * BigInteger publicExponent,
- * BigInteger privateExponent,
- * BigInteger primeP,
- * BigInteger primeQ,
- * BigInteger primeExponentP,
- * BigInteger primeExponentQ,
- * BigInteger crtCoefficient,
- * RSAOtherPrimeInfo[] otherPrimeInfo)
- * </code> ctor<br>
- * Assertion: NullPointerException if primeExponentQ is null
- */
- public final void testRSAMultiPrimePrivateCrtKeySpec08() {
- try {
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- null,
- BigInteger.ONE,
- opi);
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #9 for
- * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
- * BigInteger publicExponent,
- * BigInteger privateExponent,
- * BigInteger primeP,
- * BigInteger primeQ,
- * BigInteger primeExponentP,
- * BigInteger primeExponentQ,
- * BigInteger crtCoefficient,
- * RSAOtherPrimeInfo[] otherPrimeInfo)
- * </code> ctor<br>
- * Assertion: NullPointerException if crtCoefficient is null
- */
- public final void testRSAMultiPrimePrivateCrtKeySpec09() {
- try {
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- null,
- opi);
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #10 for
- * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
- * BigInteger publicExponent,
- * BigInteger privateExponent,
- * BigInteger primeP,
- * BigInteger primeQ,
- * BigInteger primeExponentP,
- * BigInteger primeExponentQ,
- * BigInteger crtCoefficient,
- * RSAOtherPrimeInfo[] otherPrimeInfo)
- * </code> ctor<br>
- * Assertion: otherPrimeInfo can be null
- */
- public final void testRSAMultiPrimePrivateCrtKeySpec10() {
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- null);
- }
-
- /**
- * Test #11 for
- * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
- * BigInteger publicExponent,
- * BigInteger privateExponent,
- * BigInteger primeP,
- * BigInteger primeQ,
- * BigInteger primeExponentP,
- * BigInteger primeExponentQ,
- * BigInteger crtCoefficient,
- * RSAOtherPrimeInfo[] otherPrimeInfo)
- * </code> ctor<br>
- * Assertion: IllegalArgumentException if otherPrimeInfo length is 0
- */
- public final void testRSAMultiPrimePrivateCrtKeySpec11() {
- try {
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- new RSAOtherPrimeInfo[0]);
- fail("Expected IAE not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Test #12 for
- * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
- * BigInteger publicExponent,
- * BigInteger privateExponent,
- * BigInteger primeP,
- * BigInteger primeQ,
- * BigInteger primeExponentP,
- * BigInteger primeExponentQ,
- * BigInteger crtCoefficient,
- * RSAOtherPrimeInfo[] otherPrimeInfo)
- * </code> ctor<br>
- * Assertion: constructs <code>RSAMultiPrimePrivateCrtKeySpec</code>
- * object using valid parameters. Constructed object must be
- * instance of RSAPrivateKeySpec.
- */
- public final void testRSAMultiPrimePrivateCrtKeySpec12() {
- KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- assertTrue(ks instanceof RSAPrivateKeySpec);
- }
-
- /**
- * Test for <code>getCrtCoefficient()</code> method<br>
- * Assertion: returns crt coefficient
- */
- public final void testGetCrtCoefficient() {
- RSAMultiPrimePrivateCrtKeySpec ks =
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- assertTrue(BigInteger.ONE.equals(ks.getCrtCoefficient()));
- }
-
- /**
- * Test for <code>getPrimeExponentP()</code> method<br>
- * Assertion: returns prime exponent P
- */
- public final void testGetPrimeExponentP() {
- RSAMultiPrimePrivateCrtKeySpec ks =
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- assertTrue(BigInteger.ONE.equals(ks.getPrimeExponentP()));
- }
-
- /**
- * Test for <code>getPrimeExponentQ()</code> method<br>
- * Assertion: returns prime exponent Q
- */
- public final void testGetPrimeExponentQ() {
- RSAMultiPrimePrivateCrtKeySpec ks =
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- assertTrue(BigInteger.ONE.equals(ks.getPrimeExponentQ()));
- }
-
- /**
- * Test for <code>getPrimeP()</code> method<br>
- * Assertion: returns prime P
- */
- public final void testGetPrimeP() {
- RSAMultiPrimePrivateCrtKeySpec ks =
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- assertTrue(BigInteger.ONE.equals(ks.getPrimeP()));
- }
-
- /**
- * Test for <code>getPrimeQ()</code> method<br>
- * Assertion: returns prime Q
- */
- public final void testGetPrimeQ() {
- RSAMultiPrimePrivateCrtKeySpec ks =
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- assertTrue(BigInteger.ONE.equals(ks.getPrimeQ()));
- }
-
- /**
- * Test for <code>getPublicExponent()</code> method<br>
- * Assertion: returns public exponent
- */
- public final void testGetPublicExponent() {
- RSAMultiPrimePrivateCrtKeySpec ks =
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- assertTrue(BigInteger.ONE.equals(ks.getPublicExponent()));
- }
-
- /**
- * Test #1 for <code>getOtherPrimeInfo()</code> method<br>
- * Assertion: returns array of RSAOtherPrimeInfo
- */
- public final void testGetOtherPrimeInfo01() {
- RSAMultiPrimePrivateCrtKeySpec ks =
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- assertTrue(checkOtherPrimeInfo(ks.getOtherPrimeInfo()));
- }
-
- /**
- * Test #2 for <code>getOtherPrimeInfo()</code> method<br>
- * Assertion: returns null if null has been passed to the
- * constructor as otherPrimeInfo parameter
- */
- public final void testGetOtherPrimeInfo02() {
- RSAMultiPrimePrivateCrtKeySpec ks =
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- null);
- assertNull(ks.getOtherPrimeInfo());
- }
-
- //
- // immutability tests
- //
-
- /**
- * Tests that internal state of the object
- * can not be modified by modifying initial array
- */
- public final void testIsStatePreserved1() {
- // Create initial array
- RSAOtherPrimeInfo[] opi1 = opi.clone();
-
- RSAMultiPrimePrivateCrtKeySpec ks = new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi1);
-
- // Modify initial array
- opi1[2] = new RSAOtherPrimeInfo(BigInteger.ZERO,
- BigInteger.ZERO,
- BigInteger.ZERO);
-
- // Check that above modification
- // does not affect internal state
- assertTrue(checkOtherPrimeInfo(ks.getOtherPrimeInfo()));
- }
-
- /**
- * Tests that internal state of the object
- * can not be modified using array reference
- * returned by <code>getOtherPrimeInfo()</code>
- * method
- */
- public final void testIsStatePreserved2() {
- // Create initial array
- RSAOtherPrimeInfo[] opi1 = opi.clone();
-
- RSAMultiPrimePrivateCrtKeySpec ks = new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi1);
-
- RSAOtherPrimeInfo[] ret = ks.getOtherPrimeInfo();
-
- // Modify returned array
- ret[2] = new RSAOtherPrimeInfo(BigInteger.ZERO,
- BigInteger.ZERO,
- BigInteger.ZERO);
-
- // Check that above modification
- // does not affect internal state
- assertTrue(checkOtherPrimeInfo(ks.getOtherPrimeInfo()));
- }
-
- //
- // Tests for inherited methods
- //
-
- /**
- * Test for <code>getModulus()</code> method<br>
- * Assertion: returns modulus
- */
- public final void testGetModulus() {
- RSAMultiPrimePrivateCrtKeySpec ks =
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- assertTrue(BigInteger.ONE.equals(ks.getModulus()));
- }
-
- /**
- * Test for <code>getPrivateExponent()</code> method<br>
- * Assertion: returns private exponent
- */
- public final void testGetPrivateExponent() {
- RSAMultiPrimePrivateCrtKeySpec ks =
- new RSAMultiPrimePrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- opi);
- assertTrue(BigInteger.ONE.equals(ks.getPrivateExponent()));
- }
-
-// private stuff
-//
-
- /**
- * Compares array passed as a parameter with reference one<br>
- * <p/>
- * <code>private static final RSAOtherPrimeInfo[] opi</code>
- *
- * @param toBeChecked Array to be compared
- * @return true if arrays are equal
- */
- private boolean checkOtherPrimeInfo(RSAOtherPrimeInfo[] toBeChecked) {
- if (toBeChecked == null || toBeChecked.length != opi.length) {
- return false;
- }
- for (int i = 0; i < opi.length; i++) {
- if (opi[i].getPrime().equals(toBeChecked[i].getPrime()) &&
- opi[i].getExponent().equals(toBeChecked[i].getExponent()) &&
- opi[i].getCrtCoefficient().equals(toBeChecked[i].getCrtCoefficient())) {
- continue;
- }
- return false;
- }
- return true;
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAOtherPrimeInfoTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAOtherPrimeInfoTest.java
deleted file mode 100644
index bd6c2f8..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAOtherPrimeInfoTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.RSAOtherPrimeInfo;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>RSAOtherPrimeInfo</code> class fields and methods.
- */
-public class RSAOtherPrimeInfoTest extends TestCase {
-
- /**
- * Constructor for RSAOtherPrimeInfoTest.
- *
- * @param name
- */
- public RSAOtherPrimeInfoTest(String name) {
- super(name);
- }
-
- /**
- * Test #1 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
- * Assertion: constructs <code>RSAOtherPrimeInfo</code>
- * object using valid parameter
- */
- public final void testRSAOtherPrimeInfo01() {
- Object o =
- new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
- BigInteger.valueOf(2L),
- BigInteger.valueOf(3L));
- assertTrue(o instanceof RSAOtherPrimeInfo);
- }
-
- /**
- * Test #2 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
- * Assertion: NullPointerException if prime is null
- */
- public final void testRSAOtherPrimeInfo02() {
- try {
- new RSAOtherPrimeInfo(null,
- BigInteger.valueOf(2L),
- BigInteger.valueOf(3L));
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #3 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
- * Assertion: NullPointerException if primeExponent is null
- */
- public final void testRSAOtherPrimeInfo03() {
- try {
- new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
- null,
- BigInteger.valueOf(3L));
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #4 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
- * Assertion: NullPointerException if crtCoefficient is null
- */
- public final void testRSAOtherPrimeInfo04() {
- try {
- new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
- BigInteger.valueOf(2L),
- null);
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #5 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
- * Assertion: NullPointerException if prime and crtCoefficient is null
- */
- public final void testRSAOtherPrimeInfo05() {
- try {
- new RSAOtherPrimeInfo(null,
- BigInteger.valueOf(2L),
- null);
- fail("Expected NPE not thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test for <code>getCrtCoefficient()</code> method<br>
- * Assertion: returns CRT coefficient value
- */
- public final void testGetCrtCoefficient() {
- RSAOtherPrimeInfo ropi =
- new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
- BigInteger.valueOf(2L),
- BigInteger.valueOf(3L));
- assertEquals(3L, ropi.getCrtCoefficient().longValue());
- }
-
- /**
- * Test for <code>getPrime()</code> method<br>
- * Assertion: returns prime value
- */
- public final void testGetPrime() {
- RSAOtherPrimeInfo ropi =
- new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
- BigInteger.valueOf(2L),
- BigInteger.valueOf(3L));
- assertEquals(1L, ropi.getPrime().longValue());
- }
-
- /**
- * Test for <code>getExponent()</code> method<br>
- * Assertion: returns prime exponent value
- */
- public final void testGetExponent() {
- RSAOtherPrimeInfo ropi =
- new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
- BigInteger.valueOf(2L),
- BigInteger.valueOf(3L));
- assertEquals(2L, ropi.getExponent().longValue());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateCrtKeySpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateCrtKeySpecTest.java
deleted file mode 100644
index 98924d3..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateCrtKeySpecTest.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.KeySpec;
-import java.security.spec.RSAPrivateCrtKeySpec;
-import java.security.spec.RSAPrivateKeySpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>RSAPrivateCrtKeySpec</code> class fields and methods
- */
-public class RSAPrivateCrtKeySpecTest extends TestCase {
-
- /**
- * Constructor for RSAPrivateCrtKeySpecTest.
- *
- * @param name
- */
- public RSAPrivateCrtKeySpecTest(String name) {
- super(name);
- }
-
- /**
- * Test #1 for <code>RSAPrivateCrtKeySpec</code> constructor
- * Assertion: Constructs <code>RSAPrivateCrtKeySpec</code>
- * object using valid parameters
- */
- public final void testRSAPrivateCrtKeySpec01() {
- KeySpec ks = new RSAPrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE);
- assertTrue(ks instanceof RSAPrivateCrtKeySpec);
- }
-
- /**
- * Test #2 for <code>RSAPrivateCrtKeySpec</code> constructor
- * Assertion: Constructs <code>RSAPrivateCrtKeySpec</code>
- * object using valid parameters
- */
- public final void testRSAPrivateCrtKeySpec02() {
- KeySpec ks = new RSAPrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE);
- assertTrue(ks instanceof RSAPrivateKeySpec);
- }
-
- /**
- * Test #3 for <code>RSAPrivateCrtKeySpec</code> constructor
- * Assertion: Constructs <code>RSAPrivateCrtKeySpec</code>
- * object using valid parameters
- */
- public final void testRSAPrivateCrtKeySpec03() {
- new RSAPrivateCrtKeySpec(
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null);
- }
-
- /**
- * Test for <code>getCrtCoefficient()</code> method<br>
- * Assertion: returns crt coefficient
- */
- public final void testGetCrtCoefficient() {
- RSAPrivateCrtKeySpec ks = new RSAPrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.valueOf(5L));
- assertTrue(BigInteger.valueOf(5L).equals(ks.getCrtCoefficient()));
- }
-
- /**
- * Test for <code>getPrimeExponentP()</code> method<br>
- * Assertion: returns prime exponent P
- */
- public final void testGetPrimeExponentP() {
- RSAPrivateCrtKeySpec ks = new RSAPrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.valueOf(5L),
- BigInteger.ONE,
- BigInteger.ONE);
- assertTrue(BigInteger.valueOf(5L).equals(ks.getPrimeExponentP()));
- }
-
- /**
- * Test for <code>getPrimeExponentQ()</code> method<br>
- * Assertion: returns prime exponent Q
- */
- public final void testGetPrimeExponentQ() {
- RSAPrivateCrtKeySpec ks = new RSAPrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.valueOf(5L),
- BigInteger.ONE);
- assertTrue(BigInteger.valueOf(5L).equals(ks.getPrimeExponentQ()));
- }
-
- /**
- * Test for <code>getPrimeP()</code> method<br>
- * Assertion: returns prime P
- */
- public final void testGetPrimeP() {
- RSAPrivateCrtKeySpec ks = new RSAPrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.valueOf(5L),
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE);
- assertTrue(BigInteger.valueOf(5L).equals(ks.getPrimeP()));
- }
-
- /**
- * Test for <code>getPrimeQ()</code> method<br>
- * Assertion: returns prime Q
- */
- public final void testGetPrimeQ() {
- RSAPrivateCrtKeySpec ks = new RSAPrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.valueOf(5L),
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE);
- assertTrue(BigInteger.valueOf(5L).equals(ks.getPrimeQ()));
- }
-
- /**
- * Test for <code>getPublicExponent()</code> method<br>
- * Assertion: returns public exponent
- */
- public final void testGetPublicExponent() {
- RSAPrivateCrtKeySpec ks = new RSAPrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.valueOf(5L),
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE);
- assertTrue(BigInteger.valueOf(5L).equals(ks.getPublicExponent()));
- }
-
- //
- // Tests for inherited methods
- //
-
- /**
- * Test for <code>getModulus()</code> method<br>
- * Assertion: returns modulus
- */
- public final void testGetModulus() {
- RSAPrivateCrtKeySpec ks = new RSAPrivateCrtKeySpec(
- BigInteger.valueOf(5L),
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE);
- assertTrue(BigInteger.valueOf(5L).equals(ks.getModulus()));
- }
-
- /**
- * Test for <code>getPrivateExponent()</code> method<br>
- * Assertion: returns private exponent
- */
- public final void testGetPrivateExponent() {
- RSAPrivateCrtKeySpec ks = new RSAPrivateCrtKeySpec(
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.valueOf(5L),
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE,
- BigInteger.ONE);
- assertTrue(BigInteger.valueOf(5L).equals(ks.getPrivateExponent()));
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateKeySpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateKeySpecTest.java
deleted file mode 100644
index 00c4a7c..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateKeySpecTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.KeySpec;
-import java.security.spec.RSAPrivateKeySpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>RSAPrivateKeySpec</code> class fields and methods
- */
-public class RSAPrivateKeySpecTest extends TestCase {
-
- /**
- * Constructor for RSAPrivateKeySpecTest.
- *
- * @param name
- */
- public RSAPrivateKeySpecTest(String name) {
- super(name);
- }
-
- /**
- * Test for <code>RSAPrivateKeySpec(BigInteger,BigInteger)</code> ctor
- * Assertion: constructs <code>RSAPrivateKeySpec</code>
- * object using valid parameters
- */
- public final void testRSAPrivateKeySpec() {
- KeySpec ks = new RSAPrivateKeySpec(BigInteger.valueOf(1234567890L),
- BigInteger.valueOf(3L));
- assertTrue(ks instanceof RSAPrivateKeySpec);
- }
-
- /**
- * Test for <code>getModulus()</code> method<br>
- * Assertion: returns modulus
- */
- public final void testGetModulus() {
- RSAPrivateKeySpec rpks =
- new RSAPrivateKeySpec(BigInteger.valueOf(1234567890L),
- BigInteger.valueOf(3L));
- assertEquals(1234567890L, rpks.getModulus().longValue());
- }
-
- /**
- * Test for <code>getPrivateExponent()</code> method<br>
- * Assertion: returns private exponent
- */
- public final void testGetPrivateExponent() {
- RSAPrivateKeySpec rpks =
- new RSAPrivateKeySpec(BigInteger.valueOf(1234567890L),
- BigInteger.valueOf(3L));
- assertEquals(3L, rpks.getPrivateExponent().longValue());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPublicKeySpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPublicKeySpecTest.java
deleted file mode 100644
index 7440804..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPublicKeySpecTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.KeySpec;
-import java.security.spec.RSAPublicKeySpec;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>RSAPublicKeySpec</code> class fields and methods
- */
-public class RSAPublicKeySpecTest extends TestCase {
-
- /**
- * Constructor for RSAPublicKeySpecTest.
- *
- * @param name
- */
- public RSAPublicKeySpecTest(String name) {
- super(name);
- }
-
-
- /**
- * Test #1 for <code>RSAPublicKeySpec</code> constructor
- * Assertion: Constructs <code>RSAPublicKeySpec</code>
- * object using valid parameters
- */
- public final void testRSAPublicKeySpec01() {
- KeySpec ks =
- new RSAPublicKeySpec(BigInteger.valueOf(1234567890L),
- BigInteger.valueOf(3L));
-
- assertTrue(ks instanceof RSAPublicKeySpec);
- }
-
- /**
- * Test #2 for <code>RSAPublicKeySpec</code> constructor
- * Assertion: Constructs <code>RSAPublicKeySpec</code>
- * object using valid parameters
- */
- public final void testRSAPublicKeySpec02() {
- KeySpec ks =
- new RSAPublicKeySpec(null, null);
-
- assertTrue(ks instanceof RSAPublicKeySpec);
- }
-
- /**
- * Test for <code>getModulus()</code> method<br>
- * Assertion: returns modulus
- */
- public final void testGetModulus() {
- RSAPublicKeySpec rpks =
- new RSAPublicKeySpec(BigInteger.valueOf(1234567890L),
- BigInteger.valueOf(3L));
- assertTrue(BigInteger.valueOf(1234567890L).equals(rpks.getModulus()));
- }
-
- /**
- * Test for <code>getPublicExponent()</code> method<br>
- * Assertion: returns public exponent
- */
- public final void testGetPublicExponent() {
- RSAPublicKeySpec rpks =
- new RSAPublicKeySpec(BigInteger.valueOf(3L),
- BigInteger.valueOf(1234567890L));
- assertTrue(BigInteger.valueOf(1234567890L).equals(rpks.getPublicExponent()));
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/X509EncodedKeySpecTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/X509EncodedKeySpecTest.java
deleted file mode 100644
index 14a3ec4..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/X509EncodedKeySpecTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.security.spec.EncodedKeySpec;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>X509EncodedKeySpec</code> class fields and methods
- */
-public class X509EncodedKeySpecTest extends TestCase {
-
- /**
- * Constructor for X509EncodedKeySpecTest.
- *
- * @param name
- */
- public X509EncodedKeySpecTest(String name) {
- super(name);
- }
-
- //
- // Test cases
- //
-
- /**
- * Test for <code>X509EncodedKeySpec</code> constructor<br>
- * Assertion: constructs new <code>X509EncodedKeySpec</code>
- * object using valid parameter
- */
- public final void testX509EncodedKeySpec() {
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
-
- EncodedKeySpec eks = new X509EncodedKeySpec(encodedKey);
-
- assertTrue(eks instanceof X509EncodedKeySpec);
- }
-
- /**
- * Test for <code>getEncoded()</code> method<br>
- * Assertion: returns encoded key
- */
- public final void testGetEncoded() {
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
-
- X509EncodedKeySpec eks = new X509EncodedKeySpec(encodedKey);
-
- byte[] ek = eks.getEncoded();
-
- assertTrue(Arrays.equals(encodedKey, ek));
- }
-
- /**
- * Test for <code>getFormat()</code> method
- * Assertion: returns format name (always "X.509")
- */
- public final void testGetFormat() {
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
-
- X509EncodedKeySpec meks = new X509EncodedKeySpec(encodedKey);
-
- assertEquals("X.509", meks.getFormat());
- }
-
- /**
- * Tests that internal state of the object
- * can not be changed by modifying initial
- * array value
- */
- public final void testIsStatePreserved1() {
- // Reference array
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
- // Reference array's copy will be used for test
- byte[] encodedKeyCopy = encodedKey.clone();
-
- X509EncodedKeySpec meks = new X509EncodedKeySpec(encodedKeyCopy);
-
- // Modify initial array's value
- encodedKeyCopy[3] = (byte) 5;
-
- // Get encoded key
- byte[] ek = meks.getEncoded();
-
- // Check using reference array that
- // byte value has not been changed
- assertTrue(Arrays.equals(encodedKey, ek));
- }
-
- /**
- * Tests that internal state of the object
- * can not be modified using returned value
- * of <code>getEncoded()</code> method
- */
- public final void testIsStatePreserved2() {
- // Reference array
- byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
- // Reference array's copy will be used for test
- byte[] encodedKeyCopy = encodedKey.clone();
-
- X509EncodedKeySpec meks = new X509EncodedKeySpec(encodedKeyCopy);
-
- byte[] ek = meks.getEncoded();
-
- // Modify returned array
- ek[3] = (byte) 5;
-
- // Get encoded key again
- byte[] ek1 = meks.getEncoded();
-
- // Check using reference array that
- // byte value has not been changed
- assertTrue(Arrays.equals(encodedKey, ek1));
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.java
deleted file mode 100644
index bc4ce3f..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.spec.serialization;
-
-import java.security.spec.InvalidKeySpecException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for InvalidKeySpecException serialization
- */
-
-public class InvalidKeySpecExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- Exception cause = new Exception(msgs[1]);
- InvalidKeySpecException dExc = new InvalidKeySpecException(msgs[0], cause);
- String msg = null;
- Throwable th = null;
- return new Object[] { new InvalidKeySpecException(), new InvalidKeySpecException(msg),
- new InvalidKeySpecException(msgs[1]),
- new InvalidKeySpecException(new Throwable()), new InvalidKeySpecException(th),
- new InvalidKeySpecException(msgs[1], dExc) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.java
deleted file mode 100644
index ecf4f4d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.spec.serialization;
-
-import java.security.spec.InvalidParameterSpecException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for InvalidParameterSpecException serialization
- */
-
-public class InvalidParameterSpecExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new InvalidParameterSpecException(),
- new InvalidParameterSpecException(null),
- new InvalidParameterSpecException(msgs[1]) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateEncodingExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateEncodingExceptionTest.java
deleted file mode 100644
index f6b59bf..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateEncodingExceptionTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.javax.security.cert;
-
-import javax.security.cert.CertificateEncodingException;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>DigestException</code> class constructors and methods.
- */
-public class CertificateEncodingExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertificateEncodingExceptionTests.
- *
- * @param arg0
- */
- public CertificateEncodingExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertificateEncodingException()</code> constructor
- * Assertion: constructs CertificateEncodingException with no detail message
- */
- public void testCertificateEncodingException01() {
- CertificateEncodingException tE = new CertificateEncodingException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateEncodingException(String)</code> constructor
- * Assertion: constructs CertificateEncodingException with detail message
- * msg. Parameter <code>msg</code> is not null.
- */
- public void testCertificateEncodingException02() {
- CertificateEncodingException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateEncodingException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateEncodingException(String)</code> constructor
- * Assertion: constructs CertificateEncodingException when <code>msg</code>
- * is null
- */
- public void testCertificateEncodingException03() {
- String msg = null;
- CertificateEncodingException tE = new CertificateEncodingException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExceptionTest.java
deleted file mode 100644
index ad2b12b..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExceptionTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.javax.security.cert;
-
-import javax.security.cert.CertificateException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>DigestException</code> class constructors and methods.
- */
-public class CertificateExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertificateExceptionTests.
- *
- * @param arg0
- */
- public CertificateExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertificateException()</code> constructor Assertion:
- * constructs CertificateException with no detail message
- */
- public void testCertificateException01() {
- CertificateException tE = new CertificateException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateException(String)</code> constructor
- * Assertion: constructs CertificateException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testCertificateException02() {
- CertificateException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateException(String)</code> constructor
- * Assertion: constructs CertificateException when <code>msg</code> is
- * null
- */
- public void testCertificateException03() {
- String msg = null;
- CertificateException tE = new CertificateException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExpiredExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExpiredExceptionTest.java
deleted file mode 100644
index 262deec..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExpiredExceptionTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.javax.security.cert;
-
-import javax.security.cert.CertificateExpiredException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>DigestException</code> class constructors and methods.
- */
-public class CertificateExpiredExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertificateExpiredExceptionTests.
- *
- * @param arg0
- */
- public CertificateExpiredExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertificateExpiredException()</code> constructor
- * Assertion: constructs CertificateExpiredException with no detail message
- */
- public void testCertificateExpiredException01() {
- CertificateExpiredException tE = new CertificateExpiredException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateExpiredException(String)</code> constructor
- * Assertion: constructs CertificateExpiredException with detail message
- * msg. Parameter <code>msg</code> is not null.
- */
- public void testCertificateExpiredException02() {
- CertificateExpiredException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateExpiredException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateExpiredException(String)</code> constructor
- * Assertion: constructs CertificateExpiredException when <code>msg</code>
- * is null
- */
- public void testCertificateExpiredException03() {
- String msg = null;
- CertificateExpiredException tE = new CertificateExpiredException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateNotYetValidExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateNotYetValidExceptionTest.java
deleted file mode 100644
index 5600928..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateNotYetValidExceptionTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.javax.security.cert;
-
-import javax.security.cert.CertificateNotYetValidException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>DigestException</code> class constructors and methods.
- */
-public class CertificateNotYetValidExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertificateNotYetValidExceptionTests.
- *
- * @param arg0
- */
- public CertificateNotYetValidExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertificateNotYetValidException()</code> constructor
- * Assertion: constructs CertificateNotYetValidException with no detail
- * message
- */
- public void testCertificateNotYetValidException01() {
- CertificateNotYetValidException tE = new CertificateNotYetValidException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateNotYetValidException(String)</code>
- * constructor Assertion: constructs CertificateNotYetValidException with
- * detail message msg. Parameter <code>msg</code> is not null.
- */
- public void testCertificateNotYetValidException02() {
- CertificateNotYetValidException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateNotYetValidException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateNotYetValidException(String)</code>
- * constructor Assertion: constructs CertificateNotYetValidException when
- * <code>msg</code> is null
- */
- public void testCertificateNotYetValidException03() {
- String msg = null;
- CertificateNotYetValidException tE = new CertificateNotYetValidException(
- msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateParsingExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateParsingExceptionTest.java
deleted file mode 100644
index fe18857..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateParsingExceptionTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.javax.security.cert;
-
-import javax.security.cert.CertificateParsingException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>DigestException</code> class constructors and methods.
- */
-public class CertificateParsingExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for CertificateParsingExceptionTests.
- *
- * @param arg0
- */
- public CertificateParsingExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>CertificateParsingException()</code> constructor
- * Assertion: constructs CertificateParsingException with no detail message
- */
- public void testCertificateParsingException01() {
- CertificateParsingException tE = new CertificateParsingException();
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>CertificateParsingException(String)</code> constructor
- * Assertion: constructs CertificateParsingException with detail message
- * msg. Parameter <code>msg</code> is not null.
- */
- public void testCertificateParsingException02() {
- CertificateParsingException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new CertificateParsingException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>CertificateParsingException(String)</code> constructor
- * Assertion: constructs CertificateParsingException when <code>msg</code>
- * is null
- */
- public void testCertificateParsingException03() {
- String msg = null;
- CertificateParsingException tE = new CertificateParsingException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateTest.java
deleted file mode 100644
index 1b0017f..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.javax.security.cert;
-
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.PublicKey;
-import java.security.SignatureException;
-
-import javax.security.cert.Certificate;
-import javax.security.cert.CertificateEncodingException;
-import javax.security.cert.CertificateException;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class CertificateTest extends TestCase {
-
- /**
- * The stub class used for testing of non abstract methods.
- */
- private class TBTCert extends Certificate {
- public byte[] getEncoded()
- throws CertificateEncodingException {
- return null;
- }
-
- public void verify(PublicKey key)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- }
-
- public void verify(PublicKey key, String sigProvider)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- }
-
- public String toString() {
- return null;
- }
-
- public PublicKey getPublicKey() {
- return null;
- }
- }
-
- /**
- * equals(Object obj) method testing. Tests the correctness of equal
- * operation: it should be reflexive, symmetric, transitive, consistent
- * and should be false on null object.
- */
- public void testEquals() {
- TBTCert tbt_cert = new TBTCert() {
- public byte[] getEncoded() {
- return new byte[] { 1, 2, 3 };
- }
- };
-
- TBTCert tbt_cert_1 = new TBTCert() {
- public byte[] getEncoded() {
- return new byte[] { 1, 2, 3 };
- }
- };
-
- TBTCert tbt_cert_2 = new TBTCert() {
- public byte[] getEncoded() {
- return new byte[] { 1, 2, 3 };
- }
- };
-
- TBTCert tbt_cert_3 = new TBTCert() {
- public byte[] getEncoded() {
- return new byte[] { 3, 2, 1 };
- }
- };
-
- // checking for reflexive law:
- assertTrue("The equivalence relation should be reflexive.",
- tbt_cert.equals(tbt_cert));
-
- assertEquals("The Certificates with equal encoded form should be equal",
- tbt_cert, tbt_cert_1);
- // checking for symmetric law:
- assertTrue("The equivalence relation should be symmetric.",
- tbt_cert_1.equals(tbt_cert));
-
- assertEquals("The Certificates with equal encoded form should be equal",
- tbt_cert_1, tbt_cert_2);
- // checking for transitive law:
- assertTrue("The equivalence relation should be transitive.",
- tbt_cert.equals(tbt_cert_2));
-
- assertFalse("Should not be equal to null object.",
- tbt_cert.equals(null));
-
- assertFalse("The Certificates with differing encoded form "
- + "should not be equal", tbt_cert.equals(tbt_cert_3));
- assertFalse("The Certificates should not be equals to the object "
- + "which is not an instance of Certificate",
- tbt_cert.equals(new Object()));
- }
-
- /**
- * hashCode() method testing.
- */
- public void testHashCode() {
- TBTCert tbt_cert = new TBTCert() {
- public byte[] getEncoded() {
- return new byte[] { 1, 2, 3 };
- }
- };
- TBTCert tbt_cert_1 = new TBTCert() {
- public byte[] getEncoded() {
- return new byte[] { 1, 2, 3 };
- }
- };
-
- assertTrue("Equal objects should have the same hash codes.",
- tbt_cert.hashCode() == tbt_cert_1.hashCode());
- }
-
- public static Test suite() {
- return new TestSuite(CertificateTest.class);
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/X509CertificateTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/X509CertificateTest.java
deleted file mode 100644
index ab541f3..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/X509CertificateTest.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.javax.security.cert;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.security.cert.CertificateFactory;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-
-import javax.security.cert.CertificateEncodingException;
-import javax.security.cert.CertificateException;
-import javax.security.cert.CertificateExpiredException;
-import javax.security.cert.CertificateNotYetValidException;
-import javax.security.cert.X509Certificate;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-/**
- */
-
-public class X509CertificateTest extends TestCase {
-
- // Testing data was generated by using of classes
- // from org.apache.harmony.security.asn1 package encoded
- // by org.apache.harmony.misc.Base64 class.
-
- private static String base64cert =
- "-----BEGIN CERTIFICATE-----\n" +
- "MIIC+jCCAragAwIBAgICAiswDAYHKoZIzjgEAwEBADAdMRswGQYDVQQKExJDZXJ0a" +
- "WZpY2F0ZSBJc3N1ZXIwIhgPMTk3MDAxMTIxMzQ2NDBaGA8xOTcwMDEyNDAzMzMyMF" +
- "owHzEdMBsGA1UEChMUU3ViamVjdCBPcmdhbml6YXRpb24wGTAMBgcqhkjOOAQDAQE" +
- "AAwkAAQIDBAUGBwiBAgCqggIAVaOCAhQwggIQMA8GA1UdDwEB/wQFAwMBqoAwEgYD" +
- "VR0TAQH/BAgwBgEB/wIBBTAUBgNVHSABAf8ECjAIMAYGBFUdIAAwZwYDVR0RAQH/B" +
- "F0wW4EMcmZjQDgyMi5OYW1lggdkTlNOYW1lpBcxFTATBgNVBAoTDE9yZ2FuaXphdG" +
- "lvboYaaHR0cDovL3VuaWZvcm0uUmVzb3VyY2UuSWSHBP///wCIByoDolyDsgMwDAY" +
- "DVR0eAQH/BAIwADAMBgNVHSQBAf8EAjAAMIGZBgNVHSUBAf8EgY4wgYsGBFUdJQAG" +
- "CCsGAQUFBwMBBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMDBggrBgEFBQcDB" +
- "AYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEFBQcDBwYIKwYBBQUHAwgGCCsGAQUFBw" +
- "MJBggrBgEFBQgCAgYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GA1UdNgEB/wQDAgE" +
- "BMA4GBCpNhgkBAf8EAwEBATBkBgNVHRIEXTBbgQxyZmNAODIyLk5hbWWCB2ROU05h" +
- "bWWkFzEVMBMGA1UEChMMT3JnYW5pemF0aW9uhhpodHRwOi8vdW5pZm9ybS5SZXNvd" +
- "XJjZS5JZIcE////AIgHKgOiXIOyAzAJBgNVHR8EAjAAMAoGA1UdIwQDAQEBMAoGA1" +
- "UdDgQDAQEBMAoGA1UdIQQDAQEBMAwGByqGSM44BAMBAQADMAAwLQIUAL4QvoazNWP" +
- "7jrj84/GZlhm09DsCFQCBKGKCGbrP64VtUt4JPmLjW1VxQA==\n" +
- "-----END CERTIFICATE-----";
-
- private java.security.cert.X509Certificate cert;
- private javax.security.cert.X509Certificate tbt_cert;
-
- protected void setUp() throws Exception {
- try {
- ByteArrayInputStream bais =
- new ByteArrayInputStream(base64cert.getBytes());
-
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- this.cert = (java.security.cert.X509Certificate)
- cf.generateCertificate(bais);
- this.tbt_cert = X509Certificate.getInstance(cert.getEncoded());
- } catch (java.security.cert.CertificateException e) {
- // The requested certificate type is not available.
- // Test pass..
- this.cert = null;
- } catch (javax.security.cert.CertificateException e) {
- // The requested certificate type is not available.
- // Test pass..
- this.cert = null;
- }
- }
-
- /**
- * getInstance(InputStream inStream) method testing.
- */
- public void testGetInstance1() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- try {
- ByteArrayInputStream bais =
- new ByteArrayInputStream(cert.getEncoded());
-
- X509Certificate.getInstance(bais);
- } catch (java.security.cert.CertificateEncodingException e) {
- e.printStackTrace();
- fail("Unexpected CertificateEncodingException was thrown.");
- } catch (CertificateEncodingException e) {
- e.printStackTrace();
- fail("Unexpected CertificateEncodingException was thrown.");
- } catch (CertificateException e) {
- // The requested certificate type is not available.
- // Test pass..
- }
-
- // Regression for HARMONY-756
- try {
- X509Certificate.getInstance((InputStream) null);
- fail("No expected CertificateException");
- } catch (CertificateException e) {
- //expected;
- }
- }
-
- /**
- * getInstance(byte[] certData) method testing.
- */
- public void testGetInstance2() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- try {
- X509Certificate.getInstance(cert.getEncoded());
- } catch (java.security.cert.CertificateEncodingException e) {
- e.printStackTrace();
- fail("Unexpected CertificateEncodingException was thrown.");
- } catch (CertificateException e) {
- // The requested certificate type is not available.
- // Test pass..
- }
-
- // Regression for HARMONY-756
- try {
- X509Certificate.getInstance((byte[]) null);
- fail("No expected CertificateException");
- } catch (CertificateException e) {
- //expected;
- }
- }
-
- /**
- * checkValidity() method testing.
- */
- public void testCheckValidity1() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- Date date = new Date();
- Date nb_date = tbt_cert.getNotBefore();
- Date na_date = tbt_cert.getNotAfter();
- try {
- tbt_cert.checkValidity();
- assertFalse("CertificateExpiredException expected",
- date.compareTo(na_date) > 0);
- assertFalse("CertificateNotYetValidException expected",
- date.compareTo(nb_date) < 0);
- } catch (CertificateExpiredException e) {
- assertTrue("Unexpected CertificateExpiredException was thrown",
- date.compareTo(na_date) > 0);
- } catch (CertificateNotYetValidException e) {
- assertTrue("Unexpected CertificateNotYetValidException was thrown",
- date.compareTo(nb_date) < 0);
- }
- }
-
- /**
- * checkValidity(Date date) method testing.
- */
- public void testCheckValidity2() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- Date[] date = new Date[4];
- Calendar calendar = Calendar.getInstance();
- for (int i = 0; i < date.length; i++) {
- calendar.set(i * 50, Calendar.JANUARY, 1);
- date[i] = calendar.getTime();
- }
- Date nb_date = tbt_cert.getNotBefore();
- Date na_date = tbt_cert.getNotAfter();
- for (int i = 0; i < date.length; i++) {
- try {
- tbt_cert.checkValidity(date[i]);
- assertFalse("CertificateExpiredException expected",
- date[i].compareTo(na_date) > 0);
- assertFalse("CertificateNotYetValidException expected",
- date[i].compareTo(nb_date) < 0);
- } catch (CertificateExpiredException e) {
- assertTrue("Unexpected CertificateExpiredException was thrown",
- date[i].compareTo(na_date) > 0);
- } catch (CertificateNotYetValidException e) {
- assertTrue("Unexpected CertificateNotYetValidException "
- + "was thrown", date[i].compareTo(nb_date) < 0);
- }
- }
- }
-
- /**
- * getVersion() method testing.
- */
- public void testGetVersion() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- assertEquals("The version is not correct.",
- tbt_cert.getVersion(), 2);
- }
-
- /**
- * getSerialNumber() method testing.
- */
- public void testGetSerialNumber() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- assertEquals("The serial number is not correct.",
- tbt_cert.getSerialNumber(), cert.getSerialNumber());
- }
-
- /**
- * getIssuerDN() method testing.
- */
- public void testGetIssuerDN() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- assertEquals("The issuer DN is not correct.",
- tbt_cert.getIssuerDN(), cert.getIssuerDN());
- }
-
- /**
- * getSubjectDN() method testing.
- */
- public void testGetSubjectDN() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- assertEquals("The subject DN is not correct.",
- tbt_cert.getSubjectDN(), cert.getSubjectDN());
- }
-
- /**
- * getNotBefore() method testing.
- */
- public void testGetNotBefore() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- assertEquals("The NotBefore date is not correct.",
- tbt_cert.getNotBefore(), cert.getNotBefore());
- }
-
- /**
- * getNotAfter() method testing.
- */
- public void testGetNotAfter() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- assertEquals("The NotAfter date is not correct.",
- tbt_cert.getNotAfter(), cert.getNotAfter());
- }
-
- /**
- * getSigAlgName() method testing.
- */
- public void testGetSigAlgName() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- assertEquals("The name of signature algorithm is not correct.",
- tbt_cert.getSigAlgName(), cert.getSigAlgName());
- }
-
- /**
- * getSigAlgOID() method testing.
- */
- public void testGetSigAlgOID() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- assertEquals("The name of OID of signature algorithm is not correct.",
- tbt_cert.getSigAlgOID(), cert.getSigAlgOID());
- }
-
- /**
- * getSigAlgParams() method testing.
- */
- public void testGetSigAlgParams() {
- if (this.cert == null) {
- // The requested certificate type is not available.
- // Test can not be applied.
- return;
- }
- assertTrue("The byte array with encoded algorithm parameters "
- + "is not correct.", Arrays.equals(tbt_cert.getSigAlgParams(),
- cert.getSigAlgParams()));
- }
-
- public static Test suite() {
- return new TestSuite(X509CertificateTest.class);
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.java
deleted file mode 100644
index cd38914..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.javax.security.cert.serialization;
-
-import javax.security.cert.CertificateEncodingException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertificateEncodingException serialization
- */
-
-public class CertificateEncodingExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new CertificateEncodingException(),
- new CertificateEncodingException(null),
- new CertificateEncodingException(msgs[0]),
- new CertificateEncodingException(msgs[1]) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.java
deleted file mode 100644
index 46ca665..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.javax.security.cert.serialization;
-
-import javax.security.cert.CertificateException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertificateException serialization
- */
-
-public class CertificateExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new CertificateException(), new CertificateException(null),
- new CertificateException(msgs[0]),
- new CertificateException(msgs[1]) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.java
deleted file mode 100644
index 9b1c20f..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.javax.security.cert.serialization;
-
-import javax.security.cert.CertificateExpiredException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertificateExpiredException serialization
- */
-
-public class CertificateExpiredExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
-
- return new Object[] { new CertificateExpiredException(),
- new CertificateExpiredException(null),
- new CertificateExpiredException(msgs[1]) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.java
deleted file mode 100644
index 859541d..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.javax.security.cert.serialization;
-
-import javax.security.cert.CertificateNotYetValidException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertificateNotYetValidException serialization
- */
-
-public class CertificateNotYetValidExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new CertificateNotYetValidException(),
- new CertificateNotYetValidException(null),
- new CertificateNotYetValidException(msgs[1]) };
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.java
deleted file mode 100644
index e58082a..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.javax.security.cert.serialization;
-
-import javax.security.cert.CertificateParsingException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for CertificateParsingException serialization
- */
-
-public class CertificateParsingExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- protected Object[] getData() {
- return new Object[] { new CertificateParsingException(),
- new CertificateParsingException(null),
- new CertificateParsingException(msgs[1]),
- new CertificateParsingException(msgs[1]) };
- }
-
-}
diff --git a/security/src/test/api/java/tests/api/java/security/AccessControlContextTest.java b/security/src/test/api/java/tests/api/java/security/AccessControlContextTest.java
deleted file mode 100644
index 943fcbb..0000000
--- a/security/src/test/api/java/tests/api/java/security/AccessControlContextTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tests.api.java.security;
-
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.ProtectionDomain;
-import java.util.PropertyPermission;
-
-public class AccessControlContextTest extends junit.framework.TestCase {
-
- /**
- * @tests java.security.AccessControlContext#AccessControlContext(java.security.ProtectionDomain[])
- */
- public void test_Constructor$Ljava_security_ProtectionDomain() {
- // Test for method
- // java.security.AccessControlContext(java.security.ProtectionDomain [])
-
- // Create a permission which is not normally granted
- final Permission perm = new PropertyPermission("java.class.path",
- "read");
- PermissionCollection col = perm.newPermissionCollection();
- col.add(perm);
- final ProtectionDomain pd = new ProtectionDomain(null, col);
- AccessControlContext acc = new AccessControlContext(
- new ProtectionDomain[] { pd });
- try {
- acc.checkPermission(perm);
- } catch (SecurityException e) {
- fail("Should have permission");
- }
-
- final boolean[] result = new boolean[] { false };
- Thread th = new Thread(new Runnable() {
- public void run() {
- AccessControlContext acc = new AccessControlContext(
- new ProtectionDomain[] { pd });
- try {
- acc.checkPermission(perm);
- result[0] = true;
- } catch (SecurityException e) {
- }
- }
- });
- th.start();
- try {
- th.join();
- } catch (InterruptedException e) {
- // ignore
- }
- assertTrue("Thread should have permission", result[0]);
- }
-
- /**
- * @tests java.security.AccessControlContext#AccessControlContext(java.security.AccessControlContext,
- *java.security.DomainCombiner)
- */
- public void test_ConstructorLjava_security_AccessControlContextLjava_security_DomainCombiner() {
- AccessControlContext context = AccessController.getContext();
- try {
- new AccessControlContext(context, null);
- } catch (NullPointerException e) {
- fail("should not throw NullPointerException");
- }
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/tests/api/java/security/DomainCombinerTest.java b/security/src/test/api/java/tests/api/java/security/DomainCombinerTest.java
deleted file mode 100644
index 1fb7c74..0000000
--- a/security/src/test/api/java/tests/api/java/security/DomainCombinerTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tests.api.java.security;
-
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.AllPermission;
-import java.security.BasicPermission;
-import java.security.CodeSource;
-import java.security.DomainCombiner;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.security.PrivilegedAction;
-import java.security.ProtectionDomain;
-import java.security.SecurityPermission;
-import java.security.cert.Certificate;
-
-public class DomainCombinerTest extends junit.framework.TestCase {
-
- /**
- * @tests java.security.DomainCombiner#combine(java.security.ProtectionDomain[],
- *java.security.ProtectionDomain[])
- */
- public void test_combine$Ljava_security_ProtectionDomain$Ljava_security_ProtectionDomain() {
- final boolean[] calledDomainCombiner = new boolean[] { false, false };
-
- class MyCombiner implements DomainCombiner {
- int i;
-
- MyCombiner(int i) {
- this.i = i;
- }
-
- public ProtectionDomain[] combine(
- ProtectionDomain[] executionDomains,
- ProtectionDomain[] parentDomains) {
- calledDomainCombiner[i] = true;
- PermissionCollection pc = new Permissions();
- pc.add(new AllPermission());
- ProtectionDomain pd;
- // if run with the system classloader then there will be no
- // execution domains
- if (executionDomains.length > 0) {
- pd = new ProtectionDomain(executionDomains[0]
- .getCodeSource(), pc);
- } else {
- pd = new ProtectionDomain(parentDomains[0].getCodeSource(),
- pc);
- }
- return new ProtectionDomain[] { pd };
- }
- }
-
- ProtectionDomain[] domains = new ProtectionDomain[] { new ProtectionDomain(
- new CodeSource(null, (Certificate[]) null), new Permissions()) };
-
- AccessControlContext parent = new AccessControlContext(domains);
- AccessControlContext c0 = new AccessControlContext(parent,
- new MyCombiner(0));
- final AccessControlContext c1 = new AccessControlContext(parent,
- new MyCombiner(1));
-
- class TestPermission extends BasicPermission {
- TestPermission(String s) {
- super(s);
- }
- }
-
- }
-}
diff --git a/security/src/test/impl/java.injected/java/security/Provider_ImplTest.java b/security/src/test/impl/java.injected/java/security/Provider_ImplTest.java
deleted file mode 100644
index 86a1d49..0000000
--- a/security/src/test/impl/java.injected/java/security/Provider_ImplTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package java.security;
-
-import java.util.HashMap;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>Provider</code> constructor and methods
- */
-public class Provider_ImplTest extends TestCase {
-
- Provider p;
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- p = new MyProvider();
- }
-
- /*
- * Class under test for String toString()
- */
- public final void testToString() {
- assertEquals("Incorrect provider.toString()", "MyProvider version 1.0",
- p.toString());
- }
-
- public final void testImplementsAlg() {
- HashMap hm = new HashMap();
- hm.put("KeySize", "1024");
- hm.put("AAA", "BBB");
- Provider.Service s = new Provider.Service(p, "Type", "Algorithm",
- "className", null, hm);
- p.putService(s);
- if (!p.implementsAlg("Type", "Algorithm", null, null) ||
- !p.implementsAlg("MessageDigest", "SHA-1", null, null)) {
- fail("Case 1. implementsAlg failed");
- }
- if (!p.implementsAlg("Type", "Algorithm", "KeySize", "512")) {
- fail("Case 2. implementsAlg failed");
- }
- if (p.implementsAlg("Type", "Algorithm", "KeySize", "1025")) {
- fail("Case 3. implementsAlg failed");
- }
- if (!p.implementsAlg("Type", "Algorithm", "AAA", "BBB")) {
- fail("Case 3. implementsAlg failed");
- }
- }
-
- public final void testSetProviderNumber() {
- p.setProviderNumber(100);
- assertEquals("Incorrect ProviderNumber", 100, p.getProviderNumber());
- }
-
- public final void testGetProviderNumber() {
- assertEquals("Incorrect ProviderNumber", -1, p.getProviderNumber());
-
- int i = Security.addProvider(p);
- assertEquals("Incorrect ProviderNumber", i, p.getProviderNumber());
- Security.removeProvider(p.getName()); // clean up
- }
-
- class MyProvider extends Provider {
- MyProvider() {
- super("MyProvider", 1.0, "Provider for testing");
- put("MessageDigest.SHA-1", "SomeClassName");
- put("MessageDigest.abc", "SomeClassName");
- put("Alg.Alias.MessageDigest.SHA1", "SHA-1");
- }
-
- MyProvider(String name, double version, String info) {
- super(name, version, info);
- }
- }
-}
diff --git a/security/src/test/impl/java.injected/java/security/Security_ImplTest.java b/security/src/test/impl/java.injected/java/security/Security_ImplTest.java
deleted file mode 100644
index c50c38e..0000000
--- a/security/src/test/impl/java.injected/java/security/Security_ImplTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package java.security;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>Security</code> constructor and methods
- */
-public class Security_ImplTest extends TestCase {
-
- public final void testGetAlgorithmProperty() {
- assertNull("Incorrect result on null parameter", Security
- .getAlgorithmProperty(null, "MyService"));
- assertNull("Incorrect result on null parameter", Security
- .getAlgorithmProperty("MyAlgorithm", null));
- assertNull("Incorrect result (provider not added)", Security
- .getAlgorithmProperty("MyAlgorithm", "MyService"));
-
- Provider p = new MyProvider();
- Security.addProvider(p);
- try {
- assertEquals("Incorrect result (provider added)",
- "SomeClassName", Security.getAlgorithmProperty("MyAlGoriThm", "MySerVicE"));
- } finally { //clean up
- Security.removeProvider(p.getName());
- }
- }
-
- /*
- * Class under test for Provider[] getProviders()
- */
- public final void testGetProviders() {
- Provider[] providers;
-
- providers = Security.getProviders();
- for (int i = 0; i < providers.length; i++) {
- // position is 1-based
- assertEquals("Incorrect provider number", i + 1, providers[i]
- .getProviderNumber());
- }
- }
-
- /**
- * @tests java.security.Security#getProviders(String)
- */
- public final void test_getProvidersLjava_lang_String() {
- // Regression for Harmony-3154 (non-bug difference)
- try {
- Security.getProviders("AAA.BBB CCC");
- fail("AAA.BBB CCC: No expected InvalidParameterException");
- } catch (InvalidParameterException e) {
- }
- }
-
- /**
- * @tests java.security.Security#getProviders(Map)
- */
- public final void test_getProvidersLjava_util_Map() {
- // Regression for Harmony-3154 (non-bug difference)
- Map<String, String> m = new HashMap<String, String>();
- m.put("AAA.BBB CCC", "");
- m.put("AAA.BBB", "");
- try {
- Security.getProviders(m);
- fail("attribute value is empty string: No expected InvalidParameterException");
- } catch (InvalidParameterException e) {
- }
- }
-
- public final void testGetAlgorithms() {
- Set alg1;
- Set alg2;
-
- alg1 = Security.getAlgorithms("AAAAAAAAAAAAAAA");
- assertTrue("failed for non-existent service", alg1 != null);
- assertEquals("failed for non-existent service", 0, alg1.size());
-
- alg1 = Security.getAlgorithms("SecureRandom");
- alg2 = Security.getAlgorithms("seCuReranDom");
- assertEquals("different size", alg1.size(), alg2.size());
- assertTrue("different content", alg2.containsAll(alg1));
-
- Provider p = new MyProvider();
-
- try {
- Security.addProvider(p);
- alg1 = Security.getAlgorithms("MyService");
- assertEquals("failed for MyService", 1, alg1.size());
- assertTrue("failed for MyService", alg1.contains("MyAlgorithm"));
- } finally { //clean up
- Security.removeProvider(p.getName());
- }
- }
-
- @SuppressWarnings("serial")
- class MyProvider extends Provider {
- MyProvider() {
- super("MyProvider", 1.0, "Provider for testing");
- put("MessageDigest.SHA-1", "SomeClassName");
- put("MyService.MyAlgorithm", "SomeClassName");
- put("MyService.MyAlgorithm KeySize", "1024");
- }
- }
-
-}
diff --git a/security/src/test/impl/java.injected/java/security/Signature_Impl1Test.java b/security/src/test/impl/java.injected/java/security/Signature_Impl1Test.java
deleted file mode 100644
index 60fd3e2..0000000
--- a/security/src/test/impl/java.injected/java/security/Signature_Impl1Test.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package java.security;
-
-import org.apache.harmony.security.tests.support.MySignature1;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>Signature</code> constructor and methods
- */
-public class Signature_Impl1Test extends TestCase {
-
- /*
- * Class under test for int sign(byte[], int, int)
- */
- public void testSignbyteArrayintint() throws Exception {
- MySignature1 s = new MySignature1("ABC");
- byte[] b = new byte[8];
- try {
- s.sign(b, 0, 5);
- fail("No expected SignatureException 1");
- } catch (SignatureException e) {
- }
-
- s.initVerify(new MyPublicKey());
-
- try {
- s.sign(b, 0, 5);
- fail("No expected SignatureException 1");
- } catch (SignatureException e) {
- }
-
- s.initSign(new MyPrivateKey());
- s.sign(b, 0, 5);
- assertEquals("state", Signature.SIGN, s.getState());
- assertTrue("sign() failed", s.runEngineSign);
- }
-
- /*
- * Class under test for String toString()
- */
- public void testToString() {
- MySignature1 s = new MySignature1("ABC");
- assertEquals("toString() failed", "SIGNATURE ABC state: UNINITIALIZED",
- s.toString());
- }
-
- private class MyKey implements Key {
- public String getFormat() {
- return "123";
- }
-
- public byte[] getEncoded() {
- return null;
- }
-
- public String getAlgorithm() {
- return "aaa";
- }
- }
-
- private class MyPublicKey extends MyKey implements PublicKey {
- }
-
- private class MyPrivateKey extends MyKey implements PrivateKey {
- }
-
-}
diff --git a/security/src/test/impl/java.injected/java/security/Signature_Impl2Test.java b/security/src/test/impl/java.injected/java/security/Signature_Impl2Test.java
deleted file mode 100644
index 936cde4..0000000
--- a/security/src/test/impl/java.injected/java/security/Signature_Impl2Test.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package java.security;
-
-import org.apache.harmony.security.tests.support.MySignature1;
-import org.apache.harmony.security.tests.support.MySignature2;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>Signature</code> constructor and methods
- */
-public class Signature_Impl2Test extends TestCase {
-
- /**
- * Provider
- */
- Provider p;
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- p = new MyProvider();
- Security.insertProviderAt(p, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(p.getName());
- }
-
- /*
- * Class under test for Signature getInstance(String)
- */
- public void testGetInstanceString1() throws Exception {
- Signature sig = Signature.getInstance("ABC");
- checkSig1(sig, p);
- }
-
- /*
- * Class under test for Signature getInstance(String)
- */
- public void testGetInstanceString2() throws Exception {
- Signature sig = Signature.getInstance("CBA");
- checkSig2(sig, p);
- }
-
- /*
- * Class under test for Signature getInstance(String, String)
- */
- public void testGetInstanceStringString1() throws Exception {
- Signature sig = Signature.getInstance("ABC", "MyProvider");
- checkSig1(sig, p);
- }
-
- /*
- * Class under test for Signature getInstance(String, String)
- */
- public void testGetInstanceStringString2() throws Exception {
- Signature sig = Signature.getInstance("CBA", "MyProvider");
- checkSig2(sig, p);
- }
-
-
- /*
- * Class under test for Signature getInstance(String, Provider)
- */
- public void testGetInstanceStringProvider1() throws Exception {
- Provider p1 = new MyProvider();
- Signature sig = Signature.getInstance("ABC", p1);
- checkSig1(sig, p1);
- }
-
- /*
- * Class under test for Signature getInstance(String, Provider)
- */
- public void testGetInstanceStringProvider2() throws Exception {
- Provider p2 = new MyProvider();
- Signature sig = Signature.getInstance("CBA", p2);
- checkSig2(sig, p2);
- }
-
- private void checkSig1(Signature s, Provider p) throws Exception {
- byte[] b = { 1, 2, 3, 4 };
- assertTrue("getInstance() failed", s instanceof MySignature1);
- assertEquals("getProvider() failed", p, s.getProvider());
- assertEquals("getAlgorithm() failed", "ABC", s.getAlgorithm());
-
- try {
- s.sign();
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
-
- s.initVerify(new MyPublicKey());
-
- try {
- s.sign();
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
-
- s.initSign(new MyPrivateKey());
- s.sign();
- assertEquals("Incorrect state", Signature.SIGN, ((MySignature1) s)
- .getState());
- assertTrue("sign() failed", ((MySignature1) s).runEngineSign);
-
- s.initVerify(new MyPublicKey());
- s.update((byte) 1);
-
- s.initSign(new MyPrivateKey());
- s.update((byte) 1);
-
- assertEquals("Incorrect state", Signature.SIGN, ((MySignature1) s)
- .getState());
- assertTrue("sign() failed", ((MySignature1) s).runEngineUpdate1);
-
- s.initSign(new MyPrivateKey());
-
- try {
- s.verify(b);
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
- s.initVerify(new MyPublicKey());
- s.verify(b);
- assertEquals("Incorrect state", Signature.VERIFY, ((MySignature1) s)
- .getState());
- assertTrue("verify() failed", ((MySignature1) s).runEngineVerify);
- }
-
- private void checkSig2(Signature s, Provider p) throws Exception {
- byte[] b = { 1, 2, 3, 4 };
-
- assertEquals("getProvider() failed", p, s.getProvider());
- assertEquals("getAlgorithm() failed", "CBA", s.getAlgorithm());
-
- s.initVerify(new MyCertificate());
-
- try {
- s.sign(b, 0, 5);
- fail("No expected IllegalArgumentException 1");
- } catch (IllegalArgumentException e) {
- }
-
- s.initSign(new MyPrivateKey());
- s.sign(b, 0, 3);
-
- assertTrue("sign() failed", MySignature2.runEngineSign);
- s.update(b);
- s.initSign(new MyPrivateKey());
- s.update(b);
- assertTrue("update() failed", MySignature2.runEngineUpdate2);
-
- s.initSign(new MyPrivateKey());
- try {
- s.verify(b, 0, 3);
- fail("No expected SignatureException");
- } catch (SignatureException e) {
- }
- s.initVerify(new MyPublicKey());
-
- try {
- s.verify(b, 0, 5);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- } catch (SignatureException e) {
- }
-
- s.verify(b, 0, 3);
- assertTrue("verify() failed", MySignature2.runEngineVerify);
- }
-
- private class MyProvider extends Provider {
- MyProvider() {
- super("MyProvider", 1.0, "Provider for testing");
- put("Signature.ABC", "org.apache.harmony.security.tests.support.MySignature1");
- put("Signature.CBA", "org.apache.harmony.security.tests.support.MySignature2");
- }
-
- MyProvider(String name, double version, String info) {
- super(name, version, info);
- }
- }
-
- private class MyKey implements Key {
- public String getFormat() {
- return "123";
- }
-
- public byte[] getEncoded() {
- return null;
- }
-
- public String getAlgorithm() {
- return "aaa";
- }
- }
-
- private class MyPublicKey extends MyKey implements PublicKey {
- }
-
- private class MyPrivateKey extends MyKey implements PrivateKey {
- }
-
- private class MyCertificate extends java.security.cert.Certificate {
- public MyCertificate() {
- super("MyCertificateType");
- }
-
- public PublicKey getPublicKey() {
- return new MyPublicKey();
- }
-
- public byte[] getEncoded() {
- return null;
- }
-
- public void verify(PublicKey key) {
- }
-
- public void verify(PublicKey key, String sigProvider) {
- }
-
- public String toString() {
- return "MyCertificate";
- }
- }
-}
diff --git a/security/src/test/impl/java.injected/java/security/URIParameterTest.java b/security/src/test/impl/java.injected/java/security/URIParameterTest.java
deleted file mode 100644
index a45dee4..0000000
--- a/security/src/test/impl/java.injected/java/security/URIParameterTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package java.security;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.security.auth.login.Configuration;
-
-import junit.framework.TestCase;
-
-public class URIParameterTest extends TestCase {
-
- private URIParameter uriParameter;
- private URI uri;
-
- /**
- * @tests {@link java.security.URIParamter#constructor(java.net.URI)}
- */
- public void test_Constructor() throws URISyntaxException {
- try {
- new URIParameter(null);
- fail("Should throw NPE");
- } catch (NullPointerException e) {
- // expected
- }
-
- assertTrue(uriParameter instanceof Policy.Parameters);
- assertTrue(uriParameter instanceof Configuration.Parameters);
- }
-
- /**
- * @tests {@link java.security.URIParameter#getURI()}
- */
- public void testGetURI() {
- URI u = uriParameter.getURI();
- assertEquals(uri, u);
- assertSame(uri, u);
- }
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- uri = new URI("http://www.test.com");
- uriParameter = new URIParameter(uri);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- uriParameter = null;
- uri = null;
- }
-}
diff --git a/security/src/test/impl/java.injected/java/security/cert/X509CRLSelectorTest.java b/security/src/test/impl/java.injected/java/security/cert/X509CRLSelectorTest.java
deleted file mode 100644
index 2663f6d..0000000
--- a/security/src/test/impl/java.injected/java/security/cert/X509CRLSelectorTest.java
+++ /dev/null
@@ -1,602 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package java.security.cert;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Principal;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.cert.CRLException;
-import java.security.cert.X509CRLEntry;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Set;
-import javax.security.auth.x500.X500Principal;
-
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.asn1.ASN1OctetString;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class X509CRLSelectorTest extends TestCase {
-
- /**
- * The abstract class stub implementation.
- */
- private class TestCRL extends X509CRL {
-
- private X500Principal principal = null;
- private BigInteger crlNumber = null;
- private Date thisUpdate = null;
- private Date nextUpdate = null;
-
- public TestCRL(X500Principal principal) {
- this.principal = principal;
- }
-
- public TestCRL(Date thisUpdate, Date nextUpdate) {
- setUpdateDates(thisUpdate, nextUpdate);
- }
-
- public TestCRL(BigInteger crlNumber) {
- setCrlNumber(crlNumber);
- }
-
- public void setUpdateDates(Date thisUpdate, Date nextUpdate) {
- this.thisUpdate = thisUpdate;
- this.nextUpdate = nextUpdate;
- }
-
- public void setCrlNumber(BigInteger crlNumber) {
- this.crlNumber = crlNumber;
- }
-
- public X500Principal getIssuerX500Principal() {
- return principal;
- }
-
- public String toString() {
- return null;
- }
-
- public boolean isRevoked(Certificate cert) {
- return true;
- }
-
- public Set getNonCriticalExtensionOIDs() {
- return null;
- }
-
- public Set getCriticalExtensionOIDs() {
- return null;
- }
-
- public byte[] getExtensionValue(String oid) {
- if ("2.5.29.20".equals(oid) && (crlNumber != null)) {
- return ASN1OctetString.getInstance().encode(
- ASN1Integer.getInstance().encode(
- crlNumber.toByteArray()));
- }
- return null;
- }
-
- public boolean hasUnsupportedCriticalExtension() {
- return false;
- }
-
- public byte[] getEncoded() {
- return null;
- }
-
- public void verify(PublicKey key)
- throws CRLException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- }
-
- public void verify(PublicKey key, String sigProvider)
- throws CRLException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- }
-
- public int getVersion() {
- return 2;
- }
-
- public Principal getIssuerDN() {
- return null;
- }
-
- public Date getThisUpdate() {
- return thisUpdate;
- }
-
- public Date getNextUpdate() {
- return nextUpdate;
- }
-
- public X509CRLEntry getRevokedCertificate(BigInteger serialNumber) {
- return null;
- }
-
- public Set getRevokedCertificates() {
- return null;
- }
-
- public byte[] getTBSCertList() {
- return null;
- }
-
- public byte[] getSignature() {
- return null;
- }
-
- public String getSigAlgName() {
- return null;
- }
-
- public String getSigAlgOID() {
- return null;
- }
-
- public byte[] getSigAlgParams() {
- return null;
- }
- }
-
- /**
- * setIssuers(Collection <X500Principal> issuers) method testing.
- * Tests if CRLs with any issuers match the selector in the case of
- * null issuerNames criteria, if specified issuers match the selector,
- * and if not specified issuer does not match the selector.
- */
- public void testSetIssuers() {
- X509CRLSelector selector = new X509CRLSelector();
- X500Principal iss1 = new X500Principal("O=First Org.");
- X500Principal iss2 = new X500Principal("O=Second Org.");
- X500Principal iss3 = new X500Principal("O=Third Org.");
- TestCRL crl1 = new TestCRL(iss1);
- TestCRL crl2 = new TestCRL(iss2);
- TestCRL crl3 = new TestCRL(iss3);
-
- selector.setIssuers(null);
- assertTrue("Any CRL issuers should match in the case of null issuers.",
- selector.match(crl1) && selector.match(crl2));
-
- ArrayList issuers = new ArrayList(2);
- issuers.add(iss1);
- issuers.add(iss2);
- selector.setIssuers(issuers);
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl1) && selector.match(crl2));
- assertFalse("The CRL should not match the selection criteria.",
- selector.match(crl3));
- issuers.add(iss3);
- assertFalse("The internal issuer collection is not protected "
- + "against the modifications.", selector.match(crl3));
- }
-
- /**
- * setIssuerNames(Collection <?> names) method testing.
- * Tests if CRLs with any issuers match the selector in the case of
- * null issuerNames criteria, if specified issuers match the selector,
- * if not specified issuer does not match the selector, and if the
- * internal collection of issuer names is copied during initialization.
- */
- public void testSetIssuerNames() {
- X509CRLSelector selector = new X509CRLSelector();
- String iss1 = "O=First Org.";
- byte[] iss2 = new byte[]
- //manually obtained DER encoding of "O=Second Org." issuer name;
- { 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
- 83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46 };
- String iss3 = "O=Third Org.";
- TestCRL crl1 = new TestCRL(new X500Principal(iss1));
- TestCRL crl2 = new TestCRL(new X500Principal(iss2));
- TestCRL crl3 = new TestCRL(new X500Principal(iss3));
-
- try {
- selector.setIssuerNames(null);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertTrue("Any CRL issuers should match in the case of null issuers.",
- selector.match(crl1) && selector.match(crl2));
-
- ArrayList issuers = new ArrayList(2);
- issuers.add(iss1);
- issuers.add(iss2);
- try {
- selector.setIssuerNames(issuers);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl1) && selector.match(crl2));
- assertFalse("The CRL should not match the selection criteria.",
- selector.match(crl3));
- issuers.add(iss3);
- assertFalse("The internal issuer collection is not protected "
- + "against the modifications.", selector.match(crl3));
- }
-
- /**
- * addIssuer(X500Principal issuer) method testing.
- * Tests if CRLs with specified issuers match the selector,
- * and if not specified issuer does not match the selector.
- */
- public void testAddIssuer() {
- X509CRLSelector selector = new X509CRLSelector();
- X500Principal iss1 = new X500Principal("O=First Org.");
- X500Principal iss2 = new X500Principal("O=Second Org.");
- TestCRL crl1 = new TestCRL(iss1);
- TestCRL crl2 = new TestCRL(iss2);
-
- selector.addIssuer(iss1);
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl1));
- assertFalse("The CRL should not match the selection criteria.",
- selector.match(crl2));
- selector.addIssuer(iss2);
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl2));
- }
-
- /**
- * addIssuerName(String name) method testing.
- * Tests if CRLs with specified issuers match the selector,
- * and if not specified issuer does not match the selector.
- */
- public void testAddIssuerName1() {
- X509CRLSelector selector = new X509CRLSelector();
- String iss1 = "O=First Org.";
- String iss2 = "O=Second Org.";
- TestCRL crl1 = new TestCRL(new X500Principal(iss1));
- TestCRL crl2 = new TestCRL(new X500Principal(iss2));
-
- try {
- selector.addIssuerName(iss1);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl1));
- assertFalse("The CRL should not match the selection criteria.",
- selector.match(crl2));
- try {
- selector.addIssuerName(iss2);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl2));
- }
-
- /**
- * addIssuerName(byte[] name) method testing.
- * Tests if CRLs with specified issuers match the selector,
- * and if not specified issuer does not match the selector.
- */
- public void testAddIssuerName2() {
- X509CRLSelector selector = new X509CRLSelector();
- byte[] iss1 = new byte[]
- //manually obtained DER encoding of "O=First Org." issuer name;
- { 48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10,
- 70, 105, 114, 115, 116, 32, 79, 114, 103, 46 };
- byte[] iss2 = new byte[]
- //manually obtained DER encoding of "O=Second Org." issuer name;
- { 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
- 83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46 };
- TestCRL crl1 = new TestCRL(new X500Principal(iss1));
- TestCRL crl2 = new TestCRL(new X500Principal(iss2));
-
- try {
- selector.addIssuerName(iss1);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl1));
- assertFalse("The CRL should not match the selection criteria.",
- selector.match(crl2));
- try {
- selector.addIssuerName(iss2);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl2));
- }
-
- /**
- * setMinCRLNumber(BigInteger minCRL) method testing.
- * Tests if CRLs with any crl number value match the selector in the case of
- * null crlNumber criteria, if specified minCRL value matches the selector,
- * and if CRL with inappropriate crlNumber value does not match the selector.
- */
- public void testSetMinCRLNumber() {
- X509CRLSelector selector = new X509CRLSelector();
- BigInteger minCRL = new BigInteger("10000");
- TestCRL crl = new TestCRL(minCRL);
-
- selector.setMinCRLNumber(null);
- assertTrue("Any CRL should match in the case of null minCRLNumber.",
- selector.match(crl));
- selector.setMinCRLNumber(minCRL);
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl));
- selector.setMinCRLNumber(new BigInteger("10001"));
- assertFalse("The CRL should not match the selection criteria.",
- selector.match(crl));
- }
-
- /**
- * setMaxCRLNumber(BigInteger maxCRL) method testing.
- * Tests if CRLs with any crl number value match the selector in the case of
- * null crlNumber criteria, if specified maxCRL value matches the selector,
- * and if CRL with inappropriate crlNumber value does not match the selector.
- */
- public void testSetMaxCRLNumber() {
- X509CRLSelector selector = new X509CRLSelector();
- BigInteger maxCRL = new BigInteger("10000");
- TestCRL crl = new TestCRL(maxCRL);
-
- selector.setMaxCRLNumber(null);
- assertTrue("Any CRL should match in the case of null minCRLNumber.",
- selector.match(crl));
- selector.setMaxCRLNumber(maxCRL);
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl));
- selector.setMaxCRLNumber(new BigInteger("9999"));
- assertFalse("The CRL should not match the selection criteria.",
- selector.match(crl));
- }
-
- /**
- * setDateAndTime(Date dateAndTime) method testing.
- * Tests if CRLs with any update dates match the selector in the case of
- * null dateAndTime criteria, if correct dates match and incorrect
- * do not match the selector.
- */
- public void testSetDateAndTime() {
- X509CRLSelector selector = new X509CRLSelector();
- TestCRL crl = new TestCRL(new Date(200), new Date(300));
- selector.setDateAndTime(null);
- assertTrue("Any CRL should match in the case of null dateAndTime.",
- selector.match(crl));
- selector.setDateAndTime(new Date(200));
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl));
- selector.setDateAndTime(new Date(250));
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl));
- selector.setDateAndTime(new Date(300));
- assertTrue("The CRL should match the selection criteria.",
- selector.match(crl));
- selector.setDateAndTime(new Date(150));
- assertFalse("The CRL should not match the selection criteria.",
- selector.match(crl));
- selector.setDateAndTime(new Date(350));
- assertFalse("The CRL should not match the selection criteria.",
- selector.match(crl));
- }
-
- /**
- * getIssuers() method testing.
- * Tests if the method return null in the case of not specified issuers,
- * if the returned collection corresponds to the specified issuers and
- * this collection is unmodifiable.
- */
- public void testGetIssuers() throws Exception {
- X509CRLSelector selector = new X509CRLSelector();
- X500Principal iss1 = new X500Principal("O=First Org.");
- X500Principal iss2 = new X500Principal("O=Second Org.");
- X500Principal iss3 = new X500Principal("O=Third Org.");
- String iss_name_1 = "O=First String DN";
- String iss_name_2 = "O=Second String DN";
- String iss_name_3 = "O=Third String DN";
- assertNull("The collection should be null.",
- selector.getIssuers());
- selector.addIssuerName(iss_name_1);
- selector.addIssuer(iss1);
- selector.addIssuerName(iss_name_2);
- selector.addIssuer(iss2);
- selector.addIssuerName(iss_name_3);
-
- Collection result = selector.getIssuers();
- assertEquals("Size does not correspond to expected",
- 5, result.size());
- try {
- result.add(iss3);
- fail("The returned collection should be unmodifiable.");
- } catch (UnsupportedOperationException e) {
- }
- assertTrue("The collection should contain the specified DN.",
- result.contains(iss1));
- assertTrue("The collection should contain the specified DN.",
- result.contains(iss2));
- assertTrue("The collection should contain the specified DN.",
- result.contains(new X500Principal(iss_name_1)));
- assertTrue("The collection should contain the specified DN.",
- result.contains(new X500Principal(iss_name_2)));
- selector.addIssuer(iss3);
- assertTrue("The collection should contain the specified DN.",
- result.contains(iss3));
- }
-
- /**
- * getIssuerNames() method testing.
- * Tests if the method return null in the case of not specified issuers,
- * if the returned collection corresponds to the specified issuers.
- */
- public void testGetIssuerNames() {
- X509CRLSelector selector = new X509CRLSelector();
- byte[] iss1 = new byte[]
- //manually obtained DER encoding of "O=First Org." issuer name;
- { 48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10,
- 70, 105, 114, 115, 116, 32, 79, 114, 103, 46 };
- byte[] iss2 = new byte[]
- //manually obtained DER encoding of "O=Second Org." issuer name;
- { 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
- 83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46 };
- assertNull("The collection should be null.",
- selector.getIssuerNames());
- try {
- selector.addIssuerName(iss1);
- selector.addIssuerName(iss2);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- Collection result = selector.getIssuerNames();
- assertEquals("The collection should contain all of the specified DNs.",
- 2, result.size());
- }
-
- /**
- * getMinCRL() method testing.
- * Tests if the method return null in the case of not specified minCRL
- * criteria, and if the returned value corresponds to the specified one.
- */
- public void testGetMinCRL() {
- X509CRLSelector selector = new X509CRLSelector();
- assertNull("Initially the minCRL should be null.",
- selector.getMinCRL());
- BigInteger minCRL = new BigInteger("10000");
- selector.setMinCRLNumber(minCRL);
- assertTrue("The result should be equal to specified.",
- minCRL.equals(selector.getMinCRL()));
- }
-
- /**
- * getMaxCRL() method testing.
- * Tests if the method return null in the case of not specified maxCRL
- * criteria, and if the returned value corresponds to the specified one.
- */
- public void testGetMaxCRL() {
- X509CRLSelector selector = new X509CRLSelector();
- assertNull("Initially the maxCRL should be null.",
- selector.getMaxCRL());
- BigInteger maxCRL = new BigInteger("10000");
- selector.setMaxCRLNumber(maxCRL);
- assertTrue("The result should be equal to specified.",
- maxCRL.equals(selector.getMaxCRL()));
- }
-
- /**
- * getDateAndTime() method testing.
- * Tests if the method return null in the case of not specified dateAndTime
- * criteria, and if the returned value corresponds to the specified one.
- */
- public void testGetDateAndTime() {
- X509CRLSelector selector = new X509CRLSelector();
- assertNull("Initially the dateAndTime criteria should be null.",
- selector.getDateAndTime());
- Date date = new Date(200);
- selector.setDateAndTime(date);
- assertTrue("The result should be equal to specified.",
- date.equals(selector.getDateAndTime()));
- }
-
- /**
- * match(CRL crl) method testing.
- * Tests if the null object matches to the selector or not.
- */
- public void testMatch() {
- X509CRLSelector selector = new X509CRLSelector();
- assertFalse("The null object should not match",
- selector.match((X509CRL) null));
- }
-
- /**
- * clone() method testing.
- * Tests if the selector is cloned correctly: the crl which matche to
- * the initial selector should match to the clone and the change of clone
- * should not cause the change of initial selector.
- */
- public void testClone() {
- X509CRLSelector selector = new X509CRLSelector();
- X500Principal iss1 = new X500Principal("O=First Org.");
- X500Principal iss2 = new X500Principal("O=Second Org.");
- X500Principal iss3 = new X500Principal("O=Third Org.");
- BigInteger minCRL = new BigInteger("10000");
- BigInteger maxCRL = new BigInteger("10000");
- Date date = new Date(200);
-
- selector.addIssuer(iss1);
- selector.addIssuer(iss2);
- selector.setMinCRLNumber(minCRL);
- selector.setMaxCRLNumber(maxCRL);
- selector.setDateAndTime(date);
-
- X509CRLSelector clone = (X509CRLSelector) selector.clone();
- TestCRL crl = new TestCRL(iss1);
- crl.setCrlNumber(minCRL);
- crl.setUpdateDates(new Date(200), new Date(200));
- assertTrue("The specified CRL should match the clone selector.",
- selector.match(crl));
-
- clone.addIssuer(iss3);
- assertFalse("The changes of the clone selector should not cause "
- + "the changes of initial object",
- selector.getIssuerNames().size() == 3);
- }
-
- public void testToString() {
- X509CRLSelector selector = new X509CRLSelector();
- X500Principal iss1 = new X500Principal("O=First Org.");
- X500Principal iss2 = new X500Principal("O=Second Org.");
- BigInteger minCRL = new BigInteger("10000");
- BigInteger maxCRL = new BigInteger("10000");
- Date date = new Date(200);
-
- selector.addIssuer(iss1);
- selector.addIssuer(iss2);
- selector.setMinCRLNumber(minCRL);
- selector.setMaxCRLNumber(maxCRL);
- selector.setDateAndTime(date);
-
- assertNotNull("The result should not be null.", selector.toString());
- }
-
- public static Test suite() {
- return new TestSuite(X509CRLSelectorTest.class);
- }
-
-}
diff --git a/security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java b/security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java
deleted file mode 100644
index ba27d56..0000000
--- a/security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java
+++ /dev/null
@@ -1,2920 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package java.security.cert;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Principal;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateExpiredException;
-import java.security.cert.CertificateNotYetValidException;
-import java.security.cert.X509Certificate;
-import java.security.spec.InvalidKeySpecException;
-import java.util.Date;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Iterator;
-import java.util.Collection;
-import javax.security.auth.x500.X500Principal;
-
-import org.apache.harmony.security.asn1.ASN1Boolean;
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.asn1.ASN1OctetString;
-import org.apache.harmony.security.asn1.ASN1Oid;
-import org.apache.harmony.security.asn1.ASN1Sequence;
-import org.apache.harmony.security.asn1.ASN1Type;
-
-import org.apache.harmony.security.tests.support.TestKeyPair;
-import org.apache.harmony.security.x501.Name;
-import org.apache.harmony.security.x509.AlgorithmIdentifier;
-import org.apache.harmony.security.x509.CertificatePolicies;
-import org.apache.harmony.security.x509.EDIPartyName;
-import org.apache.harmony.security.x509.Extension;
-import org.apache.harmony.security.x509.Extensions;
-import org.apache.harmony.security.x509.GeneralName;
-import org.apache.harmony.security.x509.GeneralNames;
-import org.apache.harmony.security.x509.GeneralSubtree;
-import org.apache.harmony.security.x509.GeneralSubtrees;
-import org.apache.harmony.security.x509.NameConstraints;
-import org.apache.harmony.security.x509.ORAddress;
-import org.apache.harmony.security.x509.OtherName;
-import org.apache.harmony.security.x509.PolicyInformation;
-import org.apache.harmony.security.x509.PrivateKeyUsagePeriod;
-import org.apache.harmony.security.x509.SubjectPublicKeyInfo;
-import org.apache.harmony.security.x509.TBSCertificate;
-import org.apache.harmony.security.x509.Validity;
-
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * X509CertSelectorTest
- */
-public class X509CertSelectorTest extends TestCase {
-
- /**
- * The abstract class stub implementation.
- */
- private class TestCert extends X509Certificate {
-
- /* Stuff fields */
- protected String equalCriteria = null; // to simplify method equals()
- protected BigInteger serialNumber = null;
- protected X500Principal issuer = null;
- protected X500Principal subject = null;
- protected byte[] keyIdentifier = null;
- protected Date date = null;
- protected Date notBefore = null;
- protected Date notAfter = null;
- protected PublicKey key = null;
- protected boolean[] keyUsage = null;
- protected List extKeyUsage = null;
- protected int pathLen = -1;
- protected GeneralNames sans = null;
- protected byte[] encoding = null;
- protected String[] policies = null;
- protected NameConstraints nameConstraints = null;
-
- /* Stuff methods */
- public TestCert() {
- }
-
- public TestCert(GeneralNames sans) {
- setSubjectAlternativeNames(sans);
- }
-
- public TestCert(NameConstraints nameConstraints) {
- this.nameConstraints = nameConstraints;
- }
-
- public TestCert(String equalCriteria) {
- setEqualCriteria(equalCriteria);
- }
-
- public TestCert(String[] policies) {
- setPolicies(policies);
- }
-
- public TestCert(BigInteger serial) {
- setSerialNumber(serial);
- }
-
- public TestCert(X500Principal principal) {
- setIssuer(principal);
- setSubject(principal);
- }
-
- public TestCert(byte[] array) {
- setKeyIdentifier(array);
- }
-
- public TestCert(Date date) {
- setDate(date);
- }
-
- public TestCert(Date notBefore, Date notAfter) {
- setPeriod(notBefore, notAfter);
- }
-
- public TestCert(PublicKey key) {
- setPublicKey(key);
- }
-
- public TestCert(boolean[] keyUsage) {
- setKeyUsage(keyUsage);
- }
-
- public TestCert(Set extKeyUsage) {
- setExtendedKeyUsage(extKeyUsage);
- }
-
- public TestCert(int pathLen) {
- this.pathLen = pathLen;
- }
-
- public void setPolicies(String[] policies) {
- this.policies = policies;
- }
-
- public void setSubjectAlternativeNames(GeneralNames sans) {
- this.sans = sans;
- }
-
- public void setExtendedKeyUsage(Set extKeyUsage) {
- this.extKeyUsage = (extKeyUsage == null)
- ? null
- : new ArrayList(extKeyUsage);
- }
-
- public void setKeyUsage(boolean[] keyUsage) {
- this.keyUsage = (keyUsage == null) ? null
- : (boolean[]) keyUsage.clone();
- }
-
- public void setPublicKey(PublicKey key) {
- this.key = key;
- }
-
- public void setPeriod(Date notBefore, Date notAfter) {
- this.notBefore = notBefore;
- this.notAfter = notAfter;
- }
-
- public void setSerialNumber(BigInteger serial) {
- this.serialNumber = serial;
- }
-
- public void setEqualCriteria(String equalCriteria) {
- this.equalCriteria = equalCriteria;
- }
-
- public void setIssuer(X500Principal issuer) {
- this.issuer = issuer;
- }
-
- public void setSubject(X500Principal subject) {
- this.subject = subject;
- }
-
- public void setKeyIdentifier(byte[] subjectKeyID) {
- this.keyIdentifier = subjectKeyID.clone();
- }
-
- public void setDate(Date date) {
- this.date = new Date(date.getTime());
- }
-
- public void setEncoding(byte[] encoding) {
- this.encoding = encoding;
- }
-
- /* Method implementations */
- public boolean equals(Object cert) {
- if (cert == null) {
- return false;
- }
- if ((equalCriteria == null)
- || (((TestCert) cert).equalCriteria == null)) {
- return false;
- } else {
- return equalCriteria.equals(((TestCert) cert).equalCriteria);
- }
- }
-
- public String toString() {
- if (equalCriteria != null) {
- return equalCriteria;
- }
- return "";
- }
-
- public void checkValidity() throws CertificateExpiredException,
- CertificateNotYetValidException {
- }
-
- public void checkValidity(Date date)
- throws CertificateExpiredException,
- CertificateNotYetValidException {
- if (this.date == null) {
- throw new CertificateExpiredException();
- }
- int result = this.date.compareTo(date);
- if (result > 0) {
- throw new CertificateExpiredException();
- }
- if (result < 0) {
- throw new CertificateNotYetValidException();
- }
- }
-
- public int getVersion() {
- return 3;
- }
-
- public BigInteger getSerialNumber() {
- return (serialNumber == null)
- ? new BigInteger("1111")
- : serialNumber;
- }
-
- public Principal getIssuerDN() {
- return issuer;
- }
-
- public X500Principal getIssuerX500Principal() {
- return issuer;
- }
-
- public Principal getSubjectDN() {
- return subject;
- }
-
- public X500Principal getSubjectX500Principal() {
- return subject;
- }
-
- public Date getNotBefore() {
- return null;
- }
-
- public Date getNotAfter() {
- return null;
- }
-
- public byte[] getTBSCertificate()
- throws CertificateEncodingException {
- return null;
- }
-
- public byte[] getSignature() {
- return null;
- }
-
- public String getSigAlgName() {
- return null;
- }
-
- public String getSigAlgOID() {
- return null;
- }
-
- public byte[] getSigAlgParams() {
- return null;
- }
-
- public boolean[] getIssuerUniqueID() {
- return null;
- }
-
- public boolean[] getSubjectUniqueID() {
- return null;
- }
-
- public boolean[] getKeyUsage() {
- return keyUsage;
- }
-
- public List/*<String>*/ getExtendedKeyUsage()
- throws CertificateParsingException {
- return extKeyUsage;
- }
-
- public int getBasicConstraints() {
- return pathLen;
- }
-
- public Collection/*<List<?>>*/ getSubjectAlternativeNames()
- throws CertificateParsingException {
- return sans.getPairsList();
- }
-
-
- public void verify(PublicKey key)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- }
-
- public void verify(PublicKey key,
- String sigProvider)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- }
-
- public PublicKey getPublicKey() {
- return key;
- }
-
- public byte[] getEncoded() throws CertificateEncodingException {
- return encoding;
- }
-
- public Set getNonCriticalExtensionOIDs() {
- return null;
- }
-
- public Set getCriticalExtensionOIDs() {
- return null;
- }
-
- public byte[] getExtensionValue(String oid) {
- if (("2.5.29.14".equals(oid)) || ("2.5.29.35".equals(oid))) {
- // Extension value is represented as an OctetString
- return ASN1OctetString.getInstance().encode(keyIdentifier);
- }
- if ("2.5.29.16".equals(oid)) {
- PrivateKeyUsagePeriod pkup =
- new PrivateKeyUsagePeriod(notBefore, notAfter);
- byte[] encoded = pkup.getEncoded();
- return ASN1OctetString.getInstance().encode(encoded);
- }
- if (("2.5.29.37".equals(oid)) && (extKeyUsage != null)) {
- ASN1Oid[] oa = new ASN1Oid[extKeyUsage.size()];
- String[] val = new String[extKeyUsage.size()];
- Iterator it = extKeyUsage.iterator();
- int id = 0;
- while (it.hasNext()) {
- oa[id] = ASN1Oid.getInstanceForString();
- val[id++] = (String) it.next();
- }
- return ASN1OctetString.getInstance().encode(
- new ASN1Sequence(oa).encode(val));
- }
- if ("2.5.29.19".equals(oid)) {
- return ASN1OctetString.getInstance().encode(
- new ASN1Sequence(
- new ASN1Type[] {
- ASN1Boolean.getInstance(),
- ASN1Integer.getInstance()
- }).encode(
- new Object[] {
- new Boolean(pathLen != -1),
- BigInteger.valueOf(pathLen).
- toByteArray()
- })
- );
- }
- if ("2.5.29.17".equals(oid) && (sans != null)) {
- if (sans.getNames() == null) {
- return null;
- }
- return ASN1OctetString.getInstance().encode(
- GeneralNames.ASN1.encode(sans));
- }
- if ("2.5.29.32".equals(oid) && (policies != null)
- && (policies.length > 0)) {
- // Certificate Policies Extension (as specified in rfc 3280)
- CertificatePolicies certificatePolicies =
- new CertificatePolicies();
- for (int i = 0; i < policies.length; i++) {
- PolicyInformation policyInformation =
- new PolicyInformation(policies[i]);
- certificatePolicies.addPolicyInformation(policyInformation);
- }
- return ASN1OctetString.getInstance().encode(
- certificatePolicies.getEncoded());
- }
- if ("2.5.29.30".equals(oid) && (nameConstraints != null)) {
- // Name Constraints Extension (as specified in rfc 3280)
- return ASN1OctetString.getInstance().encode(
- nameConstraints.getEncoded());
- }
- return null;
- }
-
- public boolean hasUnsupportedCriticalExtension() {
- return false;
- }
- }
-
- /* ********************************************************************** */
- /* ************************* Test implementation ************************ */
- /* ********************************************************************** */
-
- /**
- * setCertificate(X509Certificate certificate) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match
- */
- public void testSetCertificate() {
- TestCert cert_1 = new TestCert("same certificate");
- TestCert cert_2 = new TestCert("other certificate");
- X509CertSelector selector = new X509CertSelector();
-
- selector.setCertificate(null);
- assertTrue("Any certificates should match in the case of null "
- + "certificateEquals criteria.",
- selector.match(cert_1) && selector.match(cert_2));
- selector.setCertificate(cert_1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.setCertificate(cert_2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getCertificate() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- */
- public void testGetCertificate() {
- TestCert cert_1 = new TestCert("same certificate");
- TestCert cert_2 = new TestCert("other certificate");
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null", selector.getCertificate());
- selector.setCertificate(cert_1);
- assertEquals("The returned certificate should be equal to specified",
- cert_1, selector.getCertificate());
- assertFalse("The returned certificate should differ",
- cert_2.equals(selector.getCertificate()));
- }
-
- /**
- * setSerialNumber(BigInteger serial) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match
- */
- public void testSetSerialNumber() {
- BigInteger ser1 = new BigInteger("10000");
- BigInteger ser2 = new BigInteger("10001");
- TestCert cert_1 = new TestCert(ser1);
- TestCert cert_2 = new TestCert(ser2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setSerialNumber(null);
- assertTrue("Any certificate should match in the case of null "
- + "serialNumber criteria.",
- selector.match(cert_1) && selector.match(cert_2));
- selector.setSerialNumber(ser1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.setSerialNumber(ser2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getSerialNumber() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- */
- public void testGetSerialNumber() {
- BigInteger ser1 = new BigInteger("10000");
- BigInteger ser2 = new BigInteger("10001");
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null", selector.getSerialNumber());
- selector.setSerialNumber(ser1);
- assertEquals("The returned serial number should be equal to specified",
- ser1, selector.getSerialNumber());
- assertFalse("The returned serial number should differ",
- ser2.equals(selector.getSerialNumber()));
- }
-
- /**
- * setIssuer(X500Principal issuer) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match
- */
- public void testSetIssuer1() {
- X500Principal iss1 = new X500Principal("O=First Org.");
- X500Principal iss2 = new X500Principal("O=Second Org.");
- TestCert cert_1 = new TestCert(iss1);
- TestCert cert_2 = new TestCert(iss2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setIssuer((X500Principal) null);
- assertTrue("Any certificates should match "
- + "in the case of null issuer criteria.",
- selector.match(cert_1) && selector.match(cert_2));
- selector.setIssuer(iss1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.setIssuer(iss2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getIssuer() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- */
- public void testGetIssuer() {
- X500Principal iss1 = new X500Principal("O=First Org.");
- X500Principal iss2 = new X500Principal("O=Second Org.");
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null", selector.getIssuer());
- selector.setIssuer(iss1);
- assertEquals("The returned issuer should be equal to specified",
- iss1, selector.getIssuer());
- assertFalse("The returned issuer should differ",
- iss2.equals(selector.getIssuer()));
- }
-
- /**
- * setIssuer(String issuerDN) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match
- */
- public void testSetIssuer2() throws IOException {
- String name1 = "O=First Org.";
- String name2 = "O=Second Org.";
- X500Principal iss1 = new X500Principal(name1);
- X500Principal iss2 = new X500Principal(name2);
- TestCert cert_1 = new TestCert(iss1);
- TestCert cert_2 = new TestCert(iss2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setIssuer((String) null);
- assertTrue(
- "Any certificates should match in the case of null issuer criteria.",
- selector.match(cert_1) && selector.match(cert_2));
-
- selector.setIssuer(name1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.setIssuer(name2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getIssuerAsString() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- */
- public void testGetIssuerAsString() {
- String name1 = "O=First Org.";
- String name2 = "O=Second Org.";
- X500Principal iss1 = new X500Principal(name1);
- X500Principal iss2 = new X500Principal(name2);
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null", selector.getIssuerAsString());
- selector.setIssuer(iss1);
- assertEquals("The returned issuer should be equal to specified",
- new X500Principal(name1),
- new X500Principal(selector.getIssuerAsString()));
- assertFalse("The returned issuer should differ",
- new X500Principal(name2).equals(
- new X500Principal(selector.getIssuerAsString())));
- selector.setIssuer(iss2);
- assertEquals("The returned issuer should be equal to specified",
- new X500Principal(name2),
- new X500Principal(selector.getIssuerAsString()));
- }
-
- /**
- * setIssuer(byte[] issuerDN) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match
- */
- public void testSetIssuer3() throws IOException {
- byte[] name1 = new byte[]
- //manually obtained DER encoding of "O=First Org." issuer name;
- { 48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10,
- 70, 105, 114, 115, 116, 32, 79, 114, 103, 46 };
- byte[] name2 = new byte[]
- //manually obtained DER encoding of "O=Second Org." issuer name;
- { 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
- 83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46 };
- X500Principal iss1 = new X500Principal(name1);
- X500Principal iss2 = new X500Principal(name2);
- TestCert cert_1 = new TestCert(iss1);
- TestCert cert_2 = new TestCert(iss2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setIssuer((byte[]) null);
- assertTrue(
- "Any certificates should match in the case of null issuer criteria.",
- selector.match(cert_1) && selector.match(cert_2));
-
- selector.setIssuer(name1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.setIssuer(name2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getIssuerAsBytes() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- */
- public void testGetIssuerAsBytes() throws IOException {
- byte[] name1 = new byte[]
- //manually obtained DER encoding of "O=First Org." issuer name;
- { 48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10,
- 70, 105, 114, 115, 116, 32, 79, 114, 103, 46 };
- byte[] name2 = new byte[]
- //manually obtained DER encoding of "O=Second Org." issuer name;
- { 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
- 83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46 };
- X500Principal iss1 = new X500Principal(name1);
- X500Principal iss2 = new X500Principal(name2);
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null", selector.getIssuerAsBytes());
-
- selector.setIssuer(iss1);
- assertEquals("The returned issuer should be equal to specified",
- new X500Principal(name1), new X500Principal(selector
- .getIssuerAsBytes()));
- assertFalse("The returned issuer should differ", new X500Principal(
- name2).equals(new X500Principal(selector.getIssuerAsBytes())));
-
- selector.setIssuer(iss2);
- assertEquals("The returned issuer should be equal to specified",
- new X500Principal(name2), new X500Principal(selector
- .getIssuerAsBytes()));
- }
-
- /**
- * setSubject(X500Principal subject) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match
- */
- public void testSetSubject1() {
- X500Principal sub1 = new X500Principal("O=First Org.");
- X500Principal sub2 = new X500Principal("O=Second Org.");
- TestCert cert_1 = new TestCert(sub1);
- TestCert cert_2 = new TestCert(sub2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setSubject((X500Principal) null);
- assertTrue("Any certificates should match "
- + "in the case of null subjcet criteria.",
- selector.match(cert_1) && selector.match(cert_2));
- selector.setSubject(sub1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.setSubject(sub2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getSubject() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- */
- public void testGetSubject() {
- X500Principal sub1 = new X500Principal("O=First Org.");
- X500Principal sub2 = new X500Principal("O=Second Org.");
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null", selector.getSubject());
- selector.setSubject(sub1);
- assertEquals("The returned subject should be equal to specified",
- sub1, selector.getSubject());
- assertFalse("The returned subject should differ",
- sub2.equals(selector.getSubject()));
- }
-
- /**
- * setSubject(String subjectDN) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match
- */
- public void testSetSubject2() throws IOException {
- String name1 = "O=First Org.";
- String name2 = "O=Second Org.";
- X500Principal sub1 = new X500Principal(name1);
- X500Principal sub2 = new X500Principal(name2);
- TestCert cert_1 = new TestCert(sub1);
- TestCert cert_2 = new TestCert(sub2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setSubject((String) null);
- assertTrue(
- "Any certificates should match in the case of null subject criteria.",
- selector.match(cert_1) && selector.match(cert_2));
-
- selector.setSubject(name1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
-
- selector.setSubject(name2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getSubjectAsString() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- */
- public void testGetSubjectAsString() {
- String name1 = "O=First Org.";
- String name2 = "O=Second Org.";
- X500Principal sub1 = new X500Principal(name1);
- X500Principal sub2 = new X500Principal(name2);
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null",
- selector.getSubjectAsString());
- selector.setSubject(sub1);
- assertEquals("The returned subject should be equal to specified",
- new X500Principal(name1),
- new X500Principal(selector.getSubjectAsString()));
- assertFalse("The returned subject should differ",
- new X500Principal(name2).equals(
- new X500Principal(selector.getSubjectAsString())));
- selector.setSubject(sub2);
- assertEquals("The returned subject should be equal to specified",
- new X500Principal(name2),
- new X500Principal(selector.getSubjectAsString()));
- }
-
- /**
- * setSubject(byte[] subjectDN) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match
- */
- public void testSetSubject3() throws IOException {
- byte[] name1 = new byte[]
- //manually obtained DER encoding of "O=First Org." issuer name;
- { 48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10,
- 70, 105, 114, 115, 116, 32, 79, 114, 103, 46 };
- byte[] name2 = new byte[]
- //manually obtained DER encoding of "O=Second Org." issuer name;
- { 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
- 83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46 };
- X500Principal sub1 = new X500Principal(name1);
- X500Principal sub2 = new X500Principal(name2);
- TestCert cert_1 = new TestCert(sub1);
- TestCert cert_2 = new TestCert(sub2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setSubject((byte[]) null);
- assertTrue(
- "Any certificates should match in the case of null issuer criteria.",
- selector.match(cert_1) && selector.match(cert_2));
-
- selector.setSubject(name1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
-
- selector.setSubject(name2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getSubjectAsBytes() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- */
- public void testGetSubjectAsBytes() throws IOException {
- byte[] name1 = new byte[]
- //manually obtained DER encoding of "O=First Org." issuer name;
- { 48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10,
- 70, 105, 114, 115, 116, 32, 79, 114, 103, 46 };
- byte[] name2 = new byte[]
- //manually obtained DER encoding of "O=Second Org." issuer name;
- { 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
- 83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46 };
- X500Principal sub1 = new X500Principal(name1);
- X500Principal sub2 = new X500Principal(name2);
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null", selector.getSubjectAsBytes());
- selector.setSubject(sub1);
-
- assertEquals("The returned issuer should be equal to specified",
- new X500Principal(name1), new X500Principal(selector
- .getSubjectAsBytes()));
- assertFalse("The returned issuer should differ", new X500Principal(
- name2).equals(new X500Principal(selector.getSubjectAsBytes())));
-
- selector.setSubject(sub2);
- assertEquals("The returned issuer should be equal to specified",
- new X500Principal(name2), new X500Principal(selector
- .getSubjectAsBytes()));
- }
-
- /**
- * setSubjectKeyIdentifier(byte[] subjectKeyID) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match, and if the initialization
- * object are copied during the initialization.
- */
- public void testSetSubjectKeyIdentifier() {
- byte[] skid1 = new byte[] { 1, 2, 3, 4, 5 }; // random value
- byte[] skid2 = new byte[] { 5, 4, 3, 2, 1 }; // random value
- TestCert cert_1 = new TestCert(skid1);
- TestCert cert_2 = new TestCert(skid2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setSubjectKeyIdentifier(null);
- assertTrue("Any certificate should match in the case of null "
- + "serialNumber criteria.",
- selector.match(cert_1) && selector.match(cert_2));
- selector.setSubjectKeyIdentifier(skid1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.setSubjectKeyIdentifier(skid2);
- skid2[0]++;
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getSubjectKeyIdentifier() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- * and its modification does not cause the modification of internal object.
- */
- public void testGetSubjectKeyIdentifier() {
- byte[] skid1 = new byte[] { 1, 2, 3, 4, 5 }; // random value
- byte[] skid2 = new byte[] { 4, 5, 5, 4, 3, 2, 1 }; // random value
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null",
- selector.getSubjectKeyIdentifier());
- selector.setSubjectKeyIdentifier(skid1);
- assertTrue("The returned keyID should be equal to specified",
- Arrays.equals(skid1, selector.getSubjectKeyIdentifier()));
- selector.getSubjectKeyIdentifier()[0]++;
- assertTrue("The returned keyID should be equal to specified",
- Arrays.equals(skid1, selector.getSubjectKeyIdentifier()));
- assertFalse("The returned keyID should differ",
- Arrays.equals(skid2, selector.getSubjectKeyIdentifier()));
- }
-
- /**
- * setAuthorityKeyIdentifier(byte[] authorityKeyID) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match, and if the initialization
- * object are copied during the initialization.
- */
- public void testSetAuthorityKeyIdentifier() {
- byte[] akid1 = new byte[] { 1, 2, 3, 4, 5 }; // random value
- byte[] akid2 = new byte[] { 5, 4, 3, 2, 1 }; // random value
- TestCert cert_1 = new TestCert(akid1);
- TestCert cert_2 = new TestCert(akid2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setAuthorityKeyIdentifier(null);
- assertTrue("Any certificate should match in the case of null "
- + "serialNumber criteria.",
- selector.match(cert_1) && selector.match(cert_2));
- selector.setAuthorityKeyIdentifier(akid1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.setAuthorityKeyIdentifier(akid2);
- akid2[0]++;
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getAuthorityKeyIdentifier() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- * and its modification does not cause the modification of internal object.
- */
- public void testGetAuthorityKeyIdentifier() {
- byte[] akid1 = new byte[] { 4, 5, 1, 2, 3, 4, 5 }; // random value
- byte[] akid2 = new byte[] { 4, 5, 5, 4, 3, 2, 1 }; // random value
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null",
- selector.getAuthorityKeyIdentifier());
- selector.setAuthorityKeyIdentifier(akid1);
- assertTrue("The returned keyID should be equal to specified",
- Arrays.equals(akid1, selector.getAuthorityKeyIdentifier()));
- selector.getAuthorityKeyIdentifier()[0]++;
- assertTrue("The returned keyID should be equal to specified",
- Arrays.equals(akid1, selector.getAuthorityKeyIdentifier()));
- assertFalse("The returned keyID should differ",
- Arrays.equals(akid2, selector.getAuthorityKeyIdentifier()));
- }
-
- /**
- * setCertificateValid(Date certificateValid) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match, and if the initialization
- * object are copied during the initialization.
- */
- public void testSetCertificateValid() {
- Date date1 = new Date(100);
- Date date2 = new Date(200);
- TestCert cert_1 = new TestCert(date1);
- TestCert cert_2 = new TestCert(date2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setCertificateValid(null);
- assertTrue("Any certificate should match in the case of null "
- + "serialNumber criteria.",
- selector.match(cert_1) && selector.match(cert_2));
- selector.setCertificateValid(date1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.setCertificateValid(date2);
- date2.setTime(300);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getCertificateValid() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- * and its modification does not cause the modification of internal object.
- */
- public void testGetCertificateValid() {
- Date date1 = new Date(100);
- Date date2 = new Date(200);
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null",
- selector.getCertificateValid());
- selector.setCertificateValid(date1);
- assertTrue("The returned date should be equal to specified",
- date1.equals(selector.getCertificateValid()));
- selector.getCertificateValid().setTime(200);
- assertTrue("The returned date should be equal to specified",
- date1.equals(selector.getCertificateValid()));
- assertFalse("The returned date should differ",
- date2.equals(selector.getCertificateValid()));
- }
-
- /**
- * setPrivateKeyValid(Date privateKeyValid) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match, and if the initialization
- * object are copied during the initialization.
- */
- public void testSetPrivateKeyValid() {
- Date date1 = new Date(100000000);
- Date date2 = new Date(200000000);
- Date date3 = new Date(300000000);
- Date date4 = new Date(150000000);
- Date date5 = new Date(250000000);
- TestCert cert_1 = new TestCert(date1, date2);
- TestCert cert_2 = new TestCert(date2, date3);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setPrivateKeyValid(null);
- assertTrue("Any certificate should match in the case of null "
- + "privateKeyValid criteria.",
- selector.match(cert_1) && selector.match(cert_2));
- selector.setPrivateKeyValid(date4);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.setPrivateKeyValid(date5);
- date5.setTime(date4.getTime());
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getPrivateKeyValid() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- * and its modification does not cause the modification of internal object.
- */
- public void testGetPrivateKeyValid() {
- Date date1 = new Date(100);
- Date date2 = new Date(200);
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null",
- selector.getPrivateKeyValid());
- selector.setPrivateKeyValid(date1);
- assertTrue("The returned date should be equal to specified",
- date1.equals(selector.getPrivateKeyValid()));
- selector.getPrivateKeyValid().setTime(200);
- assertTrue("The returned date should be equal to specified",
- date1.equals(selector.getPrivateKeyValid()));
- assertFalse("The returned date should differ",
- date2.equals(selector.getPrivateKeyValid()));
- }
-
- /**
- * setSubjectPublicKeyAlgID(String oid) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match
- */
- public void testSetSubjectPublicKeyAlgID() throws Exception {
- String pkaid1 = "1.2.840.113549.1.1.1"; // RSA (source: http://asn1.elibel.tm.fr)
- String pkaid2 = "1.2.840.10040.4.1"; // DSA (source: http://asn1.elibel.tm.fr)
-
- PublicKey pkey1 = new TestKeyPair("RSA").getPublic();
- PublicKey pkey2 = new TestKeyPair("DSA").getPublic();
-
- TestCert cert_1 = new TestCert(pkey1);
- TestCert cert_2 = new TestCert(pkey2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setSubjectPublicKeyAlgID(null);
- assertTrue("Any certificate should match in the case of null "
- + "subjectPublicKeyAlgID criteria.", selector.match(cert_1)
- && selector.match(cert_2));
-
- selector.setSubjectPublicKeyAlgID(pkaid1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
-
- selector.setSubjectPublicKeyAlgID(pkaid2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * @tests java.security.cert.X509CertSelector#setSubjectPublicKeyAlgID(java.lang.String)
- */
- public void test_setSubjectPublicKeyAlgIDLjava_lang_String() throws Exception {
- //Regression for HARMONY-465
- X509CertSelector obj = new X509CertSelector();
- try {
- obj.setSubjectPublicKeyAlgID("abc");
- fail("IOException expected");
- } catch (IOException e) {
- // expected
- }
- }
-
- /**
- * getSubjectPublicKeyAlgID() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- */
- public void testGetSubjectPublicKeyAlgID() throws IOException {
- String pkaid1 = "1.2.840.113549.1.1.1"; // RSA encryption (source: http://asn1.elibel.tm.fr)
- String pkaid2 = "1.2.840.113549.1.1.2"; // MD2 with RSA encryption (source: http://asn1.elibel.tm.fr)
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null",
- selector.getSubjectPublicKeyAlgID());
-
- selector.setSubjectPublicKeyAlgID(pkaid1);
- assertTrue("The returned oid should be equal to specified",
- pkaid1.equals(selector.getSubjectPublicKeyAlgID()));
- assertFalse("The returned oid should differ",
- pkaid2.equals(selector.getSubjectPublicKeyAlgID()));
- }
-
- /**
- * setSubjectPublicKey(PublicKey key) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match.
- */
- public void testSetSubjectPublicKey1() throws Exception {
- PublicKey pkey1 = new TestKeyPair("RSA").getPublic();
- PublicKey pkey2 = new TestKeyPair("DSA").getPublic();
-
- TestCert cert_1 = new TestCert(pkey1);
- TestCert cert_2 = new TestCert(pkey2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setSubjectPublicKey((PublicKey) null);
- assertTrue("Any certificate should match in the case of null "
- + "subjectPublicKey criteria.",
- selector.match(cert_1) && selector.match(cert_2));
- selector.setSubjectPublicKey(pkey1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.setSubjectPublicKey(pkey2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getSubjectPublicKey() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value corresponds to specified
- */
- public void testGetSubjectPublicKey1() throws Exception {
-
- PublicKey pkey = new TestKeyPair("RSA").getPublic();
-
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null",
- selector.getSubjectPublicKey());
- selector.setSubjectPublicKey(pkey);
- PublicKey result = selector.getSubjectPublicKey();
-
- assertEquals("The name of algorithm should be RSA",
- result.getAlgorithm(), "RSA");
- }
-
- /**
- * setSubjectPublicKey(byte[] key) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match, and if the initialization
- * object are copied during the initialization.
- */
- public void testSetSubjectPublicKey2() throws Exception {
- PublicKey pkey1 = new TestKeyPair("RSA").getPublic();
- PublicKey pkey2 = new TestKeyPair("DSA").getPublic();
-
- byte[] encoding1 = pkey1.getEncoded();
- byte[] encoding2 = pkey2.getEncoded();
- TestCert cert_1 = new TestCert(pkey1);
- TestCert cert_2 = new TestCert(pkey2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setSubjectPublicKey((byte[]) null);
- assertTrue("Any certificate should match in the case of null "
- + "subjectPublicKey criteria.", selector.match(cert_1)
- && selector.match(cert_2));
-
- selector.setSubjectPublicKey(encoding1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
-
- encoding1[0]++;
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
-
- selector.setSubjectPublicKey(encoding2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getSubjectPublicKey() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value corresponds to specified
- */
- public void testGetSubjectPublicKey2() throws Exception {
-
- PublicKey pkey = new TestKeyPair("RSA").getPublic();
-
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null",
- selector.getSubjectPublicKey());
-
- selector.setSubjectPublicKey(pkey.getEncoded());
-
- PublicKey result = selector.getSubjectPublicKey();
-
- assertEquals("The name of algorithm should be RSA",
- result.getAlgorithm(), "RSA");
- }
-
- /**
- * setKeyUsage(boolean[] keyUsage) method testing.
- * Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match, and if the initialization
- * object are copied during the initialization. Also checks if selector
- * matches the certificate which does not have a keyUsage extension.
- */
- public void testSetKeyUsage() {
- boolean[] ku1 = new boolean[]
- { true, true, true, true, true, true, true, true, true };
- // decipherOnly is disallowed
- boolean[] ku2 = new boolean[]
- { true, true, true, true, true, true, true, true, false };
- TestCert cert_1 = new TestCert(ku1);
- TestCert cert_2 = new TestCert(ku2);
- TestCert cert_3 = new TestCert((boolean[]) null);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setKeyUsage(null);
- assertTrue("Any certificate should match in the case of null "
- + "keyUsage criteria.",
- selector.match(cert_1) && selector.match(cert_2));
- selector.setKeyUsage(ku1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- assertTrue("The certificate which does not have a keyUsage extension "
- + "implicitly allows all keyUsage values.",
- selector.match(cert_3));
- selector.setKeyUsage(ku2);
- ku2[0] = !ku2[0];
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getKeyUsage() method testing.
- * Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
- * and its modification does not cause the modification of internal object.
- */
- public void testGetKeyUsage() {
- boolean[] ku = new boolean[]
- { true, false, true, false, true, false, true, false, true };
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null", selector.getKeyUsage());
- selector.setKeyUsage(ku);
- assertTrue("The returned date should be equal to specified",
- Arrays.equals(ku, selector.getKeyUsage()));
- boolean[] result = selector.getKeyUsage();
- result[0] = !result[0];
- assertTrue("The returned keyUsage should be equal to specified",
- Arrays.equals(ku, selector.getKeyUsage()));
- }
-
- /**
- * setExtendedKeyUsage(Set<String> keyPurposeSet) method testing.
- */
- public void testSetExtendedKeyUsage() throws IOException {
- HashSet ku1 = new HashSet(Arrays.asList(new String[] {
- "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
- "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
- "1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7" }
- ));
- HashSet ku2 = new HashSet(Arrays.asList(new String[] {
- "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
- "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
- "1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6" }));
- TestCert cert_1 = new TestCert(ku1);
- TestCert cert_2 = new TestCert(ku2);
- TestCert cert_3 = new TestCert((Set) null);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setExtendedKeyUsage(null);
- assertTrue("Any certificate should match in the case of null "
- + "extendedKeyUsage criteria.", selector.match(cert_1)
- && selector.match(cert_2));
-
- selector.setExtendedKeyUsage(ku1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- assertTrue("The certificate which does not have a keyUsage extension "
- + "implicitly allows all keyUsage values.", selector
- .match(cert_3));
- ku1.remove("1.3.6.1.5.5.7.3.7"); // remove the missing in ku2 keyUsage
- assertFalse("The modification of initialization object "
- + "should not affect the modification of internal object.",
- selector.match(cert_2));
-
- selector.setExtendedKeyUsage(ku2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getExtendedKeyUsage() method testing.
- */
- public void testGetExtendedKeyUsage() {
- HashSet ku = new HashSet(Arrays.asList(new String[] {
- "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
- "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
- "1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7" }
- ));
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null",
- selector.getExtendedKeyUsage());
- try {
- selector.setExtendedKeyUsage(ku);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertTrue("The returned extendedKeyUsage should be equal to specified",
- ku.equals(selector.getExtendedKeyUsage()));
- try {
- selector.getExtendedKeyUsage().add("KRIBLE-GRABLI");
- fail("The returned Set should be immutable.");
- } catch (UnsupportedOperationException e) {
- }
- }
-
- /**
- * setSubjectAlternativeNames(Collection<List<?>> names) method testing.
- */
- public void testSetSubjectAlternativeNames() {
- try {
- GeneralName san0 =
- new GeneralName(new OtherName("1.2.3.4.5",
- new byte[] { 1, 2, 0, 1 }));
- GeneralName san1 = new GeneralName(1, "rfc@822.Name");
- GeneralName san2 = new GeneralName(2, "dNSName");
- GeneralName san3 = new GeneralName(new ORAddress());
- GeneralName san4 = new GeneralName(new Name("O=Organization"));
- GeneralName san5 =
- new GeneralName(new EDIPartyName("assigner", "party"));
- GeneralName san6 = new GeneralName(6, "http://uniform.Resource.Id");
- GeneralName san7 = new GeneralName(7, "1.1.1.1");
- GeneralName san8 = new GeneralName(8, "1.2.3.4444.55555");
-
- GeneralNames sans_1 = new GeneralNames();
- sans_1.addName(san0);
- sans_1.addName(san1);
- sans_1.addName(san2);
- sans_1.addName(san3);
- sans_1.addName(san4);
- sans_1.addName(san5);
- sans_1.addName(san6);
- sans_1.addName(san7);
- sans_1.addName(san8);
- GeneralNames sans_2 = new GeneralNames();
- sans_2.addName(san0);
-
- TestCert cert_1 = new TestCert(sans_1);
- TestCert cert_2 = new TestCert(sans_2);
- X509CertSelector selector = new X509CertSelector();
- selector.setMatchAllSubjectAltNames(true);
-
- selector.setSubjectAlternativeNames(null);
- assertTrue("Any certificate should match in the case of null "
- + "subjectAlternativeNames criteria.",
- selector.match(cert_1) && selector.match(cert_2));
-
- Collection sans = sans_1.getPairsList();
- selector.setSubjectAlternativeNames(sans);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match "
- + "the selection criteria.", selector.match(cert_2));
- sans.clear();
- assertTrue("The modification of initialization object "
- + "should not affect the modification "
- + "of internal object.", selector.match(cert_1));
- selector.setSubjectAlternativeNames(sans_2.getPairsList());
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- }
-
- /**
- * addSubjectAlternativeName(int type, String name) method testing.
- */
- public void testAddSubjectAlternativeName1() throws IOException {
- String name1 = "rfc@822.Name";
- String name2 = "dNSName";
- String name4 = "O=Organization";
- String name6 = "http://uniform.Resource.Id";
- String name7 = "255.255.255.0";
- String name8 = "1.2.3.4444.55555";
-
- GeneralName san1 = new GeneralName(1, name1);
- GeneralName san2 = new GeneralName(2, name2);
- GeneralName san4 = new GeneralName(4, name4);
- GeneralName san6 = new GeneralName(6, name6);
- GeneralName san7 = new GeneralName(7, name7);
- GeneralName san8 = new GeneralName(8, name8);
-
- GeneralNames sans_1 = new GeneralNames();
- sans_1.addName(san1);
- sans_1.addName(san2);
- sans_1.addName(san4);
- sans_1.addName(san6);
- sans_1.addName(san7);
- sans_1.addName(san8);
- GeneralNames sans_2 = new GeneralNames();
- sans_2.addName(san1);
- sans_2.addName(san2);
-
- TestCert cert_1 = new TestCert(sans_1);
- TestCert cert_2 = new TestCert(sans_2);
- X509CertSelector selector = new X509CertSelector();
- selector.setMatchAllSubjectAltNames(true);
-
- try {
- selector.addSubjectAlternativeName(1, name1);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
-
- try {
- selector.addSubjectAlternativeName(2, name2);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
-
- try {
- selector.addSubjectAlternativeName(4, name4);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- try {
- selector.addSubjectAlternativeName(6, name6);
- selector.addSubjectAlternativeName(7, name7);
- selector.addSubjectAlternativeName(8, name8);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * addSubjectAlternativeName(int type, byte[] name) method testing.
- */
- public void testAddSubjectAlternativeName2() {
- try {
- GeneralName san0 =
- new GeneralName(new OtherName("1.2.3.4.5",
- ASN1Integer.getInstance().encode(
- BigInteger.valueOf(55L).toByteArray())
- ));
- GeneralName san1 = new GeneralName(1, "rfc@822.Name");
- GeneralName san2 = new GeneralName(2, "dNSName");
- GeneralName san3 = new GeneralName(new ORAddress());
- GeneralName san4 = new GeneralName(new Name("O=Organization"));
- GeneralName san5 =
- new GeneralName(new EDIPartyName("assigner", "party"));
- GeneralName san6 = new GeneralName(6, "http://uniform.Resource.Id");
- GeneralName san7 = new GeneralName(new byte[] { 1, 1, 1, 1 });
- GeneralName san8 = new GeneralName(8, "1.2.3.4444.55555");
-
- GeneralNames sans_1 = new GeneralNames();
- sans_1.addName(san0);
- sans_1.addName(san1);
- sans_1.addName(san2);
- sans_1.addName(san3);
- sans_1.addName(san4);
- sans_1.addName(san5);
- sans_1.addName(san6);
- sans_1.addName(san7);
- sans_1.addName(san8);
- GeneralNames sans_2 = new GeneralNames();
- sans_2.addName(san0);
- sans_2.addName(san1);
- sans_2.addName(san2);
-
- TestCert cert_1 = new TestCert(sans_1);
- TestCert cert_2 = new TestCert(sans_2);
- X509CertSelector selector = new X509CertSelector();
- selector.setMatchAllSubjectAltNames(true);
-
- selector.addSubjectAlternativeName(0, san0.getEncodedName());
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- selector.addSubjectAlternativeName(1, san1.getEncodedName());
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- selector.addSubjectAlternativeName(2, san2.getEncodedName());
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- selector.addSubjectAlternativeName(3, san3.getEncodedName());
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.addSubjectAlternativeName(4, san4.getEncodedName());
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match "
- + "the selection criteria.", selector.match(cert_2));
- selector.addSubjectAlternativeName(5, san5.getEncodedName());
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match "
- + "the selection criteria.", selector.match(cert_2));
- selector.addSubjectAlternativeName(6, san6.getEncodedName());
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match "
- + "the selection criteria.", selector.match(cert_2));
- selector.addSubjectAlternativeName(7, san7.getEncodedName());
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match "
- + "the selection criteria.", selector.match(cert_2));
- byte[] oid = san8.getEncodedName();
- selector.addSubjectAlternativeName(8, oid);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match "
- + "the selection criteria.", selector.match(cert_2));
- oid[3] += 1;
- assertTrue("The byte array should be cloned to protect against "
- + "subsequent modifications.", selector.match(cert_1));
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- }
-
- /**
- * getSubjectAlternativeNames() method testing.
- */
- public void testGetSubjectAlternativeNames() {
- try {
- GeneralName san1 = new GeneralName(1, "rfc@822.Name");
- GeneralName san2 = new GeneralName(2, "dNSName");
-
- GeneralNames sans = new GeneralNames();
- sans.addName(san1);
- sans.addName(san2);
-
- TestCert cert_1 = new TestCert(sans);
- X509CertSelector selector = new X509CertSelector();
-
- assertNull("Selector should return null",
- selector.getSubjectAlternativeNames());
-
- selector.setSubjectAlternativeNames(sans.getPairsList());
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- selector.getSubjectAlternativeNames().clear();
- assertTrue("The modification of initialization object "
- + "should not affect the modification "
- + "of internal object.", selector.match(cert_1));
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- }
-
- /**
- * setMatchAllSubjectAltNames(boolean matchAllNames) method testing.
- */
- public void testSetMatchAllSubjectAltNames() {
- try {
- GeneralName san1 = new GeneralName(1, "rfc@822.Name");
- GeneralName san2 = new GeneralName(2, "dNSName");
-
- GeneralNames sans_1 = new GeneralNames();
- sans_1.addName(san1);
- GeneralNames sans_2 = new GeneralNames();
- sans_2.addName(san1);
- sans_2.addName(san2);
-
- TestCert cert = new TestCert(sans_1);
- X509CertSelector selector = new X509CertSelector();
- selector.setMatchAllSubjectAltNames(true);
-
- selector.setSubjectAlternativeNames(sans_2.getPairsList());
- assertFalse("Only certificate which contain all of the specified "
- + "subject alternative names should match.",
- selector.match(cert));
- selector.setMatchAllSubjectAltNames(false);
- /*
- assertTrue("The certificate which contain at least one of the "
- + "specified subject alternative names must match.",
- selector.match(cert));
- */
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- }
-
- /**
- * getMatchAllSubjectAltNames() method testing.
- */
- public void testGetMatchAllSubjectAltNames() {
- X509CertSelector selector = new X509CertSelector();
- assertTrue("The matchAllNames initially should be true",
- selector.getMatchAllSubjectAltNames());
- selector.setMatchAllSubjectAltNames(false);
- assertFalse("The value should be false",
- selector.getMatchAllSubjectAltNames());
- }
-
- /**
- * setNameConstraints(byte[] bytes) method testing.
- * Constructs the NameConstraints DER structure with
- * GeneralNames of types: 1, 2, 6, 7 and set it as a criterion.
- */
- public void testSetNameConstraints0() throws IOException {
- // Restrictions apply only when the specified name form is present.
- // If no name of the type is in the certificate,
- // the certificate is acceptable (rfc 3280).
-
- GeneralName[] name_constraints = new GeneralName[] {
- new GeneralName(1, "822.Name"),
- new GeneralName(1, "rfc@822.Name"),
- new GeneralName(2, "Name.org"),
- new GeneralName(2, "dNS.Name.org"),
- //new GeneralName(4, "O=Organization"),
- new GeneralName(6, "http://.Resource.Id"),
- new GeneralName(6, "http://uniform.Resource.Id"),
- new GeneralName(7, "1.1.1.1"),
- // new GeneralName(7, new byte[] {1, 1, 1, 1, 3, 3, 3, 3}),
- new GeneralName(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1 }),
- // new GeneralName(7, new byte[] {1, 1, 1, 1, 1, 1, 1, 1,
- // 1, 1, 1, 1, 1, 1, 1, 1,
- // 3, 3, 3, 3, 3, 3, 3, 3,
- // 3, 3, 3, 3, 3, 3, 3, 3})
- };
-
- // names which should match divided from names which should not
- // match by null
- GeneralName[][] alternative_names = new GeneralName[][] {
- {
- new GeneralName(1, "rfc@822.Name"),
- null,
- new GeneralName(1, "rfc@Other.Name")
- }, {
- new GeneralName(1, "rfc@822.Name"),
- null,
- new GeneralName(1, "rfc@Other.Name")
- }, {
- new GeneralName(2, "Name.org"),
- new GeneralName(2, "dNS.Name.org"),
- null,
- new GeneralName(2, "dNS.OtherName.org")
- }, {
- new GeneralName(2, "dNS.Name.org"),
- null,
- new GeneralName(2, "Name.org"),
- new GeneralName(2, "dNS.OtherName.org")
- }, {
-
- // new GeneralName(4, "O=Organization"),
- // null,
- // new GeneralName(4, "O=OtherOrganization")
- //}, {
-
- new GeneralName(6, "http://uniform.Resource.Id/location"),
- null,
- //new GeneralName(6, "http://Resource.Id")
- }, {
- new GeneralName(6, "http://uniform.Resource.Id"),
- null,
- new GeneralName(6, "http://Resource.Id")
- }, {
- new GeneralName(new byte[] { 1, 1, 1, 1 }),
- null,
- new GeneralName(new byte[] { 2, 2, 2, 2 })
- // }, {
- // new GeneralName(7, new byte[] {1, 1, 1, 1}),
- // new GeneralName(7, new byte[] {2, 2, 2, 2}),
- // new GeneralName(7, new byte[] {3, 3, 3, 3}),
- // null,
- // new GeneralName(7, new byte[] {4, 4, 4, 4})
- }, {
- new GeneralName(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1 }),
- null,
- new GeneralName(new byte[] { 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2 }),
- // }, {
- // new GeneralName(7, new byte[] {1, 1, 1, 1, 1, 1, 1, 1,
- // 1, 1, 1, 1, 1, 1, 1, 1}),
- // new GeneralName(7, new byte[] {2, 2, 2, 2, 2, 2, 2, 2,
- // 2, 2, 2, 2, 2, 2, 2, 2}),
- // new GeneralName(7, new byte[] {3, 3, 3, 3, 3, 3, 3, 3,
- // 3, 3, 3, 3, 3, 3, 3, 3}),
- // null,
- // new GeneralName(7, new byte[] {4, 4, 4, 4, 4, 4, 4, 4,
- // 4, 4, 4, 4, 4, 4, 4, 4}),
- }
- };
-
- X509CertSelector selector = new X509CertSelector();
- String subject = "O=Organization";
- X500Principal x500Subject = new X500Principal(subject);
- try {
- Name nameSubject = new Name(subject);
- for (int i = 0; i < name_constraints.length; i++) {
- // make the subtrees (part of name constraints)
- // this subtrees will be used as permited and as excluded
- GeneralSubtree subtree =
- new GeneralSubtree(name_constraints[i]);
- GeneralSubtrees subtrees = new GeneralSubtrees();
- NameConstraints constraints;
- subtrees.addSubtree(subtree);
- // start the checking for each alt. name corresponding
- // to current name_constraints[i]
- boolean check_matching = true;
- for (int j = 0; j < alternative_names[i].length; j++) {
- GeneralNames alt_names_extension = new GeneralNames();
- if (alternative_names[i][j] == null) {
- // double trick: turn the switch and check that the
- // restrictions apply only when the specified name
- // form is presented. If no name of the type is in the
- // certificate, the certificate is acceptable.
- check_matching = false;
- } else {
- alt_names_extension.addName(alternative_names[i][j]);
- }
- TestCert certificate = new TestCert(alt_names_extension);
- certificate.setSubject(x500Subject);
- certificate.setEncoding(getCertEncoding(nameSubject,
- alt_names_extension));
- // first check if permited name match
- constraints = new NameConstraints(subtrees, null);
- selector.setNameConstraints(constraints.getEncoded());
- boolean expected = check_matching
- || (alternative_names[i][j] == null);
- assertTrue("The method match() for:\n "
- + alternative_names[i][j]
- + "\nand permited name\n "
- + name_constraints[i]
- + "\nshould return: " + expected,
- selector.match(certificate) == expected);
- // second check if excluded name does not match
- constraints = (check_matching)
- // check for 'Any name matching a
- // restriction in the excludedSubtrees
- // field is invalid regardless of
- // information appearing in the
- // permittedSubtrees'.
- ? new NameConstraints(subtrees, subtrees)
- : new NameConstraints(null, subtrees);
- selector.setNameConstraints(constraints.getEncoded());
- expected = !check_matching
- || (alternative_names[i][j] == null);
- assertTrue("The method match() for:\n "
- + alternative_names[i][j]
- + "\nand excluded name\n "
- + name_constraints[i]
- + "\nshould return: " + expected,
- selector.match(certificate) == expected);
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- }
-
- /**
- * setNameConstraints(byte[] bytes) method testing.
- * Constructs the NameConstraints DER structure with
- * GeneralNames of types: 1, 2, 6, 7 and set it as a criterion.
- */
- public void testSetNameConstraints1() throws IOException {
-
- GeneralName[] name_constraints = new GeneralName[] {
- new GeneralName(1, "822.Name"),
- new GeneralName(1, "rfc@822.Name"),
- new GeneralName(2, "Name.org"),
- new GeneralName(2, "dNS.Name.org"),
- new GeneralName(6, "http://.Resource.Id"),
- new GeneralName(6, "http://uniform.Resource.Id"),
- new GeneralName(7, "1.1.1.1"),
- new GeneralName(7, "1.1.1.1/3.3.3.3"),
- new GeneralName(7, "0101:0101:0101:0101:0101:0101:0101:0101"),
- new GeneralName(7, "0101:0101:0101:0101:0101:0101:0101:0101"
- + "/0303:0303:0303:0303:0303:0303:0303:0303"),
- };
-
- // Names which should match divided from names which should not
- // match by null.
- // Restrictions apply only when the specified name form is present.
- // If no name of the type is in the certificate, the certificate
- // is acceptable (rfc 3280). This assertion is checked during processing
- // of null GeneralName object (it also serves as separator).
- GeneralName[][] alternative_names = new GeneralName[][] {
- {
- new GeneralName(1, "rfc@822.Name"),
- null,
- new GeneralName(1, "rfc@Other.Name")
- }, {
- new GeneralName(1, "rfc@822.Name"),
- null,
- new GeneralName(1, "rfc@Other.Name")
- }, {
- new GeneralName(2, "Name.org"),
- new GeneralName(2, "dNS.Name.org"),
- null,
- new GeneralName(2, "dNS.OtherName.org")
- }, {
- new GeneralName(2, "dNS.Name.org"),
- null,
- new GeneralName(2, "Name.org"),
- new GeneralName(2, "dNS.OtherName.org")
- }, {
-
- new GeneralName(6, "http://uniform.Resource.Id/location"),
- null,
- new GeneralName(6, "http://Resource.Id")
- }, {
- new GeneralName(6, "http://uniform.Resource.Id"),
- null,
- new GeneralName(6, "http://Resource.Id")
- }, {
- new GeneralName(new byte[] { 1, 1, 1, 1 }),
- null,
- new GeneralName(new byte[] { 2, 2, 2, 2 })
- }, {
- new GeneralName(new byte[] { 1, 1, 1, 1 }),
- new GeneralName(new byte[] { 2, 2, 2, 2 }),
- new GeneralName(new byte[] { 3, 3, 3, 3 }),
- null,
- new GeneralName(new byte[] { 4, 4, 4, 4 })
- }, {
- new GeneralName(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1 }),
- null,
- new GeneralName(new byte[] { 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2 }),
- }, {
- new GeneralName(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1 }),
- new GeneralName(new byte[] { 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2 }),
- new GeneralName(new byte[] { 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3 }),
- null,
- new GeneralName(new byte[] { 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4 }),
- }
- };
-
- X509CertSelector selector = new X509CertSelector();
- String subject = "O=Organization";
- X500Principal x500Subject = new X500Principal(subject);
- try {
- Name nameSubject = new Name(subject);
- for (int i = 0; i < name_constraints.length; i++) {
- // make the subtrees (part of name constraints)
- // this subtrees will be used as permited and as excluded
- GeneralSubtree subtree =
- new GeneralSubtree(name_constraints[i]);
- GeneralSubtrees subtrees = new GeneralSubtrees();
- NameConstraints constraints;
- subtrees.addSubtree(subtree);
- // start the checking for each alt. name corresponding
- // to current name_constraints[i]
- boolean check_matching = true;
- for (int j = 0; j < alternative_names[i].length; j++) {
- GeneralNames alt_names_extension = new GeneralNames();
- if (alternative_names[i][j] == null) {
- // double trick: turn the switch and check that the
- // restrictions apply only when the specified name
- // form is presented. If no name of the type is in the
- // certificate, the certificate is acceptable.
- check_matching = false;
- } else {
- alt_names_extension.addName(alternative_names[i][j]);
- }
- TestCert certificate = new TestCert(alt_names_extension);
- certificate.setSubject(x500Subject);
- certificate.setEncoding(getCertEncoding(nameSubject,
- alt_names_extension));
- // first check if permited name match
- constraints = new NameConstraints(subtrees, null);
- selector.setNameConstraints(constraints.getEncoded());
- boolean expected = check_matching
- || (alternative_names[i][j] == null);
- assertTrue("The method match() for:\n "
- + alternative_names[i][j]
- + "\nand permited name\n "
- + name_constraints[i]
- + "\nshould return: " + expected,
- selector.match(certificate) == expected);
- // second check if excluded name does not match
- constraints = (check_matching)
- // check for 'Any name matching a
- // restriction in the excludedSubtrees
- // field is invalid regardless of
- // information appearing in the
- // permittedSubtrees'.
- ? new NameConstraints(subtrees, subtrees)
- : new NameConstraints(null, subtrees);
- selector.setNameConstraints(constraints.getEncoded());
- expected = !check_matching
- || (alternative_names[i][j] == null);
- assertTrue("The method match() for:\n "
- + alternative_names[i][j]
- + "\nand excluded name\n "
- + name_constraints[i]
- + "\nshould return: " + expected,
- selector.match(certificate) == expected);
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- }
-
- /**
- * setNameConstraints(byte[] bytes) method testing.
- * Constructs the different NameConstraints DER structures with
- * GeneralNames of type 4 and checks if the different certificates
- * matches or does not.
- */
- public void testSetNameConstraints2() {
- // As specified in rfc 3280:
- //
- // Restrictions apply only when the specified name form is present.
- // If no name of the type is in the certificate,
- // the certificate is acceptable.
- //
- // Restrictions of the form directoryName MUST be applied to the
- // subject field in the certificate and to the subjectAltName
- // extensions of type directoryName.
- //
- // According to p. 4.1.2.4 comparing the encoded forms of the names.
-
- String[][] variants = new String[][] {
- // subject Alternative Presented name Absent name
- // name name perm(t)/excl(f) perm(f)/excl(t)
- { "O=Org", "O=Org", "O=Org", "O=Org2" },
- { "O=Org", "O=Org1", "O=Org", "O=Org2" },
- { "O=Org1", "O=Org", "O=Org", "O=Org2" },
- };
-
- X509CertSelector selector = new X509CertSelector();
- try {
- for (int i = 0; i < variants.length; i++) {
- // make the names objects
- X500Principal subject = new X500Principal(variants[i][0]);
- Name subject_name = new Name(variants[i][0]);
- GeneralName alt_name = new GeneralName(4, variants[i][1]);
- // make the certificate to be checked
- GeneralNames alt_names_extension = new GeneralNames();
- alt_names_extension.addName(alt_name);
- TestCert certificate = new TestCert(alt_names_extension);
- certificate.setSubject(subject);
- certificate.setEncoding(getCertEncoding(subject_name,
- alt_names_extension));
- // make the subtrees (part of name constraints)
- // this subtrees will be used as permited and as excluded
- // name which is presented in certificate:
- GeneralSubtrees pos_subtrees = new GeneralSubtrees();
- pos_subtrees.addSubtree(
- new GeneralSubtree(
- new GeneralName(4, variants[i][2])));
- // name which is absent in certificate:
- GeneralSubtrees neg_subtrees = new GeneralSubtrees();
- neg_subtrees.addSubtree(
- new GeneralSubtree(
- new GeneralName(4, variants[i][3])));
-
- NameConstraints constraints;
- // Work with name which is presented in certificate
- // first check if certificate with permited name matches:
- constraints = new NameConstraints(pos_subtrees, null);
- selector.setNameConstraints(constraints.getEncoded());
- assertTrue("The method match() for certificate "
- + "with subject:\n "
- + variants[i][0]
- + "\nand with alternative name:\n "
- + variants[i][1]
- + "\nand permited name\n "
- + variants[i][2]
- + "\nshould return true",
- selector.match(certificate));
- // second check if certificate with excluded name doesn't match:
- constraints = new NameConstraints(pos_subtrees, pos_subtrees);
- selector.setNameConstraints(constraints.getEncoded());
- assertTrue("The method match() for certificate "
- + "with subject:\n "
- + variants[i][0]
- + "\nand with alternative name:\n "
- + variants[i][1]
- + "\nand excluded name\n "
- + variants[i][2]
- + "\nshould return false",
- !selector.match(certificate));
- // Work with name which is not presented in certificate
- // first check if the certificate without permited name
- // does not match:
- constraints = new NameConstraints(neg_subtrees, null);
- selector.setNameConstraints(constraints.getEncoded());
- assertTrue("The method match() for certificate "
- + "with subject:\n "
- + variants[i][0]
- + "\nand with alternative name:\n "
- + variants[i][1]
- + "\nand permited name\n "
- + variants[i][3]
- + "\nshould return false",
- !selector.match(certificate));
- // second check if certificate without excluded name matches:
- constraints = new NameConstraints(neg_subtrees, neg_subtrees);
- selector.setNameConstraints(constraints.getEncoded());
- assertTrue("The method match() for certificate "
- + "with subject:\n "
- + variants[i][0]
- + "\nand with alternative name:\n "
- + variants[i][1]
- + "\nand excluded name\n "
- + variants[i][3]
- + "\nshould return false",
- !selector.match(certificate));
- }
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- }
-
- /**
- * Constructs the encoded form of certificate with specified subject field
- * of TBSCertificate and specified alternative names.
- */
- private byte[] getCertEncoding(Name subject, GeneralNames subjectAltNames)
- throws IOException {
- // make the TBSCertificate for Certificate
- int version = 2; //v3
- BigInteger serialNumber = BigInteger.valueOf(555L);
- AlgorithmIdentifier signature = new AlgorithmIdentifier("1.2.3.44.555");
- Name issuer = new Name("O=Certificate Issuer");
- Validity validity = new Validity(new Date(100000000),
- new Date(200000000));
- SubjectPublicKeyInfo subjectPublicKeyInfo =
- new SubjectPublicKeyInfo(
- new AlgorithmIdentifier("1.2.840.113549.1.1.2"),
- new byte[10]);
- boolean[] issuerUniqueID = new boolean[]
- { true, false, true, false, true, false, true, false };
- boolean[] subjectUniqueID = new boolean[]
- { false, true, false, true, false, true, false, true };
-
- Extension extension = new Extension("2.5.29.17",
- true, subjectAltNames.getEncoded());
- Extensions extensions = new Extensions();
- extensions.addExtension(extension);
-
- TBSCertificate tbsCertificate = new TBSCertificate(version,
- serialNumber, signature, issuer, validity, subject,
- subjectPublicKeyInfo, issuerUniqueID, subjectUniqueID,
- extensions);
-
- // make the Certificate
- org.apache.harmony.security.x509.Certificate certificate =
- new org.apache.harmony.security.x509.Certificate
- (tbsCertificate, signature, new byte[10]);
-
- return certificate.getEncoded();
- }
-
- /**
- * getNameConstraints() method testing.
- */
- public void testGetNameConstraints() {
- }
-
- /**
- * setBasicConstraints(int minMaxPathLen) method testing.
- */
- public void testSetBasicConstraints() {
- try {
- new X509CertSelector().setBasicConstraints(-3);
- fail("IllegalArgumentException should be thrown.");
- } catch (IllegalArgumentException e) {
- }
-
- int plen1 = 2;
- int plen2 = -1;
- TestCert cert_1 = new TestCert(plen1);
- TestCert cert_2 = new TestCert(plen2);
- X509CertSelector selector = new X509CertSelector();
-
- selector.setBasicConstraints(-1);
- assertTrue("Any certificate should match in the case of -1 "
- + "pathLen criteria.",
- selector.match(cert_1) && selector.match(cert_2));
- selector.setBasicConstraints(plen1);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_1));
- assertFalse("The certificate should not match the selection criteria.",
- selector.match(cert_2));
- selector.setBasicConstraints(plen2);
- assertTrue("The certificate should match the selection criteria.",
- selector.match(cert_2));
- }
-
- /**
- * getBasicConstraints() method testing.
- */
- public void testGetBasicConstraints() {
- int plen1 = 2;
- int plen2 = -1;
- X509CertSelector selector = new X509CertSelector();
-
- assertEquals("Selector should return -1",
- selector.getBasicConstraints(), -1);
- selector.setBasicConstraints(plen1);
- assertEquals("The returned value should be equal to specified",
- plen1, selector.getBasicConstraints());
- assertFalse("The returned value should differ",
- plen2 == selector.getBasicConstraints());
- }
-
- /**
- * setPolicy(Set<String> certPolicySet) method testing.
- */
- public void testSetPolicy() {
- String[] policies_1 = new String[] {
- "0.0.0.0.0.0",
- "1.1.1.1.1.1",
- };
- String[] policies_2 = new String[] {
- "0.0.0.0.0.0",
- "1.1.1.1.1.1",
- "2.2.2.2.2.2"
- };
- String[] policies_3 = new String[] {
- "2.2.2.2.2.2"
- };
- String[] policies_4 = new String[] { };
- X509CertSelector selector = new X509CertSelector();
- HashSet set = new HashSet(Arrays.asList(policies_1));
- try {
- selector.setPolicy(set);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- TestCert cert_1 = new TestCert(policies_1);
- TestCert cert_2 = new TestCert(policies_2);
- TestCert cert_3 = new TestCert(policies_3);
- TestCert cert_4 = new TestCert(policies_4);
- assertTrue("The certificate should match the specified criteria",
- selector.match(cert_1));
- assertTrue("The certificate should match the specified criteria",
- selector.match(cert_2));
- assertFalse("The certificate should not match the specified criteria",
- selector.match(cert_3));
- assertFalse("The certificate should not match the specified criteria",
- selector.match(cert_4));
- set.add("2.2.2.2.2.2");
- assertFalse("The modification of the set should not cause the "
- + "modification of internal object",
- selector.match(cert_3));
- set = new HashSet();
- try {
- selector.setPolicy(set);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertTrue("The certificate should match the specified criteria",
- selector.match(cert_1));
- assertTrue("The certificate should match the specified criteria",
- selector.match(cert_2));
- assertTrue("The certificate should match the specified criteria",
- selector.match(cert_3));
- assertFalse("The certificate should not match the specified criteria",
- selector.match(cert_4));
- set.add("2.2.2.2.2.2");
- try {
- selector.setPolicy(set);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- assertFalse("The certificate should not match the specified criteria",
- selector.match(cert_1));
- assertTrue("The certificate should match the specified criteria",
- selector.match(cert_2));
- assertTrue("The certificate should match the specified criteria",
- selector.match(cert_3));
- assertFalse("The certificate should not match the specified criteria",
- selector.match(cert_4));
- }
-
- /**
- * getPolicy() method testing.
- */
- public void testGetPolicy() {
- String[] policies = new String[] {
- "0.0.0.0.0.0",
- "1.1.1.1.1.1",
- "2.2.2.2.2.2"
- };
- X509CertSelector selector = new X509CertSelector();
- HashSet set = new HashSet(Arrays.asList(policies));
- try {
- selector.setPolicy(set);
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- Set result = selector.getPolicy();
- try {
- result.remove(policies[0]);
- fail("An immutable set should be returned.");
- } catch (UnsupportedOperationException e) {
- }
- if (result.size() != 3) {
- fail("The size of returned set differs from specified.");
- }
- for (int i = 0; i < policies.length; i++) {
- if (!result.contains(policies[i])) {
- fail("The set does not have specified policy.");
- }
- }
- }
-
- /**
- * setPathToNames(Collection<List<?>> names) method testing.
- */
- public void testSetPathToNames() {
- try {
- GeneralName[] names = new GeneralName[] {
- new GeneralName(1, "rfc@822.Name"),
- new GeneralName(1, "rfc@822.AnotherName"),
- new GeneralName(2, "dNSName"),
- new GeneralName(2, "AnotherdNSName"),
- new GeneralName(4, "O=Organization"),
- new GeneralName(4, "O=Another Organization"),
- new GeneralName(6, "http://uniform.Resource.Id"),
- new GeneralName(6, "http://another.uniform.Resource.Id"),
- new GeneralName(7, "1.1.1.1"),
- new GeneralName(7, "2.2.2.2")
- };
-
- X509CertSelector selector = new X509CertSelector();
-
- TestCert cert;
- GeneralSubtrees subtrees;
- NameConstraints constraints;
- for (int i = 0; i < names.length; i += 2) {
- // Set up the pathToNames criterion
- ArrayList pathToNames = new ArrayList();
- pathToNames.add(names[i].getAsList());
- selector.setPathToNames(pathToNames);
-
- // Construct the subtrees without the current name
- subtrees = new GeneralSubtrees();
- for (int j = 0; j < names.length; j++) {
- if (i != j && i + 1 != j) {
- subtrees.addSubtree(new GeneralSubtree(names[j]));
- }
- }
- constraints = new NameConstraints(subtrees, null);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate does not contain the names "
- + "of such type so method match() should "
- + "return true.", selector.match(cert));
-
- constraints = new NameConstraints(subtrees, subtrees);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate does not contain the names "
- + "of such type so method match() should "
- + "return true.", selector.match(cert));
-
- constraints = new NameConstraints(null, subtrees);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate does not contain the names "
- + "of such type so method match() should "
- + "return true.", selector.match(cert));
-
- subtrees.addSubtree(new GeneralSubtree(names[i + 1]));
-
- constraints = new NameConstraints(subtrees, null);
- cert = new TestCert(constraints);
- assertFalse("The Name Constraints Extension of the "
- + "certificate does not contain the name "
- + "as a permitted name so method match() "
- + "should return false", selector.match(cert));
-
- constraints = new NameConstraints(subtrees, subtrees);
- cert = new TestCert(constraints);
- assertFalse("The Name Constraints Extension of the "
- + "certificate does not contain the name "
- + "as an excluded name but it does not "
- + "contain this name as a permitted so match()"
- + "should return false", selector.match(cert));
-
- constraints = new NameConstraints(null, subtrees);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate does not contain the name "
- + "as an excluded name so method match() "
- + "should return true", selector.match(cert));
-
- subtrees.addSubtree(new GeneralSubtree(names[i]));
-
- constraints = new NameConstraints(subtrees, null);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate contains the name "
- + "as a permitted name so method match() "
- + "should return true", selector.match(cert));
-
- constraints = new NameConstraints(subtrees, subtrees);
- cert = new TestCert(constraints);
- assertFalse("The Name Constraints Extension of the "
- + "certificate contains the name "
- + "as an excluded name so method match() "
- + "should return false", selector.match(cert));
-
- constraints = new NameConstraints(null, subtrees);
- cert = new TestCert(constraints);
- assertFalse("The Name Constraints Extension of the "
- + "certificate contains the name "
- + "as an excluded name so method match() "
- + "should return false", selector.match(cert));
-
- pathToNames.clear();
- assertFalse("The modification of initialization parameter "
- + "should not cause the modification of "
- + "internal object ", selector.match(cert));
- }
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- }
-
- /**
- * addPathToName(int type, String name) method testing.
- */
- public void testAddPathToName1() {
- try {
- int[] types = new int[] { 1, 1, 2, 2, 4, 4, 6, 6, 7, 7 };
- String[] names = new String[] {
- "rfc@822.Name",
- "rfc@822.AnotherName",
- "dNSName",
- "AnotherdNSName",
- "O=Organization",
- "O=Another Organization",
- "http://uniform.Resource.Id",
- "http://another.uniform.Resource.Id",
- "1.1.1.1",
- "2.2.2.2"
- };
-
- X509CertSelector selector = new X509CertSelector();
-
- TestCert cert;
- GeneralSubtrees subtrees;
- NameConstraints constraints;
- for (int i = 0; i < names.length - 2; i += 2) {
- // Set up the pathToNames criterion
- selector.addPathToName(types[i], names[i]);
-
- // Construct the subtrees without the current name
- subtrees = new GeneralSubtrees();
- for (int j = i + 2; j < names.length; j++) {
- if (i != j && i + 1 != j) {
- subtrees.addSubtree(
- new GeneralSubtree(
- new GeneralName(types[j], names[j])));
- }
- }
- constraints = new NameConstraints(subtrees, null);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate does not contain the names "
- + "of such type so method match() should "
- + "return true.", selector.match(cert));
-
- constraints = new NameConstraints(subtrees, subtrees);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate does not contain the names "
- + "of such type so method match() should "
- + "return true.", selector.match(cert));
-
- constraints = new NameConstraints(null, subtrees);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate does not contain the names "
- + "of such type so method match() should "
- + "return true.", selector.match(cert));
-
- subtrees.addSubtree(
- new GeneralSubtree(
- new GeneralName(types[i + 1], names[i + 1])));
-
- constraints = new NameConstraints(subtrees, null);
- cert = new TestCert(constraints);
- assertFalse("The Name Constraints Extension of the "
- + "certificate does not contain the name "
- + "as a permitted name so method match() "
- + "should return false", selector.match(cert));
-
- constraints = new NameConstraints(subtrees, subtrees);
- cert = new TestCert(constraints);
- assertFalse("The Name Constraints Extension of the "
- + "certificate does not contain the name "
- + "as an excluded name but it does not "
- + "contain this name as a permitted so match()"
- + "should return false", selector.match(cert));
-
- constraints = new NameConstraints(null, subtrees);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate does not contain the name "
- + "as an excluded name so method match() "
- + "should return true", selector.match(cert));
-
- subtrees.addSubtree(
- new GeneralSubtree(
- new GeneralName(types[i], names[i])));
-
- constraints = new NameConstraints(subtrees, null);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate contains the name "
- + "as a permitted name so method match() "
- + "should return true", selector.match(cert));
-
- constraints = new NameConstraints(subtrees, subtrees);
- cert = new TestCert(constraints);
- assertFalse("The Name Constraints Extension of the "
- + "certificate contains the name "
- + "as an excluded name so method match() "
- + "should return false", selector.match(cert));
-
- constraints = new NameConstraints(null, subtrees);
- cert = new TestCert(constraints);
- assertFalse("The Name Constraints Extension of the "
- + "certificate contains the name "
- + "as an excluded name so method match() "
- + "should return false", selector.match(cert));
- }
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- }
-
- /**
- * addPathToName(int type, byte[] name) method testing.
- */
- public void testAddPathToName2() {
- try {
- int[] types = new int[] { 1, 1, 2, 2, 4, 4, 6, 6, 7, 7 };
- byte[][] names = new byte[][] {
- new GeneralName(1, "rfc@822.Name").getEncodedName(),
- new GeneralName(1, "rfc@822.AnotherName").getEncodedName(),
- new GeneralName(2, "dNSName").getEncodedName(),
- new GeneralName(2, "AnotherdNSName").getEncodedName(),
- new GeneralName(4, "O=Organization").getEncodedName(),
- new GeneralName(4, "O=Another Organization").getEncodedName(),
- new GeneralName(6, "http://uniform.Resource.Id")
- .getEncodedName(),
- new GeneralName(6, "http://another.uniform.Resource.Id")
- .getEncodedName(),
- new GeneralName(7, "1.1.1.1").getEncodedName(),
- new GeneralName(7, "2.2.2.2").getEncodedName()
- };
-
- X509CertSelector selector = new X509CertSelector();
-
- TestCert cert;
- GeneralSubtrees subtrees;
- NameConstraints constraints;
- for (int i = 0; i < names.length - 2; i += 2) {
- // Set up the pathToNames criterion
- selector.addPathToName(types[i], names[i]);
-
- // Construct the subtrees without the current name
- subtrees = new GeneralSubtrees();
- for (int j = i + 2; j < names.length; j++) {
- if (i != j && i + 1 != j) {
- subtrees.addSubtree(
- new GeneralSubtree(
- new GeneralName(types[j], names[j])));
- }
- }
- constraints = new NameConstraints(subtrees, null);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate does not contain the names "
- + "of such type so method match() should "
- + "return true.", selector.match(cert));
-
- constraints = new NameConstraints(subtrees, subtrees);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate does not contain the names "
- + "of such type so method match() should "
- + "return true.", selector.match(cert));
-
- constraints = new NameConstraints(null, subtrees);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate does not contain the names "
- + "of such type so method match() should "
- + "return true.", selector.match(cert));
-
- subtrees.addSubtree(
- new GeneralSubtree(
- new GeneralName(types[i + 1], names[i + 1])));
-
- constraints = new NameConstraints(subtrees, null);
- cert = new TestCert(constraints);
- assertFalse("The Name Constraints Extension of the "
- + "certificate does not contain the name "
- + "as a permitted name so method match() "
- + "should return false", selector.match(cert));
-
- constraints = new NameConstraints(subtrees, subtrees);
- cert = new TestCert(constraints);
- assertFalse("The Name Constraints Extension of the "
- + "certificate does not contain the name "
- + "as an excluded name but it does not "
- + "contain this name as a permitted so match()"
- + "should return false", selector.match(cert));
-
- constraints = new NameConstraints(null, subtrees);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate does not contain the name "
- + "as an excluded name so method match() "
- + "should return true", selector.match(cert));
-
- subtrees.addSubtree(
- new GeneralSubtree(
- new GeneralName(types[i], names[i])));
-
- constraints = new NameConstraints(subtrees, null);
- cert = new TestCert(constraints);
- assertTrue("The Name Constraints Extension of the "
- + "certificate contains the name "
- + "as a permitted name so method match() "
- + "should return true", selector.match(cert));
-
- constraints = new NameConstraints(subtrees, subtrees);
- cert = new TestCert(constraints);
- assertFalse("The Name Constraints Extension of the "
- + "certificate contains the name "
- + "as an excluded name so method match() "
- + "should return false", selector.match(cert));
-
- constraints = new NameConstraints(null, subtrees);
- cert = new TestCert(constraints);
- assertFalse("The Name Constraints Extension of the "
- + "certificate contains the name "
- + "as an excluded name so method match() "
- + "should return false", selector.match(cert));
- }
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- }
-
- /**
- * getPathToNames() method testing.
- */
- public void testGetPathToNames() {
- try {
- byte[] encoding =
- new GeneralName(1, "rfc@822.Name").getEncodedName();
-
- X509CertSelector selector = new X509CertSelector();
-
- selector.addPathToName(1, encoding);
- encoding[0]++;
- Collection coll = selector.getPathToNames();
- Iterator it = coll.iterator();
- List list = (List) it.next();
- Object result = list.get(1);
- if ((result instanceof byte[])
- && (encoding[0] == ((byte[]) result)[0])) {
- fail("Deep copy should be performed on pathToNames.");
- }
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown.");
- }
- }
-
- /**
- * toString() method testing.
- */
- public void testToString() throws Exception {
- BigInteger serial = new BigInteger("10000");
- X500Principal issuer = new X500Principal("O=Issuer Org.");
- X500Principal subject = new X500Principal("O=Subject Org.");
- byte[] subject_auth_KeyID = new byte[] { 1, 2, 3, 4, 5 };
- Date certValid = new Date(2000000000);
- Date[] privateKeyValid = new Date[] {
- new Date(100000000L),
- new Date(200000000L),
- new Date(300000000L)
- };
- String pkAlgID = "1.2.840.113549.1.1.4"; // MD5 with RSA encryption (source: http://asn1.elibel.tm.fr)
- PublicKey pkey;
-
- pkey = new TestKeyPair("RSA").getPublic();
-
- boolean[] keyUsage = new boolean[]
- { true, true, true, true, true, true, true, true, false };
- // OID values was taken from rfc 3280
- HashSet extKeyUsage = new HashSet(Arrays.asList(new String[] {
- "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
- "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
- "1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7" }
- ));
- GeneralNames subjectAltNames = new GeneralNames(Arrays.asList(
- new GeneralName[] {
- new GeneralName(1, "rfc@822.Name"),
- new GeneralName(2, "dNSName"),
- new GeneralName(6, "http://uniform.Resource.Id"),
- new GeneralName(7, "1.1.1.1")
- }
- ));
- String[] policies = new String[] {
- "0.0.0.0.0.0",
- "1.1.1.1.1.1",
- };
- TestCert cert = new TestCert("certificate equality criteria");
-
- X509CertSelector selector = new X509CertSelector();
- selector.setCertificate(cert);
- selector.setSerialNumber(serial);
- selector.setIssuer(issuer);
- selector.setSubject(subject);
- selector.setSubjectKeyIdentifier(subject_auth_KeyID);
- selector.setAuthorityKeyIdentifier(subject_auth_KeyID);
- selector.setCertificateValid(certValid);
- selector.setPrivateKeyValid(privateKeyValid[1]);
- selector.setSubjectPublicKey(pkey);
- selector.setSubjectPublicKeyAlgID(pkAlgID);
- selector.setKeyUsage(keyUsage);
- selector.setExtendedKeyUsage(extKeyUsage);
- selector.setSubjectAlternativeNames(subjectAltNames.getPairsList());
- selector.setMatchAllSubjectAltNames(true);
- selector.setPolicy(new HashSet(Arrays.asList(policies)));
-
- assertNotNull("The result should not be null.",
- selector.toString());
- }
-
- /**
- * match(Certificate cert) method testing.
- * Tests if the null object matches to the selector or does not,
- * and if the certificate conforming to the multiple matching criteria
- * matches or does not..
- */
- public void testMatch() throws Exception {
- BigInteger serial = new BigInteger("10000");
- X500Principal issuer = new X500Principal("O=Issuer Org.");
- X500Principal subject = new X500Principal("O=Subject Org.");
- byte[] subject_auth_KeyID = new byte[] { 1, 2, 3, 4, 5 }; // random value
- Date certValid = new Date(2000000000);
- Date[] privateKeyValid = new Date[] {
- new Date(100000000L),
- new Date(200000000L),
- new Date(300000000L)
- };
- String pkAlgID = "1.2.840.113549.1.1.1"; // RSA encryption (source: http://asn1.elibel.tm.fr)
- PublicKey pkey;
-
- pkey = new TestKeyPair("RSA").getPublic();
-
- boolean[] keyUsage = new boolean[]
- { true, true, true, true, true, true, true, true, false };
- // OID values was taken from rfc 3280
- HashSet extKeyUsage = new HashSet(Arrays.asList(new String[] {
- "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
- "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
- "1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7" }
- ));
- GeneralNames subjectAltNames = new GeneralNames(Arrays.asList(
- new GeneralName[] {
- new GeneralName(1, "rfc@822.Name"),
- new GeneralName(2, "dNSName"),
- new GeneralName(6, "http://uniform.Resource.Id"),
- new GeneralName(7, "1.1.1.1")
- }
- ));
- String[] policies = new String[] {
- "0.0.0.0.0.0",
- "1.1.1.1.1.1",
- };
-
- TestCert cert = new TestCert("certificate equality criteria");
- cert.setSerialNumber(serial);
- cert.setIssuer(issuer);
- cert.setSubject(subject);
- cert.setKeyIdentifier(subject_auth_KeyID);
- cert.setDate(certValid);
- cert.setPeriod(privateKeyValid[0], privateKeyValid[2]);
- cert.setPublicKey(pkey);
- cert.setKeyUsage(keyUsage);
- cert.setExtendedKeyUsage(extKeyUsage);
- cert.setSubjectAlternativeNames(subjectAltNames);
- cert.setPolicies(policies);
-
- X509CertSelector selector = new X509CertSelector();
- selector.setCertificate(cert);
- selector.setSerialNumber(serial);
- selector.setIssuer(issuer);
- selector.setSubject(subject);
- selector.setSubjectKeyIdentifier(subject_auth_KeyID);
- selector.setAuthorityKeyIdentifier(subject_auth_KeyID);
- selector.setCertificateValid(certValid);
- selector.setPrivateKeyValid(privateKeyValid[1]);
- selector.setSubjectPublicKey(pkey);
- selector.setSubjectPublicKeyAlgID(pkAlgID);
- selector.setKeyUsage(keyUsage);
- selector.setExtendedKeyUsage(extKeyUsage);
- selector.setSubjectAlternativeNames(subjectAltNames.getPairsList());
- selector.setMatchAllSubjectAltNames(true);
- selector.setPolicy(new HashSet(Arrays.asList(policies)));
-
- assertFalse("The null object should not match",
- selector.match((X509Certificate) null));
- assertTrue("The certificate should match the selector",
- selector.match(cert));
- }
-
- /**
- * @tests java.security.cert.X509CertSelector#match(java.security.cert.Certificate)
- */
- public void test_matchLjava_security_cert_Certificate() {
-
- // Regression for HARMONY-186
- TestCert cert = new TestCert();
- cert.setKeyUsage(new boolean[] { true, false, true, false, false,
- false, false, false, false });
-
- X509CertSelector certSelector = new X509CertSelector();
-
- certSelector.setKeyUsage(new boolean[] { true, false, true });
- assertTrue("Assert 1: ", certSelector.match(cert));
-
- certSelector.setKeyUsage(new boolean[] { true, true, true });
- assertFalse("Assert 2: ", certSelector.match(cert));
- }
-
- /**
- * clone() method testing.
- */
- public void testClone() throws Exception {
- BigInteger serial = new BigInteger("10000");
- X500Principal issuer = new X500Principal("O=Issuer Org.");
- X500Principal subject = new X500Principal("O=Subject Org.");
- byte[] subject_auth_KeyID = new byte[] { 1, 2, 3, 4, 5 }; // random value
- Date certValid = new Date(2000000000);
- Date[] privateKeyValid = new Date[] {
- new Date(100000000L),
- new Date(200000000L),
- new Date(300000000L)
- };
- String pkAlgID = "1.2.840.113549.1.1.1"; // RSA encryption (source: http://asn1.elibel.tm.fr)
- PublicKey pkey;
-
- pkey = new TestKeyPair("RSA").getPublic();
-
- boolean[] keyUsage = new boolean[]
- { true, true, true, true, true, true, true, true, false };
- // OID values was taken from rfc 3280
- HashSet extKeyUsage = new HashSet(Arrays.asList(new String[] {
- "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
- "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
- "1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7" }
- ));
- GeneralNames subjectAltNames = new GeneralNames(Arrays.asList(
- new GeneralName[] {
- new GeneralName(1, "rfc@822.Name"),
- new GeneralName(2, "dNSName"),
- new GeneralName(6, "http://uniform.Resource.Id"),
- new GeneralName(7, "1.1.1.1")
- }
- ));
- String[] policies = new String[] {
- "0.0.0.0.0.0",
- "1.1.1.1.1.1",
- };
-
- TestCert cert = new TestCert("certificate equality criteria");
- cert.setSerialNumber(serial);
- cert.setIssuer(issuer);
- cert.setSubject(subject);
- cert.setKeyIdentifier(subject_auth_KeyID);
- cert.setDate(certValid);
- cert.setPeriod(privateKeyValid[0], privateKeyValid[2]);
- cert.setPublicKey(pkey);
- cert.setKeyUsage(keyUsage);
- cert.setExtendedKeyUsage(extKeyUsage);
- cert.setSubjectAlternativeNames(subjectAltNames);
- cert.setPolicies(policies);
-
- X509CertSelector selector = new X509CertSelector();
- selector.setCertificate(cert);
- selector.setSerialNumber(serial);
- selector.setIssuer(issuer);
- selector.setSubject(subject);
- selector.setSubjectKeyIdentifier(subject_auth_KeyID);
- selector.setAuthorityKeyIdentifier(subject_auth_KeyID);
- selector.setCertificateValid(certValid);
- selector.setPrivateKeyValid(privateKeyValid[1]);
- selector.setSubjectPublicKey(pkey);
- selector.setSubjectPublicKeyAlgID(pkAlgID);
- selector.setKeyUsage(keyUsage);
- selector.setExtendedKeyUsage(extKeyUsage);
- selector.setSubjectAlternativeNames(subjectAltNames.getPairsList());
- selector.setMatchAllSubjectAltNames(true);
- selector.setPolicy(new HashSet(Arrays.asList(policies)));
-
- assertTrue("The certificate should match the selector",
- ((X509CertSelector) selector.clone()).match(cert));
- }
-
-
- public static Test suite() {
- return new TestSuite(X509CertSelectorTest.class);
- }
-
-}
diff --git a/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java b/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java
deleted file mode 100644
index bd0f348..0000000
--- a/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package java.security.cert;
-
-import java.io.ByteArrayInputStream;
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Principal;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.util.Date;
-import java.util.Set;
-
-import javax.security.auth.x500.X500Principal;
-
-import org.apache.harmony.luni.util.Base64;
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * X509CertificateTest
- */
-public class X509CertificateTest extends TestCase {
-
- // Base64 encoded form of ASN.1 DER encoded X.509 Certificate
- // (see RFC 3280 at http://www.ietf.org/rfc/rfc3280.txt)
- // (generated by using of classes from
- // org.apache.harmony.security.x509 package)
- static String base64cert =
- "MIIByzCCATagAwIBAgICAiswCwYJKoZIhvcNAQEFMB0xGzAZBgNVBAoT"
- + "EkNlcnRpZmljYXRlIElzc3VlcjAeFw0wNjA0MjYwNjI4MjJaFw0zMzAz"
- + "MDExNjQ0MDlaMB0xGzAZBgNVBAoTEkNlcnRpZmljYXRlIElzc3VlcjCB"
- + "nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAkLGLsPdSPDMyP1OUOKu+"
- + "U3cvbNK5RGaQ3bXc5aDjvApx43BcaoXgt6YD/5yXz0OsIooj5yA37+bY"
- + "JGcVrvFD5FMPdDd3vjNPQOep0MzG4CdbkaZde5SigPabOMQYS4oUyLBx"
- + "W3LGG0mUODe5AGGqtqXU0GlKg4K2je6cCtookCUCAwEAAaMeMBwwGgYD"
- + "VR0RAQH/BBAwDoEMcmZjQDgyMi5OYW1lMAsGCSqGSIb3DQEBBQOBgQBZ"
- + "pVXj01dOpqnZErU+Qb50j8lJD1dIaz1eJTvJCSadj7ziV1VtnnapI07c"
- + "XEa7ONzcHQTYTG10poHfOK/a0BaULF3GlctDESilwQYbW5BdfpAlZpbH"
- + "AFLcUDh6Eq50kc+0A/anh/j3mgBNuvbIMo7hHNnZB6k/prswm2BszyLD"
- + "yw==";
-
- // Base64 encoded form of ASN.1 DER encoded X.509 CRL
- // (see RFC 3280 at http://www.ietf.org/rfc/rfc3280.txt)
- // (generated by using of classes from
- // org.apache.harmony.security.x509 package)
- static String base64crl =
- "MIHXMIGXAgEBMAkGByqGSM44BAMwFTETMBEGA1UEChMKQ1JMIElzc3Vl"
- + "chcNMDYwNDI3MDYxMzQ1WhcNMDYwNDI3MDYxNTI1WjBBMD8CAgIrFw0w"
- + "NjA0MjcwNjEzNDZaMCowCgYDVR0VBAMKAQEwHAYDVR0YBBUYEzIwMDYw"
- + "NDI3MDYxMzQ1LjQ2OFqgDzANMAsGA1UdFAQEBAQEBDAJBgcqhkjOOAQD"
- + "AzAAMC0CFQCk0t0DTyu82QpajbBlxX9uXvUDSgIUSBN4g+xTEeexs/0k"
- + "9AkjBhjF0Es=";
-
- // has stub implementation for abstract methods
- private static class MyX509Certificate extends X509Certificate {
-
- public void checkValidity()
- throws CertificateExpiredException,
- CertificateNotYetValidException {
- }
-
- public void checkValidity(Date date)
- throws CertificateExpiredException,
- CertificateNotYetValidException {
- }
-
- public int getVersion() {
- return 3;
- }
-
- public BigInteger getSerialNumber() {
- return null;
- }
-
- public Principal getIssuerDN() {
- return null;
- }
-
- public Principal getSubjectDN() {
- return null;
- }
-
- public Date getNotBefore() {
- return null;
- }
-
- public Date getNotAfter() {
- return null;
- }
-
- public byte[] getTBSCertificate()
- throws CertificateEncodingException {
- return null;
- }
-
- public byte[] getSignature() {
- return null;
- }
-
- public String getSigAlgName() {
- return null;
- }
-
- public String getSigAlgOID() {
- return null;
- }
-
- public byte[] getSigAlgParams() {
- return null;
- }
-
- public boolean[] getIssuerUniqueID() {
- return null;
- }
-
- public boolean[] getSubjectUniqueID() {
- return null;
- }
-
- public boolean[] getKeyUsage() {
- return null;
- }
-
- public int getBasicConstraints() {
- return 0;
- }
-
- public void verify(PublicKey key)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- }
-
- public void verify(PublicKey key,
- String sigProvider)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- }
-
- public String toString() {
- return "";
- }
-
- public PublicKey getPublicKey() {
- return null;
- }
-
- public byte[] getEncoded() throws CertificateEncodingException {
- return null;
- }
-
- public Set getNonCriticalExtensionOIDs() {
- return null;
- }
-
- public Set getCriticalExtensionOIDs() {
- return null;
- }
-
- public byte[] getExtensionValue(String oid) {
- return null;
- }
-
- public boolean hasUnsupportedCriticalExtension() {
- return false;
- }
- }
-
- /**
- * @tests java.security.cert.X509Certificate#getType()
- */
- public void testGetType() {
- assertEquals("X.509", new MyX509Certificate().getType());
- }
-
- /**
- * @tests java.security.cert.X509Certificate#getIssuerX500Principal()
- */
- public void testGetIssuerX500Principal() {
- // return valid encoding
- MyX509Certificate cert = new MyX509Certificate() {
- public byte[] getEncoded() {
- return TestUtils.getX509Certificate_v1();
- }
-
- ;
- };
-
- assertEquals(new X500Principal("CN=Z"), cert.getIssuerX500Principal());
- }
-
- /**
- * @tests java.security.cert.X509Certificate#getSubjectX500Principal()
- */
- public void testGetSubjectX500Principal() {
- // return valid encoding
- MyX509Certificate cert = new MyX509Certificate() {
- public byte[] getEncoded() {
- return TestUtils.getX509Certificate_v1();
- }
-
- ;
- };
-
- assertEquals(new X500Principal("CN=Y"), cert.getSubjectX500Principal());
- }
-
- /**
- * @tests java.security.cert.X509Certificate#getExtendedKeyUsage()
- */
- public void testGetExtendedKeyUsage() throws CertificateParsingException {
- assertNull(new MyX509Certificate().getExtendedKeyUsage());
- }
-
- /**
- * @tests java.security.cert.X509Certificate#getSubjectAlternativeNames()
- */
- public void testGetSubjectAlternativeNames()
- throws CertificateParsingException {
-
- assertNull(new MyX509Certificate().getSubjectAlternativeNames());
- }
-
- /**
- * @tests java.security.cert.X509Certificate#getIssuerAlternativeNames()
- */
- public void testGetIssuerAlternativeNames()
- throws CertificateParsingException {
-
- assertNull(new MyX509Certificate().getIssuerAlternativeNames());
- }
-
- /**
- * @tests java.security.cert.X509Certificate#getExtensionValue()
- */
- public void testGetExtensionValue() throws Exception {
- // Regression for HARMONY-419
- ByteArrayInputStream is = null;
- CertificateFactory certFactory = CertificateFactory
- .getInstance("X.509");
- is = new ByteArrayInputStream(Base64.decode(base64cert.getBytes("UTF-8")));
- X509Certificate cert = (X509Certificate) certFactory
- .generateCertificate(is);
- cert.getExtensionValue("1.1.1.1");
-
- is = new ByteArrayInputStream(Base64.decode(base64crl.getBytes("UTF-8")));
- X509CRL crl = (X509CRL) certFactory.generateCRL(is);
- crl.getExtensionValue("1.1.1.1");
- }
-
-
- public static Test suite() {
- return new TestSuite(X509CertificateTest.class);
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/SystemScopeTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/SystemScopeTest.java
deleted file mode 100644
index d8341d6..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/SystemScopeTest.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Aleksei Y. Semenov
- */
-
-package org.apache.harmony.security.tests;
-
-import java.security.Identity;
-import java.security.IdentityScope;
-import java.security.KeyManagementException;
-import java.util.Enumeration;
-
-import org.apache.harmony.security.SystemScope;
-import org.apache.harmony.security.tests.support.IdentityScopeStub;
-import org.apache.harmony.security.tests.support.PublicKeyStub;
-
-import junit.framework.TestCase;
-
-
-/**
- * Unit test for class org.apache.harmony.security.SystemScope
- */
-
-public class SystemScopeTest extends TestCase {
-
- IdentityScope ss = null;
- final static boolean mode = true;
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- if (mode) ss = new SystemScope("SystemScope");
- else {
- ss = IdentityScope.getSystemScope();
- Enumeration e = ss.identities();
- while (e.hasMoreElements())
- ss.removeIdentity((Identity) e.nextElement());
- }
- }
-
- /**
- * Constructor for SystemScopeTest.
- *
- * @param arg0
- */
- public SystemScopeTest(String arg0) {
- super(arg0);
- }
-
- /**
- * verify SystemScope.size() returns number of Identities
- */
-
- public void testSize() throws Exception {
- //SystemScope ss = new SystemScope("SystemScope");
- assertEquals(0, ss.size());
- ss.addIdentity(new IdentityScopeStub("aaa"));
- assertEquals(1, ss.size());
- ss.addIdentity(new IdentityScopeStub("bbb"));
- assertEquals(2, ss.size());
- }
-
- /*
- * verify getIdentity(String) returns requested identity or null if not found
- */
- public void testGetIdentityString() throws Exception {
- //SystemScope ss = new SystemScope("SystemScope");
- assertNull(ss.getIdentity("aaa"));
-
- java.security.Identity aaa = new IdentityScopeStub("aaa");
- ss.addIdentity(aaa);
- assertSame(aaa, ss.getIdentity(aaa.getName()));
- assertNull(ss.getIdentity("bbb"));
-
- }
-
- /*
- * verify getIdentity(PublicKey) returns requested identity or null if not found
- */
- public void testGetIdentityPublicKey() throws Exception {
- //SystemScope ss = new SystemScope("SystemScope");
- java.security.PublicKey kkk = new PublicKeyStub("kkk", "fff", null);
- assertNull(ss.getIdentity(kkk));
- java.security.Identity aaa = new IdentityScopeStub("aaa");
- aaa.setPublicKey(kkk);
- ss.addIdentity(aaa);
-
- assertSame(aaa, ss.getIdentity(kkk));
- }
-
- /**
- * verify that only one identity with given name or public key can be added
- * i.e. KeyManagementException is thrown
- */
- public void testAddIdentity() throws Exception {
-// SystemScope ss = new SystemScope("SystemScope");
- java.security.PublicKey kkk = new PublicKeyStub("kkk", "fff", null);
- java.security.Identity aaa = new IdentityScopeStub("aaa");
- aaa.setPublicKey(kkk);
- ss.addIdentity(aaa);
-
- java.security.Identity bbb = new IdentityScopeStub("aaa");
- try {
- ss.addIdentity(bbb);
- fail("KeyManagementException should be thrown for already used name");
- } catch (KeyManagementException ok) {
- }
-
- java.security.Identity ccc = new IdentityScopeStub("ccc");
- ccc.setPublicKey(kkk);
- try {
- ss.addIdentity(ccc);
- fail("KeyManagementException should be thrown for already used key");
- } catch (KeyManagementException ok) {
- }
-
-
- }
-
- /**
- * verify that identities are removed
- *
- * @throws Exception
- */
-
- public void testRemoveIdentity() throws Exception {
-// SystemScope ss = new SystemScope("SystemScope");
- java.security.Identity aaa = new IdentityScopeStub("aaa");
- ss.addIdentity(aaa);
- assertEquals(1, ss.size());
- ss.removeIdentity(aaa);
- assertEquals(0, ss.size());
- }
-
- public void testIdentities() throws Exception {
-// SystemScope ss = new SystemScope("SystemScope");
- java.security.Identity aaa = new IdentityScopeStub("aaa");
- java.security.Identity bbb = new IdentityScopeStub("bbb");
- ss.addIdentity(aaa);
- ss.addIdentity(bbb);
-
- boolean hasAaa = false, hasBbb = false;
- Enumeration e = ss.identities();
- while (e.hasMoreElements()) {
- Object i = e.nextElement();
- if (!hasAaa) hasAaa = (i == aaa);
- if (!hasBbb) hasBbb = (i == bbb);
- }
- assertTrue(hasAaa && hasBbb);
- }
-
- /*
- * Class under test for void SystemScope()
- */
- public void testSystemScope() {
- }
-
- /*
- * Class under test for void SystemScope(String)
- */
- public void testSystemScopeString() {
- SystemScope ss = new SystemScope("SystemScope");
- assertEquals("SystemScope", ss.getName());
- }
-
- /*
- * Class under test for void SystemScope(String, IdentityScope)
- */
- public void testSystemScopeStringIdentityScope() throws Exception {
- SystemScope ss = new SystemScope("SystemScope");
- SystemScope nested = new SystemScope("NestedScope", ss);
- assertEquals("NestedScope", nested.getName());
- assertSame(ss, nested.getScope());
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/AnyTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/AnyTest.java
deleted file mode 100644
index 6c23e07..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/AnyTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Stepan M. Mishura
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.apache.harmony.security.asn1.ASN1Any;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-import junit.framework.TestCase;
-
-
-/**
- * ASN.1 DER test for ANY type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-
-public class AnyTest extends TestCase {
-
- private static byte[] encoded = new byte[] { 0x01, 0x03, 0x11, 0x13, 0x15 };
-
- public void testDecode() throws IOException {
- DerInputStream in = new DerInputStream(encoded);
- assertTrue(Arrays.equals(encoded, (byte[]) ASN1Any.getInstance()
- .decode(in)));
- }
-
- public void testEncode() throws IOException {
- DerOutputStream out = new DerOutputStream(ASN1Any.getInstance(),
- encoded);
- assertTrue("False", Arrays.equals(encoded, out.encoded));
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BerInputStreamTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BerInputStreamTest.java
deleted file mode 100644
index 6b9b34b..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BerInputStreamTest.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Stepan M. Mishura
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.asn1.ASN1Constants;
-import org.apache.harmony.security.asn1.ASN1Exception;
-import org.apache.harmony.security.asn1.BerInputStream;
-
-/**
- * Tests BerInputStream implementation
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-
-public class BerInputStreamTest extends TestCase {
-
- /**
- * @tests org.apache.harmony.security.asn1.BerInputStream#BerInputStream(
- *java.io.ByteArrayInputStream)
- */
- public void test_CtorLjava_io_ByteArrayInputStream() throws IOException {
-
- //
- // tests for decoding initial length of encodings
- //
- Object[][] testcase = {
- // length = 0x01
- { new byte[] { 0x30, (byte) 0x81, 0x01 }, BigInteger.valueOf(1) },
- // length = 0xFF
- { new byte[] { 0x30, (byte) 0x81, (byte) 0xFF },
- BigInteger.valueOf(0xFF) },
- // length = 0x0101
- { new byte[] { 0x30, (byte) 0x82, 0x01, 0x01 },
- BigInteger.valueOf(0x0101) },
- // length = 0xFFFF
- { new byte[] { 0x30, (byte) 0x82, (byte) 0xFF, (byte) 0xFF },
- BigInteger.valueOf(0xFFFF) },
- // length = 0x0FFFFF
- {
- new byte[] { 0x30, (byte) 0x83, 0x0F, (byte) 0xFF,
- (byte) 0xFF }, BigInteger.valueOf(0x0FFFFF) },
- // length = 0xFFFFFF
- {
- new byte[] { 0x30, (byte) 0x83, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF },
- BigInteger.valueOf(0xFFFFFF) },
- // length = 0xFFFFFF (encoded length has extra byte)
- {
- new byte[] { 0x30, (byte) 0x84, 0x00, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF },
- BigInteger.valueOf(0xFFFFFF) }, };
-
- // positive testcases
- for (int i = 0; i < testcase.length; i++) {
- try {
- BerInputStream in = new BerInputStream(
- new ByteArrayInputStream((byte[]) testcase[i][0]));
-
- int expected = ((BigInteger) testcase[i][1]).intValue();
-
- assertEquals(expected, in.getLength());
- } catch (IOException e) {
- e.printStackTrace();
- fail("Testcase: " + i + "\nUnexpected exception." + e);
- }
- }
-
- // negative testcase
- try {
- new BerInputStream(new ByteArrayInputStream(new byte[] { 0x30,
- (byte) 0x84, 0x01, 0x01, 0x01, 0x01 }));
- fail("No expected ASN1Exception");
- } catch (ASN1Exception e) {
- assertTrue(e.getMessage().startsWith("Too long"));
- }
-
- //
- // Test for correct internal array reallocation
- // Regression for HARMONY-5054
- //
-
- // must be greater then buffer initial size (16K)
- int arrayLength = 17000;
-
- // 1 byte for tag and 3 for length
- byte[] encoding = new byte[arrayLength + 4];
-
- // fill tag and length bytes
- encoding[0] = ASN1Constants.TAG_OCTETSTRING;
- encoding[1] = (byte) 0x82; // length is encoded in two bytes
- encoding[2] = (byte) (arrayLength >> 8);
- encoding[3] = (byte) (arrayLength & 0xFF);
-
- BerInputStream in = new BerInputStream(new ByteArrayInputStream(
- encoding));
- assertEquals(encoding.length, in.getBuffer().length);
- }
-
- /**
- * @tests org.apache.harmony.security.asn1.BerInputStream#BerInputStream(byte[],
- *int, int)
- */
- public void test_Ctor$LbyteLintLint() throws IOException {
-
- //
- // tests for 'expectedLength' parameter
- //
- byte[] encoded = new byte[] { 0x01, 0x01, 0x03, // boolean bytes
- 0x06, 0x02, 0x01, 0x03, // oid bytes
- 0x01, 0x00 // just random bytes
- };
-
- // pass boolean encoding
- BerInputStream in = new BerInputStream(encoded, 0, 3);
- assertEquals("boolean", 1, in.getLength());
-
- // pass oid encoding
- in = new BerInputStream(encoded, 3, 4);
- assertEquals("boolean", 2, in.getLength());
-
- // pass random encoding (equals to ANY)
- in = new BerInputStream(encoded, 7, 2);
- assertEquals("any", 0, in.getLength());
-
- // extra bytes for oid
- try {
- new BerInputStream(encoded, 3, 5);
- fail("No expected ASN1Exception");
- } catch (ASN1Exception e) {
- assertEquals("Wrong content length", e.getMessage());
- }
-
- // less bytes for oid
- try {
- new BerInputStream(encoded, 3, 3);
- fail("No expected ASN1Exception");
- } catch (ASN1Exception e) {
- assertEquals("Wrong content length", e.getMessage());
- }
- }
-
- /**
- * @tests org.apache.harmony.security.asn1.BerInputStream#readContent()
- */
- public void test_readContent() throws IOException {
-
- byte[] encoding = { ASN1Constants.TAG_OCTETSTRING, 0x0F, 0x01, 0x02,
- 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
- 0x0D, 0x0E, 0x0F };
-
- // a custom input stream that doesn't return all data at once
- ByteArrayInputStream in = new ByteArrayInputStream(encoding) {
- public int read(byte[] b, int off, int len) {
- if (len < 2) {
- return super.read(b, off, len);
- } else {
- return super.read(b, off, 4);
- }
-
- }
- };
-
- BerInputStream berIn = new BerInputStream(in);
- berIn.readContent();
-
- assertTrue(Arrays.equals(encoding, berIn.getEncoded()));
-
- //
- // negative test case: the stream returns only 4 bytes of content
- //
- in = new ByteArrayInputStream(encoding) {
-
- int i = 0;
-
- public int read(byte[] b, int off, int len) {
- if (i == 0) {
- i++;
- return super.read(b, off, 4);
- } else {
- return 0;
- }
-
- }
- };
- berIn = new BerInputStream(in);
- try {
- berIn.readContent();
- fail("No expected ASN1Exception");
- } catch (ASN1Exception e) {
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BitStringTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BitStringTest.java
deleted file mode 100644
index a3eeeb8..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BitStringTest.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Stepan M. Mishura
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.asn1.ASN1BitString;
-import org.apache.harmony.security.asn1.ASN1Exception;
-import org.apache.harmony.security.asn1.BitString;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-import org.apache.harmony.security.asn1.ASN1BitString.ASN1NamedBitList;
-
-/**
- * ASN.1 DER test for Bitstring type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-
-public class BitStringTest extends TestCase {
-
- private static Object[][] validBitstring = new Object[][] {
- //bitstring array format: bitstring object/ byte array
- //
- { new BitString(new byte[] { }, 0), // object
- new byte[] { 0x03, 0x01, 0x00 } },
- //
- { new BitString(new byte[] { 0x05 }, 0), // object
- new byte[] { 0x03, 0x02, 0x00, 0x05 } },
- //
- { new BitString(new byte[] { (byte) 0x80 }, 7), // object
- new byte[] { 0x03, 0x02, 0x07, (byte) 0x80 } } };
-
- public void testDecode_Encode() throws IOException {
-
- // decoder/encoder for testing
- ASN1BitString asn1 = ASN1BitString.getInstance();
-
- // decode from byte array
- for (int i = 0; i < validBitstring.length; i++) {
- DerInputStream in = new DerInputStream(
- (byte[]) validBitstring[i][1]);
-
- BitString expected = (BitString) validBitstring[i][0];
- BitString decoded = (BitString) asn1.decode(in);
-
- assertEquals("Testcase: " + i, expected.unusedBits,
- decoded.unusedBits);
-
- assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
- decoded.bytes));
- }
-
- // decode from input stream
- for (int i = 0; i < validBitstring.length; i++) {
- DerInputStream in = new DerInputStream(new ByteArrayInputStream(
- (byte[]) validBitstring[i][1]));
-
- BitString expected = (BitString) validBitstring[i][0];
- BitString decoded = (BitString) asn1.decode(in);
-
- assertEquals("Testcase: " + i, expected.unusedBits,
- decoded.unusedBits);
-
- assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
- decoded.bytes));
- }
-
- // encoding
- for (int i = 0; i < validBitstring.length; i++) {
- DerOutputStream out = new DerOutputStream(asn1,
- validBitstring[i][0]);
- assertTrue("Testcase: " + i, Arrays.equals(
- (byte[]) validBitstring[i][1], out.encoded));
- }
- }
-
- public void testDecode_Invalid() throws IOException {
- byte[][] invalid = new byte[][] {
- // wrong tag: tag is not 0x03
- new byte[] { 0x02, 0x01, 0x00 },
- // wrong length: length is 0
- new byte[] { 0x03, 0x00 },
- // wrong content: unused bits value > 7
- new byte[] { 0x03, 0x03, 0x09, 0x0F, 0x0F },
- // wrong content: not 0 unused bits for empty string
- new byte[] { 0x03, 0x01, 0x01 },
- // wrong content: unused bits in final octet are not 0
- new byte[] { 0x03, 0x02, 0x01, 0x01 },
- // wrong content: constructed encoding
- new byte[] { 0x23, 0x03, 0x03, 0x01, 0x00 } };
-
- for (int i = 0; i < invalid.length; i++) {
- try {
- DerInputStream in = new DerInputStream(invalid[i]);
- ASN1BitString.getInstance().decode(in);
- fail("No expected ASN1Exception for: " + i);
- } catch (ASN1Exception e) {
- }
- }
- }
-
- //
- //
- // Named Bit List
- //
- //
-
- public void testDecodeNamedBitList() throws IOException {
-
- Object[][] testcaseBoolean = new Object[][] {
- // bitstring array format: bitstring object/ byte array
- //
- { new boolean[] { }, // object
- new byte[] { 0x03, 0x01, 0x00 } },
- //
- { new boolean[] { true }, // object
- new byte[] { 0x03, 0x02, 0x07, (byte) 0x80 } },
- //
- { new boolean[] { true, false, true }, // object
- new byte[] { 0x03, 0x02, 0x05, (byte) 0xA0 } },
- //
- {
- new boolean[] { true, true, true, true, true, true,
- true, true }, // object
- new byte[] { 0x03, 0x02, 0x00, (byte) 0xFF } },
- //
- {
- new boolean[] { false, false, false, false, false,
- false, false, false, true }, // object
- new byte[] { 0x03, 0x03, 0x07, 0x00, (byte) 0x80 } } };
-
- ASN1NamedBitList decoder = new ASN1NamedBitList();
-
- for (int i = 0; i < testcaseBoolean.length; i++) {
- DerInputStream in = new DerInputStream(
- (byte[]) testcaseBoolean[i][1]);
-
- assertTrue("Testcase: " + i, Arrays.equals(
- (boolean[]) testcaseBoolean[i][0], (boolean[]) decoder
- .decode(in)));
- }
- }
-
- public void testDecodeNamedBitList_SizeConstraints() throws IOException {
-
- Object[][] testcaseBoolean = new Object[][] {
- //bitstring array format: bitstring object/ byte array
- //
- {
- new boolean[] { false, false, false, false, false,
- false, false, false }, // object
- new byte[] { 0x03, 0x01, 0x00 } },
- //
- {
- new boolean[] { true, false, false, false, false,
- false, false, false }, // object
- new byte[] { 0x03, 0x02, 0x07, (byte) 0x80 } },
- //
- {
- new boolean[] { true, false, true, false, false, false,
- false, false }, // object
- new byte[] { 0x03, 0x02, 0x05, (byte) 0xA0 } },
- //
- {
- new boolean[] { true, true, true, true, true, true,
- true, true }, // object
- new byte[] { 0x03, 0x02, 0x00, (byte) 0xFF } },
- //
- {
- new boolean[] { false, false, false, false, false,
- false, false, false, true }, // object
- new byte[] { 0x03, 0x03, 0x07, 0x00, (byte) 0x80 } } };
-
- ASN1NamedBitList decoder = new ASN1NamedBitList(8);
-
- for (int i = 0; i < testcaseBoolean.length; i++) {
- DerInputStream in = new DerInputStream(
- (byte[]) testcaseBoolean[i][1]);
-
- assertTrue("Testcase: " + i, Arrays.equals(
- (boolean[]) testcaseBoolean[i][0], (boolean[]) decoder
- .decode(in)));
- }
- }
-
- public void testEncodeNamedBitList() throws IOException {
-
- Object[][] testcaseBoolean = new Object[][] {
- //bitstring array format: bitstring object/ byte array
- //
- { new boolean[] { }, // object
- new byte[] { 0x03, 0x01, 0x00 } },
- //
- { new boolean[] { false }, // object
- new byte[] { 0x03, 0x01, 0x00 } },
- //
- { new boolean[] { true }, // object
- new byte[] { 0x03, 0x02, 0x07, (byte) 0x80 } },
- //
- { new boolean[] { true, false, true }, // object
- new byte[] { 0x03, 0x02, 0x05, (byte) 0xA0 } },
- //
- {
- new boolean[] { true, true, true, true, true, true,
- true, true }, // object
- new byte[] { 0x03, 0x02, 0x00, (byte) 0xFF } },
- //
- {
- new boolean[] { false, false, false, false, false,
- false, false, false, true }, // object
- new byte[] { 0x03, 0x03, 0x07, 0x00, (byte) 0x80 } } };
-
- ASN1NamedBitList encoder = new ASN1NamedBitList();
-
- for (int i = 0; i < testcaseBoolean.length; i++) {
- DerOutputStream out = new DerOutputStream(encoder,
- testcaseBoolean[i][0]);
- assertTrue("Testcase: " + i, Arrays.equals(
- (byte[]) testcaseBoolean[i][1], out.encoded));
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BooleanTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BooleanTest.java
deleted file mode 100644
index 4671351..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BooleanTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.asn1.ASN1Boolean;
-import org.apache.harmony.security.asn1.ASN1Exception;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-
-/**
- * ASN.1 DER test for Boolean type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-public class BooleanTest extends TestCase {
-
- private static byte[] eFalse = new byte[] { 0x01, 0x01, 0x00 };
-
- private static byte[] eTrue = new byte[] { 0x01, 0x01, (byte) 0xFF };
-
- public void test_Decode_Encode() throws IOException {
-
- // oid decoder/encoder for testing
- ASN1Boolean asn1 = ASN1Boolean.getInstance();
-
- // decoding false
- DerInputStream in = new DerInputStream(eFalse);
- assertEquals("Decoding false value", Boolean.FALSE, asn1.decode(in));
-
- // decoding true
- in = new DerInputStream(eTrue);
- assertEquals("Decoding true value", Boolean.TRUE, asn1.decode(in));
-
- // encoding false
- DerOutputStream out = new DerOutputStream(asn1, Boolean.FALSE);
- assertTrue("Encoding false value", Arrays.equals(eFalse, out.encoded));
-
- // encoding true
- out = new DerOutputStream(asn1, Boolean.TRUE);
- assertTrue("Encoding true value", Arrays.equals(eTrue, out.encoded));
- }
-
- public void testDecode_Invalid() throws IOException {
-
- byte[][] invalid = new byte[][] {
- // wrong tag: tag is not 0x01
- new byte[] { 0x02, 0x01, 0x00 },
- // wrong length: length is not 1
- new byte[] { 0x01, 0x02, 0x00 },
- // wrong content: content is not 0x01 or 0xFF
- new byte[] { 0x01, 0x01, 0x33 } };
-
- for (int i = 0; i < invalid.length; i++) {
- try {
- DerInputStream in = new DerInputStream(invalid[i]);
- ASN1Boolean.getInstance().decode(in);
- fail("No expected ASN1Exception for: " + i);
- } catch (ASN1Exception e) {
- }
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ChoiceTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ChoiceTest.java
deleted file mode 100644
index 272ad3a..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ChoiceTest.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Stepan M. Mishura
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.asn1.ASN1Any;
-import org.apache.harmony.security.asn1.ASN1BitString;
-import org.apache.harmony.security.asn1.ASN1Boolean;
-import org.apache.harmony.security.asn1.ASN1Choice;
-import org.apache.harmony.security.asn1.ASN1Explicit;
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.asn1.ASN1Oid;
-import org.apache.harmony.security.asn1.ASN1SequenceOf;
-import org.apache.harmony.security.asn1.ASN1Type;
-import org.apache.harmony.security.asn1.BerInputStream;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-
-/**
- * ASN.1 DER test for Choice type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-
-public class ChoiceTest extends TestCase {
-
- private static ASN1SequenceOf sequence = new ASN1SequenceOf(ASN1Boolean
- .getInstance());
-
- //
- // choice ::= CHOICE {
- // boolean BOOLEAN,
- // sequenceof SEQUENCE OF BOOLEAN,
- // int INTEGER
- // }
- //
-
- private static ASN1Choice choice = new ASN1Choice(new ASN1Type[] {
- ASN1Boolean.getInstance(), sequence, ASN1Integer.getInstance() }) {
-
- public int getIndex(Object object) {
- if (object instanceof Boolean) {
- return 0; // ASN1Boolean
- } else if (object instanceof Collection) {
- return 1; // ASN1SequenceOf
- } else {
- return 2; // ASN1Integer
- }
- }
-
- public Object getObjectToEncode(Object object) {
- return object;
- }
- };
-
- //
- // Test Cases
- //
-
- private static Object[][] testcases = {
- // format: object to encode / byte array
-
- // choice = Boolean (false)
- { Boolean.FALSE, new byte[] { 0x01, 0x01, 0x00 } },
-
- // choice = Boolean (true)
- { Boolean.TRUE, new byte[] { 0x01, 0x01, (byte) 0xFF } },
-
- // choice = SequenceOf (empty)
- { new ArrayList(), new byte[] { 0x30, 0x00 } },
-
- //TODO add testcase for another ASN.1 type`
-
- };
-
- public void testDecode_Valid() throws IOException {
-
- for (int i = 0; i < testcases.length; i++) {
- DerInputStream in = new DerInputStream((byte[]) testcases[i][1]);
- assertEquals("Test case: " + i, testcases[i][0], choice.decode(in));
- }
- }
-
- //FIXME need testcase for decoding invalid encodings
-
- public void testEncode() throws IOException {
-
- for (int i = 0; i < testcases.length; i++) {
- DerOutputStream out = new DerOutputStream(choice, testcases[i][0]);
- assertTrue("Test case: " + i, Arrays.equals(
- (byte[]) testcases[i][1], out.encoded));
- }
- }
-
- public void testChoiceInSequenceOf() throws IOException {
-
- ASN1Choice choice = new ASN1Choice(new ASN1Type[] {
- ASN1Boolean.getInstance(), ASN1Integer.getInstance() }) {
-
- public int getIndex(Object object) {
- if (object instanceof Boolean) {
- return 0; // ASN1Boolean
- } else {
- return 1; // ASN1Integer
- }
- }
-
- public Object getObjectToEncode(Object object) {
- return object;
- }
- };
-
- ASN1SequenceOf sequenceOf = new ASN1SequenceOf(choice);
-
- ArrayList list = new ArrayList();
- list.add(Boolean.FALSE);
- list.add(new byte[] { 0x09 });
-
- byte[] encoded = new byte[] {
- // Sequence Of
- 0x30, 0x06,
- // Boolean
- 0x01, 0x01, 0x00,
- // Integer
- 0x02, 0x01, 0x09 };
-
- assertTrue("Encoded: ", Arrays.equals(encoded, sequenceOf.encode(list)));
-
- List values = (List) sequenceOf.decode(encoded);
-
- assertEquals("Size: ", 2, values.size());
- assertEquals("First: ", Boolean.FALSE, values.get(0));
- assertTrue("Second: ", Arrays.equals(new byte[] { 0x09 },
- (byte[]) values.get(1)));
- }
-
- //
- //
- //
- //
- //
-
- public void test_ExplicitChoice() throws IOException {
-
- ASN1Choice choice = new ASN1Choice(new ASN1Type[] { ASN1Boolean
- .getInstance() }) {
-
- public Object getObjectToEncode(Object obj) {
- return obj;
- }
-
- public int getIndex(Object obj) {
- return 0;
- }
- };
-
- ASN1Explicit explicit = new ASN1Explicit(0, choice);
-
- byte[] encoded = new byte[] { (byte) 0xA0, 0x03, 0x01, 0x01, 0x00 };
-
- assertEquals("False: ", Boolean.FALSE, explicit.decode(encoded));
-
- encoded[4] = (byte) 0xFF;
-
- assertEquals("True: ", Boolean.TRUE, explicit.decode(encoded));
- }
-
- /**
- * TODO Put method description here
- */
- public void testChoiceOfChoice() throws Exception {
-
- ASN1Choice choice1 = new ASN1Choice(new ASN1Type[] {
- ASN1Oid.getInstance(), // first
- ASN1Boolean.getInstance(),// second: decoded component
- ASN1Integer.getInstance() // third
- }) {
-
- public Object getDecodedObject(BerInputStream in)
- throws IOException {
-
- assertEquals("choice1", 1, in.choiceIndex);
-
- return in.content;
- }
-
- public Object getObjectToEncode(Object obj) {
- return obj;
- }
-
- public int getIndex(Object obj) {
- return 0;
- }
- };
-
- ASN1Choice choice2 = new ASN1Choice(new ASN1Type[] { choice1, // first: decoded component
- ASN1BitString.getInstance() // second
- }) {
-
- public Object getDecodedObject(BerInputStream in)
- throws IOException {
-
- assertEquals("choice2", 0, in.choiceIndex);
-
- return in.content;
- }
-
- public Object getObjectToEncode(Object obj) {
- return obj;
- }
-
- public int getIndex(Object obj) {
- return 0;
- }
- };
-
- Boolean b = (Boolean) choice2.decode(new byte[] { 0x01, 0x01, 0x00 });
-
- assertTrue(b == Boolean.FALSE);
- }
-
- /**
- * TODO Put method description here
- */
- public void testDistinctTags() throws Exception {
-
- ASN1Choice choice1 = new ASN1Choice(new ASN1Type[] {
- ASN1Boolean.getInstance(),// component to be checked
- ASN1Oid.getInstance(), ASN1Integer.getInstance() }) {
-
- public Object getObjectToEncode(Object obj) {
- return obj;
- }
-
- public int getIndex(Object obj) {
- return 0;
- }
- };
-
- // two ASN.1 booleans
- try {
- new ASN1Choice(new ASN1Type[] { choice1, //
- ASN1Boolean.getInstance() // component to be checked
- }) {
-
- public Object getObjectToEncode(Object obj) {
- return obj;
- }
-
- public int getIndex(Object obj) {
- return 0;
- }
- };
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
-
- // ASN.1 ANY
- try {
- new ASN1Choice(new ASN1Type[] { choice1,//
- ASN1Any.getInstance() // component to be checked
- }) {
-
- public Object getObjectToEncode(Object obj) {
- return obj;
- }
-
- public int getIndex(Object obj) {
- return 0;
- }
- };
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
-
- // two choices
- ASN1Choice choice2 = new ASN1Choice(new ASN1Type[] {
- ASN1BitString.getInstance(), //
- ASN1Boolean.getInstance() //component to be checked
- }) {
-
- public Object getObjectToEncode(Object obj) {
- return obj;
- }
-
- public int getIndex(Object obj) {
- return 0;
- }
- };
-
- try {
- new ASN1Choice(new ASN1Type[] { choice1, choice2 }) {
-
- public Object getObjectToEncode(Object obj) {
- return obj;
- }
-
- public int getIndex(Object obj) {
- return 0;
- }
- };
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/DerGeneralizedTimeEDTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/DerGeneralizedTimeEDTest.java
deleted file mode 100644
index 1ef20de..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/DerGeneralizedTimeEDTest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.apache.harmony.security.asn1.ASN1GeneralizedTime;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-import junit.framework.TestCase;
-
-
-/**
- * ASN.1 DER test for GeneralizedTime type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-public class DerGeneralizedTimeEDTest extends TestCase {
-
- private ASN1GeneralizedTime gTime = ASN1GeneralizedTime.getInstance();
-
- /**
- * GENERALIZED TIME DER Encoder test
- *
- * @throws ParseException
- */
- public final void testGeneralizedEncoder() throws Exception {
- // full fractional seconds
- Date myDate = getGmtDate(1101980374187L);
- byte[] encoded =
- new DerOutputStream(gTime, myDate).encoded;
- String rep = new String(encoded, 2, encoded[1] & 0xff, "UTF-8");
- assertEquals("full", "20041202093934.187Z", rep);
-
- // 2 digit fractional seconds (last 0 must be trimmed out)
- myDate = getGmtDate(1101980374180L);
- encoded =
- new DerOutputStream(gTime, myDate).encoded;
- rep = new String(encoded, 2, encoded[1] & 0xff, "UTF-8");
- assertEquals("2 fraction", "20041202093934.18Z", rep);
-
- // 1 digit fractional seconds (last 2 0s must be trimmed out)
- myDate = getGmtDate(1101980374100L);
- encoded =
- new DerOutputStream(gTime, myDate).encoded;
- rep = new String(encoded, 2, encoded[1] & 0xff, "UTF-8");
- assertEquals("1 fraction", "20041202093934.1Z", rep);
-
- // no fractional seconds (last 3 0s and "." must be trimmed out)
- myDate = getGmtDate(1101980374000L);
- encoded =
- new DerOutputStream(gTime, myDate).encoded;
- rep = new String(encoded, 2, encoded[1] & 0xff, "UTF-8");
- assertEquals("no fraction", "20041202093934Z", rep);
-
- // midnight
- SimpleDateFormat sdf =
- new SimpleDateFormat("dd.MM.yyyy HH:mm");
- sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
- myDate = sdf.parse("06.06.2004 00:00");
- encoded =
- new DerOutputStream(gTime, myDate).encoded;
- rep = new String(encoded, 2, encoded[1] & 0xff, "UTF-8");
- assertEquals("midnight", "20040606000000Z", rep);
- }
-
- /**
- * GENERALIZED TIME DER Encoder/Decoder test
- * (byte array case)
- *
- * @throws ParseException
- * @throws IOException
- */
- public final void testGeneralizedEncoderDecoder01()
- throws ParseException,
- IOException {
- runTest(false);
- }
-
- /**
- * GENERALIZED TIME DER Encoder/Decoder test
- * (InputStream case)
- *
- * @throws ParseException
- * @throws IOException
- */
- public final void testGeneralizedEncoderDecoder02()
- throws ParseException,
- IOException {
- runTest(true);
- }
-
- private final void runTest(boolean useInputStream)
- throws IOException, ParseException {
- // full fractional seconds
- Date myDate = new Date(1101980374187L);
- byte[] encoded =
- new DerOutputStream(gTime, myDate).encoded;
- DerInputStream dis = useInputStream
- ? new DerInputStream(new ByteArrayInputStream(encoded))
- : new DerInputStream(encoded);
- assertEquals("full", myDate, gTime.decode(dis));
-
- // 2 digit fractional seconds (last 0 must be trimmed out)
- myDate = new Date(1101980374180L);
- encoded =
- new DerOutputStream(gTime, myDate).encoded;
- dis = useInputStream
- ? new DerInputStream(new ByteArrayInputStream(encoded))
- : new DerInputStream(encoded);
- assertEquals("2 fraction", myDate, gTime.decode(dis));
-
- // 1 digit fractional seconds (last 2 0s must be trimmed out)
- myDate = new Date(1101980374100L);
- encoded =
- new DerOutputStream(gTime, myDate).encoded;
- dis = useInputStream
- ? new DerInputStream(new ByteArrayInputStream(encoded))
- : new DerInputStream(encoded);
- assertEquals("1 fraction", myDate, gTime.decode(dis));
-
- // no fractional seconds (last 3 0s and "." must be trimmed out)
- myDate = new Date(1101980374000L);
- encoded =
- new DerOutputStream(gTime, myDate).encoded;
- dis = useInputStream
- ? new DerInputStream(new ByteArrayInputStream(encoded))
- : new DerInputStream(encoded);
- assertEquals("no fraction", myDate, gTime.decode(dis));
-
- // midnight
- myDate = new SimpleDateFormat("MM.dd.yyyy HH:mm").
- parse("06.06.2004 00:00");
- encoded =
- new DerOutputStream(gTime, myDate).encoded;
- dis = useInputStream
- ? new DerInputStream(new ByteArrayInputStream(encoded))
- : new DerInputStream(encoded);
- assertEquals("midnight", myDate, gTime.decode(dis));
-
- // date 100 ms
- myDate = new Date(100L);
- encoded =
- new DerOutputStream(gTime, myDate).encoded;
- dis = useInputStream
- ? new DerInputStream(new ByteArrayInputStream(encoded))
- : new DerInputStream(encoded);
- assertEquals("100ms", myDate, gTime.decode(dis));
- }
-
- private static Date getGmtDate(long mills) {
- return new Date(mills);
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/DerUTCTimeEDTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/DerUTCTimeEDTest.java
deleted file mode 100644
index 0e253cf..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/DerUTCTimeEDTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.apache.harmony.security.asn1.ASN1UTCTime;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-import junit.framework.TestCase;
-
-
-/**
- * ASN.1 DER test for UTCTime type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-public class DerUTCTimeEDTest extends TestCase {
-
- private ASN1UTCTime uTime = ASN1UTCTime.getInstance();
-
- private final int workersNumber = 10;
- private boolean mtTestPassed;
-
- /**
- * UTC TIME DER Encoder test
- *
- * @throws ParseException
- */
- public final void testUTCEncoder() throws Exception {
- // no fractional seconds (last 3 0s and "." must be trimmed out)
- Date myDate = getGmtDate(1101980374187L);
- byte[] encoded =
- new DerOutputStream(uTime, myDate).encoded;
- String rep = new String(encoded, 2, encoded[1] & 0xff, "UTF-8");
- assertEquals("no fraction", "041202093934Z", rep);
-
- // midnight
- SimpleDateFormat sdf =
- new SimpleDateFormat("dd.MM.yyyy HH:mm");
- sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
- myDate = sdf.parse("06.06.2004 00:00");
- encoded =
- new DerOutputStream(uTime, myDate).encoded;
- rep = new String(encoded, 2, encoded[1] & 0xff, "UTF-8");
- assertEquals("midnight", "040606000000Z", rep);
- }
-
- /**
- * UTC TIME DER Encoder/Decoder test
- * (byte array case)
- *
- * @throws ParseException
- * @throws IOException
- */
- public final void testUTCEncoderDecoder01()
- throws ParseException,
- IOException {
- runTest(false);
- }
-
- /**
- * UTC TIME DER Encoder/Decoder test
- * (InputStream case)
- *
- * @throws ParseException
- * @throws IOException
- */
- public final void testUTCEncoderDecoder02()
- throws ParseException,
- IOException {
- runTest(true);
- }
-
- private final void runTest(boolean useInputStream)
- throws IOException, ParseException {
- Date myDate = new Date(1101980374187L);
- byte[] encoded =
- new DerOutputStream(uTime, myDate).encoded;
- DerInputStream dis = useInputStream
- ? new DerInputStream(new ByteArrayInputStream(encoded))
- : new DerInputStream(encoded);
- // the difference only fractional-seconds
- assertEquals(187, (myDate.getTime() - ((Date) uTime.decode(dis)).getTime()));
-
- // midnight
- myDate = new SimpleDateFormat("MM.dd.yyyy HH:mm").
- parse("06.06.2004 00:00");
- encoded =
- new DerOutputStream(uTime, myDate).encoded;
- dis = useInputStream
- ? new DerInputStream(new ByteArrayInputStream(encoded))
- : new DerInputStream(encoded);
- assertEquals(myDate, uTime.decode(dis));
- }
-
- public final void testMt() throws InterruptedException {
- mtTestPassed = true;
- Thread[] workers = new Thread[workersNumber];
- for (int i = 0; i < workersNumber; i++) {
- workers[i] = new TestWorker();
- }
- for (int i = 0; i < workersNumber; i++) {
- workers[i].start();
- }
- for (int i = 0; i < workersNumber; i++) {
- workers[i].join();
- }
- assertTrue(mtTestPassed);
- }
-
- private static Date getGmtDate(long mills) {
- return new Date(mills);
- }
-
- /**
- * MT Test worker thread
- *
- * @author Vladimir Molotkov
- * @version 0.1
- */
- private class TestWorker extends Thread {
-
- public void run() {
- for (int i = 0; i < 100; i++) {
- try {
- // Perform DER encoding/decoding:
- if (i % 2 == 0) {
- testUTCEncoderDecoder01();
- } else {
- testUTCEncoderDecoder02();
- }
- } catch (Throwable e) {
- System.err.println(e);
- mtTestPassed = false;
- return;
- }
- }
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ExplicitTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ExplicitTest.java
deleted file mode 100644
index 7ebc553..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ExplicitTest.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Stepan M. Mishura
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.apache.harmony.security.asn1.ASN1Boolean;
-import org.apache.harmony.security.asn1.ASN1Constants;
-import org.apache.harmony.security.asn1.ASN1Explicit;
-import org.apache.harmony.security.asn1.ASN1SequenceOf;
-import org.apache.harmony.security.asn1.ASN1Type;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-import junit.framework.TestCase;
-
-
-/**
- * ASN.1 DER test for Explicitly tagged type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-
-public class ExplicitTest extends TestCase {
-
- private static ASN1SequenceOf sequence = new ASN1SequenceOf(ASN1Boolean
- .getInstance());
-
- private static Object[][] taggedType;
-
- protected void setUp() throws Exception {
- super.setUp();
-
- taggedType = new Object[][] {
- //format: object to encode / ASN.1 tagged type / byte array
-
- //
- // Boolean = false
- //
-
- // [UNIVERSAL 5] Boolean
- new Object[] {
- Boolean.FALSE,
- new byte[] { 0x25, 0x03, 0x01, 0x01, 0x00 },
- new ASN1Explicit(ASN1Constants.CLASS_UNIVERSAL, 5,
- ASN1Boolean.getInstance()) },
-
- // [APPLICATION 5] Boolean
- new Object[] {
- Boolean.FALSE,
- new byte[] { 0x65, 0x03, 0x01, 0x01, 0x00 },
- new ASN1Explicit(ASN1Constants.CLASS_APPLICATION, 5,
- ASN1Boolean.getInstance()) },
-
- // [CONTEXT-SPECIFIC 5] Boolean
- new Object[] {
- Boolean.FALSE,
- new byte[] { (byte) 0xA5, 0x03, 0x01, 0x01, 0x00 },
- new ASN1Explicit(ASN1Constants.CLASS_CONTEXTSPECIFIC,
- 5, ASN1Boolean.getInstance()) },
-
- // [5] Boolean (default = CONTEXT-SPECIFIC)
- new Object[] { Boolean.FALSE,
- new byte[] { (byte) 0xA5, 0x03, 0x01, 0x01, 0x00 },
- new ASN1Explicit(5, ASN1Boolean.getInstance()) },
-
- // [PRIVATE 5] Boolean
- new Object[] {
- Boolean.FALSE,
- new byte[] { (byte) 0xE5, 0x03, 0x01, 0x01, 0x00 },
- new ASN1Explicit(ASN1Constants.CLASS_PRIVATE, 5,
- ASN1Boolean.getInstance()) },
-
- //
- // Boolean = true
- //
-
- // [UNIVERSAL 5] Boolean
- new Object[] {
- Boolean.TRUE,
- new byte[] { 0x25, 0x03, 0x01, 0x01, (byte) 0xFF },
- new ASN1Explicit(ASN1Constants.CLASS_UNIVERSAL, 5,
- ASN1Boolean.getInstance()) },
-
- // [APPLICATION 5] Boolean
- new Object[] {
- Boolean.TRUE,
- new byte[] { 0x65, 0x03, 0x01, 0x01, (byte) 0xFF },
- new ASN1Explicit(ASN1Constants.CLASS_APPLICATION, 5,
- ASN1Boolean.getInstance()) },
-
- // [CONTEXT-SPECIFIC 5] Boolean
- new Object[] {
- Boolean.TRUE,
- new byte[] { (byte) 0xA5, 0x03, 0x01, 0x01, (byte) 0xFF },
- new ASN1Explicit(ASN1Constants.CLASS_CONTEXTSPECIFIC,
- 5, ASN1Boolean.getInstance()) },
-
- // [5] Boolean (default = CONTEXT-SPECIFIC)
- new Object[] {
- Boolean.TRUE,
- new byte[] { (byte) 0xA5, 0x03, 0x01, 0x01, (byte) 0xFF },
- new ASN1Explicit(ASN1Constants.CLASS_CONTEXTSPECIFIC,
- 5, ASN1Boolean.getInstance()) },
-
- // [PRIVATE 5] Boolean
- new Object[] {
- Boolean.TRUE,
- new byte[] { (byte) 0xE5, 0x03, 0x01, 0x01, (byte) 0xFF },
- new ASN1Explicit(ASN1Constants.CLASS_PRIVATE, 5,
- ASN1Boolean.getInstance()) },
- //
- // SequenceOf - testing constructed ASN.1 type
- //
-
- // [UNIVERSAL 5] SequenceOf
- new Object[] {
- new ArrayList(),
- new byte[] { 0x25, 0x02, 0x30, 0x00 },
- new ASN1Explicit(ASN1Constants.CLASS_UNIVERSAL, 5,
- sequence) },
-
- // [APPLICATION 5] SequenceOf
- new Object[] {
- new ArrayList(),
- new byte[] { 0x65, 0x02, 0x30, 0x00 },
- new ASN1Explicit(ASN1Constants.CLASS_APPLICATION, 5,
- sequence) },
-
- // [CONTEXT-SPECIFIC 5] SequenceOf
- new Object[] {
- new ArrayList(),
- new byte[] { (byte) 0xA5, 0x02, 0x30, 0x00 },
- new ASN1Explicit(ASN1Constants.CLASS_CONTEXTSPECIFIC,
- 5, sequence) },
-
- // [5] SequenceOf (default = CONTEXT-SPECIFIC)
- new Object[] {
- new ArrayList(),
- new byte[] { (byte) 0xA5, 0x02, 0x30, 0x00 },
- new ASN1Explicit(ASN1Constants.CLASS_CONTEXTSPECIFIC,
- 5, sequence) },
-
- // [PRIVATE 5] SequenceOf
- new Object[] {
- new ArrayList(),
- new byte[] { (byte) 0xE5, 0x02, 0x30, 0x00 },
- new ASN1Explicit(ASN1Constants.CLASS_PRIVATE, 5,
- sequence) } };
- }
-
- public void testDecode_Valid() throws IOException {
-
- for (int i = 0; i < taggedType.length; i++) {
- DerInputStream in = new DerInputStream((byte[]) taggedType[i][1]);
- assertEquals("Test case: " + i, taggedType[i][0],
- ((ASN1Type) taggedType[i][2]).decode(in));
- }
- }
-
- //FIXME need testcase for decoding invalid encodings
-
- public void testEncode() throws IOException {
-
- for (int i = 0; i < taggedType.length; i++) {
- DerOutputStream out = new DerOutputStream(
- (ASN1Type) taggedType[i][2], taggedType[i][0]);
- assertTrue("Test case: " + i, Arrays.equals(
- (byte[]) taggedType[i][1], out.encoded));
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/GeneralizedTimeTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/GeneralizedTimeTest.java
deleted file mode 100644
index 01dabf1..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/GeneralizedTimeTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.asn1.ASN1GeneralizedTime;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-/**
- * ASN.1 DER test for GeneralizedTime type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-
-public class GeneralizedTimeTest extends TestCase {
-
- // decoder/encoder for testing
- private static final ASN1GeneralizedTime gtime = ASN1GeneralizedTime
- .getInstance();
-
- // data for testing with format: date string/DER encoding/Date object
- private static final Object[][] validGeneralizedTimes;
-
- static {
- SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss", Locale.US);
- sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
-
- validGeneralizedTimes = new Object[][] {
- // YYYYMMDD-HHMMSS = "19000101000000Z"
- {
- "1 Jan 1900 00:00:00",
- new byte[] { 0x18, 0x0F, 0x31, 0x39, 0x30, 0x30, 0x30,
- 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
- 0x30, 0x5A }, null },
- // YYYYMMDD-HHMMSS = "19490203040506Z"
- {
- "3 Feb 1949 04:05:06",
- new byte[] { 0x18, 0x0F, 0x31, 0x39, 0x34, 0x39, 0x30,
- 0x32, 0x30, 0x33, 0x30, 0x34, 0x30, 0x35, 0x30,
- 0x36, 0x5A }, null },
- // YYYYMMDD-HHMMSS = "2000708091011Z"
- {
- "8 Jul 2000 09:10:11",
- new byte[] { 0x18, 0x0F, 0x32, 0x30, 0x30, 0x30, 0x30,
- 0x37, 0x30, 0x38, 0x30, 0x39, 0x31, 0x30, 0x31,
- 0x31, 0x5A }, null },
- // YYYYMMDD-HHMMSS = "20501213141516Z"
- {
- "13 Dec 2050 14:15:16",
- new byte[] { 0x18, 0x0F, 0x32, 0x30, 0x35, 0x30, 0x31,
- 0x32, 0x31, 0x33, 0x31, 0x34, 0x31, 0x35, 0x31,
- 0x36, 0x5A }, null },
- // YYYYMMDD-HHMMSS = "20501213141516Z"
- {
- "29 Mar 2332 06:56:40",
- new byte[] { 0x18, 0x0F, 0x32, 0x33, 0x33, 0x32, 0x30,
- 0x33, 0x32, 0x39, 0x30, 0x36, 0x35, 0x36, 0x34,
- 0x30, 0x5A }, null },
- };
-
- try {
- // fill values for Date objects by parsing date string
- for (int i = 0; i < validGeneralizedTimes.length; i++) {
- validGeneralizedTimes[i][2] = sdf
- .parseObject((String) validGeneralizedTimes[i][0]);
- }
- } catch (ParseException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Verifies DER decoding/encoding ASN.1 GeneralizedTime.
- * GeneralizedTime expresses Greenwich Mean Time by
- * the following pattern: YYYYMMDDHHMMSS'Z'
- */
- public void test_Decode_Encode() throws Exception {
-
- // decoding byte array
- for (int i = 0; i < validGeneralizedTimes.length; i++) {
- DerInputStream in = new DerInputStream(
- (byte[]) validGeneralizedTimes[i][1]);
- assertEquals("Decoding array for " + validGeneralizedTimes[i][0],
- validGeneralizedTimes[i][2], //expected
- gtime.decode(in)); //decoded
- }
-
- // decoding input stream
- for (int i = 0; i < validGeneralizedTimes.length; i++) {
- DerInputStream in = new DerInputStream(new ByteArrayInputStream(
- (byte[]) validGeneralizedTimes[i][1]));
- assertEquals("Decoding stream for " + validGeneralizedTimes[i][0],
- validGeneralizedTimes[i][2], //expected
- gtime.decode(in)); //decoded
- }
-
- // encoding date object
- for (int i = 0; i < validGeneralizedTimes.length; i++) {
- DerOutputStream out = new DerOutputStream(gtime,
- validGeneralizedTimes[i][2]);
- assertTrue("Encoding date for " + validGeneralizedTimes[i][0],
- Arrays.equals((byte[]) validGeneralizedTimes[i][1], // expected
- out.encoded)); //encoded
- }
- }
-
- /**
- * Tests milliseconds result of encoding/decoding on the date after 2050.
- */
- public void test_Milliseconds() throws IOException {
- // Regression test for HARMONY-1252
- long old_date = 11431151800000L;
- long new_date = ((Date) gtime.decode(gtime.encode(new Date(old_date))))
- .getTime();
- assertEquals(old_date, new_date);
- }
-
- public void test_EncodeMilliseconds() throws IOException {
- //cRegression for HARMONY-2302
- long old_date = 1164358741071L;
- long new_date = ((Date) gtime.decode(gtime.encode(new Date(old_date))))
- .getTime();
- assertEquals(old_date, new_date);
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ImplicitTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ImplicitTest.java
deleted file mode 100644
index d0c5e95..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ImplicitTest.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Stepan M. Mishura
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.asn1.ASN1Boolean;
-import org.apache.harmony.security.asn1.ASN1Constants;
-import org.apache.harmony.security.asn1.ASN1Exception;
-import org.apache.harmony.security.asn1.ASN1Implicit;
-import org.apache.harmony.security.asn1.ASN1OctetString;
-import org.apache.harmony.security.asn1.ASN1SequenceOf;
-import org.apache.harmony.security.asn1.ASN1Type;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-
-/**
- * ASN.1 DER test for Implicitly tagged type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-
-public class ImplicitTest extends TestCase {
-
- private static ASN1SequenceOf sequence = new ASN1SequenceOf(ASN1Boolean
- .getInstance());
-
- private static Object[][] taggedType = {
- // format: object to encode / ASN.1 tagged type / byte array
-
- //
- // Boolean = false
- //
-
- // [UNIVERSAL 5] Boolean
- {
- Boolean.FALSE,
- new byte[] { 0x05, 0x01, 0x00 },
- new ASN1Implicit(ASN1Constants.CLASS_UNIVERSAL, 5,
- ASN1Boolean.getInstance()) },
-
- // [APPLICATION 5] Boolean
- {
- Boolean.FALSE,
- new byte[] { 0x45, 0x01, 0x00 },
- new ASN1Implicit(ASN1Constants.CLASS_APPLICATION, 5,
- ASN1Boolean.getInstance()) },
-
- // [CONTEXT-SPECIFIC 5] Boolean
- {
- Boolean.FALSE,
- new byte[] { (byte) 0x85, 0x01, 0x00 },
- new ASN1Implicit(ASN1Constants.CLASS_CONTEXTSPECIFIC, 5,
- ASN1Boolean.getInstance()) },
-
- // [5] Boolean (default = CONTEXT-SPECIFIC)
- { Boolean.FALSE, new byte[] { (byte) 0x85, 0x01, 0x00 },
- new ASN1Implicit(5, ASN1Boolean.getInstance()) },
-
- // [PRIVATE 5] Boolean
- {
- Boolean.FALSE,
- new byte[] { (byte) 0xC5, 0x01, 0x00 },
- new ASN1Implicit(ASN1Constants.CLASS_PRIVATE, 5,
- ASN1Boolean.getInstance()) },
-
- //
- // Boolean = true
- //
-
- // [UNIVERSAL 5] Boolean
- {
- Boolean.TRUE,
- new byte[] { 0x05, 0x01, (byte) 0xFF },
- new ASN1Implicit(ASN1Constants.CLASS_UNIVERSAL, 5,
- ASN1Boolean.getInstance()) },
-
- // [APPLICATION 5] Boolean
- {
- Boolean.TRUE,
- new byte[] { 0x45, 0x01, (byte) 0xFF },
- new ASN1Implicit(ASN1Constants.CLASS_APPLICATION, 5,
- ASN1Boolean.getInstance()) },
-
- // [CONTEXT-SPECIFIC 5] Boolean
- {
- Boolean.TRUE,
- new byte[] { (byte) 0x85, 0x01, (byte) 0xFF },
- new ASN1Implicit(ASN1Constants.CLASS_CONTEXTSPECIFIC, 5,
- ASN1Boolean.getInstance()) },
-
- // [5] Boolean (default = CONTEXT-SPECIFIC)
- {
- Boolean.TRUE,
- new byte[] { (byte) 0x85, 0x01, (byte) 0xFF },
- new ASN1Implicit(ASN1Constants.CLASS_CONTEXTSPECIFIC, 5,
- ASN1Boolean.getInstance()) },
-
- // [PRIVATE 5] Boolean
- {
- Boolean.TRUE,
- new byte[] { (byte) 0xC5, 0x01, (byte) 0xFF },
- new ASN1Implicit(ASN1Constants.CLASS_PRIVATE, 5,
- ASN1Boolean.getInstance()) },
- //
- // SequenceOf - testing constructed ASN.1 type
- //
-
- // [UNIVERSAL 5] SequenceOf
- {
- new ArrayList(),
- new byte[] { 0x25, 0x00 },
- new ASN1Implicit(ASN1Constants.CLASS_UNIVERSAL, 5, sequence) },
-
- // [APPLICATION 5] SequenceOf
- {
- new ArrayList(),
- new byte[] { 0x65, 0x00 },
- new ASN1Implicit(ASN1Constants.CLASS_APPLICATION, 5,
- sequence) },
-
- // [CONTEXT-SPECIFIC 5] SequenceOf
- {
- new ArrayList(),
- new byte[] { (byte) 0xA5, 0x00 },
- new ASN1Implicit(ASN1Constants.CLASS_CONTEXTSPECIFIC, 5,
- sequence) },
-
- // [5] SequenceOf (default = CONTEXT-SPECIFIC)
- {
- new ArrayList(),
- new byte[] { (byte) 0xA5, 0x00 },
- new ASN1Implicit(ASN1Constants.CLASS_CONTEXTSPECIFIC, 5,
- sequence) },
-
- // [PRIVATE 5] SequenceOf
- { new ArrayList(), new byte[] { (byte) 0xE5, 0x00 },
- new ASN1Implicit(ASN1Constants.CLASS_PRIVATE, 5, sequence) } };
-
- public void testDecode_Valid() throws IOException {
-
- for (int i = 0; i < taggedType.length; i++) {
- DerInputStream in = new DerInputStream((byte[]) taggedType[i][1]);
- assertEquals("Test case: " + i, taggedType[i][0],
- ((ASN1Type) taggedType[i][2]).decode(in));
- }
- }
-
- // FIXME need testcase for decoding invalid encodings
-
- public void testEncode() throws IOException {
-
- for (int i = 0; i < taggedType.length; i++) {
- DerOutputStream out = new DerOutputStream(
- (ASN1Type) taggedType[i][2], taggedType[i][0]);
- assertTrue("Test case: " + i, Arrays.equals(
- (byte[]) taggedType[i][1], out.encoded));
- }
- }
-
- /**
- * Tests 2 consecutive implicit string type tagging
- * <p/>
- * TYPE1 = [1] IMPLICIT OCTET STRING
- * TYPE2 = [2] IMPLICIT TYPE1
- */
- public void testConsecutiveStringTagging() throws Exception {
- ASN1Implicit type1 = new ASN1Implicit(1, ASN1OctetString.getInstance());
-
- ASN1Implicit type2 = new ASN1Implicit(2, type1);
-
- byte[] primitiveEncoding = new byte[] {
- // tag: class(CONTEXT SPECIFIC) + number (2)
- (byte) 0x82,
- // length
- 0x03,
- // value
- 0x00, 0x01, 0x02 };
-
- byte[] constructedEncoding = new byte[] {
- // tag: class(CONTEXT SPECIFIC) + constructed +number (2)
- (byte) 0xA2,
- // length
- 0x00 };
-
- byte[] array = new byte[] { 0x00, 0x01, 0x02 };
-
- // decode primitive
- assertTrue(Arrays.equals(array, (byte[]) type2
- .decode(primitiveEncoding)));
-
- // encode primitive
- assertTrue(Arrays.equals(primitiveEncoding, type2.encode(array)));
-
- // decode constructed
- try {
- type2.decode(constructedEncoding);
- fail("No expected ASN1Exception");
- } catch (ASN1Exception e) {
- // FIXME any other check instead of comparing the message???
- assertEquals(
- "ASN.1 octetstring: constructed identifier at [0]. Not valid for DER.",
- e.getMessage());
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/IntegerTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/IntegerTest.java
deleted file mode 100644
index 4f849fe..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/IntegerTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Stepan M. Mishura
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.asn1.ASN1Exception;
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-
-/**
- * ASN.1 DER test for INTEGER type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-
-public class IntegerTest extends TestCase {
-
- public static final Object[][] validTestcase = {
- // BigInteger / two's-complement representation / encoding
- { new BigInteger("0"), null, null },
- { new BigInteger("1"), null, null },
- { new BigInteger("-1"), null, null },
- { new BigInteger("127"), null, null },
- { new BigInteger("-127"), null, null },
- { new BigInteger("128"), null, null },
- { new BigInteger("-128"), null, null },
- { new BigInteger("32767"), null, null },
- { new BigInteger("-32767"), null, null },
- { new BigInteger("32768"), null, null },
- { new BigInteger("-32768"), null, null },
- { new BigInteger("1234567890"), null, null },
- { new BigInteger("-1234567890"), null, null },
- { // 20 octets
- new BigInteger(new byte[] { 0x7F, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }), null,
- null }, };
-
- static {
- for (int i = 0; i < validTestcase.length; i++) {
- // get two's-complement representation
- byte[] array = ((BigInteger) validTestcase[i][0]).toByteArray();
-
- // create encoding
- byte[] encoded = new byte[array.length + 2];
- encoded[0] = 0x02;
- encoded[1] = (byte) (encoded.length - 2);
- System.arraycopy(array, 0, encoded, 2, encoded[1]);
-
- // assign is to testcases
- validTestcase[i][1] = array;
- validTestcase[i][2] = encoded;
- }
- }
-
- /**
- * Tests decoding/encoding integers to/from byte array
- */
- public void testDecode_Encode() throws IOException {
-
- // oid decoder/encoder for testing
- ASN1Integer asn1 = ASN1Integer.getInstance();
-
- // decode from byte array
- for (int i = 0; i < validTestcase.length; i++) {
- DerInputStream in = new DerInputStream((byte[]) validTestcase[i][2]);
- assertTrue((validTestcase[i][0]).toString(), // message
- Arrays.equals((byte[]) validTestcase[i][1], // expected
- (byte[]) asn1.decode(in))); // returned
- }
-
- // decode from input stream
- for (int i = 0; i < validTestcase.length; i++) {
- DerInputStream in = new DerInputStream(new ByteArrayInputStream(
- (byte[]) validTestcase[i][2]));
- assertTrue((validTestcase[i][0]).toString(), //message
- Arrays.equals((byte[]) validTestcase[i][1], //expected
- (byte[]) asn1.decode(in))); //returned
- }
-
- // encoding
- for (int i = 0; i < validTestcase.length; i++) {
- DerOutputStream out = new DerOutputStream(asn1, validTestcase[i][1]);
- assertTrue((validTestcase[i][0]).toString(), //message
- Arrays.equals((byte[]) validTestcase[i][2], //expected
- out.encoded));//returned
- }
- }
-
- /**
- * Tests invalid ASN.1 integer encodings
- */
- public void testDecode_Invalid() throws IOException {
- byte[][] invalid = new byte[][] {
- // wrong tag: tag is not 0x02
- new byte[] { 0x01, 0x01, 0x00 },
- // wrong length: length is 0
- new byte[] { 0x02, 0x00 },
- // wrong content: is not encoded in minimum number of octets
- new byte[] { 0x02, 0x02, 0x00, 0x00 },
- // wrong content: is not encoded in minimum number of octets
- new byte[] { 0x02, 0x02, (byte) 0xFF, (byte) 0x80 } };
-
- for (int i = 0; i < invalid.length; i++) {
- try {
- DerInputStream in = new DerInputStream(invalid[i]);
- ASN1Integer.getInstance().decode(in);
- fail("No expected ASN1Exception for:" + i);
- } catch (ASN1Exception e) {
- }
- }
- }
-
- public void testConversion() {
- int[] testcase = new int[] { 0, 1, -1, 127, -127, 128, -128, 32767,
- -32768, Integer.MAX_VALUE, Integer.MIN_VALUE };
-
- for (int i = 0; i < testcase.length; i++) {
- assertEquals("Testcase: " + i, testcase[i], ASN1Integer
- .toIntValue(ASN1Integer.fromIntValue(testcase[i])));
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/OidTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/OidTest.java
deleted file mode 100644
index fac0e24..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/OidTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Stepan M. Mishura
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.apache.harmony.security.asn1.ASN1Exception;
-import org.apache.harmony.security.asn1.ASN1Oid;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-import junit.framework.TestCase;
-
-
-/**
- * ASN.1 DER test for OID type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-
-public class OidTest extends TestCase {
-
- private static Object[][] oid = {
- //oid array format: string / int array / DER encoding
- { "0.0", // as string
- new int[] { 0, 0 }, // as int array
- new byte[] { 0x06, 0x01, 0x00 } },
- //
- { "0.0.3", // as string
- new int[] { 0, 0, 3 }, // as int array
- new byte[] { 0x06, 0x02, 0x00, 0x03 } },
- //
- { "0.1.3", // as string
- new int[] { 0, 1, 3 }, // as int array
- new byte[] { 0x06, 0x02, 0x01, 0x03 } },
- //
- { "0.5", // as string
- new int[] { 0, 5 }, // as int array
- new byte[] { 0x06, 0x01, 0x05 } },
- //
- { "0.39.3", // as string
- new int[] { 0, 39, 3 }, // as int array
- new byte[] { 0x06, 0x02, 0x27, 0x03 } },
- //
- { "1.0.3", // as string
- new int[] { 1, 0, 3 }, // as int array
- new byte[] { 0x06, 0x02, 0x28, 0x03 } },
- //
- { "1.1", // as string
- new int[] { 1, 1 }, // as int array
- new byte[] { 0x06, 0x01, 0x29 } },
- //
- { "1.2.1.2.1",// as string
- new int[] { 1, 2, 1, 2, 1 }, // as int array
- new byte[] { 0x06, 0x04, 0x2A, 0x01, 0x02, 0x01 } },
- //
- {
- "1.2.840.113554.1.2.2",// as string
- new int[] { 1, 2, 840, 113554, 1, 2, 2 }, // as int array
- new byte[] { 0x06, 0x09, 0x2A, (byte) 0x86, 0x48,
- (byte) 0x86, (byte) 0xF7, 0x12, 0x01, 0x02, 0x02 } },
- //
- { "1.39.3",// as string
- new int[] { 1, 39, 3 }, // as int array
- new byte[] { 0x06, 0x02, 0x4F, 0x03 } },
- //
- { "2.0.3",// as string
- new int[] { 2, 0, 3 }, // as int array
- new byte[] { 0x06, 0x02, 0x50, 0x03 } },
- //
- { "2.5.4.3",// as string
- new int[] { 2, 5, 4, 3 }, // as int array
- new byte[] { 0x06, 0x03, 0x55, 0x04, 0x03 } },
- //
- { "2.39.3", // as string
- new int[] { 2, 39, 3 }, // as int array
- new byte[] { 0x06, 0x02, 0x77, 0x03 } },
- //
- { "2.40.3", // as string
- new int[] { 2, 40, 3 }, // as int array
- new byte[] { 0x06, 0x02, 0x78, 0x03 } },
- //
- { "2.47", // as string
- new int[] { 2, 47 }, // as int array
- new byte[] { 0x06, 0x01, 0x7F } },
- //
- { "2.48", // as string
- new int[] { 2, 48 }, // as int array
- new byte[] { 0x06, 0x02, (byte) 0x81, 0x00 } },
- //
- { "2.48.5", // as string
- new int[] { 2, 48, 5 }, // as int array
- new byte[] { 0x06, 0x03, (byte) 0x81, 0x00, 0x05 } },
- //
- { "2.100.3", // as string
- new int[] { 2, 100, 3 }, // as int array
- new byte[] { 0x06, 0x03, (byte) 0x81, 0x34, 0x03 } } };
-
- public void test_MappingToIntArray() throws IOException {
-
- // oid decoder/encoder for testing
- ASN1Oid asn1 = ASN1Oid.getInstance();
-
- // testing decoding
- for (int i = 0; i < oid.length; i++) {
-
- int[] decoded = (int[]) asn1.decode(new DerInputStream(
- (byte[]) oid[i][2]));
-
- assertTrue("Failed to decode oid: " + oid[i][0], // error message
- Arrays.equals((int[]) oid[i][1], // expected array
- decoded));
- }
-
- // testing encoding
- for (int i = 0; i < oid.length; i++) {
-
- byte[] encoded = new DerOutputStream(ASN1Oid.getInstance(),
- oid[i][1]).encoded;
-
- assertTrue("Failed to encode oid: " + oid[i][0], // error message
- Arrays.equals((byte[]) oid[i][2], // expected encoding
- encoded));
- }
- }
-
- public void testDecode_Invalid() throws IOException {
- byte[][] invalid = new byte[][] {
- // wrong tag: tag is not 0x06
- new byte[] { 0x02, 0x01, 0x00 },
- // wrong length: length is 0
- new byte[] { 0x06, 0x00 },
- // wrong content: bit 8 of the last byte is not 0
- new byte[] { 0x06, 0x02, (byte) 0x81, (byte) 0x80 },
- // wrong content: is not encoded in fewest number of bytes
- //FIXME new byte[] { 0x06, 0x02, (byte) 0x80, (byte) 0x01 }
- };
-
- for (int i = 0; i < invalid.length; i++) {
- try {
- DerInputStream in = new DerInputStream(invalid[i]);
- ASN1Oid.getInstance().decode(in);
- fail("No expected ASN1Exception for:" + i);
- } catch (ASN1Exception e) {
- }
- }
- }
-
- public void test_MappingToString() throws IOException {
-
- // oid decoder/encoder for testing
- ASN1Oid asn1 = ASN1Oid.getInstanceForString();
-
- // testing decoding
- for (int i = 0; i < oid.length; i++) {
- assertEquals("Failed to decode oid: " + oid[i][0], // error message
- oid[i][0], // expected string
- asn1.decode(new DerInputStream((byte[]) oid[i][2])));
- }
-
- // testing encoding
- for (int i = 0; i < oid.length; i++) {
- assertTrue("Failed to encode oid: " + oid[i][0], // error message
- Arrays.equals((byte[]) oid[i][2], // expected encoding
- new DerOutputStream(asn1, oid[i][0]).encoded));
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceOfTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceOfTest.java
deleted file mode 100644
index 3a0c336..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceOfTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Stepan M. Mishura
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.apache.harmony.security.asn1.ASN1Boolean;
-import org.apache.harmony.security.asn1.ASN1Exception;
-import org.apache.harmony.security.asn1.ASN1SequenceOf;
-import org.apache.harmony.security.asn1.BerInputStream;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-import junit.framework.TestCase;
-
-
-/**
- * ASN.1 DER test for SequenceOf type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-
-public class SequenceOfTest extends TestCase {
-
- private static ASN1SequenceOf sequenceOf = new ASN1SequenceOf(ASN1Boolean
- .getInstance());
-
- //
- // Test Cases
- //
-
- private static Object[][] testcases = new Object[][] {
- // format: object to encode / byte array
-
- // sequence : empty sequence
- new Object[] { new ArrayList(), new byte[] { 0x30, 0x00 } },
-
- // sequence : false
- new Object[] { (new MyArray()).addMy(Boolean.FALSE),
- new byte[] { 0x30, 0x03, 0x01, 0x01, 0x00 } },
-
- // sequence : true
- new Object[] { (new MyArray()).addMy(Boolean.TRUE),
- new byte[] { 0x30, 0x03, 0x01, 0x01, (byte) 0xFF } },
-
- // sequence : true, false
- new Object[] {
- (new MyArray()).addMy(Boolean.TRUE).addMy(Boolean.FALSE),
- new byte[] { 0x30, 0x06, // sequence of
- 0x01, 0x01, (byte) 0xFF, // true
- 0x01, 0x01, 0x00 } //false
- },
-
- //TODO add testcase for another ASN.1 type`
-
- };
-
- public void testDecode_Valid() throws IOException {
-
- for (int i = 0; i < testcases.length; i++) {
- try {
- DerInputStream in = new DerInputStream((byte[]) testcases[i][1]);
- assertEquals("Test case: " + i, testcases[i][0], sequenceOf
- .decode(in));
- } catch (ASN1Exception e) {
- fail("Test case: " + i + "\n" + e.getMessage());
- }
- }
- }
-
- //FIXME need testcase for decoding invalid encodings
-
- public void testEncode() throws IOException {
-
- for (int i = 0; i < testcases.length; i++) {
- DerOutputStream out = new DerOutputStream(sequenceOf,
- testcases[i][0]);
- assertTrue("Test case: " + i, Arrays.equals(
- (byte[]) testcases[i][1], out.encoded));
- }
- }
-
- public void testVerify() throws IOException {
-
- ASN1SequenceOf seqVerify = new ASN1SequenceOf(ASN1Boolean.getInstance()) {
-
- public Object getDecodedObject(BerInputStream in)
- throws IOException {
- throw new IOException(
- "Method getDecodedObject MUST not be invoked");
- }
- };
-
- for (int i = 0; i < testcases.length; i++) {
- DerInputStream in = new DerInputStream((byte[]) testcases[i][1]);
- in.setVerify();
- seqVerify.decode(in);
- }
- }
-
- //
- // Support class
- //
- public static class MyArray extends ArrayList {
-
- public MyArray addMy(Object o) {
- add(o);
- return this;
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceTest.java
deleted file mode 100644
index cae8995..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceTest.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Stepan M. Mishura
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.harmony.security.asn1.ASN1Boolean;
-import org.apache.harmony.security.asn1.ASN1Exception;
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.asn1.ASN1Sequence;
-import org.apache.harmony.security.asn1.ASN1SequenceOf;
-import org.apache.harmony.security.asn1.ASN1Type;
-import org.apache.harmony.security.asn1.BerInputStream;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-import junit.framework.TestCase;
-
-
-/**
- * ASN.1 DER test for Sequence type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-
-public class SequenceTest extends TestCase {
-
- private static ASN1SequenceOf sequenceOf = new ASN1SequenceOf(ASN1Boolean
- .getInstance());
-
- private static ArrayList defaultList;
-
- private static ASN1Sequence sequence;
-
- private static Object[][] testcases;
-
- protected void setUp() throws Exception {
- super.setUp();
-
- //
- // sequence ::= SEQUENCE {
- // boolean BOOLEAN, DEFAULT true
- // list SEQUENCE OF BOOLEAN, DEFAULT list(false)
- // }
- //
-
- defaultList = new ArrayList();
- defaultList.add(Boolean.FALSE);
-
- sequence = new ASN1Sequence(new ASN1Type[] { ASN1Boolean.getInstance(),
- sequenceOf }) {
- {
- setDefault(Boolean.TRUE, 0);
- setDefault(defaultList, 1);
- }
-
- protected Object getDecodedObject(BerInputStream in)
- throws IOException {
- Object[] values = (Object[]) in.content;
- return new AppClass((Boolean) values[0], (List) values[1]);
- }
-
- protected void getValues(Object object, Object[] values) {
- AppClass obj = (AppClass) object;
-
- values[0] = obj.ok;
- values[1] = obj.list;
- }
- };
-
- //
- // Test Cases
- //
-
- testcases = new Object[][] {
- // format: object to encode / byte array
-
- // sequence : all values are default
- { new AppClass(Boolean.TRUE, defaultList),
- new byte[] { 0x30, 0x00 } },
-
- // sequence : true, default
- { new AppClass(Boolean.FALSE, defaultList),
- new byte[] { 0x30, 0x03, 0x01, 0x01, 0x00 } },
-
- // sequence = default, empty sequence
- { new AppClass(Boolean.TRUE, new ArrayList()),
- new byte[] { 0x30, 0x02, 0x30, 0x00 } },
-
- // sequence = false, empty sequence
- { new AppClass(Boolean.FALSE, new ArrayList()),
- new byte[] { 0x30, 0x05, 0x01, 0x01, 0x00, 0x30, 0x00 } },
-
- //TODO add testcase for another ASN.1 type`
-
- };
- }
-
- //
- // Application class
- //
-
- public static class AppClass {
-
- public Boolean ok;
-
- public List list;
-
- public AppClass(Boolean ok, List list) {
- this.ok = ok;
- this.list = list;
- }
-
- public boolean equals(Object o) {
- if (o instanceof AppClass) {
- AppClass obj = (AppClass) o;
- return ok.equals(obj.ok) && list.equals(obj.list);
- }
- return false;
- }
- }
-
- public void testDecode_Valid() throws IOException {
-
- for (int i = 0; i < testcases.length; i++) {
- try {
- DerInputStream in = new DerInputStream((byte[]) testcases[i][1]);
- assertEquals("Test case: " + i, testcases[i][0], sequence
- .decode(in));
- } catch (ASN1Exception e) {
- fail("Test case: " + i + "\n" + e.getMessage());
- }
- }
- }
-
- //FIXME need testcase for decoding invalid encodings
-
- public void testEncode() throws IOException {
-
- for (int i = 0; i < testcases.length; i++) {
- DerOutputStream out = new DerOutputStream(sequence, testcases[i][0]);
- assertTrue("Test case: " + i, Arrays.equals(
- (byte[]) testcases[i][1], out.encoded));
- }
- }
-
- public void testVerify() throws IOException {
-
- ASN1Sequence seqVerify = new ASN1Sequence(new ASN1Type[] {
- ASN1Boolean.getInstance(), sequenceOf }) {
- {
- setDefault(Boolean.TRUE, 0);
- setDefault(defaultList, 1);
- }
-
- protected Object getDecodedObject(BerInputStream in)
- throws IOException {
- throw new IOException(
- "Method getDecodedObject MUST not be invoked");
- }
- };
-
- for (int i = 0; i < testcases.length; i++) {
- DerInputStream in = new DerInputStream((byte[]) testcases[i][1]);
- in.setVerify();
- seqVerify.decode(in);
- }
- }
-
- /**
- * Tests encoding default fields
- */
- public void testEncodeDefault() throws IOException {
-
- //
- // Boolean as default
- //
- ASN1Sequence s = new ASN1Sequence(new ASN1Type[] { ASN1Boolean
- .getInstance() }) {
- {
- setDefault(Boolean.TRUE, 0);
- }
-
- protected void getValues(Object object, Object[] values) {
- values = (Object[]) object;
- }
- };
-
- byte[] expectedArray = new byte[] { 0x30, 0x00 };
-
- byte[] encoded = s.encode(new Object[] { Boolean.TRUE });
- assertTrue("Encoded boolean:", Arrays.equals(expectedArray, encoded));
-
- //
- // Integer as default
- //
- s = new ASN1Sequence(new ASN1Type[] { ASN1Integer.getInstance() }) {
- {
- setDefault(new byte[] { 0x01 }, 0);
- }
-
- protected void getValues(Object object, Object[] values) {
- values = (Object[]) object;
- }
- };
-
- encoded = s.encode(new Object[] { new byte[] { 0x01 } });
- assertTrue("Encoded integer:", Arrays.equals(expectedArray, encoded));
- }
-
- /**
- * Tests encoding optional fields
- */
- public void testEncodeOptional() throws IOException {
-
- //
- // Test not optional
- //
- ASN1Sequence s = new ASN1Sequence(new ASN1Type[] { ASN1Boolean
- .getInstance() }) {
-
- protected void getValues(Object object, Object[] values) {
- values[0] = ((Object[]) object)[0];
- }
- };
-
- try {
- s.encode(new Object[] { null });
- fail("No expected RuntimeException");
- } catch (RuntimeException e) {
- }
-
- //
- // Test optional
- //
- s = new ASN1Sequence(new ASN1Type[] { ASN1Boolean.getInstance() }) {
- {
- setOptional(0);
- }
-
- protected void getValues(Object object, Object[] values) {
- values[0] = ((Object[]) object)[0];
- }
- };
-
- byte[] expectedArray = new byte[] { 0x30, 0x00 };
-
- byte[] encoded = s.encode(new Object[] { null });
- assertTrue("Encoded boolean:", Arrays.equals(expectedArray, encoded));
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/UTCTimeTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/UTCTimeTest.java
deleted file mode 100644
index d2b6e2f..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/UTCTimeTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.asn1.der;
-
-import java.io.ByteArrayInputStream;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.asn1.ASN1UTCTime;
-import org.apache.harmony.security.asn1.DerInputStream;
-import org.apache.harmony.security.asn1.DerOutputStream;
-
-/**
- * ASN.1 DER test for UTCTime type
- *
- * @see http://asn1.elibel.tm.fr/en/standards/index.htm
- */
-
-public class UTCTimeTest extends TestCase {
-
- // UTC time decoder/encoder for testing
- private static final ASN1UTCTime utime = ASN1UTCTime.getInstance();
-
- // data for testing with format: date string/DER encoding/Date object
- public static final Object[][] validUTCTimes;
-
- static {
- SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss", Locale.US);
- sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
-
- validUTCTimes = new Object[][] {
- // YYMMDD-HHMMSS = "500708091011Z"
- {
- "8 Jul 1950 09:10:11",
- new byte[] { 0x17, 0x0D, 0x35, 0x30, 0x30, 0x37, 0x30,
- 0x38, 0x30, 0x39, 0x31, 0x30, 0x31, 0x31, 0x5A },
- null },
- //YYMMDD-HHMMSS = "991213141516Z"
- {
- "13 Dec 1999 14:15:16",
- new byte[] { 0x17, 0x0D, 0x39, 0x39, 0x31, 0x32, 0x31,
- 0x33, 0x31, 0x34, 0x31, 0x35, 0x31, 0x36, 0x5A },
- null },
- // YYMMDD-HHMMSS = "000101000000Z"
- {
- "01 Jan 2000 00:00:00",
- new byte[] { 0x17, 0x0D, 0x30, 0x30, 0x30, 0x31, 0x30,
- 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5A },
- null },
- // YYMMDD-HHMMSS = "490203040506Z"
- {
- "3 Feb 2049 04:05:06",
- new byte[] { 0x17, 0x0D, 0x34, 0x39, 0x30, 0x32, 0x30,
- 0x33, 0x30, 0x34, 0x30, 0x35, 0x30, 0x36, 0x5A },
- null },
- };
-
- try {
- // fill values for Date objects by parsing date string
- for (int i = 0; i < validUTCTimes.length; i++) {
- validUTCTimes[i][2] = sdf
- .parseObject((String) validUTCTimes[i][0]);
- }
- } catch (ParseException e) {
- throw new RuntimeException(e.getMessage());
- }
- }
-
- /**
- * Verifies decoding/encoding ASN.1 UTCTime.
- * It must interpret the year field (YY) as follows:
- * - if YY is greater than or equal to 50 then interpreted as 19YY
- * - and if YY is less than 50 then interpreted as 20YY.
- */
- public void testDecodeEncode() throws Exception {
-
- // decoding byte array
- for (int i = 0; i < validUTCTimes.length; i++) {
- DerInputStream in = new DerInputStream((byte[]) validUTCTimes[i][1]);
- assertEquals("Decoding array for " + validUTCTimes[i][0],
- validUTCTimes[i][2], //expected
- utime.decode(in)); //decoded
- }
-
- // decoding input stream
- for (int i = 0; i < validUTCTimes.length; i++) {
- DerInputStream in = new DerInputStream(new ByteArrayInputStream(
- (byte[]) validUTCTimes[i][1]));
- assertEquals("Decoding stream for " + validUTCTimes[i][0],
- validUTCTimes[i][2], //expected
- utime.decode(in)); //decoded
- }
-
- // encoding date object
- for (int i = 0; i < validUTCTimes.length; i++) {
- DerOutputStream out = new DerOutputStream(utime,
- validUTCTimes[i][2]);
- assertTrue("Encoding date for " + validUTCTimes[i][0], Arrays
- .equals((byte[]) validUTCTimes[i][1], // expected
- out.encoded)); //encoded
- }
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/EngineTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/EngineTest.java
deleted file mode 100644
index 5735e07..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/EngineTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.fortress;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.Provider;
-import java.security.Security;
-
-import org.apache.harmony.security.fortress.Engine;
-import org.apache.harmony.security.fortress.Services;
-import junit.framework.TestCase;
-
-
-/**
- * Tests for Engine
- */
-public class EngineTest extends TestCase {
-
- protected void tearDown() throws Exception {
- super.tearDown();
- Services.updateServiceInfo();
- }
-
- /*
- * Class under test for SpiImpl getInstance(String, Object)
- */
- public void testGetInstanceStringObject1() throws Exception {
- Provider p = new MyProvider();
- Services.initServiceInfo(p);
- Engine engine = new Engine("Service");
-
-
- engine.getInstance("AlGOrItHM", null);
-
- if (engine.provider != p) {
- fail("Incorrect provider");
- }
- if (!(engine.spi instanceof SomeClass)) {
- fail("Incorrect spi");
- }
- }
-
- /*
- * Class under test for SpiImpl getInstance(String, Object)
- */
- public void testGetInstanceStringObject2() {
- Provider p = new MyProvider();
- Services.initServiceInfo(p);
- Engine engine = new Engine("Service");
- try {
- engine.getInstance(null, null);
- fail("No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
- }
-
- /*
- * Class under test for SpiImpl getInstance(String, Provider, Object)
- */
- public void testGetInstanceStringProviderObject1() throws Exception {
- Provider p = new MyProvider();
- Services.initServiceInfo(p);
- Engine engine = new Engine("Service");
-
- engine.getInstance("AlGOrItHM", p, null);
-
- if (engine.provider != p) {
- fail("Incorrect provider");
- }
- if (!(engine.spi instanceof SomeClass)) {
- fail("Incorrect spi");
- }
- }
-
- /*
- * Class under test for SpiImpl getInstance(String, Provider, Object)
- */
- public void testGetInstanceStringProviderObject2() {
- Provider p = new MyProvider();
- Services.initServiceInfo(p);
- Engine engine = new Engine("Service");
-
- try {
- engine.getInstance(null, p, null);
- fail("No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
- }
-
- public void testGetInstanceStringProvider1() throws Exception {
- Provider p = Security.getProvider("SUN");
- if (p == null) {
- return;
- }
- Engine engine = new Engine("CertStore");
- engine.getInstance("Collection", p,
- new java.security.cert.CollectionCertStoreParameters());
- }
-
- public void testGetInstanceStringProvider2() throws Exception {
- Provider p = Security.getProvider("SUN");
- if (p == null) {
- return;
- }
-
- Engine engine = new Engine("CertStore");
- engine.getInstance("Collection",
- new java.security.cert.CollectionCertStoreParameters());
- }
-
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/MyProvider.java b/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/MyProvider.java
deleted file mode 100644
index 0d421b4..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/MyProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.fortress;
-
-import java.security.Provider;
-
-/**
- * Provider for testing
- */
-public class MyProvider extends Provider {
- MyProvider() {
- super("MyProvider", 1.0, "Provider for testing");
- put("Service.Algorithm", "org.apache.harmony.security.tests.fortress.SomeClass");
- }
-
- MyProvider(String name, double version, String info) {
- super(name, version, info);
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/ServicesTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/ServicesTest.java
deleted file mode 100644
index 39cea30..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/ServicesTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.fortress;
-
-import java.security.Provider;
-
-import org.apache.harmony.security.fortress.Services;
-import junit.framework.TestCase;
-
-
-/**
- * Tests for Services
- */
-public class ServicesTest extends TestCase {
-
- public void testInitServiceInfo() {
- Provider p = new MyProvider();
- Services.initServiceInfo(p);
- Provider ap = new AnotherProvider();
- Services.initServiceInfo(ap);
-
- Provider.Service serv = Services.getService("Service.ALGORITHM");
- if (serv == null) {
- fail("Service is null");
- }
- if (serv.getProvider() != p ||
- !"org.apache.harmony.security.tests.fortress.SomeClass".equals(serv.getClassName())) {
- fail("Incorrect Service");
- }
- Services.updateServiceInfo(); // restore from registered providers
- serv = Services.getService("Service.ALGORITHM");
- if (serv != null) {
- fail("ServiceDescription not removed");
- }
- }
-
- public void testRefresh() {
- Provider p = new MyProvider();
- Services.updateServiceInfo(); //to make needRefresh = false;
- Services.initServiceInfo(p);
- Provider.Service serv = Services.getService("Service.ALGORITHM");
- Services.refresh();
- serv = Services.getService("Service.ALGORITHM");
- if (serv == null) {
- fail("Service removed");
- }
-
- Services.setNeedRefresh();
- Services.refresh();
- serv = Services.getService("Service.ALGORITHM");
- if (serv != null) {
- fail("Service not removed");
- }
- }
-
- class AnotherProvider extends Provider {
- AnotherProvider() {
- super("MyProvider", 1.0, "Provider for testing");
- put("Service.Algorithm", "AnotherClassName");
- }
-
- AnotherProvider(String name, double version, String info) {
- super(name, version, info);
- }
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/SomeClass.java b/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/SomeClass.java
deleted file mode 100644
index 4218af8..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/SomeClass.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.fortress;
-
-public class SomeClass {
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator_ImplTest.java
deleted file mode 100644
index 1a45f42..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator_ImplTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.AlgorithmParameterGenerator;
-import java.security.InvalidParameterException;
-import java.security.Provider;
-import java.security.SecureRandom;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>AlgorithmParameterGenerator</code> class constructors and
- * methods.
- */
-public class AlgorithmParameterGenerator_ImplTest extends TestCase {
-
- private static String validAlgName = "DSA";
-
- public static final String srvAlgorithmParameterGenerator = "AlgorithmParameterGenerator";
-
-
- private static String validProviderName = null;
-
- private static Provider validProvider = null;
-
- private static boolean DSASupported = false;
-
- static {
- validProvider = SpiEngUtils.isSupport(
- validAlgName,
- srvAlgorithmParameterGenerator);
- DSASupported = (validProvider != null);
- validProviderName = (DSASupported ? validProvider.getName() : null);
- }
-
- protected AlgorithmParameterGenerator[] createAPGen() throws Exception {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return null;
- }
- AlgorithmParameterGenerator[] apg = new AlgorithmParameterGenerator[3];
- apg[0] = AlgorithmParameterGenerator.getInstance(validAlgName);
- apg[1] = AlgorithmParameterGenerator.getInstance(validAlgName,
- validProvider);
- apg[2] = AlgorithmParameterGenerator.getInstance(validAlgName,
- validProviderName);
- return apg;
- }
-
- /**
- * Test for <code>init(int size)</code> and
- * <code>init(int size, SecureRandom random<code> methods
- * Assertion: throws InvalidParameterException when size is incorrect
- */
- public void testAlgorithmParameterGenerator11() throws Exception {
- if (!DSASupported) {
- fail(validAlgName + " algorithm is not supported");
- return;
- }
- // Invalid key strengths (strength must be from 512 - 1024 and a multiple of 64)
- int[] keys = { -10000, -512, -1, 0, 10000 };
- SecureRandom random = new SecureRandom();
- AlgorithmParameterGenerator[] apgs = createAPGen();
- assertNotNull("AlgorithmParameterGenerator objects were not created",
- apgs);
-
- for (int i = 0; i < apgs.length; i++) {
-
- // Test invalid strengths
- for (int j = 0; j < keys.length; j++) {
- try {
- apgs[i].init(keys[j]);
- fail("Expected an invalid parameter exception for strength "
- + keys[j]);
- } catch (InvalidParameterException e) {
- // expected
- }
- try {
- apgs[i].init(keys[j], random);
- fail("Expected an invalid parameter exception for strength "
- + keys[j]);
- } catch (InvalidParameterException e) {
- // expected
- }
- try {
- apgs[i].init(keys[j], null);
- fail("Expected an invalid parameter exception for strength "
- + keys[j]);
- } catch (InvalidParameterException e) {
- // expected
- }
- }
-
- // Test valid strengths
- apgs[i].init(512);
- apgs[i].init(512, random);
- apgs[i].init(512 + 64);
- apgs[i].init(512 + 64 + 64, random);
- apgs[i].init(1024);
- apgs[i].init(1024, random);
- }
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/CodeSigner_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/CodeSigner_ImplTest.java
deleted file mode 100644
index bfcd583..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/CodeSigner_ImplTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.CodeSigner;
-import java.security.Timestamp;
-import java.security.cert.CertPath;
-import java.util.Date;
-
-import org.apache.harmony.security.tests.support.TestCertUtils;
-import junit.framework.TestCase;
-
-/**
- * Unit test for CodeSigner.
- */
-
-public class CodeSigner_ImplTest extends TestCase {
-
- private CertPath cpath = TestCertUtils.genCertPath(3, 0);
- private Date now = new Date();
-
- private Timestamp ts = new Timestamp(now, cpath);
-
- /**
- * Tests CodeSigner.hashCode()
- */
- public void testHashCode() {
- assertTrue(new CodeSigner(cpath, ts).hashCode() == (cpath.hashCode() ^ ts
- .hashCode()));
- assertTrue(new CodeSigner(cpath, null).hashCode() == cpath.hashCode());
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KSBuilder_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KSBuilder_ImplTest.java
deleted file mode 100644
index e509d2b..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KSBuilder_ImplTest.java
+++ /dev/null
@@ -1,549 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.security.InvalidKeyException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.security.spec.InvalidKeySpecException;
-import java.util.Enumeration;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.KeyStoreTestSupport;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.TestKeyPair;
-import org.apache.harmony.security.tests.support.tmpCallbackHandler;
-
-/**
- * Tests for <code>KeyStore.Builder</code> class
- */
-public class KSBuilder_ImplTest extends TestCase {
-
- private static char[] pass = { 's', 't', 'o', 'r', 'e', 'p', 'w', 'd' };
-
- private KeyStore.PasswordProtection protPass = new KeyStore.PasswordProtection(pass);
- private tmpCallbackHandler tmpCall = new tmpCallbackHandler();
- private KeyStore.CallbackHandlerProtection callbackHand = new KeyStore.CallbackHandlerProtection(tmpCall);
- private myProtectionParameter myProtParam = new myProtectionParameter(new byte[5]);
- public static String[] validValues = KeyStoreTestSupport.validValues;
-
- private static String defaultType = KeyStoreTestSupport.defaultType;
-
- private static boolean JKSSupported = false;
-
- private static Provider defaultProvider = null;
-
- static {
- defaultProvider = SpiEngUtils.isSupport(
- KeyStoreTestSupport.defaultType, KeyStoreTestSupport.srvKeyStore);
- JKSSupported = (defaultProvider != null);
- }
-
- // Creates empty KeyStore and loads it to file
- private File createKS() throws Exception {
- FileOutputStream fos = null;
- File ff = File.createTempFile("KSBuilder_ImplTest", "keystore");
- ff.deleteOnExit();
- try {
-
- KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
- fos = new FileOutputStream(ff);
- ks.load(null, null);
- ks.store(fos, pass);
- } finally {
- if (fos != null) {
- try {
- fos.close();
- } catch (IOException e) {
- }
- }
- }
- return ff;
- }
-
- /*
- * Test for method:
- * <code>newInstance(KeyStore keyStore, ProtectionParameter protectionParameter)</code>
- * <code>getKeyStore()</code>
- * <code>getProtectionParameter(String alias)</code>
- * Assertions:
- * throws NullPointerException if keyStore or protectionParameter is null
- * throws IllegalArgumentException if keyStore was not initialized
- * returns new object.
- *
- * getKeyStore() returns specified keystore;
- * getProtectionParameter(String alias)
- * throws NullPointerException when alias is null;
- * throws KeyStoreException when alias is not available;
- * returns ProtectionParameter which is used in newInstance(...)
- *
- */
- public void testNewInstanceKeyStoreProtectionParameter()
- throws KeyStoreException, NoSuchAlgorithmException, IOException,
- CertificateException, InvalidKeyException, InvalidKeySpecException {
- // exceptions verification
- try {
- KeyStore.Builder.newInstance(null, protPass);
- fail("NullPointerException must be thrown when KeyStore is null");
- } catch (NullPointerException e) {
- }
- if (!JKSSupported) {
- fail(defaultType + " type is not supported");
- return;
- }
- KeyStore.Builder ksB;
- KeyStore ks = KeyStore.getInstance(defaultType);
- try {
- KeyStore.Builder.newInstance(ks, null);
- fail("NullPointerException must be thrown when ProtectionParameter is null");
- } catch (NullPointerException e) {
- }
-
- KeyStore.PasswordProtection protPass1 = new KeyStore.PasswordProtection(
- pass);
- KeyStore.ProtectionParameter[] pp = { protPass, protPass1,
- callbackHand, myProtParam };
- TestKeyPair tkp = new TestKeyPair("DSA");
- Certificate certs[] = {
- new MCertificate("DSA", tkp.getPrivate()
- .getEncoded()),
- new MCertificate("DSA", tkp.getPrivate()
- .getEncoded()) };
- PrivateKey privKey = tkp.getPrivate();
-
- KeyStore.PrivateKeyEntry pKey = new KeyStore.PrivateKeyEntry(privKey,
- certs);
- for (int i = 0; i < pp.length; i++) {
- ks = KeyStore.getInstance(defaultType);
- try {
- KeyStore.Builder.newInstance(ks, pp[i]);
- fail("IllegalArgumentException must be thrown because KeyStore was not initialized");
- } catch (IllegalArgumentException e) {
- }
- ks.load(null, pass);
- ksB = KeyStore.Builder.newInstance(ks, pp[i]);
-
- assertEquals("Incorrect KeyStore", ksB.getKeyStore().size(), 0);
-
- ks.setEntry("aaa", pKey, pp[0]);
- ksB = KeyStore.Builder.newInstance(ks, pp[i]);
-
- // verification getKeyStore() and getProtectionParameter(String
- // alias)
- assertEquals("Incorrect KeyStore", ks, ksB.getKeyStore());
-
- try {
- ksB.getProtectionParameter(null);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- try {
- assertEquals(ksB.getProtectionParameter("aaa"), pp[i]);
- } catch (KeyStoreException e) {
- fail("Unexpected: " + e.toString() + " was thrown");
- }
-
- try {
- assertEquals(ksB.getProtectionParameter("Bad alias"), pp[i]);
- } catch (KeyStoreException e) {
- // KeyStoreException might be thrown because there is no entry with such alias
- }
-
- try {
- assertEquals(ksB.getProtectionParameter(""), pp[i]);
- } catch (KeyStoreException e) {
- // KeyStoreException might be thrown because there is no entry with such alias
- }
-
- KeyStore.ProtectionParameter pPar = ksB
- .getProtectionParameter("aaa");
-
- switch (i) {
- case 0:
- assertTrue(pPar instanceof KeyStore.PasswordProtection);
- break;
- case 1:
- assertTrue(pPar instanceof KeyStore.PasswordProtection);
- break;
- case 2:
- assertTrue(pPar instanceof KeyStore.CallbackHandlerProtection);
- break;
- case 3:
- assertTrue(pPar instanceof myProtectionParameter);
- break;
- default:
- fail("Incorrect protection parameter");
- }
- assertEquals(pPar, pp[i]);
- }
- }
-
- /*
- * Test for methods:
- * <code>newInstance(String type, Provider provider, File file,
- * ProtectionParameter protectionParameter)</code>
- * <code>getKeyStore()</code>
- * <code>getProtectionParameter(String alias)</code>
- * Assertions:
- * throws NullPointerException if type, file or protectionParameter is null;
- * throws IllegalArgumentException if file does not exist or is not file;
- * throws IllegalArgumentException if ProtectionParameter is not
- * PasswordProtection or CallbackHandlerProtection;
- * returns new object
- *
- * getKeyStore() returns specified keystore;
- * getProtectionParameter(String alias)
- * throws NullPointerException when alias is null;
- * throws KeyStoreException when alias is not available;
- * returns ProtectionParameter which is used in newInstance(...)
- *
- */
- public void testNewInstanceStringProviderFileProtectionParameter()
- throws Exception {
- if (!JKSSupported) {
- fail(defaultType + " type is not supported");
- return;
- }
- File fl = File.createTempFile("KSBuilder_ImplTest", "keystore");
- fl.deleteOnExit();
- KeyStore.Builder ksB;
- KeyStore.Builder ksB1;
- KeyStore ks = null;
- KeyStore ks1 = null;
-
- myProtectionParameter myPP = new myProtectionParameter(new byte[5]);
- // check exceptions
- try {
-
- KeyStore.Builder.newInstance(null, defaultProvider, fl, protPass);
- fail("NullPointerException must be thrown when type is null");
- } catch (NullPointerException e) {
- }
- try {
- KeyStore.Builder.newInstance(defaultType, defaultProvider, null,
- protPass);
- fail("NullPointerException must be thrown when file is null");
- } catch (NullPointerException e) {
- }
- try {
- KeyStore.Builder
- .newInstance(defaultType, defaultProvider, fl, null);
- fail("NullPointerException must be thrown when ProtectionParameter is null");
- } catch (NullPointerException e) {
- }
- try {
- KeyStore.Builder
- .newInstance(defaultType, defaultProvider, fl, myPP);
- fail("IllegalArgumentException must be thrown when ProtectionParameter is not correct");
- } catch (IllegalArgumentException e) {
- }
- try {
- KeyStore.Builder.newInstance(defaultType, defaultProvider,
- new File(fl.getAbsolutePath().concat("should_absent")),
- protPass);
- fail("IllegalArgumentException must be thrown when file does not exist");
- } catch (IllegalArgumentException e) {
- }
- try {
- // 'file' param points to directory
- KeyStore.Builder.newInstance(defaultType, defaultProvider,
- fl.getParentFile(), protPass);
- fail("IllegalArgumentException must be thrown when file does not exist");
- } catch (IllegalArgumentException e) {
- }
- ksB = KeyStore.Builder.newInstance(defaultType, defaultProvider, fl,
- protPass);
- try {
- ksB.getKeyStore();
- fail("KeyStoreException must be throw because file is empty");
- } catch (KeyStoreException e) {
- }
-
- fl = createKS();
- KeyStore.ProtectionParameter[] pp = { myPP, protPass, callbackHand };
- for (int i = 0; i < pp.length; i++) {
- if (i == 0) {
- try {
- KeyStore.Builder.newInstance(defaultType, null, fl, pp[i]);
- fail("IllegalArgumentException must be thrown for incorrect ProtectionParameter");
- } catch (IllegalArgumentException e) {
- }
- try {
- KeyStore.Builder.newInstance(defaultType, defaultProvider,
- fl, pp[i]);
- fail("IllegalArgumentException must be thrown for incorrect ProtectionParameter");
- } catch (IllegalArgumentException e) {
- }
- continue;
- }
- ksB = KeyStore.Builder.newInstance(defaultType, null, fl, pp[i]);
- ksB1 = KeyStore.Builder.newInstance(defaultType, defaultProvider,
- fl, pp[i]);
- try {
- ks = ksB.getKeyStore();
- if (i == 2) {
- fail("KeyStoreException must be thrown for incorrect ProtectionParameter");
- } else {
- assertEquals("Incorrect KeyStore size", ks.size(), 0);
- }
- } catch (KeyStoreException e) {
- if (i == 2) {
- continue;
- }
- fail("Unexpected KeyException was thrown");
- }
- try {
- ks1 = ksB1.getKeyStore();
- if (i == 2) {
- fail("KeyStoreException must be thrown for incorrect ProtectionParameter");
- }
- } catch (KeyStoreException e) {
- if (i == 2) {
- continue;
- }
- fail("Unexpected KeyException was thrown");
- }
- assertEquals("Incorrect KeyStore size", ks.size(), ks1.size());
- Enumeration iter = ks.aliases();
- String aName;
-
- while (iter.hasMoreElements()) {
- aName = (String) iter.nextElement();
- assertEquals("Incorrect ProtectionParameter", ksB
- .getProtectionParameter(aName), pp[i]);
- }
-
- try {
- assertEquals(ksB.getProtectionParameter("Bad alias"), pp[i]);
- } catch (KeyStoreException e) {
- // KeyStoreException might be thrown because there is no entry with such alias
- }
-
- iter = ks1.aliases();
- while (iter.hasMoreElements()) {
- aName = (String) iter.nextElement();
- assertEquals("Incorrect ProtectionParameter", ksB1
- .getProtectionParameter(aName), pp[i]);
- }
-
- try {
- assertEquals(ksB1.getProtectionParameter("Bad alias"), pp[i]);
- } catch (KeyStoreException e) {
- // KeyStoreException might be thrown because there is no entry with such alias
- }
- }
- }
-
- /*
- * Test for method:
- * <code>newInstance(String type, Provider provider,
- * ProtectionParameter protectionParameter)</code>
- * <code>getKeyStore()</code>
- * <code>getProtectionParameter(String alias)</code>
- * Assertions:
- * throws NullPointerException if type, or protectionParameter is null;
- * returns new object
- *
- * getKeyStore() returns empty keystore
- * getProtectionParameter(String alias)
- * throws NullPointerException when alias is null;
- * throws KeyStoreException when alias is not available
- *
- */
- public void testNewInstanceStringProviderProtectionParameter()
- throws KeyStoreException {
- if (!JKSSupported) {
- fail(defaultType + " type is not supported");
- return;
- }
- try {
- KeyStore.Builder.newInstance(null,
- defaultProvider, protPass);
- fail("NullPointerException must be thrown when type is null");
- } catch (NullPointerException e) {
- }
- try {
- KeyStore.Builder.newInstance(defaultType,
- defaultProvider, null);
- fail("NullPointerException must be thrown when ProtectionParameter is null");
- } catch (NullPointerException e) {
- }
- myProtectionParameter myPP = new myProtectionParameter(new byte[5]);
- KeyStore.ProtectionParameter[] pp = { protPass, myPP, callbackHand };
- KeyStore.Builder ksB, ksB1;
- KeyStore ks = null;
- for (int i = 0; i < pp.length; i++) {
- ksB = KeyStore.Builder.newInstance(defaultType, defaultProvider,
- pp[i]);
- ksB1 = KeyStore.Builder.newInstance(defaultType, null, pp[i]);
- switch (i) {
- case 0:
- try {
- ks = ksB.getKeyStore();
- assertNotNull("KeyStore is null", ks);
- try {
- assertEquals(ksB.getProtectionParameter("Bad alias"),
- pp[i]);
- } catch (KeyStoreException e) {
- // KeyStoreException might be thrown because there is no entry with such alias
- }
-
- ks = ksB1.getKeyStore();
- assertNotNull("KeyStore is null", ks);
-
- try {
- assertEquals(ksB1.getProtectionParameter("Bad alias"),
- pp[i]);
- } catch (KeyStoreException e) {
- // KeyStoreException might be thrown because there is no entry with such alias
- }
- } catch (KeyStoreException e) {
- try {
- ks = ksB.getKeyStore();
- } catch (KeyStoreException e1) {
- assertEquals("Incorrect exception", e.getMessage(), e1
- .getMessage());
- }
- }
- break;
- case 1:
- case 2:
- Exception ex1 = null;
- Exception ex2 = null;
- try {
- ks = ksB.getKeyStore();
- } catch (KeyStoreException e) {
- ex1 = e;
- }
- try {
- ks = ksB.getKeyStore();
- } catch (KeyStoreException e) {
- ex2 = e;
- }
- assertEquals("Incorrect exception", ex1.getMessage(), ex2
- .getMessage());
-
-
- try {
- ksB.getProtectionParameter("aaa");
- fail("IllegalStateException must be thrown because getKeyStore() was not invoked");
- } catch (IllegalStateException e) {
- }
-
- try {
- ks = ksB1.getKeyStore();
- } catch (KeyStoreException e) {
- ex1 = e;
- }
- try {
- ks = ksB1.getKeyStore();
- } catch (KeyStoreException e) {
- ex2 = e;
- }
- assertEquals("Incorrect exception", ex1.getMessage(), ex2
- .getMessage());
-
-
- try {
- ksB1.getProtectionParameter("aaa");
- fail("IllegalStateException must be thrown because getKeyStore() was not invoked");
- } catch (IllegalStateException e) {
- }
- break;
-
- }
- }
- }
-
- /**
- * Additional class for creation Certificate object
- */
- public class MCertificate extends Certificate {
- private final byte[] encoding;
-
- private final String type;
-
- public MCertificate(String type, byte[] encoding) {
- super(type);
- this.encoding = encoding;
- this.type = type;
- }
-
- public byte[] getEncoded() throws CertificateEncodingException {
- return encoding.clone();
- }
-
- public void verify(PublicKey key) throws CertificateException,
- NoSuchAlgorithmException, InvalidKeyException,
- NoSuchProviderException, SignatureException {
- }
-
- public void verify(PublicKey key, String sigProvider)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException, SignatureException {
- }
-
- public String toString() {
- return "[MCertificate, type: " + getType() + "]";
- }
-
- public PublicKey getPublicKey() {
- return new PublicKey() {
- public String getAlgorithm() {
- return type;
- }
-
- public byte[] getEncoded() {
- return encoding;
- }
-
- public String getFormat() {
- return "test";
- }
- };
- }
- }
-}
-
-/**
- * Additional class for creating KeyStoreBuilder
- */
-class myProtectionParameter implements KeyStore.ProtectionParameter {
- public myProtectionParameter(byte[] param) {
- if (param == null) {
- throw new NullPointerException("param is null");
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KeyStore_Impl1Test.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KeyStore_Impl1Test.java
deleted file mode 100644
index a05c599..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KeyStore_Impl1Test.java
+++ /dev/null
@@ -1,982 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.ByteArrayOutputStream;
-import java.security.Key;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.KeyStoreSpi;
-import java.security.NoSuchProviderException;
-import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.UnrecoverableEntryException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.Certificate;
-import java.util.Arrays;
-
-import org.apache.harmony.security.tests.support.KeyStoreTestSupport;
-import org.apache.harmony.security.tests.support.MyKeyStoreSpi;
-import org.apache.harmony.security.tests.support.MyLoadStoreParams;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.TestKeyPair;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyStore</code> constructor and methods
- */
-
-public class KeyStore_Impl1Test extends TestCase {
-
- public static final String srvKeyStore = KeyStoreTestSupport.srvKeyStore;
- public static String[] validValues = KeyStoreTestSupport.validValues;
-
- private static final String[] aliases = { "", "alias", "Alias", "ALIAS",
- "new alias", "another alias", "ADDITIONAL", "THE SAME ALIAS" };
-
- private static String[] invalidValues = SpiEngUtils.invalidValues;
-
- public static String defaultType = KeyStoreTestSupport.defaultType;
- public static boolean JKSSupported = KeyStoreTestSupport.JKSSupported;
- public static String defaultProviderName = KeyStoreTestSupport.defaultProviderName;
- public static Provider defaultProvider = KeyStoreTestSupport.defaultProvider;
-
- private static String NotSupportMsg = "Default KeyStore type is not supported";
-
- public KeyStore[] createKS() throws Exception {
- assertTrue(NotSupportMsg, JKSSupported);
- KeyStore[] kpg = new KeyStore[3];
-
- kpg[0] = KeyStore.getInstance(defaultType);
- kpg[1] = KeyStore.getInstance(defaultType, defaultProvider);
- kpg[2] = KeyStore.getInstance(defaultType, defaultProviderName);
- return kpg;
- }
-
- /**
- * Test for <code>getInstance(String type)</code> method
- * Assertion:
- * returns KeyStoreException object
- */
- public void testKeyStore03() throws KeyStoreException {
- assertTrue(NotSupportMsg, JKSSupported);
- KeyStore ks;
- for (int i = 0; i < validValues.length; i++) {
- ks = KeyStore.getInstance(validValues[i]);
- assertEquals("Incorrect type", ks.getType(), validValues[i]);
- }
- }
-
- /**
- * Test for <code>getInstance(String type, String provider)</code> method
- * Assertion: throws IllegalArgumentException when provider is null or empty
- */
- public void testKeyStore04() throws Exception {
- assertTrue(NotSupportMsg, JKSSupported);
- String provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyStore.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null (type: "
- .concat(validValues[i]).concat(" )"));
- } catch (IllegalArgumentException e) {
- }
- try {
- KeyStore.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty (type: "
- .concat(validValues[i]).concat(" )"));
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String type, String provider)</code> method
- * Assertion: throws NoSuchProviderException when provider is not available
- */
- public void testKeyStore05() throws KeyStoreException {
- assertTrue(NotSupportMsg, JKSSupported);
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- KeyStore.getInstance(validValues[i], invalidValues[j]);
- fail("NoSuchProviderException must be thrown (type: "
- .concat(validValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(" )"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String type, String provider)</code> method
- * Assertion:
- * throws NullPointerException when type is null
- * throws KeyStoreException when type is not available
- */
- public void testKeyStore06() throws NoSuchProviderException {
- assertTrue(NotSupportMsg, JKSSupported);
- try {
- KeyStore.getInstance(null, defaultProviderName);
- fail("KeyStoreException must be thrown when type is null");
- } catch (KeyStoreException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyStore.getInstance(invalidValues[i], defaultProviderName);
- fail("KeyStoreException must be thrown (type: ".concat(
- invalidValues[i]).concat(" provider: ").concat(
- defaultProviderName).concat(" )"));
- } catch (KeyStoreException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String type, String provider)</code> method
- * Assertion: returns KeyStore object
- */
- public void testKeyStore07() throws Exception {
- assertTrue(NotSupportMsg, JKSSupported);
- KeyStore ks;
- for (int i = 0; i < validValues.length; i++) {
- ks = KeyStore.getInstance(validValues[i], defaultProviderName);
- assertEquals("Incorrect type", ks.getType(), validValues[i]);
- assertEquals("Incorrect provider", ks.getProvider().getName(),
- defaultProviderName);
- }
- }
-
- /**
- * Test for <code>getInstance(String type, Provider provider)</code> method
- * Assertion: throws IllegalArgumentException when provider is null
- */
- public void testKeyStore08() throws KeyStoreException {
- assertTrue(NotSupportMsg, JKSSupported);
- Provider provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyStore.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null (type: "
- .concat(validValues[i]).concat(" )"));
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String type, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when type is null
- * throws KeyStoreException when type is not available
- */
- public void testKeyStore09() {
- assertTrue(NotSupportMsg, JKSSupported);
- try {
- KeyStore.getInstance(null, defaultProvider);
- fail("KeyStoreException must be thrown when type is null");
- } catch (KeyStoreException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyStore.getInstance(invalidValues[i], defaultProvider);
- fail("KeyStoreException must be thrown when type is null (type: "
- .concat(invalidValues[i]).concat(" provider: ").concat(
- defaultProvider.getName()).concat(" )"));
- } catch (KeyStoreException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String type, Provider provider)</code>
- * method
- * Assertion: returns KeyStore object
- */
- public void testKeyStore10() throws KeyStoreException {
- assertTrue(NotSupportMsg, JKSSupported);
- KeyStore ks;
- for (int i = 0; i < validValues.length; i++) {
- ks = KeyStore.getInstance(validValues[i], defaultProvider);
- assertEquals("Incorrect type", ks.getType(), validValues[i]);
- assertEquals("Incorrect provider", ks.getProvider(),
- defaultProvider);
- }
- }
-
- /**
- * Test for methods:
- * <code>getKey(String alias, char[] password)</code>
- * <code>getCertificateChain(String alias)</code>
- * <code>getCertificate(String alias)</code>
- * <code>getCreationDate(String alias)</code>
- * <code>setKeyEntry(String alias, Key key, char[] password, Certificate[] chain)</code>
- * <code>setKeyEntry(String alias, byte[] key, Certificate[] chain)</code>
- * <code>setCertificateEntry(String alias, Certificate cert)</code>
- * <code>deleteEntry(String alias)</code>
- * <code>Enumeration aliases()</code>
- * <code>containsAlias(String alias)</code>
- * <code>size()</code>
- * <code>isKeyEntry(String alias)</code>
- * <code>isCertificateEntry(String alias)</code>
- * <code>getCertificateAlias(Certificate cert)</code>
- * <code>store(OutputStream stream, char[] password)</code>
- * Assertion: throws KeyStoreException when KeyStore was not initialized
- */
- public void testKeyStore11() throws Exception {
- assertTrue(NotSupportMsg, JKSSupported);
- String msgF = "KeyStoreException must be thrown because KeyStore was not initialized";
- KeyStore[] kss = createKS();
- assertNotNull("KeyStore objects were not created", kss);
- for (int i = 0; i < kss.length; i++) {
- try {
- kss[i].getKey("", new char[1]);
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].getCertificateChain("");
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].getCertificate("");
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].getCreationDate("");
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].aliases();
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].containsAlias("");
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].size();
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].setKeyEntry("", null, new char[0], new Certificate[0]);
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].setKeyEntry("", new byte[0], new Certificate[0]);
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].setCertificateEntry("", null);
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].deleteEntry("");
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].isKeyEntry("");
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].isCertificateEntry("");
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].getCertificateAlias(null);
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- ByteArrayOutputStream ba = new ByteArrayOutputStream();
- try {
- kss[i].store(ba, new char[0]);
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].store(new MyLoadStoreParams(
- new KeyStore.PasswordProtection(new char[0])));
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- KeyStore.TrustedCertificateEntry entry = new KeyStore.TrustedCertificateEntry(
- new KeyStoreTestSupport.MCertificate("type", new byte[0]));
- try {
- kss[i].setEntry("aaa", entry, null);
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].getEntry("aaa", null);
- fail(msgF);
- } catch (KeyStoreException e) {
- }
- }
- }
-
- /**
- * Test for
- * <code>setEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter params)</code>
- * <code>containsAlias(String alias)</code>
- * <code>getEntry(String alias)</code>
- * <code>getCertificate(String alias)</code>
- * <code>isCertificateEntry(String alias)</code>
- * <code>isKeyEntry(String alias)</code>
- * methods Assertions: setEntry(..) throws NullPointerException when alias
- * or entry is null;
- * <p/>
- * containsAlias(..), getEntry(..), isCertificateEntry(..), isKeyEntry(...)
- * throw NullPointerException when alias is null;
- * <p/>
- * setEntry(..) stores Entry and getEntry(..) returns it when
- * KeyStore.TrustedCertificateEntry is used; getCertificate(...) returns
- * used trusted certificate.
- */
- public void testEntry01() throws Exception {
- assertTrue(NotSupportMsg, JKSSupported);
- KeyStoreTestSupport.MCertificate trust = new KeyStoreTestSupport.MCertificate(
- "type", new byte[0]);
- KeyStore.TrustedCertificateEntry entry = new KeyStore.TrustedCertificateEntry(
- trust);
- KeyStore[] kss = createKS();
- assertNotNull("KeyStore objects were not created", kss);
-
- for (int i = 0; i < kss.length; i++) {
- kss[i].load(null, null);
- try {
- kss[i].setEntry(null, entry, null);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- try {
- kss[i].setEntry("ZZZ", null, null);
- fail("NullPointerException should be thrown when entry is null");
- } catch (NullPointerException e) {
- }
- for (int j = 0; j < aliases.length; j++) {
- kss[i].setEntry(aliases[j], entry, null);
- }
- }
- for (int i = 0; i < kss.length; i++) {
- try {
- kss[i].containsAlias(null);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- try {
- kss[i].isCertificateEntry(null);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- try {
- kss[i].isKeyEntry(null);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- try {
- kss[i].getEntry(null, null);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- KeyStore.Entry en;
- for (int j = 0; j < aliases.length; j++) {
- assertFalse("Incorrect alias", kss[i].containsAlias("Bad"
- .concat(aliases[j])));
- assertTrue("Incorrect alias", kss[i].containsAlias(aliases[j]));
- assertTrue("Not CertificateEntry", kss[i]
- .isCertificateEntry(aliases[j]));
- assertFalse("Incorrect KeyEntry", kss[i].isKeyEntry(aliases[j]));
- en = kss[i].getEntry(aliases[j], null);
- assertTrue("Incorrect Entry",
- en instanceof KeyStore.TrustedCertificateEntry);
- assertEquals("Incorrect certificate",
- ((KeyStore.TrustedCertificateEntry) en)
- .getTrustedCertificate(), entry
- .getTrustedCertificate());
- assertEquals("Incorrect certificate", kss[i]
- .getCertificate(aliases[j]), trust);
- }
- }
- }
-
-
- /**
- * Test for
- * <code>setEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter params)</code>
- * <code>containsAlias(String alias)</code>
- * <code>getEntry(String alias)</code>
- * <code>isCertificateEntry(String alias)</code>
- * <code>isKeyEntry(String alias)</code>
- * methods
- * Assertions:
- * getEntry(...) throws KeyStoreException if password is incorrect;
- * setEntry(..) throws KeyStoreException if password is destroyed;
- * <p/>
- * setEntry(..) throws KeyStoreException when incorrect Entry is used;
- * <p/>
- * setEntry(..) stores Entry and getEntry(...) returns it when
- * KeyStore.PrivateKeyEntry is used.
- */
- public void testEntry02() throws Exception {
- assertTrue(NotSupportMsg, JKSSupported);
- TestKeyPair tkp = new TestKeyPair("DSA");
- KeyStoreTestSupport.MCertificate certs[] = {
- new KeyStoreTestSupport.MCertificate("DSA", tkp.getPrivate()
- .getEncoded()),
- new KeyStoreTestSupport.MCertificate("DSA", tkp.getPrivate()
- .getEncoded()) };
- PrivateKey privKey = tkp.getPrivate();
- KeyStore.PrivateKeyEntry pKey = new KeyStore.PrivateKeyEntry(privKey,
- certs);
- char[] pwd = { 'p', 'a', 's', 's', 'w', 'd' };
- KeyStore.PasswordProtection pPath = new KeyStore.PasswordProtection(pwd);
- KeyStore.PasswordProtection anotherPath = new KeyStore.PasswordProtection(
- new char[0]);
- KeyStoreTestSupport.ProtPar pPar = new KeyStoreTestSupport.ProtPar();
- KeyStore[] kss = createKS();
- assertNotNull("KeyStore objects were not created", kss);
- for (int i = 0; i < kss.length; i++) {
- kss[i].load(null, null);
- for (int j = 0; j < aliases.length; j++) {
- kss[i].setEntry(aliases[j], pKey, pPath);
- }
- KeyStore.Entry en;
- Certificate[] cc;
- for (int j = 0; j < aliases.length; j++) {
- assertTrue("Incorrect alias", kss[i].containsAlias(aliases[j]));
- assertTrue("Not KeyEntry", kss[i].isKeyEntry(aliases[j]));
- assertFalse("Incorrect CertificateEntry", kss[i]
- .isCertificateEntry(aliases[j]));
-
- en = kss[i].getEntry(aliases[j], pPath);
- assertTrue("Incorrect Entry",
- en instanceof KeyStore.PrivateKeyEntry);
- Key key = pKey.getPrivateKey();
- Key key1 = ((KeyStore.PrivateKeyEntry) en).getPrivateKey();
- if (!key.getAlgorithm().equals(key1.getAlgorithm()) ||
- !key.getFormat().equals(key1.getFormat())) {
- fail("Incorrect key");
- }
- byte[] enc = key.getEncoded();
- byte[] enc1 = key1.getEncoded();
- assertTrue("Diff. keys encoding", Arrays.equals(enc, enc1));
-
- cc = ((KeyStore.PrivateKeyEntry) en).getCertificateChain();
- assertEquals("Incorrect CertificateChain", cc.length,
- certs.length);
- for (int t = 0; t < cc.length; t++) {
- assertEquals("Incorrect CertificateChain", cc[t], certs[t]);
- }
-
- key = kss[i].getKey(aliases[j], pwd);
- key1 = privKey;
- if (!key.getAlgorithm().equals(key1.getAlgorithm()) ||
- !key.getFormat().equals(key1.getFormat())) {
- fail("Incorrect Entry: key");
- }
- enc = key.getEncoded();
- enc1 = key1.getEncoded();
- assertTrue("Incorrect Entry: Diff. keys encoding", Arrays.equals(enc, enc1));
-
- cc = kss[i].getCertificateChain(aliases[j]);
- assertEquals("Incorrect CertificateChain", cc.length,
- certs.length);
- for (int t = 0; t < cc.length; t++) {
- assertEquals("Incorrect CertificateChain", cc[t], certs[t]);
- }
- try {
- kss[i].getEntry(aliases[j], anotherPath);
- fail("KeyStoreException or UnrecoverableEntryException should be thrown "
- + "because password is incorrect");
- } catch (KeyStoreException e) {
- } catch (UnrecoverableEntryException e) {
- }
- }
- }
- pPath.destroy();
- for (int i = 0; i < kss.length; i++) {
- try {
- kss[i].setEntry("ZZZ", pKey, pPath);
- fail("KeyStoreException should be thrown because password is destroyed");
- } catch (KeyStoreException e) {
- }
-
- for (int j = 0; j < aliases.length; j++) {
- try {
- kss[i].getEntry(aliases[j], pPath);
- fail("KeyStoreException should be thrown because password is destroyed");
- } catch (KeyStoreException e) {
- }
-
- try {
- kss[i].getEntry(aliases[j], pPar);
- fail("UnrecoverableEntryException should be thrown");
- } catch (UnrecoverableEntryException e) {
- }
- }
- }
- }
-
- /**
- * Test for
- * <code>setEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter params)</code>
- * <code>containsAlias(String alias)</code>
- * <code>getEntry(String alias)</code>
- * <code>isCertificateEntry(String alias)</code>
- * <code>isKeyEntry(String alias)</code>
- * methods
- * Assertions:
- * setEntry(..) stores used entry and getEntry(..) returns it when
- * KeyStore.SecretKeyEntry is used;
- * <p/>
- * setEntry(..) throws KeyStoreException when incorrect Entry is used.
- * <p/>
- * FIXME: this test should be changed to verify SecretKeyEntry.
- * It is not supported.
- */
- public void testEntry03() throws Exception {
- assertTrue(NotSupportMsg, JKSSupported);
- TestKeyPair tkp = new TestKeyPair("DSA");
- KeyStoreTestSupport.SKey secKey = new KeyStoreTestSupport.SKey("DSA",
- tkp.getPrivate().getEncoded());
- KeyStore.SecretKeyEntry sKey = new KeyStore.SecretKeyEntry(
- secKey);
- char[] pwd = { 'p', 'a', 's', 's', 'w', 'd' };
- KeyStore.PasswordProtection pPath = new KeyStore.PasswordProtection(pwd);
- KeyStoreTestSupport.AnotherEntry aEntry = new KeyStoreTestSupport.AnotherEntry();
- KeyStoreTestSupport.ProtPar pPar = new KeyStoreTestSupport.ProtPar();
- KeyStore[] kss = createKS();
- assertNotNull("KeyStore objects were not created", kss);
- for (int i = 0; i < kss.length; i++) {
- kss[i].load(null, null);
- for (int j = 0; j < aliases.length; j++) {
- try {
- kss[i].setEntry(aliases[j], sKey, pPath);
- } catch (KeyStoreException e) {
- //logln("testEntry03: non-PrivateKeys not supported.");
- return;
- }
- }
-
- for (int j = 0; j < aliases.length; j++) {
- assertTrue("Incorrect alias", kss[i].containsAlias(aliases[j]));
- assertTrue("Not KeyEntry", kss[i].isKeyEntry(aliases[j]));
- assertFalse("Incorrect CertificateEntry", kss[i].isCertificateEntry(aliases[j]));
- Key key1;
- try {
- key1 = kss[i].getKey(aliases[j], pwd);
- } catch (UnrecoverableKeyException e) {
- //logln("testEntry03: non-PrivateKeys not supported.");
- return;
- }
- if (!secKey.getAlgorithm().equals(key1.getAlgorithm()) ||
- !secKey.getFormat().equals(key1.getFormat())) {
- fail("Incorrect key");
- }
- byte[] enc = secKey.getEncoded();
- byte[] enc1 = key1.getEncoded();
- assertTrue("Diff. keys encoding", Arrays.equals(enc, enc1));
- assertNull("Incorrect CertificateChain", kss[i].getCertificateChain(aliases[j]));
- }
- }
- pPath.destroy();
- for (int i = 0; i < kss.length; i++) {
- try {
- kss[i].setEntry("ZZZ", aEntry, pPath);
- fail("KeyStoreException should be thrown because password is destroyed");
- } catch (KeyStoreException e) {
- }
- for (int j = 0; j < aliases.length; j++) {
- try {
- kss[i].getEntry(aliases[j], pPath);
- fail("KeyStoreException should be thrown because password is destroyed");
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].getEntry(aliases[j], pPar);
- fail("UnrecoverableEntryException should be thrown");
- } catch (UnrecoverableEntryException e) {
- }
- }
- }
- }
-
-
- /**
- * Test for
- * <code>setCertificateEntry(String alias, Certificate cert)</code>
- * <code>containsAlias(String alias)</code>
- * <code>getCertificate(String alias)</code>
- * <code>isCertificateEntry(String alias)</code>
- * methods
- * Assertions:
- * setCertificateEntry(..), containsAlias(..), getCertificate(..) and isCertificateEntry(..)
- * throw NullPointerException when alias is null
- * <p/>
- * setCertificateEntry(..) stores used entry and getCertificate(..) returns it
- */
- public void testEntry04() throws Exception {
- assertTrue(NotSupportMsg, JKSSupported);
- KeyStoreTestSupport.MCertificate cert = new KeyStoreTestSupport.MCertificate(
- "type", new byte[0]);
- KeyStore[] kss = createKS();
- assertNotNull("KeyStore objects were not created", kss);
-
- for (int i = 0; i < kss.length; i++) {
- kss[i].load(null, null);
- try {
- kss[i].setCertificateEntry(null, cert);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- for (int j = 0; j < aliases.length; j++) {
- kss[i].setCertificateEntry(aliases[j], cert);
- }
- }
- for (int i = 0; i < kss.length; i++) {
- try {
- kss[i].containsAlias(null);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- try {
- kss[i].isCertificateEntry(null);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- try {
- kss[i].getCertificate(null);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- for (int j = 0; j < aliases.length; j++) {
- assertFalse("Incorrect alias", kss[i].containsAlias("Bad".concat(aliases[j])));
- assertTrue("Incorrect alias", kss[i].containsAlias(aliases[j]));
- assertTrue("Not CertificateEntry", kss[i].isCertificateEntry(aliases[j]));
- assertFalse("Incorrect KeyEntry", kss[i].isKeyEntry(aliases[j]));
- assertEquals("Incorrect Certificate", kss[i].getCertificate(aliases[j]),
- cert);
- }
- }
- }
-
- /**
- * Test for
- * <code>setKeyEntry(String alias, Key key, char[] password, Certificate[] chain)</code>
- * <code>containsAlias(String alias)</code>
- * <code>getKey(String alias, char[] password)</code>
- * <code>isCertificateEntry(String alias)</code>
- * <code>isKeyEntry(String alias)</code>
- * <code>setCerificateEntry(String alias, Certificate cert)</code>
- * <code>getCertificateChain(String alias)</code>
- * <code>getCertificateAlias(Certificate cert)</code>
- * methods
- * <p/>
- * Assertions:
- * setKeyEntry(..), getKeyEntry(..) and isKeyEntry(..)
- * throw NullPointerException when alias is null
- * <p/>
- * setKeyEntry(...) throws KeyStoreException when key or password
- * is null
- * <p/>
- * setCertificateEntry(..) throws KeyStoreException when KeyEntry was overwritten
- * <p/>
- * setKeyEntry(..) stores used entry, getKey(..) returns it and getCertificateChain(...)
- * returns cert
- */
- public void testEntry05() throws Exception {
- assertTrue(NotSupportMsg, JKSSupported);
- KeyStoreTestSupport.MCertificate certs[] = {
- new KeyStoreTestSupport.MCertificate("type1", new byte[10]),
- new KeyStoreTestSupport.MCertificate("type2", new byte[10]) };
- KeyStoreTestSupport.MCertificate cert = new KeyStoreTestSupport.MCertificate(
- "type", new byte[0]);
- char[] pwd = new char[0];
- TestKeyPair tkp = new TestKeyPair("DSA");
- PrivateKey key = tkp.getPrivate();
- KeyStore[] kss = createKS();
- assertNotNull("KeyStore objects were not created", kss);
- for (int i = 0; i < kss.length; i++) {
- kss[i].load(null, null);
-
- // Null as alias does not necessarily lead to NullPointerException
-
- try {
- kss[i].setKeyEntry("ZZZ", null, pwd, certs);
- fail("KeyStoreException should be thrown when key is null");
- } catch (KeyStoreException e) {
- }
- try {
- kss[i].setKeyEntry("ZZZ", key, pwd, null);
- fail("KeyStoreException or IllegalArgumentException should be thrown "
- + "when chain is null and key is private");
- } catch (IllegalArgumentException e) {
- }
- try {
- kss[i].setKeyEntry("ZZZ", key, pwd,
- new KeyStoreTestSupport.MCertificate[0]);
- fail("KeyStoreException or IllegalArgumentException should be thrown "
- + "when chain is empty and key is private");
- } catch (IllegalArgumentException e) {
- }
-
- for (int j = 0; j < aliases.length; j++) {
- kss[i].setKeyEntry(aliases[j], key, pwd, certs);
- }
-
- kss[i].setKeyEntry("KeyAlias", key, pwd, certs);
- try {
- kss[i].setCertificateEntry("KeyAlias", cert);
- fail("KeyStoreException should be thrown when we try to overwrite KeyEntry to Certificate");
- } catch (KeyStoreException e) {
- }
-
- try {
- kss[i].isKeyEntry(null);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- try {
- kss[i].getKey(null, pwd);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- try {
- kss[i].getCertificateChain(null);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- for (int j = 0; j < aliases.length; j++) {
- assertFalse("Incorrect alias", kss[i].containsAlias("Bad".concat(aliases[j])));
- assertTrue("Incorrect alias", kss[i].containsAlias(aliases[j]));
- assertTrue("Not KeyEntry", kss[i].isKeyEntry(aliases[j]));
- assertFalse("Incorrect CertificateEntry", kss[i].isCertificateEntry(aliases[j]));
- Key key1 = kss[i].getKey(aliases[j], pwd);
- if (!key.getAlgorithm().equals(key1.getAlgorithm()) ||
- !key.getFormat().equals(key1.getFormat())) {
- fail("Incorrect key");
- }
- byte[] enc = key.getEncoded();
- byte[] enc1 = key1.getEncoded();
- assertTrue("Diff. keys encoding", Arrays.equals(enc, enc1));
- Certificate[] cc = kss[i].getCertificateChain(aliases[j]);
- assertEquals("Incorrect chain", cc.length, certs.length);
- for (int t = 0; t < cc.length; t++) {
- assertEquals("Incorrect certificate", cc[t], certs[t]);
- }
- }
- assertNull(kss[i].getCertificateAlias(cert));
- String ss = kss[i].getCertificateAlias(certs[0]);
- boolean ans = false;
- for (int j = 1; j < aliases.length; j++) {
- if (ss.equals(aliases[j])) {
- ans = true;
- break;
- }
- }
- assertTrue("There is no alias for certificate <type1, new byte[10]>", ans);
- }
- }
-
- /**
- * Test for
- * <code>deleteEntry(String alias)</code>
- * <code>size()</code>
- * methods
- * Assertions:
- * throws NullPointerException when alias is null;
- * <p/>
- * deletes entry from KeyStore.
- */
- public void testEntry06() throws Exception {
- assertTrue(NotSupportMsg, JKSSupported);
- KeyStore.TrustedCertificateEntry tCert = new KeyStore.TrustedCertificateEntry(
- new KeyStoreTestSupport.MCertificate("type", new byte[0]));
-
- TestKeyPair tkp = new TestKeyPair("DSA");
- KeyStoreTestSupport.MCertificate certs[] = {
- new KeyStoreTestSupport.MCertificate("DSA", tkp.getPrivate()
- .getEncoded()),
- new KeyStoreTestSupport.MCertificate("DSA", tkp.getPrivate()
- .getEncoded()) };
- KeyStore.PrivateKeyEntry pKey = new KeyStore.PrivateKeyEntry(tkp
- .getPrivate(), certs);
- char[] pwd = { 'p', 'a', 's', 's', 'w', 'd' };
- KeyStore.PasswordProtection pp = new KeyStore.PasswordProtection(pwd);
-
- String[] aliases = { "Alias1", "Alias2", "Alias3", "Alias4", "Alias5" };
-
- KeyStore[] kss = createKS();
- assertNotNull("KeyStore objects were not created", kss);
-
- for (int i = 0; i < kss.length; i++) {
- kss[i].load(null, null);
- kss[i].setEntry(aliases[0], tCert, null);
- kss[i].setEntry(aliases[1], pKey, pp);
- kss[i].setEntry(aliases[2], pKey, pp);
-
- kss[i].setKeyEntry(aliases[3], tkp.getPrivate(), pwd, certs);
-
- kss[i].setCertificateEntry(aliases[4], certs[0]);
-
- assertEquals("Incorrect size", kss[i].size(), 5);
- try {
- kss[i].deleteEntry(null);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
- kss[i].deleteEntry(aliases[0]);
- kss[i].deleteEntry(aliases[3]);
- assertEquals("Incorrect size", kss[i].size(), 3);
- for (int j = 1; j < 5; j++) {
- if ((j == 0) || (j == 3)) {
- assertFalse("Incorrect deleted alias", kss[i]
- .containsAlias(aliases[j]));
- } else {
- assertTrue("Incorrect alias", kss[i]
- .containsAlias(aliases[j]));
- }
- }
- }
- }
-
- /**
- * Test for
- * <code>entryInstanceOf(String alias, Class class)</code>
- * method
- * Assertions:
- * throws NullPointerException when alias is null
- * returns false if KeyStore does not contain entry with defined alias
- * returns false if defined alias is not correspond Entry
- * returns false
- * setEntry(..) throws KeyStoreException when incorrect Entry is used;
- * <p/>
- * setEntry(..) stores Entry and getEntry(...) returns it when
- * KeyStore.PrivateKeyEntry is used.
- */
- public void testEntry07() throws Exception {
- assertTrue(NotSupportMsg, JKSSupported);
- TestKeyPair tkp = new TestKeyPair("DSA");
- KeyStoreTestSupport.MCertificate certs[] = {
- new KeyStoreTestSupport.MCertificate("DSA", tkp.getPrivate()
- .getEncoded()),
- new KeyStoreTestSupport.MCertificate("DSA", tkp.getPrivate()
- .getEncoded()) };
- PrivateKey privKey = tkp.getPrivate();
- KeyStore.PrivateKeyEntry pKey = new KeyStore.PrivateKeyEntry(privKey, certs);
- char[] pwd = { 'p', 'a', 's', 's', 'w', 'd' };
- String aliasKE = "KeyAlias";
- KeyStore.PasswordProtection pp = new KeyStore.PasswordProtection(pwd);
- new KeyStore.PasswordProtection(new char[0]);
- KeyStore[] kss = createKS();
- assertNotNull("KeyStore objects were not created", kss);
-
- for (int i = 0; i < kss.length; i++) {
- kss[i].load(null, null);
- // set entries
- for (int j = 0; j < aliases.length; j++) {
- kss[i].setEntry(aliases[j], pKey, pp);
- }
- kss[i].setKeyEntry(aliasKE, privKey, pwd, certs);
- try {
- kss[i].entryInstanceOf(null, pKey.getClass());
- fail("NullPointerEXception must be thrown");
- } catch (NullPointerException e) {
- }
- assertFalse("Incorrect class entry 1",
- kss[i].entryInstanceOf("ZZZ", pKey.getClass()));
- for (int j = 0; j < aliases.length; j++) {
- assertTrue("Incorrect class entry 2",
- kss[i].entryInstanceOf(aliases[j], pKey.getClass()));
-
- //make it compilable on 1.5
- Class c = privKey.getClass();
- assertFalse("Incorrect class entry 3",
- kss[i].entryInstanceOf(aliases[j], c));
- }
-
- //make it compilable on 1.5
- Class c = privKey.getClass();
- assertFalse("Incorrect class entry 4",
- kss[i].entryInstanceOf(aliasKE, c));
- assertTrue("Incorrect class entry 5",
- kss[i].entryInstanceOf(aliasKE, pKey.getClass()));
- }
- }
-
-
- /**
- * Test for <code>KeyStore(KeyStoreSpi spi, Provider prov, String type)</code>
- * constructor
- * Assertion: constructs KeyStore object
- */
- public void testKeyStoreConstr() throws Exception {
- assertTrue(NotSupportMsg, JKSSupported);
- KeyStoreSpi spi = new MyKeyStoreSpi();
- KeyStore keySt = new tmpKeyStore(spi, defaultProvider,
- defaultType);
- assertEquals("Incorrect name", keySt.getType(),
- defaultType);
- assertEquals("Incorrect provider", keySt.getProvider(), defaultProvider);
- char[] pwd = new char[0];
- try {
- keySt.store(null, pwd);
- fail("KeyStoreException must be thrown");
- } catch (KeyStoreException e) {
- }
- keySt = new tmpKeyStore(null, null, null);
- assertNull("Algorithm must be null", keySt.getType());
- assertNull("Provider must be null", keySt.getProvider());
- try {
- keySt.load(null, pwd);
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- }
-
-}
-
-/**
- * Additional class to verify KeyStore constructor
- */
-class tmpKeyStore extends KeyStore {
- public tmpKeyStore(KeyStoreSpi spi, Provider prov, String alg) {
- super(spi, prov, alg);
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KeyStore_Impl2Test.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KeyStore_Impl2Test.java
deleted file mode 100644
index e991d65..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KeyStore_Impl2Test.java
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.UnrecoverableEntryException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.util.Date;
-
-import javax.crypto.spec.SecretKeySpec;
-
-import org.apache.harmony.security.tests.support.KeyStoreTestSupport;
-import org.apache.harmony.security.tests.support.MyLoadStoreParams;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.cert.MyCertificate;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyStore</code> constructor and methods
- */
-
-public class KeyStore_Impl2Test extends TestCase {
-
- private static final String KeyStoreProviderClass =
- "org.apache.harmony.security.tests.support.MyKeyStoreSpi";
-
- private static final String defaultAlg = "KeyStore";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "kEyStOrE";
- validValues[3] = "KeysTORE";
- }
-
- Provider mProv;
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyKSProvider",
- "Testing provider", KeyStoreTestSupport.srvKeyStore.concat(".").concat(
- defaultAlg), KeyStoreProviderClass);
- Security.insertProviderAt(mProv, 2);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- private void checkResult(KeyStore keyS) throws KeyStoreException,
- IOException, CertificateException, NoSuchAlgorithmException,
- UnrecoverableKeyException {
- char[] pass = { 'a', 'b', 'c' };
- String alias = "aaa";
- keyS.load(null, pass);
- assertNull("getKey must return null", keyS.getKey(alias, pass));
- assertNull("getCertificate must return null", keyS
- .getCertificate(alias));
- assertNull("getCertificateChain must return null", keyS
- .getCertificateChain(alias));
- assertEquals("Incorrect result of getCreationDate", keyS
- .getCreationDate(alias), new Date(0));
- assertEquals("Incorrect result of size", keyS.size(), 0);
- assertFalse("Incorrect result of isCertificateEntry", keyS
- .isCertificateEntry(alias));
- assertFalse("Incorrect result of isKeyEntry", keyS.isKeyEntry(alias));
- assertFalse("Incorrect result of containsAlias", keyS
- .containsAlias(alias));
- assertEquals("Incorrect result of getCertificateAlias", keyS
- .getCertificateAlias(null), "");
- try {
- keyS.setCertificateEntry(alias, null);
- fail("KeyStoreException must be thrown because this method is not supported");
- } catch (KeyStoreException e) {
- }
- try {
- keyS.setEntry(alias, null, null);
- fail("NullPointerException must be thrown entry is null");
- } catch (NullPointerException e) {
- }
- KeyStore.TrustedCertificateEntry entry = new KeyStore.TrustedCertificateEntry(
- new MyCertificate("type", new byte[0]));
- try {
- keyS.setEntry(alias, entry, null);
- fail("KeyStoreException must be thrown because this method is not supported");
- } catch (KeyStoreException e) {
- }
- try {
- keyS.setKeyEntry(alias, new byte[0], null);
- fail("KeyStoreException must be thrown because this method is not supported");
- } catch (KeyStoreException e) {
- }
- try {
- keyS.setKeyEntry(alias, null, null);
- fail("KeyStoreException must be thrown because this method is not supported");
- } catch (KeyStoreException e) {
- }
- try {
- keyS.store(new ByteArrayOutputStream(), null);
- fail("IOException must be thrown");
- } catch (IOException e) {
- }
- try {
- keyS.store(null, new char[0]);
- fail("IOException or NullPointerException must be thrown for null OutputStream");
- } catch (IOException e) {
- } catch (NullPointerException e) {
- }
- ByteArrayOutputStream ba = new ByteArrayOutputStream();
- try {
- keyS.store(ba, new char[0]);
- fail("IOException must be thrown");
- } catch (IOException e) {
- }
-
- KeyStore.LoadStoreParameter lParam = new MyLoadStoreParams(
- new KeyStore.PasswordProtection(new char[0]));
- try {
- keyS.store(null);
- fail("UnsupportedOperationException must be thrown");
- } catch (UnsupportedOperationException e) {
- }
-
-
- //No exception should be thrown out.
- keyS.load(null);
-
- try {
- keyS.store(lParam);
- fail("UnsupportedOperationException must be thrown");
- } catch (UnsupportedOperationException e) {
- }
-
- keyS.load(lParam);
-
- //make it compilable on 1.5
- Class c = alias.getClass();
- assertFalse("Incorrect result of entryInstanceOf", keyS
- .entryInstanceOf(alias, c));
- }
-
- private void checkKeyStoreException(KeyStore keyS)
- throws KeyStoreException, UnrecoverableKeyException,
- UnrecoverableEntryException, NoSuchAlgorithmException, IOException,
- CertificateException {
- String alias = "aaa";
- String eMsg = "IllegalStateException must be thrown because key store was not initialized";
- try {
- keyS.aliases();
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- try {
- keyS.containsAlias(alias);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- try {
- keyS.deleteEntry(alias);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- try {
- //make it compilable on 1.5
- Class c = alias.getClass();
- keyS.entryInstanceOf(alias, c);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- try {
- keyS.getCertificate(alias);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- MyCertificate mc = new MyCertificate("type", new byte[0]);
- try {
- keyS.getCertificateAlias(mc);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- try {
- keyS.getCertificateChain(alias);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- try {
- keyS.getCreationDate(alias);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- KeyStore.PasswordProtection pp = new KeyStore.PasswordProtection(
- new char[0]);
- try {
- keyS.getEntry(alias, pp);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- try {
- keyS.getKey(alias, new char[0]);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- try {
- keyS.isCertificateEntry(alias);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- try {
- keyS.isKeyEntry(alias);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- KeyStore.TrustedCertificateEntry entry = new KeyStore.TrustedCertificateEntry(
- mc);
- Certificate[] chain = { mc };
- try {
- keyS.setEntry(alias, entry, pp);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- try {
- keyS.setKeyEntry(alias, new byte[0], chain);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- SecretKeySpec sks = new SecretKeySpec(new byte[10], "type");
- try {
- keyS.setKeyEntry(alias, sks, new char[0], chain);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- try {
- keyS.size();
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- ByteArrayOutputStream ba = new ByteArrayOutputStream();
- try {
- keyS.store(ba, new char[0]);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- KeyStore.LoadStoreParameter lParam = new MyLoadStoreParams(
- new KeyStore.PasswordProtection(new char[0]));
- try {
- keyS.store(lParam);
- fail(eMsg);
- } catch (KeyStoreException e) {
- }
- }
-
-
- /**
- * Test for <code>getInstance(String type)</code> method
- * Assertions:
- * throws NullPointerException when type is null
- * throws KeyStoreException when type is not available;
- * returns KeyStore object
- */
- public void testGetInstance01() throws KeyStoreException,
- UnrecoverableKeyException, UnrecoverableEntryException,
- NoSuchAlgorithmException, IOException, CertificateException {
- try {
- KeyStore.getInstance(null);
- fail("NullPointerException or KeyStoreException must be thrown");
- } catch (KeyStoreException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyStore.getInstance(invalidValues[i]);
- fail("KeyStoreException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (KeyStoreException e) {
- }
- }
- KeyStore keyS;
- for (int i = 0; i < validValues.length; i++) {
- keyS = KeyStore.getInstance(validValues[i]);
- assertEquals("Incorrect type", keyS.getType(), validValues[i]);
- assertEquals("Incorrect provider", keyS.getProvider(), mProv);
- checkKeyStoreException(keyS);
- checkResult(keyS);
- }
- }
-
- /**
- * Test for <code>getInstance(String type, String provider)</code> method
- * Assertions:
- * throws NullPointerException when type is null
- * throws KeyStoreException when type is not available;
- * throws IllegalArgumentException when provider is null;
- * throws NoSuchProviderException when provider is available;
- * returns KeyStore object
- */
- public void testGetInstance02() throws KeyStoreException,
- NoSuchProviderException, IllegalArgumentException,
- UnrecoverableKeyException, UnrecoverableEntryException,
- NoSuchAlgorithmException, IOException, CertificateException {
- try {
- KeyStore.getInstance(null, mProv.getName());
- fail("NullPointerException or KeyStoreException must be thrown");
- } catch (KeyStoreException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyStore.getInstance(invalidValues[i], mProv.getName());
- fail("KeyStoreException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (KeyStoreException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyStore.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (type: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- KeyStore.getInstance(validValues[i], invalidValues[j]);
- fail("NoSuchProviderException must be thrown (type: "
- .concat(invalidValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- KeyStore keyS;
- for (int i = 0; i < validValues.length; i++) {
- keyS = KeyStore.getInstance(validValues[i], mProv.getName());
- assertEquals("Incorrect type", keyS.getType(), validValues[i]);
- assertEquals("Incorrect provider", keyS.getProvider().getName(),
- mProv.getName());
- checkKeyStoreException(keyS);
- checkResult(keyS);
- }
- }
-
- /**
- * Test for <code>getInstance(String type, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when type is null
- * } catch (KeyStoreException e) {
- * throws IllegalArgumentException when provider is null;
- * returns KeyStore object
- */
- public void testGetInstance03() throws KeyStoreException,
- IllegalArgumentException, UnrecoverableKeyException,
- UnrecoverableEntryException, NoSuchAlgorithmException, IOException,
- CertificateException {
- try {
- KeyStore.getInstance(null, mProv);
- fail("KeyStoreException must be thrown");
- } catch (KeyStoreException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyStore.getInstance(invalidValues[i], mProv);
- fail("KeyStoreException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (KeyStoreException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyStore.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (type: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- KeyStore keyS;
- for (int i = 0; i < validValues.length; i++) {
- keyS = KeyStore.getInstance(validValues[i], mProv);
- assertEquals("Incorrect type", keyS.getType(), validValues[i]);
- assertEquals("Incorrect provider", keyS.getProvider(), mProv);
- checkKeyStoreException(keyS);
- checkResult(keyS);
- }
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KeyStore_Impl3Test.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KeyStore_Impl3Test.java
deleted file mode 100644
index 32847a7..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KeyStore_Impl3Test.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.Security;
-import java.security.cert.Certificate;
-
-import org.apache.harmony.security.tests.support.KeyStoreTestSupport;
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyStore</code> constructor and methods
- */
-
-public class KeyStore_Impl3Test extends TestCase {
-
- private static final String KeyStoreProviderClass = "org.apache.harmony.security.tests.support.MyKeyStore";
-
- private static final String defaultType = "KeyStore";
-
- public static boolean KSSupported = false;
-
- public static String defaultProviderName = null;
-
- public static Provider defaultProvider = null;
-
- private static String NotSupportMsg = "Default KeyStore type is not supported";
-
- Provider mProv;
-
- public KeyStore[] createKS() throws Exception {
- assertTrue(NotSupportMsg, KSSupported);
- KeyStore[] kpg = new KeyStore[3];
-
- kpg[0] = KeyStore.getInstance(defaultType);
- kpg[1] = KeyStore.getInstance(defaultType, defaultProvider);
- kpg[2] = KeyStore.getInstance(defaultType, defaultProviderName);
- return kpg;
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyKSProvider",
- "Testing provider", KeyStoreTestSupport.srvKeyStore.concat(".")
- .concat(defaultType), KeyStoreProviderClass);
- Security.insertProviderAt(mProv, 2);
- defaultProvider = SpiEngUtils.isSupport(defaultType,
- KeyStoreTestSupport.srvKeyStore);
- KSSupported = (defaultProvider != null);
- defaultProviderName = (KSSupported ? defaultProvider.getName() : null);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- /**
- * Test for <code>load(InputStream stream, char[] password)</code>
- * <code>store(InputStream stream, char[] password)</code>
- * <code>size()</code>
- * <code>getCreationDate(String alias)</code>
- * methods
- * Assertions: store(...) throws NullPointerException when stream or
- * password is null;
- * getCreationDate(...) throws NullPointerException when alias is null;
- * stores KeyStore and then loads it;
- *
- * @throws Exception
- */
-
- public void testLoadStore01() throws Exception {
- assertTrue(NotSupportMsg, KSSupported);
-
- String tType = "TestType";
- KeyStore.TrustedCertificateEntry tCert = new KeyStore.TrustedCertificateEntry(
- new KeyStoreTestSupport.MCertificate("type", new byte[0]));
-
- Certificate certs[] = {
- new KeyStoreTestSupport.MCertificate(tType, new byte[10]),
- new KeyStoreTestSupport.MCertificate(tType, new byte[20]) };
- PrivateKey pk = new KeyStoreTestSupport.MyPrivateKey(tType, "", new byte[10]);
- KeyStore.PrivateKeyEntry pKey = new KeyStore.PrivateKeyEntry(pk, certs);
- char[] pwd = { 'p', 'a', 's', 's', 'w', 'd' };
- KeyStore.PasswordProtection pPath = new KeyStore.PasswordProtection(pwd);
- String[] aliases = { "Alias1", "Alias2", "Alias3", "Alias4", "Alias5" };
-
- KeyStore[] kss = createKS();
- KeyStore[] kss1 = new KeyStore[kss.length];
- assertNotNull("KeyStore objects were not created", kss);
-
- for (int i = 0; i < kss.length; i++) {
- kss1[i] = kss[i];
- kss[i].load(null, null);
- kss[i].setEntry(aliases[0], tCert, null);
- kss[i].setEntry(aliases[1], pKey, pPath);
- kss[i].setEntry(aliases[2], pKey, pPath);
- try {
- kss[i].getCreationDate(null);
- fail("NullPointerException should be thrown when alias is null");
- } catch (NullPointerException e) {
- }
-
- kss[i].setKeyEntry(aliases[3], pk, pwd, certs);
- kss[i].setCertificateEntry(aliases[4], certs[0]);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- try {
- kss[i].store(null, pwd);
- fail("IOException or NullPointerException should be thrown when stream is null");
- } catch (IOException e) {
- } catch (NullPointerException e) {
- }
-
- //RI does not throw exception while password is null.
- kss[i].store(bos, null);
-
- kss[i].store(bos, pwd);
- ByteArrayInputStream bis = new ByteArrayInputStream(bos
- .toByteArray());
- kss1[i].load(bis, pwd);
- assertEquals("Incorrect size", kss1[i].size(), kss[i].size());
- KeyStore.Entry en, en1;
- for (int j = 0; j < 3; j++) {
- en = kss[i].getEntry(aliases[j], (j == 0 ? null : pPath));
- en1 = kss1[i].getEntry(aliases[j], (j == 0 ? null : pPath));
- if (en instanceof KeyStore.TrustedCertificateEntry) {
- assertTrue("Incorrect entry 1",
- en1 instanceof KeyStore.TrustedCertificateEntry);
- assertEquals("Incorrect Certificate",
- ((KeyStore.TrustedCertificateEntry) en)
- .getTrustedCertificate(),
- ((KeyStore.TrustedCertificateEntry) en1)
- .getTrustedCertificate());
- } else {
- if (en instanceof KeyStore.PrivateKeyEntry) {
- assertTrue("Incorrect entry 2",
- en1 instanceof KeyStore.PrivateKeyEntry);
- assertEquals(
- "Incorrect Certificate",
- ((KeyStore.PrivateKeyEntry) en).getPrivateKey(),
- ((KeyStore.PrivateKeyEntry) en1)
- .getPrivateKey());
- } else {
- if (en instanceof KeyStore.SecretKeyEntry) {
- assertTrue("Incorrect entry 3",
- en1 instanceof KeyStore.SecretKeyEntry);
- assertEquals("Incorrect Certificate",
- ((KeyStore.SecretKeyEntry) en)
- .getSecretKey(),
- ((KeyStore.SecretKeyEntry) en1)
- .getSecretKey());
- }
- }
- }
-
- assertEquals("Incorrect date", kss[i]
- .getCreationDate(aliases[j]), kss1[i]
- .getCreationDate(aliases[j]));
- }
- assertEquals("Incorrect entry", kss[i].getKey(aliases[3], pwd),
- kss1[i].getKey(aliases[3], pwd));
- assertEquals("Incorrect date", kss[i].getCreationDate(aliases[3]),
- kss1[i].getCreationDate(aliases[3]));
- assertEquals("Incorrect entry", kss[i].getCertificate(aliases[4]),
- kss1[i].getCertificate(aliases[4]));
- assertEquals("Incorrect date", kss[i].getCreationDate(aliases[4]),
- kss1[i].getCreationDate(aliases[4]));
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/MessageDigest_Impl2Test.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/MessageDigest_Impl2Test.java
deleted file mode 100644
index daa08a0..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/MessageDigest_Impl2Test.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.MessageDigest;
-import java.security.Provider;
-import java.security.Security;
-
-import org.apache.harmony.security.tests.support.MyMessageDigest1;
-import org.apache.harmony.security.tests.support.MyMessageDigest2;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>MessageDigest</code> constructor and methods
- */
-public class MessageDigest_Impl2Test extends TestCase {
-
- /**
- * Provider
- */
- Provider p;
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- p = new MyProvider();
- Security.insertProviderAt(p, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(p.getName());
- }
-
- /*
- * Class under test for MessageDigest getInstance(String)
- */
- public void testGetInstanceString1() throws Exception {
- MessageDigest md1 = MessageDigest.getInstance("ABC");
- checkMD1(md1, p);
- }
-
- /*
- * Class under test for MessageDigest getInstance(String)
- */
- public void testGetInstanceString2() throws Exception {
- MessageDigest md2 = MessageDigest.getInstance("CBA");
- checkMD2(md2, p);
- }
-
- /*
- * Class under test for MessageDigest getInstance(String, String)
- */
- public void testGetInstanceStringString1() throws Exception {
- MessageDigest md1 = MessageDigest.getInstance("ABC", "MyProvider");
- checkMD1(md1, p);
- }
-
- /*
- * Class under test for MessageDigest getInstance(String, String)
- */
- public void testGetInstanceStringString2() throws Exception {
- MessageDigest md2 = MessageDigest.getInstance("CBA", "MyProvider");
- checkMD2(md2, p);
- }
-
- /*
- * Class under test for MessageDigest getInstance(String, Provider)
- */
- public void testGetInstanceStringProvider1() throws Exception {
- Provider p = new MyProvider();
- MessageDigest md1 = MessageDigest.getInstance("ABC", p);
- checkMD1(md1, p);
- }
-
- /*
- * Class under test for MessageDigest getInstance(String, Provider)
- */
- public void testGetInstanceStringProvider2() throws Exception {
- Provider p = new MyProvider();
- MessageDigest md2 = MessageDigest.getInstance("CBA", p);
- checkMD2(md2, p);
- }
-
- /*
- * Class under test for String toString()
- */
- public void testToString() {
- MyMessageDigest1 md = new MyMessageDigest1("ABC");
- assertEquals("incorrect result", "MESSAGE DIGEST ABC", md.toString());
- }
-
- private void checkMD1(MessageDigest md1, Provider p) throws Exception {
- byte[] b = { 1, 2, 3, 4, 5 };
- assertTrue("getInstance() failed", md1 instanceof MyMessageDigest1);
- assertEquals("getProvider() failed", p, md1.getProvider());
- assertEquals("getAlgorithm() failed", "ABC", md1.getAlgorithm());
-
- md1.update((byte) 1);
- md1.update(b, 1, 4);
- assertTrue("update failed", ((MyMessageDigest1) md1).runEngineUpdate1);
- assertTrue("update failed", ((MyMessageDigest1) md1).runEngineUpdate2);
-
- assertEquals("incorrect digest result", 0, md1.digest().length);
- assertEquals("getProvider() failed", 0, md1.digest(b, 2, 3));
- assertTrue("digest failed", ((MyMessageDigest1) md1).runEngineDigest);
-
- md1.reset();
- assertTrue("reset failed", ((MyMessageDigest1) md1).runEngineReset);
-
- assertEquals("getDigestLength() failed", 0, md1.getDigestLength());
- try {
- md1.clone();
- fail("No expected CloneNotSupportedException");
- } catch (CloneNotSupportedException e) {
- }
- }
-
- private void checkMD2(MessageDigest md2, Provider p) throws Exception {
- byte[] b = { 1, 2, 3, 4, 5 };
- assertEquals("getProvider() failed", p, md2.getProvider());
- assertEquals("getAlgorithm() failed", "CBA", md2.getAlgorithm());
-
- md2.update((byte) 1);
- md2.update(b, 1, 3);
- assertTrue("update failed", MyMessageDigest2.runEngineUpdate1);
- assertTrue("update failed", MyMessageDigest2.runEngineUpdate2);
-
- assertEquals("incorrect digest result", 0, md2.digest().length);
- assertEquals("getProvider() failed", 0, md2.digest(b, 2, 3));
- assertTrue("digest failed", MyMessageDigest2.runEngineDigest);
-
- md2.reset();
- assertTrue("reset failed", MyMessageDigest2.runEngineReset);
-
- assertEquals("getDigestLength() failed", 0, md2.getDigestLength());
- try {
- md2.clone();
- fail("No expected CloneNotSupportedException");
- } catch (CloneNotSupportedException e) {
- }
- }
-
- private class MyProvider extends Provider {
- MyProvider() {
- super("MyProvider", 1.0, "Provider for testing");
- put("MessageDigest.ABC", "org.apache.harmony.security.tests.support.MyMessageDigest1");
- put("MessageDigest.CBA", "org.apache.harmony.security.tests.support.MyMessageDigest2");
- }
-
- MyProvider(String name, double version, String info) {
- super(name, version, info);
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/ProviderService_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/ProviderService_ImplTest.java
deleted file mode 100644
index 6f62650..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/ProviderService_ImplTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.Provider;
-import java.util.HashMap;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>Provider.Service</code> constructor and methods
- */
-public class ProviderService_ImplTest extends TestCase {
-
- /*
- * Class under test for String toString()
- */
- public void testToString() {
- Provider p = new MyProvider();
- Provider.Service s = new Provider.Service(p, "type", "algorithm",
- "className", null, null);
- assertEquals("first toString() failed",
- "Provider MyProvider Service type.algorithm className",
- s.toString());
-
- HashMap hm = new HashMap();
- hm.put("attribute", "value");
- hm.put("KeySize", "1024");
- hm.put("AAA", "BBB");
-
- s = new Provider.Service(p, "type", "algorithm", "className",
- null, hm);
- assertTrue("second toString() failed", s.toString().startsWith(
- "Provider MyProvider Service type.algorithm className\n"
- + "Attributes "));
- }
-
- class MyProvider extends Provider {
- MyProvider() {
- super("MyProvider", 1.0, "Provider for testing");
- put("MessageDigest.SHA-1", "SomeClassName");
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/SecureRandom_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/SecureRandom_ImplTest.java
deleted file mode 100644
index 0814df6..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/SecureRandom_ImplTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.Security;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for internal Secure Random implementation based on Random
- */
-public class SecureRandom_ImplTest extends TestCase {
-
- /**
- * Registered providers
- */
- Provider providers[] = Security.getProviders();
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- // remove all registered providers
- for (int i = 0; i < providers.length; i++) {
- Security.removeProvider(providers[i].getName());
- }
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- // restore all registered providers
- for (int i = 0; i < providers.length; i++) {
- Security.addProvider(providers[i]);
- }
- }
-
- /*
- * Class under test for void setSeed(long)
- */
- public final void testSetSeedlong() {
- SecureRandom sr = new SecureRandom();
- sr.setSeed(0);
- sr.setSeed(-1);
- sr.setSeed(11111111111L);
- }
-
- public final void testNextBytes() {
- SecureRandom sr = new SecureRandom();
- sr.nextBytes(new byte[20]);
- sr.nextBytes(new byte[1]);
-
- //Not specified behavior: throws NullPointerException if bytes is null
- try {
- sr.nextBytes(null);
- } catch (NullPointerException e) {
- }
- sr.nextBytes(new byte[5]);
- }
-
- /*
- * Class under test for SecureRandom getInstance(String)
- */
- public final void testGetInstanceString() {
- try {
- SecureRandom.getInstance("SHA1PRNG");
- fail("No expected NoSuchAlgorithmException");
- } catch (NoSuchAlgorithmException e) {
- }
- }
-
- public final void testGetProvider() {
- assertNull("Non null provider", new SecureRandom().getProvider());
- }
-
- public final void testGetAlgorithm() {
- //test default implementation
- SecureRandom sr = new SecureRandom();
- assertEquals("Incorrect algorithm", "SHA1PRNG", sr.getAlgorithm());
- assertNull("Incorrect provider", sr.getProvider());
-
- //just in case
- sr.nextBytes(new byte[100]);
- }
-
- /*
- * Class under test for void setSeed(byte[])
- */
- public final void testSetSeedbyteArray() {
- SecureRandom sr = new SecureRandom();
-
- //Not specified behavior: throws NullPointerException if bytes is null
- try {
- sr.setSeed(null);
- } catch (NullPointerException e) {
- }
-
- byte[] seed = { 1, 2, 3, 4 };
- sr.setSeed(seed);
-
- byte[] seed1 = { 1, 2, 3, 4, -2, 100, 9, 111 };
- sr.setSeed(seed1);
- }
-
- public final void testGetSeed() {
- byte[] seed = SecureRandom.getSeed(5);
- new SecureRandom(seed).nextBytes(new byte[20]);
- }
-
- public final void testGenerateSeed() {
- SecureRandom sr = new SecureRandom();
- byte[] seed = sr.generateSeed(5);
- new SecureRandom(seed).nextBytes(new byte[20]);
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/Timestamp_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/Timestamp_ImplTest.java
deleted file mode 100644
index ccc9ef1..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/Timestamp_ImplTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.security.Timestamp;
-import java.security.cert.CertPath;
-import java.util.Date;
-
-import org.apache.harmony.security.tests.support.cert.MyCertPath;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>Timestamp</code> class fields and methods
- */
-
-public class Timestamp_ImplTest extends TestCase {
-
- private Date now = new Date();
-
- private static final byte[] encoding = { 1, 2, 3 };
-
- private CertPath cpath = new MyCertPath(encoding);
-
- public void testHashCode() {
- assertTrue(new Timestamp(now, cpath).hashCode() == (now.hashCode() ^ cpath
- .hashCode()));
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertStore_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertStore_ImplTest.java
deleted file mode 100644
index 1e8ce73..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertStore_ImplTest.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.cert.CRLSelector;
-import java.security.cert.CertSelector;
-import java.security.cert.CertStore;
-import java.security.cert.CertStoreException;
-import java.security.cert.CertStoreParameters;
-import java.security.cert.X509CRLSelector;
-import java.security.cert.X509CertSelector;
-import java.util.Collection;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.SpiEngUtils.MyProvider;
-import org.apache.harmony.security.tests.support.cert.MyCertStoreParameters;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertStore</code> class constructors and methods
- */
-
-public class CertStore_ImplTest extends TestCase {
- private static final String srvCertStore = "CertStore";
- private static final String defaultAlg = "CertStore";
- private static final String CertStoreProviderClass = "org.apache.harmony.security.tests.support.cert.MyCertStoreSpi";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "CeRTSTore";
- validValues[3] = "CERTstore";
- }
-
- Provider mProv;
-
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyCertStoreProvider",
- "Provider for testing", srvCertStore
- .concat(".").concat(defaultAlg),
- CertStoreProviderClass);
- Security.insertProviderAt(mProv, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- private void checkResult(CertStore certS) throws CertStoreException,
- InvalidAlgorithmParameterException {
- CertSelector certSelector = new X509CertSelector();
- CRLSelector crlSelector = new X509CRLSelector();
- Collection collection = certS.getCertificates(certSelector);
- assertNull("Not null collection", collection);
- collection = certS.getCRLs(crlSelector);
- assertNull("Not null collection", collection);
- }
-
- /**
- * Test for method
- * <code>getInstance(String type, CertStoreParameters params)</code>
- * Assertions:
- * throws NullPointerException when type is null
- * throws NoSuchAlgorithmException when type is incorrect;
- * throws InvalidAlgorithmParameterException when params is null
- * or has incorrect value;
- * returns CertStore object
- */
- public void testGetInstance01() throws NoSuchAlgorithmException,
- InvalidAlgorithmParameterException, CertStoreException {
- CertStoreParameters p = new MyCertStoreParameters();
- mPar mp = new mPar("CertStore");
- try {
- CertStore.getInstance(null, p);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when type is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertStore.getInstance(invalidValues[i], p);
- fail("NoSuchAlgorithmException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertStore.getInstance(validValues[i], null);
- fail("InvalidAlgorithmParameterException must be thrown when params is null");
- } catch (InvalidAlgorithmParameterException e) {
- }
- try {
- CertStore.getInstance(validValues[i], mp);
- fail("InvalidAlgorithmParameterException must be thrown when params is incorrect");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- CertStore certS;
- for (int i = 0; i < validValues.length; i++) {
- certS = CertStore.getInstance(validValues[i], p);
- assertEquals("Incorrect type", certS.getType(), validValues[i]);
- assertEquals("Incorrect provider", certS.getProvider(), mProv);
- assertTrue("Invalid parameters", certS.getCertStoreParameters() instanceof MyCertStoreParameters);
- checkResult(certS);
- }
- }
-
- /**
- * Test for method
- * <code>getInstance(String type, CertStoreParameters params, String provider)</code>
- * Assertions:
- * throws NullPointerException when type is null
- * throws NoSuchAlgorithmException when type is incorrect;
- * throws IllegalArgumentException when provider is null or empty;
- * throws NoSuchProviderException when provider is available;
- * throws InvalidAlgorithmParameterException when params is null
- * returns CertStore object
- */
- public void testGetInstance02() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- InvalidAlgorithmParameterException, CertStoreException {
- CertStoreParameters p = new MyCertStoreParameters();
- mPar mp = new mPar("CertStore");
- try {
- CertStore.getInstance(null, p, mProv.getName());
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when type is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertStore.getInstance(invalidValues[i], p, mProv
- .getName());
- fail("NoSuchAlgorithmException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertStore.getInstance(validValues[i], p, prov);
- fail("IllegalArgumentException must be thrown when provider is null (type: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- try {
- CertStore.getInstance(validValues[i], p, "");
- fail("IllegalArgumentException must be thrown when provider is empty (type: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- CertStore.getInstance(validValues[i], p,
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (type: "
- .concat(validValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertStore.getInstance(validValues[i], null, mProv.getName());
- fail("InvalidAlgorithmParameterException must be thrown when params is null");
- } catch (InvalidAlgorithmParameterException e) {
- }
- try {
- CertStore.getInstance(validValues[i], mp, mProv.getName());
- fail("InvalidAlgorithmParameterException must be thrown when params is incorrect");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
- CertStore certS;
- for (int i = 0; i < validValues.length; i++) {
- certS = CertStore.getInstance(validValues[i], p, mProv
- .getName());
- assertEquals("Incorrect type", certS.getType(), validValues[i]);
- assertEquals("Incorrect provider", certS.getProvider().getName(),
- mProv.getName());
- assertTrue("Invalid parameters", certS.getCertStoreParameters() instanceof MyCertStoreParameters);
- checkResult(certS);
- }
- }
-
- /**
- * Test for method
- * <code>getInstance(String type, CertStoreParameters params, Provider provider)</code>
- * Assertions:
- * throws NullPointerException when type is null
- * throws NoSuchAlgorithmException when type is incorrect;
- * throws IllegalArgumentException when provider is null;
- * throws InvalidAlgorithmParameterException when params is null or has incorrect value
- * returns CertStore object
- */
- public void testGetInstance03() throws NoSuchAlgorithmException,
- IllegalArgumentException,
- InvalidAlgorithmParameterException, CertStoreException {
- CertStoreParameters p = new MyCertStoreParameters();
- mPar mp = new mPar("CertStore");
- try {
- CertStore.getInstance(null, p, mProv);
- fail("NullPointerException or NoSuchAlgorithmException must be thrown when type is null");
- } catch (NullPointerException e) {
- } catch (NoSuchAlgorithmException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- CertStore.getInstance(invalidValues[i], p, mProv);
- fail("NoSuchAlgorithmException must be thrown (type: ".concat(
- invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertStore.getInstance(validValues[i], p, prov);
- fail("IllegalArgumentException must be thrown when provider is null (type: "
- .concat(validValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- try {
- CertStore.getInstance(validValues[i], null, mProv);
- fail("InvalidAlgorithmParameterException must be thrown when params is null");
- } catch (InvalidAlgorithmParameterException e) {
- }
- try {
- CertStore.getInstance(validValues[i], mp, mProv);
- fail("InvalidAlgorithmParameterException must be thrown when params is incorrect");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
- CertStore certS;
- for (int i = 0; i < validValues.length; i++) {
- certS = CertStore.getInstance(validValues[i], p, mProv);
- assertEquals("Incorrect type", certS.getType(), validValues[i]);
- assertEquals("Incorrect provider", certS.getProvider(), mProv);
- assertTrue("Invalid parameters", certS.getCertStoreParameters() instanceof MyCertStoreParameters);
- checkResult(certS);
- }
- }
-}
-
-class mPar implements CertStoreParameters {
- String par = "";
-
- public mPar() {
- super();
- }
-
- public mPar(String s) {
- super();
- par = s;
- }
-
- public Object clone() {
- if (par == "") {
- return null;
- }
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory_ImplTest.java
deleted file mode 100644
index b4ee37a..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory_ImplTest.java
+++ /dev/null
@@ -1,798 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.ByteArrayInputStream;
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.PublicKey;
-import java.security.cert.CertPath;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509CRL;
-import java.security.cert.X509Certificate;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import org.apache.harmony.luni.util.Base64;
-
-import junit.framework.TestCase;
-
-/**
- * X.509 CertificateFactory provider implementation test.<br>
- * See RFC 3280 (http://www.ietf.org/rfc/rfc3280.txt) for
- * more information on X.509, and
- * http://www.ietf.org/rfc/rfc2315.txt
- * for more information on PKCS #7.
- * The testing data was generated by use of classes from
- * org.apache.harmony.security.x509 package.
- */
-public class CertificateFactory_ImplTest extends TestCase {
-
- /**
- * Base64 encoded PKCS7 SignedObject containing two X.509
- * Certificates and CRLs.
- */
- private static String pkcs7so =
- "MIIHDwYJKoZIhvcNAQcCoIIHADCCBvwCAQExADALBgkqhkiG9w0BBwGg"
- + "ggUuMIICkzCCAlOgAwIBAgICAiswCQYHKoZIzjgEAzAdMRswGQYDVQQK"
- + "ExJDZXJ0aWZpY2F0ZSBJc3N1ZXIwIxcNMDYwOTA1MDk1MzA2WhgSMjMz"
- + "NjEwMTMwMjUxMjcuODFaMB0xGzAZBgNVBAoTEkNlcnRpZmljYXRlIElz"
- + "c3VlcjCCAbgwggEsBgcqhkjOOAQBMIIBHwKBgQD9f1OBHXUSKVLfSpwu"
- + "7OTn9hG3UjzvRADDHj+AtlEmaUVdQCJR+1k9jVj6v8X1ujD2y5tVbNeB"
- + "O4AdNG/yZmC3a5lQpaSfn+gEexAiwk+7qdf+t8Yb+DtX58aophUPBPuD"
- + "9tPFHsMCNVQTWhaRMvZ1864rYdcq7/IiAxmd0UgBxwIVAJdgUI8VIwvM"
- + "spK5gqLrhAvwWBz1AoGBAPfhoIXWmz3ey7yrXDa4V7l5lK+7+jrqgvlX"
- + "TAs9B4JnUVlXjrrUWU/mcQcQgYC0SRZxI+hMKBYTt88JMozIpuE8FnqL"
- + "VHyNKOCjrh4rs6Z1kW6jfwv6ITVi8ftiegEkO8yk8b6oUZCJqIPf4Vrl"
- + "nwaSi2ZegHtVJWQBTDv+z0kqA4GFAAKBgQDyCA7AK6Kep2soxt8tIsWW"
- + "kafbYdueAkeBNnm46H0OteFa80HMuJjKJ0LjlPrdjFMARKyW/GATtQhg"
- + "hY/MrINAHmKcX5QjL1DkuJKDNggLHqj5D6efsWmLKwLvmviWLzWtjh7Y"
- + "GBZeLt0ezu2q49aKcOzkkDsCSsMz09u9284L6qMeMBwwGgYDVR0RAQH/"
- + "BBAwDoEMcmZjQDgyMi5OYW1lMAkGByqGSM44BAMDLwAwLAIUWo0C+R8P"
- + "J8LGSLsCRqJ8SOOO0SoCFGvO6mpNdzOKiwlYwfpF/Xyi7s3vMIICkzCC"
- + "AlOgAwIBAgICAiswCQYHKoZIzjgEAzAdMRswGQYDVQQKExJDZXJ0aWZp"
- + "Y2F0ZSBJc3N1ZXIwIxcNMDYwOTA1MDk1MzA2WhgSMjMzNjEwMTMwMjUx"
- + "MjcuODFaMB0xGzAZBgNVBAoTEkNlcnRpZmljYXRlIElzc3VlcjCCAbgw"
- + "ggEsBgcqhkjOOAQBMIIBHwKBgQD9f1OBHXUSKVLfSpwu7OTn9hG3Ujzv"
- + "RADDHj+AtlEmaUVdQCJR+1k9jVj6v8X1ujD2y5tVbNeBO4AdNG/yZmC3"
- + "a5lQpaSfn+gEexAiwk+7qdf+t8Yb+DtX58aophUPBPuD9tPFHsMCNVQT"
- + "WhaRMvZ1864rYdcq7/IiAxmd0UgBxwIVAJdgUI8VIwvMspK5gqLrhAvw"
- + "WBz1AoGBAPfhoIXWmz3ey7yrXDa4V7l5lK+7+jrqgvlXTAs9B4JnUVlX"
- + "jrrUWU/mcQcQgYC0SRZxI+hMKBYTt88JMozIpuE8FnqLVHyNKOCjrh4r"
- + "s6Z1kW6jfwv6ITVi8ftiegEkO8yk8b6oUZCJqIPf4VrlnwaSi2ZegHtV"
- + "JWQBTDv+z0kqA4GFAAKBgQDyCA7AK6Kep2soxt8tIsWWkafbYdueAkeB"
- + "Nnm46H0OteFa80HMuJjKJ0LjlPrdjFMARKyW/GATtQhghY/MrINAHmKc"
- + "X5QjL1DkuJKDNggLHqj5D6efsWmLKwLvmviWLzWtjh7YGBZeLt0ezu2q"
- + "49aKcOzkkDsCSsMz09u9284L6qMeMBwwGgYDVR0RAQH/BBAwDoEMcmZj"
- + "QDgyMi5OYW1lMAkGByqGSM44BAMDLwAwLAIUWo0C+R8PJ8LGSLsCRqJ8"
- + "SOOO0SoCFGvO6mpNdzOKiwlYwfpF/Xyi7s3voYIBsjCB1jCBlwIBATAJ"
- + "BgcqhkjOOAQDMBUxEzARBgNVBAoTCkNSTCBJc3N1ZXIXDTA2MDkwNTA5"
- + "NTMwN1oXDTA2MDkwNTA5NTQ0N1owQTA/AgICKxcNMDYwOTA1MDk1MzA4"
- + "WjAqMAoGA1UdFQQDCgEBMBwGA1UdGAQVGBMyMDA2MDkwNTA5NTMwNy43"
- + "MThaoA8wDTALBgNVHRQEBAICEVwwCQYHKoZIzjgEAwMvADAsAhR/l5kI"
- + "bTkuJe9HjcpZ4Ff4Ifv9xwIUIXBlDKsNFlgYdWWTxzrrJOHyMuUwgdYw"
- + "gZcCAQEwCQYHKoZIzjgEAzAVMRMwEQYDVQQKEwpDUkwgSXNzdWVyFw0w"
- + "NjA5MDUwOTUzMDdaFw0wNjA5MDUwOTU0NDdaMEEwPwICAisXDTA2MDkw"
- + "NTA5NTMwOFowKjAKBgNVHRUEAwoBATAcBgNVHRgEFRgTMjAwNjA5MDUw"
- + "OTUzMDcuNzE4WqAPMA0wCwYDVR0UBAQCAhFcMAkGByqGSM44BAMDLwAw"
- + "LAIUf5eZCG05LiXvR43KWeBX+CH7/ccCFCFwZQyrDRZYGHVlk8c66yTh"
- + "8jLlMQA=";
-
- /**
- * Base64 encoded PkiPath object containing 2 X.509 certificates.
- */
- private static String pkiPath =
- "MIIFMDCCApQwggJToAMCAQICAgIrMAkGByqGSM44BAMwHTEbMBkGA1UE"
- + "ChMSQ2VydGlmaWNhdGUgSXNzdWVyMCMXDTA2MDkwNTExMDAyM1oYEjIz"
- + "MzYxMDEzMTQwNDE4LjEyWjAdMRswGQYDVQQKExJDZXJ0aWZpY2F0ZSBJ"
- + "c3N1ZXIwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11EilS30qc"
- + "Luzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzX"
- + "gTuAHTRv8mZgt2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7"
- + "g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/yIgMZndFIAccCFQCXYFCPFSML"
- + "zLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o66oL5"
- + "V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6"
- + "i1R8jSjgo64eK7OmdZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa"
- + "5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA8ggOwCuinqdrKMbfLSLF"
- + "lpGn22HbngJHgTZ5uOh9DrXhWvNBzLiYyidC45T63YxTAESslvxgE7UI"
- + "YIWPzKyDQB5inF+UIy9Q5LiSgzYICx6o+Q+nn7FpiysC75r4li81rY4e"
- + "2BgWXi7dHs7tquPWinDs5JA7AkrDM9PbvdvOC+qjHjAcMBoGA1UdEQEB"
- + "/wQQMA6BDHJmY0A4MjIuTmFtZTAJBgcqhkjOOAQDAzAAMC0CFQCAUA72"
- + "3BIXNluugYcScXeb9vx5vAIUYreCA5ljANvzSsD0ofI+xph4//IwggKU"
- + "MIICU6ADAgECAgICKzAJBgcqhkjOOAQDMB0xGzAZBgNVBAoTEkNlcnRp"
- + "ZmljYXRlIElzc3VlcjAjFw0wNjA5MDUxMTAwMjNaGBIyMzM2MTAxMzE0"
- + "MDQxOC4xMlowHTEbMBkGA1UEChMSQ2VydGlmaWNhdGUgSXNzdWVyMIIB"
- + "uDCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2EbdS"
- + "PO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00b/Jm"
- + "YLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnxqimFQ8E+4P208UewwI1"
- + "VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUjC8yykrmCouuE"
- + "C/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdR"
- + "WVeOutRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o4KOu"
- + "HiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6A"
- + "e1UlZAFMO/7PSSoDgYUAAoGBAPIIDsArop6nayjG3y0ixZaRp9th254C"
- + "R4E2ebjofQ614VrzQcy4mMonQuOU+t2MUwBErJb8YBO1CGCFj8ysg0Ae"
- + "YpxflCMvUOS4koM2CAseqPkPp5+xaYsrAu+a+JYvNa2OHtgYFl4u3R7O"
- + "7arj1opw7OSQOwJKwzPT273bzgvqox4wHDAaBgNVHREBAf8EEDAOgQxy"
- + "ZmNAODIyLk5hbWUwCQYHKoZIzjgEAwMwADAtAhUAgFAO9twSFzZbroGH"
- + "EnF3m/b8ebwCFGK3ggOZYwDb80rA9KHyPsaYeP/y";
-
- /**
- * Base64 encoded X.509 CRL.
- */
- private static String x509crl =
- "MIHWMIGWAgEBMAkGByqGSM44BAMwFTETMBEGA1UEChMKQ1JMIElzc3Vl"
- + "chcNMDYwOTA1MDk1MzA4WhcNMDYwOTA1MDk1NDQ4WjBAMD4CAgIrFw0w"
- + "NjA5MDUwOTUzMDhaMCkwCgYDVR0VBAMKAQEwGwYDVR0YBBQYEjIwMDYw"
- + "OTA1MDk1MzA4Ljg5WqAPMA0wCwYDVR0UBAQCAhFcMAkGByqGSM44BAMD"
- + "MAAwLQIUJ1KAJumw8mOpGXT/FS5K9WwOBRICFQCR+ez59x9GH3sKoByC"
- + "IooeR20Q3Q==";
-
- /**
- * Base64 encoded X.509 Certificate.
- */
- private static String x509cert =
- "MIICkzCCAlOgAwIBAgICAiswCQYHKoZIzjgEAzAdMRswGQYDVQQKExJD"
- + "ZXJ0aWZpY2F0ZSBJc3N1ZXIwIxcNMDYwOTA4MDU1NzUxWhgSMjMzNjEx"
- + "MTAxMTM4NTUuNjJaMB0xGzAZBgNVBAoTEkNlcnRpZmljYXRlIElzc3Vl"
- + "cjCCAbgwggEsBgcqhkjOOAQBMIIBHwKBgQD9f1OBHXUSKVLfSpwu7OTn"
- + "9hG3UjzvRADDHj+AtlEmaUVdQCJR+1k9jVj6v8X1ujD2y5tVbNeBO4Ad"
- + "NG/yZmC3a5lQpaSfn+gEexAiwk+7qdf+t8Yb+DtX58aophUPBPuD9tPF"
- + "HsMCNVQTWhaRMvZ1864rYdcq7/IiAxmd0UgBxwIVAJdgUI8VIwvMspK5"
- + "gqLrhAvwWBz1AoGBAPfhoIXWmz3ey7yrXDa4V7l5lK+7+jrqgvlXTAs9"
- + "B4JnUVlXjrrUWU/mcQcQgYC0SRZxI+hMKBYTt88JMozIpuE8FnqLVHyN"
- + "KOCjrh4rs6Z1kW6jfwv6ITVi8ftiegEkO8yk8b6oUZCJqIPf4VrlnwaS"
- + "i2ZegHtVJWQBTDv+z0kqA4GFAAKBgQDyCA7AK6Kep2soxt8tIsWWkafb"
- + "YdueAkeBNnm46H0OteFa80HMuJjKJ0LjlPrdjFMARKyW/GATtQhghY/M"
- + "rINAHmKcX5QjL1DkuJKDNggLHqj5D6efsWmLKwLvmviWLzWtjh7YGBZe"
- + "Lt0ezu2q49aKcOzkkDsCSsMz09u9284L6qMeMBwwGgYDVR0RAQH/BBAw"
- + "DoEMcmZjQDgyMi5OYW1lMAkGByqGSM44BAMDLwAwLAIUO+JWKWai/8Si"
- + "2oEfhKSobLttYeYCFFO5YVDvtnmVVnvQTtUvrPpsaxJR";
-
- /**
- * Base64 encoded Private Key used for data signing.
- * This data is not directly used in the test, but it could be
- * useful in future in case of implementation of additional
- * testing data structures.
- */
- private static String b64PrivateKeySpec =
- "MIIBSwIBADCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s"
- + "5Of2EbdSPO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7"
- + "gB00b/JmYLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnxqimFQ8E+4P2"
- + "08UewwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUjC8yy"
- + "krmCouuEC/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdM"
- + "Cz0HgmdRWVeOutRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotU"
- + "fI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWf"
- + "BpKLZl6Ae1UlZAFMO/7PSSoEFgIUS24w346zv1ic3wsLOHzxQnf9aX0=";
-
- /**
- * Base64 encoded Public Key for signature verification.
- */
- private static String b64PublicKeySpec =
- "MIIBuDCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2"
- + "EbdSPO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00"
- + "b/JmYLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnxqimFQ8E+4P208Ue"
- + "wwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUjC8yykrmC"
- + "ouuEC/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0H"
- + "gmdRWVeOutRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o"
- + "4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKL"
- + "Zl6Ae1UlZAFMO/7PSSoDgYUAAoGBAPIIDsArop6nayjG3y0ixZaRp9th"
- + "254CR4E2ebjofQ614VrzQcy4mMonQuOU+t2MUwBErJb8YBO1CGCFj8ys"
- + "g0AeYpxflCMvUOS4koM2CAseqPkPp5+xaYsrAu+a+JYvNa2OHtgYFl4u"
- + "3R7O7arj1opw7OSQOwJKwzPT273bzgvq";
-
- /**
- * The name of the algorithm used for Certificate/CRL signing.
- */
- private static String publicKeyAlgorithm = "DSA";
-
- /**
- * The public key to verify generated Certificates and CRLs.
- */
- private static PublicKey publicKey;
-
- static {
- try {
- X509EncodedKeySpec publicKeySpec =
- new X509EncodedKeySpec(
- Base64.decode(b64PublicKeySpec.getBytes("UTF-8")));
- KeyFactory keyFactory =
- KeyFactory.getInstance(publicKeyAlgorithm);
- publicKey = keyFactory.generatePublic(publicKeySpec);
- } catch (NoSuchAlgorithmException e) {
- // provider is not installed, will not verify the generated data
- publicKey = null;
- } catch (Exception e) {
- // problems with a representation of the key
- e.printStackTrace();
- publicKey = null;
- }
- }
-
- // array contains allowed PEM delimiters
- private static String[][] good = {
- { "-----BEGIN\n", "\n-----END" },
- { "-----BEGIN-----\n", "\n-----END-----" },
- { "-----BEGIN PEM ENCODED DATA STRUCTURE-----\n", "\n-----END-----" },
- { "-----BEGIN MEANINGLESS SEPARATOR\n", "\n-----END PEM" },
- };
-
- // array contains not allowed PEM delimiters
- private static String[][] bad = {
- { "----BEGI\n", "\n-----END" },
- { "-----BEGI\n", "\n----END" },
- { "-----BEGI\n", "\n-----END" },
- { "-----BEGIN\n", "\n-----EN" },
- { "-----BEGIN", "\n-----END" },
- { "-----BEGIN\n", "-----END" },
- };
-
- // array contains bad PEM encoded content.
- private static String[] bad_content = {
- "MIIHDwYJ", "ABCD", "\r\n\r\n", "\n\r", ""
- };
-
- /**
- * generateCRLs method testing.
- * Generates CRLs on the base of PKCS7 SignedData Object
- */
- public void testGenerateCRLs() throws Exception {
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
-
- // Testing the CRLs generation on the base of PKCS7 SignedData object
- ByteArrayInputStream bais = new ByteArrayInputStream(
- Base64.decode(pkcs7so.getBytes("UTF-8")));
-
- Collection crls = factory.generateCRLs(bais);
- assertNotNull("Factory returned null on correct PKCS7 data", crls);
- assertEquals("The size of collection differs from expected",
- 2, crls.size());
-
- if (publicKey != null) {
- // verify the signatures
- for (Iterator i = crls.iterator(); i.hasNext(); ) {
- ((X509CRL) i.next()).verify(publicKey);
- }
- }
- }
-
- /**
- * generateCRL/generateCertificate method testing.
- * Tries to generates single CRL/Certificate
- * on the base of PKCS7 SignedData Object.
- */
- public void testGenerateCRL() throws Exception {
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
-
- ByteArrayInputStream bais = new ByteArrayInputStream(
- Base64.decode(pkcs7so.getBytes("UTF-8")));
- try {
- factory.generateCRL(bais);
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- bais = new ByteArrayInputStream(Base64.decode(pkcs7so.getBytes("UTF-8")));
- try {
- factory.generateCertificate(bais);
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- }
-
- /**
- * Generates CRLs on the base of PEM encoding.
- */
- public void testGenerateBase64CRL() throws Exception {
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
- ByteArrayInputStream bais;
-
- for (int i = 0; i < good.length; i++) {
- bais = new ByteArrayInputStream(
- (good[i][0] + x509crl + good[i][1]).getBytes("UTF-8"));
-
- X509CRL crl = (X509CRL) factory.generateCRL(bais);
- assertNotNull("Factory returned null on correct data", crl);
-
- if (publicKey != null) {
- // verify the signatures
- crl.verify(publicKey);
- }
- }
-
- for (int i = 0; i < bad_content.length; i++) {
- bais = new ByteArrayInputStream(
- (good[0][0] + bad_content[i] + good[0][1]).getBytes("UTF-8"));
- try {
- factory.generateCRL(bais);
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- // e.printStackTrace();
- }
- }
-
- for (int i = 0; i < bad.length; i++) {
- bais = new ByteArrayInputStream(
- (bad[i][0] + x509crl + bad[i][1]).getBytes("UTF-8"));
- try {
- factory.generateCRL(bais);
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- }
- }
-
- private void verifyCRLs(Collection crls) throws Exception {
- if (publicKey != null) {
- // verify the signatures
- for (Iterator it = crls.iterator(); it.hasNext(); ) {
- ((X509CRL) it.next()).verify(publicKey);
- }
- }
- }
-
- ;
-
- private void verifyCertificates(Collection certs) throws Exception {
- if (publicKey != null) {
- // verify the signatures
- for (Iterator it = certs.iterator(); it.hasNext(); ) {
- ((X509Certificate) it.next()).verify(publicKey);
- }
- }
- }
-
- ;
-
- /**
- * generateCRLs method testing.
- * Generates CRLs on the base of consequent
- * PEM X.509(ASN.1)/X.509(ASN.1)/PKCS7 forms.
- */
- public void testGenerateBase64CRLs() throws Exception {
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
-
- // ------------------------ Test Data -----------------------------
- // encoding describing codes
- int pem_x509 = 0, asn_x509 = 1, pem_pkcs = 2, asn_pkcs = 3,
- bad = 4, npe_bad = 5, npe_bad2 = 6, num_of_variants = 7;
- // error code, marks sequences as throwing exceptions
- int error = 999;
- // test sequences
- int[][] sequences = {
- { pem_x509, pem_x509 },
- { pem_x509, asn_x509 },
- { pem_x509, asn_x509, pem_x509 },
- { asn_x509, asn_x509 },
- { asn_x509, pem_x509 },
- { asn_x509, pem_x509, asn_x509 },
- // -1 means that only 1 (-(-1)) CRL will be generated
- // on the base of this encodings sequence
- { -1, pem_x509, pem_pkcs },
- { -1, pem_x509, bad },
- // {-1/*-error*/, pem_x509, npe_bad2},
- // {-1/*-error*/, pem_x509, npe_bad},
- { -2, pem_pkcs, pem_x509 }, // 2 CRLs are expected
- { -2, pem_pkcs, bad },
- { -2, pem_pkcs, npe_bad },
- { -2, pem_pkcs, npe_bad2 },
- { -1, asn_x509, pem_pkcs },
- { -1, asn_x509, bad },
- // {-1/*-error*/, asn_x509, npe_bad},
- // {-1/*-error*/, asn_x509, npe_bad2},
- // exception is expected
- { -error, bad },
- { -error, bad, asn_x509 },
- { -error, npe_bad },
- { -error, npe_bad2 },
- };
- // actual encodings
- byte[][] data = new byte[num_of_variants][];
- data[pem_x509] = (good[0][0] + x509crl + good[0][1] + "\n").getBytes("UTF-8");
- data[asn_x509] = Base64.decode(x509crl.getBytes("UTF-8"));
- data[pem_pkcs] = (good[0][0] + pkcs7so + good[0][1] + "\n").getBytes("UTF-8");
- data[asn_pkcs] = Base64.decode(pkcs7so.getBytes("UTF-8"));
- data[bad] = new byte[] { 0, 1, 1, 1, 1, 1, 0, 1 };
- data[npe_bad] = new byte[] { 0, 1, 1, 1, 1, 1, 1, 0 };
- data[npe_bad2] = new byte[] { 48, 0, 3, 4, 5, 6, 7 };
-
- // -------------------------- Test --------------------------------
- // Tests CRL generation on the base of sequences of heterogeneous
- // data format
- for (int i = 0; i < sequences.length; i++) { // for each of the sequences..
- // expected size og generated CRL collection
- int expected_size = (sequences[i][0] < 0)
- ? -sequences[i][0]
- : sequences[i].length;
- // compute the size of the encoding described by sequence
- int encoding_size = 0;
- //System.out.print("Sequence:");
- for (int j = 0; j < sequences[i].length; j++) {
- //System.out.print(" "+sequences[i][j]);
- if (sequences[i][j] >= 0) {
- encoding_size += data[sequences[i][j]].length;
- }
- }
- //System.out.println("");
- // create the encoding of described sequence
- byte[] encoding = new byte[encoding_size];
- int position = 0;
- for (int j = 0; j < sequences[i].length; j++) {
- if (sequences[i][j] >= 0) {
- System.arraycopy(
- data[sequences[i][j]], 0, // from
- encoding, position, // to
- data[sequences[i][j]].length); // length
- position += data[sequences[i][j]].length;
- }
- }
-
- if (expected_size == error) { // exception throwing test
- try {
- factory.generateCRLs(new ByteArrayInputStream(encoding));
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- } else {
- Collection crls =
- factory.generateCRLs(new ByteArrayInputStream(encoding));
- assertNotNull("Factory returned null on correct data", crls);
- assertEquals("The size of collection differs from expected",
- expected_size, crls.size());
- verifyCRLs(crls);
- }
- }
- }
-
- /**
- * generateCertificates method testing.
- * Generates Certificates on the base of consequent
- * PEM X.509(ASN.1)/X.509(ASN.1)/PKCS7 forms.
- */
- public void testGenerateBase64Certificates() throws Exception {
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
-
- // ------------------------ Test Data -----------------------------
- // encoding describing codes
- int pem_x509 = 0, asn_x509 = 1, pem_pkcs = 2, asn_pkcs = 3,
- bad = 4, bad1 = 5, bad2 = 6, num_of_variants = 7;
- // error code, marks sequences as throwing exceptions
- int error = 999;
- // test sequences
- int[][] sequences = {
- { pem_x509, pem_x509 },
- { pem_x509, asn_x509 },
- { pem_x509, asn_x509, pem_x509 },
- { asn_x509, asn_x509 },
- { asn_x509, pem_x509 },
- { asn_x509, pem_x509, asn_x509 },
- // -1 means that only 1 (-(-1)) Certificate will be generated
- // on the base of this encodings sequence
- // {-1/*-error*/, pem_x509, pem_pkcs},
- // {-1/*-error*/, pem_x509, bad},
- { -2, pem_pkcs, pem_x509 }, // 2 Certificates are expected
- { -2, pem_pkcs, bad },
- { -2, pem_pkcs, bad1 },
- { -2, pem_pkcs, bad2 },
- // {-1/*-error*/, asn_x509, pem_pkcs},
- // {-1/*-error*/, asn_x509, bad},
- // {-1/*-error*/, asn_x509, bad1},
- // {-1/*-error*/, pem_x509, bad1},
- // {-1/*-error*/, asn_x509, bad2},
- // {-1/*-error*/, pem_x509, bad2},
- // exception is expected
- { -error, bad },
- { -error, bad, asn_x509 },
- { -error, bad1 },
- { -error, bad2 },
- };
- // actual encodings
- byte[][] data = new byte[num_of_variants][];
- data[pem_x509] = (good[0][0] + x509cert + good[0][1] + "\n").getBytes("UTF-8");
- data[asn_x509] = Base64.decode(x509cert.getBytes("UTF-8"));
- data[pem_pkcs] = (good[0][0] + pkcs7so + good[0][1] + "\n").getBytes("UTF-8");
- data[asn_pkcs] = Base64.decode(pkcs7so.getBytes("UTF-8"));
- data[bad] = new byte[] { 0, 1, 1, 1, 1, 1, 0, 1 };
- data[bad1] = new byte[] { 0, 1, 1, 1, 1, 1, 1, 0 };
- data[bad2] = new byte[] { 48, 0, 3, 4, 5, 6, 7 };
-
- // -------------------------- Test --------------------------------
- // Tests Certificate generation on the base of sequences of heterogeneous
- // data format
- for (int i = 0; i < sequences.length; i++) { // for each of the sequences..
- // expected size og generated Certificate collection
- int expected_size = (sequences[i][0] < 0)
- ? -sequences[i][0]
- : sequences[i].length;
- // compute the size of the encoding described by sequence
- int encoding_size = 0;
- //System.out.print("Sequence:");
- for (int j = 0; j < sequences[i].length; j++) {
- //System.out.print(" "+sequences[i][j]);
- if (sequences[i][j] >= 0) {
- encoding_size += data[sequences[i][j]].length;
- }
- }
- //System.out.println("");
- // create the encoding of described sequence
- byte[] encoding = new byte[encoding_size];
- int position = 0;
- for (int j = 0; j < sequences[i].length; j++) {
- if (sequences[i][j] >= 0) {
- System.arraycopy(
- data[sequences[i][j]], 0, // from
- encoding, position, // to
- data[sequences[i][j]].length); // length
- position += data[sequences[i][j]].length;
- }
- }
-
- if (expected_size == error) { // exception throwing test
- try {
- factory.generateCertificates(new ByteArrayInputStream(encoding));
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- } else {
- Collection certs =
- factory.generateCertificates(new ByteArrayInputStream(encoding));
- assertNotNull("Factory returned null on correct data", certs);
- assertEquals("The size of collection differs from expected",
- expected_size, certs.size());
- verifyCertificates(certs);
- }
- }
- }
-
- /**
- * Generates CRLs/Certificates on the base of PEM PKCS7 encoding.
- */
- public void testGenerateBase64PKCS7() throws Exception {
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
-
- ByteArrayInputStream bais;
- for (int i = 0; i < good.length; i++) {
- bais = new ByteArrayInputStream(
- (good[i][0] + pkcs7so + good[i][1]).getBytes("UTF-8"));
- Collection crls = factory.generateCRLs(bais);
- assertNotNull("Factory returned null on correct PKCS7 data", crls);
- assertEquals("The size of collection differs from expected",
- 2, crls.size());
- if (publicKey != null) {
- // verify the signatures
- for (Iterator it = crls.iterator(); it.hasNext(); ) {
- ((X509CRL) it.next()).verify(publicKey);
- }
- }
- bais = new ByteArrayInputStream(
- (good[i][0] + pkcs7so + good[i][1]).getBytes("UTF-8"));
- Collection certs = factory.generateCertificates(bais);
- assertNotNull("Factory returned null on correct PKCS7 data", certs);
- assertEquals("The size of collection differs from expected",
- 2, certs.size());
- if (publicKey != null) {
- // verify the signatures
- for (Iterator it = certs.iterator(); it.hasNext(); ) {
- ((X509Certificate) it.next()).verify(publicKey);
- }
- }
- }
-
- for (int i = 0; i < bad_content.length; i++) {
- bais = new ByteArrayInputStream(
- (good[0][0] + bad_content[i] + good[0][1]).getBytes("UTF-8"));
- try {
- factory.generateCertificates(bais);
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- bais = new ByteArrayInputStream(
- (good[0][0] + bad_content[i] + good[0][1]).getBytes("UTF-8"));
- try {
- factory.generateCRLs(bais);
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- }
-
- for (int i = 0; i < bad.length; i++) {
- bais = new ByteArrayInputStream(
- (bad[i][0] + pkcs7so + bad[i][1]).getBytes("UTF-8"));
- try {
- factory.generateCRLs(bais);
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- bais = new ByteArrayInputStream(
- (bad[i][0] + pkcs7so + bad[i][1]).getBytes("UTF-8"));
- try {
- factory.generateCertificates(bais);
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- }
- }
-
- /**
- * Generates CertPaths on the base of PEM PkiPath/PKCS7 encoding.
- */
- public void testGenerateBase64CertPath() throws Exception {
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
-
- ByteArrayInputStream bais;
- List certificates;
- for (int i = 0; i < good.length; i++) {
- bais = new ByteArrayInputStream(
- (good[i][0] + pkiPath + good[i][1]).getBytes("UTF-8"));
-
- certificates = factory.generateCertPath(bais).getCertificates();
- assertEquals("The size of the list differs from expected",
- 2, certificates.size());
-
- if (publicKey != null) {
- // verify the signatures
- for (Iterator it = certificates.iterator(); it.hasNext(); ) {
- ((X509Certificate) it.next()).verify(publicKey);
- }
- }
-
- bais = new ByteArrayInputStream(
- (good[i][0] + pkiPath + good[i][1]).getBytes("UTF-8"));
-
- certificates =
- factory.generateCertPath(bais, "PkiPath").getCertificates();
- assertEquals("The size of the list differs from expected",
- 2, certificates.size());
-
- if (publicKey != null) {
- // verify the signatures
- for (Iterator it = certificates.iterator(); it.hasNext(); ) {
- ((X509Certificate) it.next()).verify(publicKey);
- }
- }
-
- bais = new ByteArrayInputStream(
- (good[i][0] + pkcs7so + good[i][1]).getBytes("UTF-8"));
-
- certificates =
- factory.generateCertPath(bais, "PKCS7").getCertificates();
- assertEquals("The size of the list differs from expected",
- 2, certificates.size());
-
- if (publicKey != null) {
- // verify the signatures
- for (Iterator it = certificates.iterator(); it.hasNext(); ) {
- ((X509Certificate) it.next()).verify(publicKey);
- }
- }
- }
-
- // testing empty PkiPath structure (ASN.1 such as 0x30, 0x00)
- bais = new ByteArrayInputStream(
- (good[0][0] + "MAB=" + good[0][1]).getBytes("UTF-8")); // "MABCDEFG"
- assertEquals("The size of the list differs from expected",
- 0, factory.generateCertPath(bais, "PkiPath")
- .getCertificates().size());
-
- // testing with bad PEM content
- for (int i = 0; i < bad_content.length; i++) {
- bais = new ByteArrayInputStream(
- (good[0][0] + bad_content[i] + good[0][1]).getBytes("UTF-8"));
- try {
- factory.generateCertPath(bais);
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- bais = new ByteArrayInputStream(
- (good[0][0] + bad_content[i] + good[0][1]).getBytes("UTF-8"));
- try {
- factory.generateCertPath(bais, "PkiPath");
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- bais = new ByteArrayInputStream(
- (good[0][0] + bad_content[i] + good[0][1]).getBytes("UTF-8"));
- try {
- factory.generateCertPath(bais, "PKCS7");
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- }
-
- for (int i = 0; i < bad.length; i++) {
- bais = new ByteArrayInputStream(
- (bad[i][0] + pkiPath + bad[i][1]).getBytes("UTF-8"));
- try {
- factory.generateCertPath(bais);
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- bais = new ByteArrayInputStream(
- (bad[i][0] + pkiPath + bad[i][1]).getBytes("UTF-8"));
- try {
- factory.generateCertPath(bais, "PkiPath");
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- bais = new ByteArrayInputStream(
- (bad[i][0] + pkcs7so + bad[i][1]).getBytes("UTF-8"));
- try {
- factory.generateCertPath(bais, "PKCS7");
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- }
- }
- }
-
- /**
- * generateCertificates method testing.
- */
- public void testGenerateCertificates() throws Exception {
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
-
- // Testing the Certificates generation
- // on the base of PKCS7 SignedData object
- ByteArrayInputStream bais = new ByteArrayInputStream(
- Base64.decode(pkcs7so.getBytes("UTF-8")));
-
- Collection certs = factory.generateCertificates(bais);
- assertNotNull("Factory returned null on correct PKCS7 data", certs);
- assertEquals("The size of collection differs from expected",
- 2, certs.size());
-
- if (publicKey != null) {
- // verify the signatures
- for (Iterator i = certs.iterator(); i.hasNext(); ) {
- ((X509Certificate) i.next()).verify(publicKey);
- }
- }
- }
-
- /**
- * generateCertificates method testing.
- */
- public void testGenerateCertPath() throws Exception {
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
-
- // Testing the CertPath generation
- // on the base of PKCS7 SignedData object
- ByteArrayInputStream bais = new ByteArrayInputStream(
- Base64.decode(pkcs7so.getBytes("UTF-8")));
-
- Collection certPath =
- factory.generateCertPath(bais, "PKCS7").getCertificates();
- assertEquals("The size of collection differs from expected",
- 2, certPath.size());
-
- if (publicKey != null) {
- // verify the signatures
- for (Iterator i = certPath.iterator(); i.hasNext(); ) {
- ((X509Certificate) i.next()).verify(publicKey);
- }
- }
-
- // testing empty PkiPath structure (ASN.1 such as 0x30, 0x00)
- bais = new ByteArrayInputStream(new byte[] { (byte) 0x30, 0x00 });
- assertEquals("The size of the list differs from expected",
- 0, factory.generateCertPath(bais, "PkiPath")
- .getCertificates().size());
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParameters_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParameters_ImplTest.java
deleted file mode 100644
index ea6e9fd..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParameters_ImplTest.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.cert.PKIXBuilderParameters;
-import java.security.cert.PKIXParameters;
-import java.security.cert.X509CertSelector;
-
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>PKIXBuilderParameters</code> fields and methods
- */
-public class PKIXBuilderParameters_ImplTest extends TestCase {
- private static final int DEFAULT_MAX_PATH_LEN = 5;
-
- /**
- * Test #1 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
- * constructor<br>
- * Assertion: creates an instance of <code>PKIXBuilderParameters</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws KeyStoreException
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector01()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- // both parameters are valid and non-null
- PKIXParameters p =
- new PKIXBuilderParameters(ks, new X509CertSelector());
- assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
- assertNotNull("certSelector", p.getTargetCertConstraints());
- }
-
- /**
- * Test #2 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
- * constructor<br>
- * Assertion: creates an instance of <code>PKIXBuilderParameters</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws KeyStoreException
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector02()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- // both parameters are valid but CertSelector is null
- PKIXParameters p =
- new PKIXBuilderParameters(ks, null);
- assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
- assertNull("certSelector", p.getTargetCertConstraints());
- }
-
- /**
- * Test #3 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
- * constructor<br>
- * Assertion: Only keystore entries that contain trusted
- * <code>X509Certificates</code> are considered; all other
- * certificate types are ignored
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws KeyStoreException
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector03()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- // both parameters are valid but CertSelector is null
- PKIXParameters p =
- new PKIXBuilderParameters(ks, null);
- assertTrue("instanceof", p instanceof PKIXBuilderParameters);
- assertEquals("size", 1, p.getTrustAnchors().size());
- }
-
- /**
- * Test #5 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
- * constructor<br>
- * Assertion: <code>KeyStoreException</code> -
- * if the <code>keystore</code> has not been initialized
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector05() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(false, 0);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- try {
- // pass not initialized KeyStore
- new PKIXBuilderParameters(ks, null);
- fail("KeyStoreException expected");
- } catch (KeyStoreException e) {
- }
- }
-
- /**
- * Test #6 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
- * constructor<br>
- * Assertion: <code>InvalidAlgorithmParameterException</code> -
- * if the <code>keystore</code> does not contain at least one
- * trusted certificate entry
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector06() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- return;
- }
-
- try {
- // pass KeyStore that does not contain trusted certificates
- new PKIXBuilderParameters(ks, null);
- fail("InvalidAlgorithmParameterException expected");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- /**
- * Test for <code>getMaxPathLength()</code> method<br>
- * Assertion: The default maximum path length, if not specified, is 5
- *
- * @throws KeyStoreException
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testGetMaxPathLength01()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- PKIXBuilderParameters p = new PKIXBuilderParameters(ks, null);
- assertEquals(DEFAULT_MAX_PATH_LEN, p.getMaxPathLength());
- }
-
- /**
- * Test #1 for <code>setMaxPathLength(int)</code> method<br>
- * Assertion: sets the maximum number of non-self-signed certificates
- * in the cert path
- *
- * @throws KeyStoreException
- * @throws InvalidAlgorithmParameterException
- *
- */
- public final void testSetMaxPathLength01()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- // all these VALID maxPathLength values must be
- // set (and get) without exceptions
- int[] testPathLength = new int[] { -1, 0, 1, 999, Integer.MAX_VALUE };
- for (int i = 0; i < testPathLength.length; i++) {
- PKIXBuilderParameters p = new PKIXBuilderParameters(ks, null);
- p.setMaxPathLength(testPathLength[i]);
- assertEquals("i=" + i, testPathLength[i], p.getMaxPathLength());
- }
- }
-
- /**
- * Test #2 for <code>setMaxPathLength(int)</code> method<br>
- * Assertion: throws InvalidParameterException if parameter is
- * less than -1
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws KeyStoreException
- */
- public final void testSetMaxPathLength02()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- PKIXBuilderParameters p = new PKIXBuilderParameters(ks, null);
-
- try {
- // pass parameter less than -1
- p.setMaxPathLength(Integer.MIN_VALUE);
- fail("InvalidParameterException expected");
- } catch (InvalidParameterException e) {
- }
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * Assertion: returns string describing this object
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws KeyStoreException
- */
- public final void testToString()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- PKIXBuilderParameters p =
- new PKIXBuilderParameters(ks, new X509CertSelector());
- String rep = p.toString();
-
- assertNotNull(rep);
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXParameters_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXParameters_ImplTest.java
deleted file mode 100644
index 822df86..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXParameters_ImplTest.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertPathParameters;
-import java.security.cert.CertStore;
-import java.security.cert.CollectionCertStoreParameters;
-import java.security.cert.PKIXCertPathChecker;
-import java.security.cert.PKIXParameters;
-import java.security.cert.X509CertSelector;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>PKIXParameters</code> fields and methods
- */
-public class PKIXParameters_ImplTest extends TestCase {
-
- /**
- * Test #1 for <code>PKIXParameters(KeyStore)</code> constructor<br>
- * Assertion: Creates an instance of <code>PKIXParameters</code>
- * that populates the set of most-trusted CAs from the trusted
- * certificate entries contained in the specified <code>KeyStore</code>
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws KeyStoreException
- */
- public final void testPKIXParametersKeyStore01() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- // use valid parameter - KeyStore containing
- // only trusted X.509 certificates
- CertPathParameters cpp = new PKIXParameters(ks);
- assertTrue(cpp instanceof PKIXParameters);
- }
-
- /**
- * Test #2 for <code>PKIXParameters(KeyStore)</code> constructor<br>
- * Assertion: Only keystore entries that contain trusted
- * <code>X509Certificates</code> are considered; all other
- * certificate types are ignored
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws KeyStoreException
- */
- public final void testPKIXParametersKeyStore02() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- // use valid parameter - KeyStore containing
- // both trusted and untrusted X.509 certificates
- PKIXParameters cpp = new PKIXParameters(ks);
- assertEquals("size", 1, cpp.getTrustAnchors().size());
- }
-
- /**
- * Test #4 for <code>PKIXParameters(KeyStore)</code> constructor<br>
- * Assertion: <code>KeyStoreException</code> -
- * if the <code>keystore</code> has not been initialized
- */
- public final void testPKIXParametersKeyStore04() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(false, 0);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- try {
- // pass not initialized KeyStore
- new PKIXParameters(ks);
- fail("KeyStoreException expected");
- } catch (KeyStoreException e) {
- }
- }
-
- /**
- * Test #5 for <code>PKIXParameters(KeyStore)</code> constructor<br>
- * Assertion: <code>InvalidAlgorithmParameterException</code> -
- * if the <code>keystore</code> does not contain at least one
- * trusted certificate entry
- */
- public final void testPKIXParametersKeyStore05() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- try {
- // pass KeyStore that does not contain trusted certificates
- new PKIXParameters(ks);
- fail("InvalidAlgorithmParameterException expected");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- /**
- * Test #5 for <code>setTrustAnchors(Set)</code> method<br>
- * Assertion: <code>Set</code> is copied to protect against
- * subsequent modifications
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws KeyStoreException
- */
- public final void testSetTrustAnchors05() throws Exception {
- // use several trusted certs in this test
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- PKIXParameters p = new PKIXParameters(ks);
- // prepare new Set
- HashSet newSet = new HashSet(p.getTrustAnchors());
- HashSet newSetCopy = (HashSet) newSet.clone();
- // set new Set
- p.setTrustAnchors(newSetCopy);
- // modify set - remove one element
- assertTrue("modified", newSetCopy.remove(newSetCopy.iterator().next()));
- // check that set maintained internally has
- // not been changed by the above modification
- assertEquals("isCopied", newSet, p.getTrustAnchors());
- }
-
- /**
- * Test #1 for <code>clone()</code> method<br>
- * Assertion: Makes a copy of this <code>PKIXParameters</code> object
- *
- * @throws KeyStoreException
- * @throws InvalidAlgorithmParameterException
- *
- * @throws NoSuchAlgorithmException
- */
- public final void testClone01() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- PKIXParameters p1 = new PKIXParameters(ks);
- // set to some non-default values
- p1.setPolicyQualifiersRejected(false);
- p1.setAnyPolicyInhibited(true);
- p1.setExplicitPolicyRequired(true);
- p1.setPolicyMappingInhibited(true);
- p1.setRevocationEnabled(false);
-
- String sigProviderName = "Some Provider";
- p1.setSigProvider(sigProviderName);
-
- X509CertSelector x509cs = new X509CertSelector();
- p1.setTargetCertConstraints(x509cs);
-
- p1.setCertStores(TestUtils.getCollectionCertStoresList());
-
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
- List l = new ArrayList();
- assertTrue("addedOk", l.add(cpc));
- p1.setCertPathCheckers(l);
-
- p1.setDate(new Date(555L));
-
- Set s = new HashSet();
- s.add("1.2.3.4.5.6.7");
- s.add("1.2.3.4.5.6.8");
- p1.setInitialPolicies(s);
-
- // TrustAnchors already set
-
- PKIXParameters p2 = (PKIXParameters) p1.clone();
-
- // check that objects match
- assertEquals("check1", p1.getPolicyQualifiersRejected(),
- p2.getPolicyQualifiersRejected());
- assertEquals("check2", p1.isAnyPolicyInhibited(),
- p2.isAnyPolicyInhibited());
- assertEquals("check3", p1.isExplicitPolicyRequired(),
- p2.isExplicitPolicyRequired());
- assertEquals("check4", p1.isPolicyMappingInhibited(),
- p2.isPolicyMappingInhibited());
- assertEquals("check5", p1.isRevocationEnabled(),
- p2.isRevocationEnabled());
- assertEquals("check6", p1.getSigProvider(), p2.getSigProvider());
-
- // just check that not null
- assertNotNull("check7", p2.getTargetCertConstraints());
-
- assertEquals("check8", p1.getCertStores(), p2.getCertStores());
-
- // just check that not empty
- assertFalse("check9", p2.getCertPathCheckers().isEmpty());
-
- assertEquals("check10", p1.getDate(), p2.getDate());
- assertEquals("check11", p1.getInitialPolicies(),
- p2.getInitialPolicies());
- assertEquals("check12", p1.getTrustAnchors(), p2.getTrustAnchors());
- }
-
- /**
- * Test #2 for <code>clone()</code> method<br>
- * Assertion: Changes to the copy will not affect
- * the original and vice versa
- *
- * @throws KeyStoreException
- * @throws InvalidAlgorithmParameterException
- *
- * @throws NoSuchAlgorithmException
- */
- public final void testClone02() throws Exception {
- PKIXParameters[] p = new PKIXParameters[2];
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- for (int i = 0; i < p.length; i++) {
- p[i] = new PKIXParameters(ks);
-
- p[i].setCertStores(TestUtils.getCollectionCertStoresList());
-
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
- List l = new ArrayList();
- assertTrue("addedOk", l.add(cpc));
- p[i].setCertPathCheckers(l);
-
- p[i].setDate(new Date(555L));
-
- p[(i == 0 ? 1 : 0)] = (PKIXParameters) p[i].clone();
-
- // modify the first object (original or copy)
- p[1].addCertStore(CertStore.getInstance("Collection",
- new CollectionCertStoreParameters()));
- p[1].addCertPathChecker(TestUtils.getTestCertPathChecker());
- // check that the second object has not been affected by
- // above modification
- assertTrue("certStores[" + i + "]",
- p[0].getCertStores().size() == 1);
- assertTrue("certPathCheckers[" + i + "]",
- p[0].getCertPathCheckers().size() == 1);
- }
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * Assertion: Returns a formatted string describing the parameters
- *
- * @throws InvalidAlgorithmParameterException
- *
- * @throws KeyStoreException
- */
- public final void testToString() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- PKIXParameters p = new PKIXParameters(ks);
- assertNotNull(p.toString());
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchor_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchor_ImplTest.java
deleted file mode 100644
index bab59df..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchor_ImplTest.java
+++ /dev/null
@@ -1,760 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.PublicKey;
-import java.security.cert.TrustAnchor;
-import java.security.cert.X509Certificate;
-import java.security.spec.InvalidKeySpecException;
-import java.util.Arrays;
-
-import javax.security.auth.x500.X500Principal;
-
-import org.apache.harmony.security.tests.support.TestKeyPair;
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for <code>TrustAnchor</code>
- */
-public class TrustAnchor_ImplTest extends TestCase {
- private static final String keyAlg = "DSA";
- // Sample of some valid CA name
- private static final String validCaNameRfc2253 =
- "CN=Test CA," +
- "OU=Testing Division," +
- "O=Test It All," +
- "L=Test Town," +
- "ST=Testifornia," +
- "C=Testland";
-
- /**
- * Test #1 for <code>TrustAnchor(X509Certificate, byte[])</code> constructor<br>
- * Assertion: creates <code>TrustAnchor</code> instance<br>
- * Test preconditions: valid parameters passed<br>
- * Expected: must pass without any exceptions
- */
- public final void testTrustAnchorX509CertificatebyteArray01()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- // sub testcase 1
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- getFullEncoding());
- // sub testcase 2
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- getEncodingPSOnly());
- // sub testcase 3
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- getEncodingESOnly());
- // sub testcase 4
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- getEncodingNoMinMax());
- }
-
- /**
- * Test #2 for <code>TrustAnchor(X509Certificate, byte[])</code> constructor<br>
- * Assertion: creates <code>TrustAnchor</code> instance<br>
- * Test preconditions: <code>null</code> as nameConstraints passed<br>
- * Expected: must pass without any exceptions
- */
- public final void testTrustAnchorX509CertificatebyteArray02()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- null);
- }
-
- /**
- * Test #3 for <code>TrustAnchor(X509Certificate, byte[])</code> constructor<br>
- * Assertion: nameConstraints cloned by the constructor<br>
- * Test preconditions: modify passed nameConstraints<br>
- * Expected: modification must not change object internal state
- */
- public final void testTrustAnchorX509CertificatebyteArray03()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- byte[] nc = getEncodingPSOnly();
- byte[] ncCopy = nc.clone();
- // sub testcase 5 - nameConstraints can be null
- TrustAnchor ta = new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- ncCopy);
- // modify
- ncCopy[0] = (byte) 0;
- // check that above modification did not change
- // object internal state
- assertTrue(Arrays.equals(nc, ta.getNameConstraints()));
- }
-
- /**
- * Test #4 for <code>TrustAnchor(X509Certificate, byte[])</code> constructor<br>
- * Assertion: <code>NullPointerException</code> if <code>X509Certificate</code>
- * parameter is <code>null</code><br>
- * Test preconditions: pass <code>null</code> as <code>X509Certificate</code><br>
- * Expected: NullPointerException
- */
- public final void testTrustAnchorX509CertificatebyteArray04()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- try {
- new TrustAnchor(null, getFullEncoding());
- fail("NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test #5 for <code>TrustAnchor(X509Certificate, byte[])</code> constructor<br>
- * Assertion: <code>IllegalArgumentException</code> if nameConstraints
- * parameter can not be decoded<br>
- * Test preconditions: pass invalid nameConstraints encoding<br>
- * Expected: IllegalArgumentException
- */
- public final void testTrustAnchorX509CertificatebyteArray05()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
-
- // sub testcase 1:
- byte[] nameConstraints = getFullEncoding();
- // corrupt encoding:
- // set wrong root seq length
- nameConstraints[2] = (byte) 0x8d;
- try {
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 2:
- nameConstraints = getFullEncoding();
- // corrupt encoding:
- // set wrong root seq length
- nameConstraints[2] = (byte) 0x8b;
- try {
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 3:
- nameConstraints = getFullEncoding();
- // corrupt encoding:
- // remove right class from seq tag
- nameConstraints[3] &= (byte) 0x3f;
- try {
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 4:
- nameConstraints = getEncodingESOnly();
- // corrupt encoding:
- // set wrong tagged value (excludedSubtrees SEQ OF) tag [2]
- nameConstraints[2] = (byte) 0xa2;
- try {
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 5:
- nameConstraints = getEncodingESOnly();
- // corrupt encoding:
- // remove CONSTRUCTED flag from tagged value (excludedSubtrees SEQ OF) tag
- nameConstraints[2] &= (byte) 0xdf;
- try {
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 6:
- nameConstraints = getEncodingESOnly();
- // corrupt encoding:
- // set CONSTRUCTED flag for PROMITIVE tagged value tag
- // (generalSubtree's 'base' as IA5String)
- nameConstraints[5] |= (byte) 0x20;
- try {
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 7:
- nameConstraints = getEncodingESOnly();
- // corrupt encoding:
- // remove scheme from URI
- // (generalSubtree's 'base' as IA5String (uniformResourceIdentifier))
- nameConstraints[12] = nameConstraints[13] = nameConstraints[14] =
- (byte) 0x6f;
- try {
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test #6 for <code>TrustAnchor(X509Certificate, byte[])</code> constructor<br>
- * Assertion: creates <code>TrustAnchor</code> instance<br>
- * Test preconditions: valid parameters passed (base as OID)<br>
- * Expected: must pass without any exceptions
- */
- public final void testTrustAnchorX509CertificatebyteArray06()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- byte[] nameConstraints = getEncodingOid();
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- nameConstraints);
- }
-
- /**
- * Test #7 for <code>TrustAnchor(X509Certificate, byte[])</code> constructor<br>
- * Assertion: <code>IllegalArgumentException</code> if nameConstraints
- * parameter can not be decoded<br>
- * Test preconditions: pass invalid nameConstraints (OID) encoding<br>
- * Expected: IllegalArgumentException
- */
- public final void testTrustAnchorX509CertificatebyteArray07()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- byte[] nameConstraints = getEncodingOid();
- //corrupt Oid
- nameConstraints[10] = (byte) 0xFF;
- try {
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test #8 for <code>TrustAnchor(X509Certificate, byte[])</code> constructor<br>
- * Assertion: <code>IllegalArgumentException</code> if nameConstraints
- * parameter can not be decoded<br>
- * Test preconditions: pass invalid nameConstraints encodings<br>
- * Expected: IllegalArgumentException
- */
- public final void testTrustAnchorX509CertificatebyteArray08()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- // GeneralName tags for this test (1,2 and 3 are omitted)
- byte[] generalNameTag = new byte[] {
- (byte) 0xa0, (byte) 0xa4, (byte) 0xa5,
- (byte) 0x86, (byte) 0x87, (byte) 0x88
- };
- // wrong (for above tags) nameConstraints encoding
- byte[] wrongEncoding = new byte[] {
- (byte) 0x30, (byte) 0x0c, // sequence + length
- (byte) 0xa1, (byte) 0x0a, // excluded subtrees, tag, len
- (byte) 0x30, (byte) 0x08, // sequence of, tag, len
- (byte) 0xa0, // element 6 - tag identifying GeneralName choice
- (byte) 0x03, // GeneralName length
- (byte) 0x01, (byte) 0x01, (byte) 0xff, // wrong GeneralName for any choice
- (byte) 0x80, (byte) 0x01, (byte) 0x00 // minimum
- };
- for (int i = 0; i < generalNameTag.length; i++) {
- wrongEncoding[6] = generalNameTag[i];
- try {
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- wrongEncoding);
- fail("IllegalArgumentException has not been thrown for tag " +
- (generalNameTag[i] & 0xff));
- } catch (IllegalArgumentException ok) {
- }
- }
- }
-
- /**
- * Test #9 for <code>TrustAnchor(X509Certificate, byte[])</code> constructor<br>
- * Assertion: <code>IllegalArgumentException</code> if nameConstraints
- * parameter can not be decoded<br>
- * Test preconditions: pass valid and then invalid nameConstraints encodings
- * (GeneralName choice is [0] OtherName)<br>
- * Expected: no exception for valid encoding and IllegalArgumentException for invalid
- *
- * @throws KeyStoreException
- */
- public final void testTrustAnchorX509CertificatebyteArray09()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- byte[] encoding = new byte[] {
- (byte) 0x30, (byte) 0x13, (byte) 0xa1, (byte) 0x11,
- (byte) 0x30, (byte) 0x0f, (byte) 0xa0, (byte) 0x0a,
- (byte) 0x06, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x02,
- (byte) 0xA0, (byte) 0x03, 1, 1, (byte) 0xff,
- (byte) 0x80, (byte) 0x01, (byte) 0x00
- };
- try {
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias), encoding);
- } catch (IllegalArgumentException failed) {
- fail("valid encoding not accepted");
- }
- // now corrupt encoding: set OtherName value tag to 1 (must be 0)
- encoding[13] = 1;
- try {
- new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias), encoding);
- fail("invalid encoding accepted");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test for <code>getNameConstraints()</code> method<br>
- * Assertion: returns <code>nameConstraints</code> der encoding<br>
- * Test preconditions: valid nameConstraints parameter passed (not null)<br>
- * Expected: encoding passed to the ctor must match returned one<br>
- * Assertion: returns new <code>nameConstraints</code> der encoding each time<br>
- * Test preconditions: valid nameConstraints parameter passed (not null)<br>
- * Expected: must return new reference each time called
- */
- public final void testGetNameConstraints()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- byte[] nc = getFullEncoding();
- // sub testcase 1
- TrustAnchor ta = new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias), nc);
- byte[] ncRet = ta.getNameConstraints();
- // assert 1
- assertTrue(Arrays.equals(nc, ncRet));
- assertNotSame(nc, ncRet);
- // assert 2
- assertNotSame(ncRet, ta.getNameConstraints());
- }
-
- /**
- * Test #2 for <code>getCAName()</code> method<br>
- * <p/>
- * Assertion: returns ... <code>null</code> if <code>TrustAnchor</code>
- * was not specified as public key and CA name or CA principal pair<br>
- * Test preconditions: test object is not specified as public key
- * and CA name or CA principal pair<br>
- * Expected: <code>null</code> as return value<br>
- *
- * @throws KeyStoreException
- */
- public final void testGetCAPublicKey02()
- throws InvalidKeySpecException, KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- TrustAnchor ta = new TrustAnchor(
- (X509Certificate) ks.getCertificate("testca1"),
- null);
- assertNull(ta.getCAPublicKey());
- }
-
- /**
- * Test #2 for <code>getCAName()</code> method<br>
- * <p/>
- * Assertion: returns ... <code>null</code> if <code>TrustAnchor</code>
- * was not specified as public key and CA name or CA principal pair<br>
- * Test preconditions: test object is not specified as public key
- * and CA name or CA principal pair<br>
- * Expected: <code>null</code> as return value<br>
- *
- * @throws KeyStoreException
- */
- public final void testGetCAName02()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- TrustAnchor ta = new TrustAnchor(
- (X509Certificate) ks.getCertificate("testca1"),
- null);
- assertNull(ta.getCAName());
- }
-
- /**
- * Test #1 for <code>getCAName()</code> method<br>
- * <p/>
- * Assertion: returns most trusted CA certificate<br>
- * Test preconditions: valid certificate passed to the constructor<br>
- * Expected: the same certificate must be returned by the method<br>
- *
- * @throws KeyStoreException
- */
- public final void testGetTrustedCert01()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- X509Certificate cert =
- (X509Certificate) ks.getCertificate("testca1");
- TrustAnchor ta = new TrustAnchor(cert, null);
- assertEquals(cert, ta.getTrustedCert());
- }
-
- /**
- * Test #2 for <code>getCA()</code> method<br>
- * <p/>
- * Assertion: returns ... <code>null</code> if <code>TrustAnchor</code>
- * was not specified as public key and CA name or CA principal pair<br>
- * Test preconditions: test object is not specified as public key
- * and CA name or CA principal pair<br>
- * Expected: <code>null</code> as return value<br>
- *
- * @throws KeyStoreException
- */
- public final void testGetCA02()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- TrustAnchor ta = new TrustAnchor(
- (X509Certificate) ks.getCertificate("testca1"),
- null);
- assertNull(ta.getCA());
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * <p/>
- * Assertion: returns string representation of this <code>TrustAnchor</code>
- * Test preconditions: several valid test objects created<br>
- * Expected: method returns not <code>null</code> in all cases<br>
- */
- public final void testToString() throws Exception {
-
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "test";
-
- // sub testcase 1
- TrustAnchor ta = new TrustAnchor(
- (X509Certificate) ks.getCertificate(certAlias),
- getFullEncoding());
-
- assertNotNull("#1", ta.toString());
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
-
- // sub testcase 2
- ta = new TrustAnchor(validCaNameRfc2253, pk, getEncodingESOnly());
-
- assertNotNull("#2", ta.toString());
-
- // sub testcase 3
- X500Principal x500p = new X500Principal(validCaNameRfc2253);
- ta = new TrustAnchor(x500p, pk, getEncodingNoMinMax());
-
- assertNotNull("#3", ta.toString());
-
- // sub testcase 4
- ta = new TrustAnchor(x500p, pk, null);
- assertNotNull("#4", ta.toString());
- }
-
- //
- // Private stuff
- //
-
- /*
- * The following methods return valid DER encoding
- * for the following ASN.1 definition (as specified in RFC 3280 -
- * Internet X.509 Public Key Infrastructure.
- * Certificate and Certificate Revocation List (CRL) Profile.
- * http://www.ietf.org/rfc/rfc3280.txt):
- *
- * NameConstraints ::= SEQUENCE {
- * permittedSubtrees [0] GeneralSubtrees OPTIONAL,
- * excludedSubtrees [1] GeneralSubtrees OPTIONAL }
- *
- * GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree
- *
- * GeneralSubtree ::= SEQUENCE {
- * base GeneralName,
- * minimum [0] BaseDistance DEFAULT 0,
- * maximum [1] BaseDistance OPTIONAL }
- *
- * BaseDistance ::= INTEGER (0..MAX)
- *
- * GeneralName ::= CHOICE {
- * otherName [0] OtherName,
- * rfc822Name [1] IA5String,
- * dNSName [2] IA5String,
- * x400Address [3] ORAddress,
- * directoryName [4] Name,
- * ediPartyName [5] EDIPartyName,
- * uniformResourceIdentifier [6] IA5String,
- * iPAddress [7] OCTET STRING,
- * registeredID [8] OBJECT IDENTIFIER}
- */
-
- //
- // Full NameConstraints encoding
- // (generated by own encoder class created during test development)
- //
- // @return Full NameConstraints encoding
- // with all OPTIONAL values presented.
- //
- private static final byte[] getFullEncoding() {
- // DO NOT MODIFY!
- return new byte[] {
- (byte) 0x30, (byte) 0x81, (byte) 0x8c, (byte) 0xa0,
- (byte) 0x44, (byte) 0x30, (byte) 0x16, (byte) 0x86,
- (byte) 0x0e, (byte) 0x66, (byte) 0x69, (byte) 0x6c,
- (byte) 0x65, (byte) 0x3a, (byte) 0x2f, (byte) 0x2f,
- (byte) 0x66, (byte) 0x6f, (byte) 0x6f, (byte) 0x2e,
- (byte) 0x63, (byte) 0x6f, (byte) 0x6d, (byte) 0x80,
- (byte) 0x01, (byte) 0x00, (byte) 0x81, (byte) 0x01,
- (byte) 0x01, (byte) 0x30, (byte) 0x16, (byte) 0x86,
- (byte) 0x0e, (byte) 0x66, (byte) 0x69, (byte) 0x6c,
- (byte) 0x65, (byte) 0x3a, (byte) 0x2f, (byte) 0x2f,
- (byte) 0x62, (byte) 0x61, (byte) 0x72, (byte) 0x2e,
- (byte) 0x63, (byte) 0x6f, (byte) 0x6d, (byte) 0x80,
- (byte) 0x01, (byte) 0x00, (byte) 0x81, (byte) 0x01,
- (byte) 0x01, (byte) 0x30, (byte) 0x12, (byte) 0x86,
- (byte) 0x0a, (byte) 0x66, (byte) 0x69, (byte) 0x6c,
- (byte) 0x65, (byte) 0x3a, (byte) 0x2f, (byte) 0x2f,
- (byte) 0x6d, (byte) 0x75, (byte) 0x75, (byte) 0x80,
- (byte) 0x01, (byte) 0x00, (byte) 0x81, (byte) 0x01,
- (byte) 0x01, (byte) 0xa1, (byte) 0x44, (byte) 0x30,
- (byte) 0x16, (byte) 0x86, (byte) 0x0e, (byte) 0x68,
- (byte) 0x74, (byte) 0x74, (byte) 0x70, (byte) 0x3a,
- (byte) 0x2f, (byte) 0x2f, (byte) 0x66, (byte) 0x6f,
- (byte) 0x6f, (byte) 0x2e, (byte) 0x63, (byte) 0x6f,
- (byte) 0x6d, (byte) 0x80, (byte) 0x01, (byte) 0x00,
- (byte) 0x81, (byte) 0x01, (byte) 0x01, (byte) 0x30,
- (byte) 0x16, (byte) 0x86, (byte) 0x0e, (byte) 0x68,
- (byte) 0x74, (byte) 0x74, (byte) 0x70, (byte) 0x3a,
- (byte) 0x2f, (byte) 0x2f, (byte) 0x62, (byte) 0x61,
- (byte) 0x72, (byte) 0x2e, (byte) 0x63, (byte) 0x6f,
- (byte) 0x6d, (byte) 0x80, (byte) 0x01, (byte) 0x00,
- (byte) 0x81, (byte) 0x01, (byte) 0x01, (byte) 0x30,
- (byte) 0x12, (byte) 0x86, (byte) 0x0a, (byte) 0x68,
- (byte) 0x74, (byte) 0x74, (byte) 0x70, (byte) 0x3a,
- (byte) 0x2f, (byte) 0x2f, (byte) 0x6d, (byte) 0x75,
- (byte) 0x75, (byte) 0x80, (byte) 0x01, (byte) 0x00,
- (byte) 0x81, (byte) 0x01, (byte) 0x01
- };
- }
-
- //
- // NameConstraints encoding without excludedSubtrees
- // (generated by own encoder class created during test development)
- //
- // @return NameConstraints encoding with
- // permittedSubtrees only; all OPTIONAL
- // values in permittedSubtrees are presented.
- //
- private static final byte[] getEncodingPSOnly() {
- // DO NOT MODIFY!
- return new byte[] {
- (byte) 0x30, (byte) 0x46, (byte) 0xa0, (byte) 0x44,
- (byte) 0x30, (byte) 0x16, (byte) 0x86, (byte) 0x0e,
- (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x66,
- (byte) 0x6f, (byte) 0x6f, (byte) 0x2e, (byte) 0x63,
- (byte) 0x6f, (byte) 0x6d, (byte) 0x80, (byte) 0x01,
- (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x01,
- (byte) 0x30, (byte) 0x16, (byte) 0x86, (byte) 0x0e,
- (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x62,
- (byte) 0x61, (byte) 0x72, (byte) 0x2e, (byte) 0x63,
- (byte) 0x6f, (byte) 0x6d, (byte) 0x80, (byte) 0x01,
- (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x01,
- (byte) 0x30, (byte) 0x12, (byte) 0x86, (byte) 0x0a,
- (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x6d,
- (byte) 0x75, (byte) 0x75, (byte) 0x80, (byte) 0x01,
- (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x01,
- };
- }
-
- //
- // NameConstraints encoding without permittedSubtrees
- // (generated by own encoder class created during test development)
- //
- // @return NameConstraints encoding with
- // excludedSubtrees only; all OPTIONAL
- // values in excludedSubtrees are presented.
- //
- private static final byte[] getEncodingESOnly() {
- // DO NOT MODIFY!
- return new byte[] {
- (byte) 0x30, (byte) 0x46, (byte) 0xa1, (byte) 0x44,
- (byte) 0x30, (byte) 0x16, (byte) 0x86, (byte) 0x0e,
- (byte) 0x68, (byte) 0x74, (byte) 0x74, (byte) 0x70, // http
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x66, // ://f
- (byte) 0x6f, (byte) 0x6f, (byte) 0x2e, (byte) 0x63, // oo.c
- (byte) 0x6f, (byte) 0x6d, (byte) 0x80, (byte) 0x01, // om
- (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x01,
- (byte) 0x30, (byte) 0x16, (byte) 0x86, (byte) 0x0e,
- (byte) 0x68, (byte) 0x74, (byte) 0x74, (byte) 0x70,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x62,
- (byte) 0x61, (byte) 0x72, (byte) 0x2e, (byte) 0x63,
- (byte) 0x6f, (byte) 0x6d, (byte) 0x80, (byte) 0x01,
- (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x01,
- (byte) 0x30, (byte) 0x12, (byte) 0x86, (byte) 0x0a,
- (byte) 0x68, (byte) 0x74, (byte) 0x74, (byte) 0x70,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x6d,
- (byte) 0x75, (byte) 0x75, (byte) 0x80, (byte) 0x01,
- (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x01,
- };
- }
-
- //
- // NameConstraints full encoding with all (OPTIONAL)
- // minimum/maximum GeneralSubtree fields OMITTED
- // (generated by own encoder class created during test development)
- //
- // @return Full NameConstraints encoding
- // with all (OPTIONAL) minimum/maximum
- // GeneralSubtree fields OMITTED
- //
- private static final byte[] getEncodingNoMinMax() {
- // DO NOT MODIFY!
- return new byte[] {
- (byte) 0x30, (byte) 0x68, (byte) 0xa0, (byte) 0x32,
- (byte) 0x30, (byte) 0x10, (byte) 0x86, (byte) 0x0e,
- (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x66,
- (byte) 0x6f, (byte) 0x6f, (byte) 0x2e, (byte) 0x63,
- (byte) 0x6f, (byte) 0x6d, (byte) 0x30, (byte) 0x10,
- (byte) 0x86, (byte) 0x0e, (byte) 0x66, (byte) 0x69,
- (byte) 0x6c, (byte) 0x65, (byte) 0x3a, (byte) 0x2f,
- (byte) 0x2f, (byte) 0x62, (byte) 0x61, (byte) 0x72,
- (byte) 0x2e, (byte) 0x63, (byte) 0x6f, (byte) 0x6d,
- (byte) 0x30, (byte) 0x0c, (byte) 0x86, (byte) 0x0a,
- (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x6d,
- (byte) 0x75, (byte) 0x75, (byte) 0xa1, (byte) 0x32,
- (byte) 0x30, (byte) 0x10, (byte) 0x86, (byte) 0x0e,
- (byte) 0x68, (byte) 0x74, (byte) 0x74, (byte) 0x70,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x66,
- (byte) 0x6f, (byte) 0x6f, (byte) 0x2e, (byte) 0x63,
- (byte) 0x6f, (byte) 0x6d, (byte) 0x30, (byte) 0x10,
- (byte) 0x86, (byte) 0x0e, (byte) 0x68, (byte) 0x74,
- (byte) 0x74, (byte) 0x70, (byte) 0x3a, (byte) 0x2f,
- (byte) 0x2f, (byte) 0x62, (byte) 0x61, (byte) 0x72,
- (byte) 0x2e, (byte) 0x63, (byte) 0x6f, (byte) 0x6d,
- (byte) 0x30, (byte) 0x0c, (byte) 0x86, (byte) 0x0a,
- (byte) 0x68, (byte) 0x74, (byte) 0x74, (byte) 0x70,
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x6d,
- (byte) 0x75, (byte) 0x75,
- };
- }
-
- // Returns OID encoding
- // (generated by own encoder class created during test development)
- private static final byte[] getEncodingOid() {
- // DO NOT MODIFY!
- return new byte[] {
- (byte) 0x30, (byte) 0x09, (byte) 0xA0, (byte) 0x07,
- (byte) 0x30, (byte) 0x05, (byte) 0x88, (byte) 0x03,
- (byte) 0x2A, (byte) 0x03, (byte) 0x04
- };
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2m_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2m_ImplTest.java
deleted file mode 100644
index 5cfe539..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2m_ImplTest.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.ECFieldF2m;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ECFieldF2m</code> class fields and methods.
- */
-public class ECFieldF2m_ImplTest extends TestCase {
-
- /**
- * Support class for this test.
- * Encapsulates <code>ECFieldF2m</code> testing
- * domain parameters.
- */
- private static final class ECFieldF2mDomainParams {
-
- /**
- * <code>NPE</code> reference object of class NullPointerException.
- * NullPointerException must be thrown by <code>ECFieldF2m</code>
- * ctors in some circumstances
- */
- static final NullPointerException NPE = new NullPointerException();
- /**
- * <code>IArgE</code> reference object of class IllegalArgumentException.
- * IllegalArgumentException must be thrown by <code>ECFieldF2m</code>
- * ctors in some circumstances
- */
- static final IllegalArgumentException IArgE = new IllegalArgumentException();
-
- /**
- * The <code>m</code> parameter for <code>ECFieldF2m</code>
- * ctor for the current test.
- */
- final int m;
- /**
- * The <code>rp</code> parameter for <code>ECFieldF2m</code>
- * ctor for the current test.
- */
- final BigInteger rp;
- /**
- * The <code>ks</code> parameter for <code>ECFieldF2m</code>
- * ctor for the current test.
- */
- final int[] ks;
-
-
- /**
- * Exception expected with this parameters set or <code>null</code>
- * if no exception expected.
- */
- final Exception x;
-
- /**
- * Constructs ECFieldF2mDomainParams
- *
- * @param m
- * @param rp
- * @param ks
- * @param expectedException
- */
- ECFieldF2mDomainParams(final int m,
- final BigInteger rp,
- final int[] ks,
- final Exception expectedException) {
- this.m = m;
- this.rp = rp;
- this.ks = ks;
- this.x = expectedException;
- }
- }
-
-
- /**
- * Set of parameters used for <code>ECFieldF2m(int, BigInteger)</code>
- * constructor tests.
- */
- private final ECFieldF2mDomainParams[] intBigIntegerCtorTestParameters =
- new ECFieldF2mDomainParams[] {
- // set 0: valid m and rp - trinomial basis params
- new ECFieldF2mDomainParams(
- 1999,
- BigInteger.valueOf(0L).setBit(0).setBit(367).setBit(1999),
- null,
- null),
- // set 1: valid m and rp - pentanomial basis params
- new ECFieldF2mDomainParams(
- 2000,
- BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).setBit(981).setBit(2000),
- null,
- null),
- // set 2: valid m, invalid (null) rp
- new ECFieldF2mDomainParams(
- 1963,
- (BigInteger) null,
- null,
- ECFieldF2mDomainParams.NPE),
- // set 3: valid m, invalid rp - bit 0 not set
- new ECFieldF2mDomainParams(
- 1999,
- BigInteger.valueOf(0L).setBit(1).setBit(367).setBit(1999),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 4: valid m, invalid rp - bit m not set
- new ECFieldF2mDomainParams(
- 1999,
- BigInteger.valueOf(0L).setBit(0).setBit(367).setBit(1998),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 5: valid m, invalid rp - bit k improperly set
- new ECFieldF2mDomainParams(
- 1999,
- BigInteger.valueOf(0L).setBit(0).setBit(2367).setBit(1999),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 6: valid m, invalid rp - k1 k2 k3
- new ECFieldF2mDomainParams(
- 2000,
- BigInteger.valueOf(0L).setBit(0).setBit(2001).setBit(2002).setBit(2003).setBit(2000),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 7: valid m, invalid rp - number of bits set
- new ECFieldF2mDomainParams(
- 2000,
- BigInteger.valueOf(0L).setBit(0).setBit(2000),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 8: valid m, invalid rp - number of bits set
- new ECFieldF2mDomainParams(
- 2000,
- BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).setBit(2000),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 9: valid m, invalid rp - number of bits set
- new ECFieldF2mDomainParams(
- 2000,
- BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).
- setBit(981).setBit(985).setBit(2000),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 10: valid m, invalid rp
- new ECFieldF2mDomainParams(
- 2000,
- BigInteger.valueOf(0L),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 11: invalid m
- new ECFieldF2mDomainParams(
- -2000,
- BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).
- setBit(981).setBit(2000),
- null,
- ECFieldF2mDomainParams.IArgE),
- };
-
- /**
- * Tests for constructor <code>ECFieldF2m(int, BigInteger)</code><br>
- * <p/>
- * Assertion: constructs new <code>ECFieldF2m</code> object
- * using valid parameters m and rp. rp represents trinomial basis.
- * <p/>
- * Assertion: constructs new <code>ECFieldF2m</code> object
- * using valid parameters m and rp. rp represents pentanomial basis.
- * <p/>
- * Assertion: IllegalArgumentException if m is not positive.
- * <p/>
- * Assertion: NullPointerException if rp is null.
- * <p/>
- * Assertion: IllegalArgumentException if rp is invalid.
- */
- public final void testECFieldF2mintBigInteger() {
- for (int i = 0; i < intBigIntegerCtorTestParameters.length; i++) {
- ECFieldF2mDomainParams tp = intBigIntegerCtorTestParameters[i];
- try {
- // perform test
- new ECFieldF2m(tp.m, tp.rp);
-
- if (tp.x != null) {
- // exception has been expected
- fail(getName() + ", set " + i +
- " FAILED: expected exception has not been thrown");
- }
- } catch (Exception e) {
- if (tp.x == null || !e.getClass().isInstance(tp.x)) {
- // exception: failure
- // if it has not been expected
- // or wrong one has been thrown
- fail(getName() + ", set " + i +
- " FAILED: unexpected " + e);
- }
- }
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECParameterSpec_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECParameterSpec_ImplTest.java
deleted file mode 100644
index b9fafe5..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECParameterSpec_ImplTest.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.ECFieldFp;
-import java.security.spec.ECParameterSpec;
-import java.security.spec.ECPoint;
-import java.security.spec.EllipticCurve;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ECParameterSpec</code> class fields and methods.
- */
-public class ECParameterSpec_ImplTest extends TestCase {
-
- //
- // Tests
- //
- // NOTE: the following tests use EC domain parameters
- // which are invalid for real EC cryptography application
- // but must be acceptable by the class under test according
- // to the API specification
- //
-
- /**
- * Test #1 for <code>ECParameterSpec(EllipticCurve, ECPoint, BigInteger, int)</code> constructor<br>
- * Assertion: creates <code>ECParameterSpec</code> instance<br>
- * Test preconditions: valid parameters passed<br>
- * Expected: must pass without any exceptions
- */
- public final void testECParameterSpec01() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
- }
-
- /**
- * Test #2 for <code>ECParameterSpec(EllipticCurve, ECPoint, BigInteger, int)</code> constructor<br>
- * Assertion: throws <code>NullPointerException</code> if
- * <code>curve</code>, <code>generator</code> or <code>order</code> is <code>null</code><br>
- * Test preconditions: pass <code>null</code> as mentioned parameters<br>
- * Expected: must throw <code>NullPointerException</code>
- */
- public final void testECParameterSpec02() {
- // Valid (see note below) parameters set
- EllipticCurve curve =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- BigInteger order = BigInteger.valueOf(5L);
-
- // Test case 1: curve is null
- try {
- new ECParameterSpec(null, generator, order, 10);
- fail("#1: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 2: generator is null
- try {
- new ECParameterSpec(curve, null, order, 10);
- fail("#2: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 3: order is null
- try {
- new ECParameterSpec(curve, generator, null, 10);
- fail("#3: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 4: all above are null
- try {
- new ECParameterSpec(null, null, null, 10);
- fail("#4: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test #3 for <code>ECParameterSpec(EllipticCurve, ECPoint, BigInteger, int)</code> constructor<br>
- * Assertion: throws <code>IllegalArgumentException</code> if
- * <code>order</code> or <code>cofactor</code> is not positive<br>
- * Test preconditions: pass not positive as mentioned parameters<br>
- * Expected: must throw <code>IllegalArgumentException</code>
- */
- public final void testECParameterSpec03() {
- // Valid (see note below) parameters set
- EllipticCurve curve =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
-
-
- // Test case 1: order is negative
- try {
- new ECParameterSpec(curve, generator, BigInteger.valueOf(-5L), 10);
- fail("#1: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
-
- // Test case 2: order == 0
- try {
- new ECParameterSpec(curve, generator, BigInteger.ZERO, 10);
- fail("#2: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
-
- // Test case 3: cofactor is negative
- try {
- new ECParameterSpec(curve, generator, BigInteger.valueOf(5L), -10);
- fail("#3: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
-
- // Test case 4: cofactor == 0
- try {
- new ECParameterSpec(curve, generator, BigInteger.valueOf(5L), 0);
- fail("#4: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
-
- // Test case 5: both order and cofactor are not positive
- try {
- new ECParameterSpec(curve, generator, BigInteger.valueOf(-5L), 0);
- fail("#5: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test for <code>getCofactor()</code> method<br>
- * Assertion: returns cofactor<br>
- * Test preconditions: <code>ECParameterSpec</code> instance
- * created using valid parameters<br>
- * Expected: must return cofactor value which is equal
- * to the one passed to the constructor
- */
- public final void testGetCofactor() {
- // Valid (see note below) parameters set
- EllipticCurve curve =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- BigInteger order = BigInteger.valueOf(5L);
- int cofactor = 10;
- ECParameterSpec ps =
- new ECParameterSpec(curve, generator, order, cofactor);
- assertEquals(cofactor, ps.getCofactor());
- }
-
- /**
- * Test for <code>getCurve()</code> method<br>
- * Assertion: returns curve<br>
- * Test preconditions: <code>ECParameterSpec</code> instance
- * created using valid parameters<br>
- * Expected: must return ref to the <code>EllipticCurve</code> object
- * which is equal to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetCurve() {
- // Valid (see note below) parameters set
- EllipticCurve curve =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- BigInteger order = BigInteger.valueOf(5L);
- int cofactor = 10;
- ECParameterSpec ps =
- new ECParameterSpec(curve, generator, order, cofactor);
- EllipticCurve curveRet = ps.getCurve();
- assertEquals(curve, curveRet);
- assertSame(curve, curveRet);
- }
-
- /**
- * Test for <code>getGenerator()</code> method<br>
- * Assertion: returns generator<br>
- * Test preconditions: <code>ECParameterSpec</code> instance
- * created using valid parameters<br>
- * Expected: must return ref to the <code>ECPoint</code> object
- * which is equal to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetGenerator() {
- // Valid (see note below) parameters set
- EllipticCurve curve =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- BigInteger order = BigInteger.valueOf(5L);
- int cofactor = 10;
- ECParameterSpec ps =
- new ECParameterSpec(curve, generator, order, cofactor);
- ECPoint generatorRet = ps.getGenerator();
- assertEquals(generator, generatorRet);
- assertSame(generator, generatorRet);
- }
-
- /**
- * Test for <code>getOrder()</code> method<br>
- * Assertion: returns order<br>
- * Test preconditions: <code>ECParameterSpec</code> instance
- * created using valid parameters<br>
- * Expected: must return ref to the <code>BigInteger</code> object
- * which is equal to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetOrder() {
- // Valid (see note below) parameters set
- EllipticCurve curve =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- BigInteger order = BigInteger.valueOf(5L);
- int cofactor = 10;
- ECParameterSpec ps =
- new ECParameterSpec(curve, generator, order, cofactor);
- BigInteger orderRet = ps.getOrder();
- assertEquals(order, orderRet);
- assertSame(order, orderRet);
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPrivateKeySpec_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPrivateKeySpec_ImplTest.java
deleted file mode 100644
index 57d9390..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPrivateKeySpec_ImplTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.ECFieldFp;
-import java.security.spec.ECParameterSpec;
-import java.security.spec.ECPoint;
-import java.security.spec.ECPrivateKeySpec;
-import java.security.spec.EllipticCurve;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ECPrivateKeySpec</code> class fields and methods.
- */
-public class ECPrivateKeySpec_ImplTest extends TestCase {
-
- //
- // Tests
- //
- // NOTE: the following tests use EC domain parameters
- // which are invalid for real EC cryptography application
- // but must be acceptable by the class under test according
- // to the API specification
- //
-
- /**
- * Test #1 for <code>ECPrivateKeySpec(BigInteger, ECParameterSpec)</code> constructor<br>
- * Assertion: creates <code>ECPrivateKeySpec</code> instance<br>
- * Test preconditions: valid parameters passed<br>
- * Expected: must pass without any exceptions
- */
- public final void testECPrivateKeySpec01() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- new ECPrivateKeySpec(BigInteger.ZERO,
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
-
- }
-
- /**
- * Test #2 for <code>ECPrivateKeySpec(BigInteger, ECParameterSpec)</code> constructor<br>
- * Assertion: throws <code>NullPointerException</code> if
- * <code>s</code> or <code>params</code> is <code>null</code><br>
- * Test preconditions: pass <code>null</code> as mentioned parameters<br>
- * Expected: must throw <code>NullPointerException</code>
- */
- public final void testECPrivateKeySpec02() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
-
- // Test case 1: s is null
- try {
- new ECPrivateKeySpec(null,
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
- fail("#1: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 2: params is null
- try {
- new ECPrivateKeySpec(BigInteger.valueOf(0L), null);
- fail("#2: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 3: both s and params are null
- try {
- new ECPrivateKeySpec(null, null);
- fail("#3: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test for <code>getParams()</code> method<br>
- * Assertion: returns associated EC parameters<br>
- * Test preconditions: <code>ECPrivateKeySpec</code> instance
- * created using valid parameters<br>
- * Expected: must return params value which is equal
- * to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetParams() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- ECParameterSpec params =
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
-
- ECPrivateKeySpec ks = new ECPrivateKeySpec(BigInteger.ZERO, params);
- ECParameterSpec paramsRet = ks.getParams();
-
- assertEquals(params, paramsRet);
- assertSame(params, paramsRet);
- }
-
- /**
- * Test for <code>getS()</code> method<br>
- * Assertion: returns associated private value<br>
- * Test preconditions: <code>ECPrivateKeySpec</code> instance
- * created using valid parameters<br>
- * Expected: must return s value which is equal
- * to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetS() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- ECParameterSpec params =
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
- BigInteger s = BigInteger.valueOf(5L);
-
- ECPrivateKeySpec ks = new ECPrivateKeySpec(s, params);
- BigInteger sRet = ks.getS();
-
- assertEquals(s, sRet);
- assertSame(s, sRet);
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPublicKeySpec_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPublicKeySpec_ImplTest.java
deleted file mode 100644
index 5ac2cda..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPublicKeySpec_ImplTest.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.ECFieldFp;
-import java.security.spec.ECParameterSpec;
-import java.security.spec.ECPoint;
-import java.security.spec.ECPublicKeySpec;
-import java.security.spec.EllipticCurve;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ECPublicKeySpec</code> class fields and methods.
- */
-public class ECPublicKeySpec_ImplTest extends TestCase {
-
- //
- // Tests
- //
- // NOTE: the following tests use EC domain parameters
- // which are invalid for real EC cryptography application
- // but must be acceptable by the class under test according
- // to the API specification
- //
-
- /**
- * Test #1 for <code>ECPublicKeySpec(ECPoint, ECParameterSpec)</code> constructor<br>
- * Assertion: creates <code>ECPublicKeySpec</code> instance<br>
- * Test preconditions: valid parameters passed<br>
- * Expected: must pass without any exceptions
- */
- public final void testECPublicKeySpec01() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- new ECPublicKeySpec(g,
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
-
- }
-
- /**
- * Test #2 for <code>ECPublicKeySpec(ECPoint, ECParameterSpec)</code> constructor<br>
- * Assertion: throws <code>NullPointerException</code> if
- * <code>w</code> or <code>params</code> is <code>null</code><br>
- * Test preconditions: pass <code>null</code> as mentioned parameters<br>
- * Expected: must throw <code>NullPointerException</code>
- */
- public final void testECPublicKeySpec02() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
-
- // Test case 1: w is null
- try {
- new ECPublicKeySpec(null,
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
- fail("#1: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 2: params is null
- try {
- new ECPublicKeySpec(g, null);
- fail("#2: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 3: both w and params are null
- try {
- new ECPublicKeySpec(null, null);
- fail("#3: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test #3 for <code>ECPublicKeySpec(ECPoint, ECParameterSpec)</code> constructor<br>
- * Assertion: throws <code>IllegalArgumentException</code> if
- * <code>w</code> is point at infinity<br>
- * Test preconditions: pass <code>ECPoint.POINT_INFINITY</code>
- * as mentioned parameter value<br>
- * Expected: must throw <code>IllegalArgumentException</code>
- */
- public final void testECPublicKeySpec03() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
-
- try {
- new ECPublicKeySpec(ECPoint.POINT_INFINITY,
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
- fail("Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test for <code>getParams()</code> method<br>
- * Assertion: returns associated EC parameters<br>
- * Test preconditions: <code>ECPublicKeySpec</code> instance
- * created using valid parameters<br>
- * Expected: must return params value which is equal
- * to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetParams() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- ECParameterSpec params =
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
-
- ECPublicKeySpec ks = new ECPublicKeySpec(g, params);
- ECParameterSpec paramsRet = ks.getParams();
-
- assertEquals(params, paramsRet);
- assertSame(params, paramsRet);
- }
-
- /**
- * Test for <code>getW()</code> method<br>
- * Assertion: returns associated public point<br>
- * Test preconditions: <code>ECPublicKeySpec</code> instance
- * created using valid parameters<br>
- * Expected: must return w value which is equal
- * to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetW() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- ECParameterSpec params =
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
-
- ECPublicKeySpec ks = new ECPublicKeySpec(g, params);
- ECPoint wRet = ks.getW();
-
- assertEquals(g, wRet);
- assertSame(g, wRet);
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurve_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurve_ImplTest.java
deleted file mode 100644
index 164cd93..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurve_ImplTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.java.security.spec;
-
-import java.math.BigInteger;
-import java.security.spec.ECFieldF2m;
-import java.security.spec.ECFieldFp;
-import java.security.spec.EllipticCurve;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>EllipticCurve</code> class fields and methods.
- */
-public class EllipticCurve_ImplTest extends TestCase {
-
- /**
- * Test #2 for <code>equals(Object other)</code> method<br>
- * Assertion: return false if this and other objects are not equal<br>
- * Test preconditions: see test comments<br>
- * Expected: all objects in this test must be NOT equal
- */
- public final void testEqualsObject02() {
- // test case 1: must not be equal to null
- EllipticCurve c2 = null, c1 =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L));
- assertFalse(c1.equals(c2));
-
- // test case 2: not equal objects - field
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L));
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(31L)),
- BigInteger.valueOf(1L),
- BigInteger.valueOf(19L));
- assertFalse(c1.equals(c2) || c2.equals(c1));
-
- // test case 3: not equal objects - a
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L));
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ZERO,
- BigInteger.valueOf(19L));
- assertFalse(c1.equals(c2) || c2.equals(c1));
-
- // test case 4: not equal objects - b
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L));
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(17L));
- assertFalse(c1.equals(c2) || c2.equals(c1));
-
- // test case 5: not equal objects - both seed not null
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L),
- new byte[24]);
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.valueOf(1L),
- BigInteger.valueOf(19L),
- new byte[25]);
- assertFalse(c1.equals(c2) || c2.equals(c1));
-
- // test case 6: not equal objects - one seed is null
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L),
- null);
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.valueOf(1L),
- BigInteger.valueOf(19L),
- new byte[24]);
- assertFalse(c1.equals(c2) || c2.equals(c1));
-
- // test case 7: not equal objects - field class
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L),
- new byte[24]);
- c2 = new EllipticCurve(new ECFieldF2m(5),
- BigInteger.ONE,
- BigInteger.valueOf(19L),
- new byte[24]);
- assertFalse(c1.equals(c2) || c2.equals(c1));
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/pkcs7/AuthenticatedAttributesTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/pkcs7/AuthenticatedAttributesTest.java
deleted file mode 100644
index 870a11c..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/pkcs7/AuthenticatedAttributesTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.pkcs7;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.pkcs7.ContentInfo;
-import org.apache.harmony.security.pkcs7.SignedData;
-import org.apache.harmony.security.pkcs7.SignerInfo;
-
-import tests.support.resource.Support_Resources;
-
-public class AuthenticatedAttributesTest extends TestCase {
-
- private static final String tSTokenPath = "AuthenticatedAttributesTest.dat";
-
- public void testDecode() throws IOException {
- InputStream in = Support_Resources.getResourceStream(tSTokenPath);
-
- try {
- // AuthenticatedAttributes is not public and can be created
- // only as a part of ContentInfo.
- ContentInfo token = (ContentInfo) ContentInfo.ASN1.decode(in);
- SignedData sigData = token.getSignedData();
- SignerInfo sigInfo = (SignerInfo) sigData.getSignerInfos().get(0);
- List authAttributes = sigInfo.getAuthenticatedAttributes();
- assertNotNull("Decoded AuthenticatedAttributes is null",
- authAttributes);
- assertEquals("Decoded AuthenticatedAttributes size is incorrect",
- 3, authAttributes.size());
-
- } finally {
- in.close();
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/pkcs7/SignerInfoTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/pkcs7/SignerInfoTest.java
deleted file mode 100644
index 81eeccb..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/pkcs7/SignerInfoTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.harmony.security.tests.pkcs7;
-
-import java.math.BigInteger;
-
-import javax.security.auth.x500.X500Principal;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.pkcs7.SignerInfo;
-import org.apache.harmony.security.x501.Name;
-import org.apache.harmony.security.x509.AlgorithmIdentifier;
-
-public class SignerInfoTest extends TestCase {
-
- public void testEncode() throws Exception {
-
- Object[] issuerAndSerialNumber = new Object[] { new Name("CN=test"),
- BigInteger.TEN.toByteArray() };
-
- SignerInfo signerInfo = new SignerInfo(1, issuerAndSerialNumber,
- new AlgorithmIdentifier("1.3.14.3.2.26"),// SHA1 OID
- null, new AlgorithmIdentifier("1.2.840.10040.4.1"),// DSA OID
- new byte[] { 0x01 },// signature
- null);
-
- byte[] encoding = SignerInfo.ASN1.encode(signerInfo);
-
- signerInfo = (SignerInfo) SignerInfo.ASN1.decode(encoding);
-
- assertEquals(new X500Principal("CN=test"), signerInfo.getIssuer());
- assertEquals(new BigInteger("10"), signerInfo.getSerialNumber());
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/utils/AlgNameMapperTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/utils/AlgNameMapperTest.java
deleted file mode 100644
index ebd1976..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/utils/AlgNameMapperTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.utils;
-
-import org.apache.harmony.security.utils.AlgNameMapper;
-
-import junit.framework.TestCase;
-
-public class AlgNameMapperTest extends TestCase {
-
- /**
- * @tests org.apache.harmony.security.utils.AlgNameMapper#getStandardName(String)
- */
- public void testGetStandardName() {
- //Regression for HARMONY-962
- // check a hardcoded mapping
- String standardName = AlgNameMapper
- .getStandardName("PBEWITHSHAAND40BITRC2-CBC");
- assertEquals("pbeWithSHAAnd40BitRC2-CBC", standardName);
- }
-
- /**
- * @tests org.apache.harmony.security.utils.AlgNameMapper#isOID(String)
- */
- public void testIsOID() {
- //Regression for HARMONY-962
- String notOID = "not.an.oid";
- String badOID = "999.88.77";
- // SHA1withDSA OID
- String normalOID = "1.2.840.10040.4.3";
-
- assertTrue(AlgNameMapper.isOID(normalOID));
- assertFalse(AlgNameMapper.isOID(badOID));
- assertFalse(AlgNameMapper.isOID(notOID));
- }
-
- /**
- * @tests org.apache.harmony.security.utils.AlgNameMapper.selectEntries(Provider)
- */
- public void testSelectEntries() {
- // Regression for HARMONY-1185
- String algStandardName = "SHA1withRSA";
- String hardcodedOID = "1.2.840.113549.1.1.5";
- String alternativeName = "SHA1WithRSAEncryption";
- String anotherAlgStandardName = "SHA1withDSA";
- String alternativeOID = "1.3.14.3.2.13";
- assertEquals(hardcodedOID, AlgNameMapper.map2OID(algStandardName));
- assertEquals(algStandardName, AlgNameMapper.map2AlgName(hardcodedOID));
-
- // Mappings taken from a provider that do not override any of hardcoded
- // mappings should not be rejected.
- assertEquals(hardcodedOID, AlgNameMapper.map2OID(alternativeName));
- assertEquals(anotherAlgStandardName, AlgNameMapper
- .map2AlgName(alternativeOID));
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x501/NameTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x501/NameTest.java
deleted file mode 100644
index 0c66003..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x501/NameTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @author Stepan M. Mishura
- */
-
-package org.apache.harmony.security.tests.x501;
-
-import java.io.ByteArrayInputStream;
-
-import org.apache.harmony.security.x501.Name;
-
-
-import junit.framework.TestCase;
-
-/**
- * Test Name class
- *
- * @see http://www.ietf.org/rfc/rfc1779.txt
- * @see http://www.ietf.org/rfc/rfc2253.txt
- */
-public class NameTest extends TestCase {
-
- private static final byte[] mess = {
- 0x30, //0 seq of
- (byte) 0x81, (byte) 0x9A, //1 len = 154
- 0x31, 0x0A, //3,4
- 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x5A,
- 0x31, 0x0A, //15,16
- 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x13, 0x01, 0x45,
- 0x31, 0x0A,
- 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x01, 0x44,
- 0x31, 0x0A,
- 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x01, 0x43,
- 0x31, 0x0A,
- 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x01, 0x42,
- 0x31, 0x15,
- 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x41,
- 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x02, 0x43, 0x41,
- 0x31, 0x0A,
- 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x13, 0x01, 0x45,
- 0x31, 0x0A,
- 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x01, 0x44,
- 0x31, 0x0A,
- 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x01, 0x43,
- 0x31, 0x0A,
- 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x01, 0x42,
- 0x31, 0x15,
- 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x41,
- 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x02, 0x43, 0x41
- };
-
- public void testGetName1779() throws Exception {
-
- Name principal = (Name) Name.ASN1.decode(mess);
-
- String s = principal.getName("RFC1779");
-
- assertEquals(
- "CN=A + ST=CA, O=B, L=C, C=D, OU=E, CN=A + ST=CA, O=B, L=C, C=D, OU=E, CN=Z",
- s);
- }
-
- public void testStreamGetName1779() throws Exception {
- ByteArrayInputStream is = new ByteArrayInputStream(mess);
-
- Name principal = (Name) Name.ASN1.decode(is);
-
- String s = principal.getName("RFC1779");
-
- assertEquals(
- "CN=A + ST=CA, O=B, L=C, C=D, OU=E, CN=A + ST=CA, O=B, L=C, C=D, OU=E, CN=Z",
- s);
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateListTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateListTest.java
deleted file mode 100644
index 7c621e6..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateListTest.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.x509;
-
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509CRL;
-import java.security.cert.X509CRLEntry;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.harmony.security.asn1.ASN1GeneralizedTime;
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.x501.Name;
-import org.apache.harmony.security.x509.AlgorithmIdentifier;
-import org.apache.harmony.security.x509.CertificateList;
-import org.apache.harmony.security.x509.Extension;
-import org.apache.harmony.security.x509.Extensions;
-import org.apache.harmony.security.x509.GeneralName;
-import org.apache.harmony.security.x509.GeneralNames;
-import org.apache.harmony.security.x509.TBSCertList;
-
-/**
- * CertificateListTest
- */
-public class CertificateListTest extends TestCase {
-
- // OID was taken from http://oid.elibel.tm.fr
- private static String algOID = "1.2.840.10040.4.3";
- //private static String algName = "SHA1withDSA";
- private static byte[] algParams = { 1, 1, 0 }; // DER boolean false encoding
- private static AlgorithmIdentifier signature;
- private static byte[] signatureValue = new byte[10];
-
- static {
- signature = new AlgorithmIdentifier(algOID, algParams);
- }
-
- private static String issuerName = "O=Certificate Issuer";
- private static Date thisUpdate = new Date();
- private static Date nextUpdate;
-
- static {
- nextUpdate = new Date(thisUpdate.getTime() + 100000);
- }
-
- private static Extension crlEntryExtension;
-
- static {
- // Invalidity Date Extension (rfc 3280)
- crlEntryExtension = new Extension("2.5.29.24",
- ASN1GeneralizedTime.getInstance().encode(new Date()));
- }
-
- private static Extensions crlEntryExtensions = new Extensions();
-
- static {
- //*
- crlEntryExtensions.addExtension(crlEntryExtension);
- // add the Certificate Issuer Extension to check if implementation
- // support indirect CRLs. As says rfc 3280 (p.62):
- // "If used by conforming CRL issuers, this extension MUST always be
- // critical. If an implementation ignored this extension it could not
- // correctly attribute CRL entries to certificates. This specification
- // RECOMMENDS that implementations recognize this extension."
- try {
- crlEntryExtensions.addExtension(
- new Extension("2.5.29.29", true,
- //*
- //ASN1OctetString.getInstance().encode(
- GeneralNames.ASN1.encode(
- new GeneralNames(Arrays.asList(
- new GeneralName[] {
- new GeneralName(new Name("O=Cert Organization"))//new GeneralName(4, "O=Organization")
- })
- )
- )
- //)
- //*/
- )
- );
- } catch (Exception e) {
- e.printStackTrace();
- }
- //*/
- }
-
- private static Date revocationDate = new Date();
- private static List revokedCertificates = Arrays.asList(
- new TBSCertList.RevokedCertificate[] {
- new TBSCertList.RevokedCertificate(BigInteger.valueOf(555),
- revocationDate, null),//crlEntryExtensions),
- new TBSCertList.RevokedCertificate(BigInteger.valueOf(666),
- revocationDate, crlEntryExtensions),
- new TBSCertList.RevokedCertificate(BigInteger.valueOf(777),
- revocationDate, null),//crlEntryExtensions)
- });
- private static Extensions crlExtensions = new Extensions(
- Arrays.asList(new Extension[] {
- new Extension("2.5.29.20", // CRL Number Extension (rfc 3280)
- ASN1Integer.getInstance().encode(
- BigInteger.valueOf(4444).toByteArray())),
- }));
-
- private CertificateList certificateList;
- private TBSCertList tbscertlist;
- private byte[] encoding;
-
- protected void setUp() throws java.lang.Exception {
- try {
- Name issuer = new Name(issuerName);
-
- tbscertlist =
- new TBSCertList(2, signature, issuer, thisUpdate,
- nextUpdate, revokedCertificates, crlExtensions);
-
- certificateList =
- new CertificateList(tbscertlist, signature, signatureValue);
-
- encoding = CertificateList.ASN1.encode(certificateList);
-
- certificateList = (CertificateList)
- CertificateList.ASN1.decode(encoding);
-
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown: " + e.getMessage());
- }
- }
-
-
- /**
- * CertificateList(TBSCertList tbsCertList, AlgorithmIdentifier
- * signatureAlgorithm, byte[] signatureValue) method testing.
- */
- public void testCertificateList() {
- try {
- AlgorithmIdentifier signature =
- new AlgorithmIdentifier(algOID, algParams);
- Name issuer = new Name(issuerName);
- TBSCertList tbscl =
- new TBSCertList(signature, issuer, thisUpdate);
- CertificateList cl =
- new CertificateList(tbscl, signature, new byte[] { 0 });
-
- byte[] encoding = CertificateList.ASN1.encode(cl);
- CertificateList.ASN1.decode(encoding);
-
- tbscl = new TBSCertList(2, signature, issuer, thisUpdate,
- nextUpdate, revokedCertificates, crlExtensions);
-
- cl = new CertificateList(tbscl, signature, new byte[] { 0 });
-
- encoding = CertificateList.ASN1.encode(cl);
- CertificateList.ASN1.decode(encoding);
-
- } catch (IOException e) {
- e.printStackTrace();
- fail("Unexpected IOException was thrown: " + e.getMessage());
- }
- }
-
- /**
- * getTbsCertList() method testing.
- */
- public void testGetTbsCertList() {
- assertTrue("Returned tbsCertList value is incorrect",
- tbscertlist.equals(certificateList.getTbsCertList()));
- }
-
- /**
- * getSignatureAlgorithm() method testing.
- */
- public void testGetSignatureAlgorithm() {
- assertTrue("Returned signatureAlgorithm value is incorrect",
- signature.equals(certificateList.getSignatureAlgorithm()));
- }
-
- /**
- * getSignatureValue() method testing.
- */
- public void testGetSignatureValue() {
- assertTrue("Returned signatureAlgorithm value is incorrect",
- Arrays.equals(signatureValue, certificateList.getSignatureValue()));
- }
-
- public void testSupportIndirectCRLs() throws Exception {
- X509CRL crl = (X509CRL)
- CertificateFactory.getInstance("X.509").generateCRL(
- new ByteArrayInputStream(encoding));
- Set rcerts = crl.getRevokedCertificates();
- System.out.println(">> rcerts:" + rcerts);
-
- System.out.println("}>> " + rcerts.toArray()[0]);
- System.out.println("}>> " + ((X509CRLEntry) rcerts.toArray()[0]).getCertificateIssuer());
- System.out.println("}>> " + ((X509CRLEntry) rcerts.toArray()[1]).getCertificateIssuer());
- System.out.println("}>> " + ((X509CRLEntry) rcerts.toArray()[2]).getCertificateIssuer());
- System.out.println(">> " + crl.getRevokedCertificate(
- BigInteger.valueOf(555)).getCertificateIssuer());
- }
-
- public static Test suite() {
- return new TestSuite(CertificateListTest.class);
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java
deleted file mode 100644
index 3aa8cbe..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.x509;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.harmony.security.x509.CertificatePolicies;
-import org.apache.harmony.security.x509.PolicyInformation;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * CertificatePoliciesTest
- */
-public class CertificatePoliciesTest extends TestCase {
-
- /**
- * CertificatePolicies() method testing.
- */
- public void testCertificatePolicies() throws Exception {
- String[] policies = new String[] {
- "0.0.0.0.0.0",
- "1.1.1.1.1.1",
- "2.2.2.2.2.2"
- };
- CertificatePolicies certificatePolicies =
- new CertificatePolicies();
- for (int i = 0; i < policies.length; i++) {
- PolicyInformation policyInformation =
- new PolicyInformation(policies[i]);
- certificatePolicies.addPolicyInformation(policyInformation);
- }
-
- byte[] encoding = certificatePolicies.getEncoded();
- List policyInformations = ((CertificatePolicies)
- CertificatePolicies.ASN1.decode(encoding))
- .getPolicyInformations();
- Iterator it = policyInformations.iterator();
- ((PolicyInformation) it.next()).getPolicyIdentifier();
- }
-
- public static Test suite() {
- return new TestSuite(CertificatePoliciesTest.class);
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateTest.java
deleted file mode 100644
index ed7a5a3..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateTest.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.x509;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.cert.CertificateFactory;
-import java.util.Arrays;
-import java.util.Date;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.x501.Name;
-import org.apache.harmony.security.x509.AlgorithmIdentifier;
-import org.apache.harmony.security.x509.Certificate;
-import org.apache.harmony.security.x509.EDIPartyName;
-import org.apache.harmony.security.x509.Extension;
-import org.apache.harmony.security.x509.Extensions;
-import org.apache.harmony.security.x509.GeneralName;
-import org.apache.harmony.security.x509.GeneralNames;
-import org.apache.harmony.security.x509.NameConstraints;
-import org.apache.harmony.security.x509.ORAddress;
-import org.apache.harmony.security.x509.OtherName;
-import org.apache.harmony.security.x509.SubjectPublicKeyInfo;
-import org.apache.harmony.security.x509.TBSCertificate;
-import org.apache.harmony.security.x509.Validity;
-
-/**
- * Testing the encoding/decoding work of the following structure:
- * (as specified in RFC 3280 -
- * Internet X.509 Public Key Infrastructure.
- * Certificate and Certificate Revocation List (CRL) Profile.
- * http://www.ietf.org/rfc/rfc3280.txt):
- * <p/>
- * <pre>
- * Certificate ::= SEQUENCE {
- * tbsCertificate TBSCertificate,
- * signatureAlgorithm AlgorithmIdentifier,
- * signatureValue BIT STRING
- * }
- *
- * TBSCertificate ::= SEQUENCE {
- * version [0] EXPLICIT Version DEFAULT v1,
- * serialNumber CertificateSerialNumber,
- * signature AlgorithmIdentifier,
- * issuer Name,
- * validity Validity,
- * subject Name,
- * subjectPublicKeyInfo SubjectPublicKeyInfo,
- * issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL,
- * -- If present, version MUST be v2 or v3
- * subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL,
- * -- If present, version MUST be v2 or v3
- * extensions [3] EXPLICIT Extensions OPTIONAL
- * -- If present, version MUST be v3
- * }
- *
- * Version ::= INTEGER { v1(0), v2(1), v3(2) }
- *
- * CertificateSerialNumber ::= INTEGER
- *
- * Validity ::= SEQUENCE {
- * notBefore Time,
- * notAfter Time
- * }
- *
- * Time ::= CHOICE {
- * utcTime UTCTime,
- * generalTime GeneralizedTime
- * }
- *
- * UniqueIdentifier ::= BIT STRING
- *
- * SubjectPublicKeyInfo ::= SEQUENCE {
- * algorithm AlgorithmIdentifier,
- * subjectPublicKey BIT STRING
- * }
- *
- * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
- *
- * Extension ::= SEQUENCE {
- * extnID OBJECT IDENTIFIER,
- * critical BOOLEAN DEFAULT FALSE,
- * extnValue OCTET STRING
- * }
- * </pre>
- */
-
-public class CertificateTest extends TestCase {
-
- /**
- * Certificate(TBSCertificate tbsCertificate, AlgorithmIdentifier
- * signatureAlgorithm, byte[] signatureValue) method testing.
- * Makes the certificate, gets its encoded form, makes new certificate
- * from this encoded form by CertificateFactory, and decodes encoded
- * form.
- */
- public void testCertificate() throws Exception {
- // make the TBSCertificate for Certificate
- int version = 2; //v3
- BigInteger serialNumber = BigInteger.valueOf(555L);
- AlgorithmIdentifier signature = new AlgorithmIdentifier("1.2.3.44.555"); // random value
- Name issuer = new Name("O=Certificate Issuer");
- Validity validity = new Validity(new Date(100000000), new Date(200000000));
- Name subject = new Name("O=Subject Organization");
- SubjectPublicKeyInfo subjectPublicKeyInfo =
- new SubjectPublicKeyInfo(new AlgorithmIdentifier("1.2.840.113549.1.1.2"),
- new byte[10]);
- boolean[] issuerUniqueID = new boolean[]
- { true, false, true, false, true, false, true, false }; // random value
- boolean[] subjectUniqueID = new boolean[]
- { false, true, false, true, false, true, false, true }; // random value
- // make the Extensions for TBSCertificate
- // Subject Alternative Names
- GeneralName[] san = new GeneralName[] {
- new GeneralName(
- new OtherName("1.2.3.4.5",
- ASN1Integer.getInstance().encode(
- BigInteger.valueOf(55L).toByteArray()))),
- new GeneralName(1, "rfc@822.Name"),
- new GeneralName(2, "dNSName"),
- new GeneralName(new ORAddress()),
- new GeneralName(4, "O=Organization"),
- new GeneralName(new EDIPartyName("assigner", "party")),
- new GeneralName(6, "http://Resource.Id"),
- new GeneralName(new byte[] { 1, 1, 1, 1 }),
- new GeneralName(8, "1.2.3.4444.55555")
- };
- GeneralNames sans = new GeneralNames(Arrays.asList(san));
- Extension extension = new Extension("2.5.29.17", true, sans.getEncoded());
- Extensions extensions = new Extensions();
- extensions.addExtension(extension);
-
- byte[] encoding = extensions.getEncoded();
- Extensions.ASN1.decode(encoding);
-
- TBSCertificate tbsCertificate = new TBSCertificate(version, serialNumber,
- signature, issuer, validity, subject, subjectPublicKeyInfo,
- issuerUniqueID, subjectUniqueID, extensions);
-
- encoding = tbsCertificate.getEncoded();
- TBSCertificate.ASN1.decode(encoding);
-
- Certificate certificate = new Certificate(tbsCertificate, signature, new byte[10]);
-
- encoding = certificate.getEncoded();
-
- Certificate.ASN1.decode(encoding);
-
- encoding = Certificate.ASN1.encode(certificate);
-
- ByteArrayInputStream bais = new ByteArrayInputStream(encoding);
-
- //try {
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- cf.generateCertificate(bais);
- //} catch (CertificateException e) {
- // there is no X.509 certificate factory implementation installed
- //}
- }
-
- /**
- * getTbsCertificate() method testing.
- */
- public void testGetTbsCertificate() throws IOException {
- // manually derived data:
- byte[] encoding = new byte[] {
- (byte) 0x30, (byte) 0x13, // NameConstraints
- (byte) 0xa1, (byte) 0x11, // GeneralSubtrees (excludedSubtrees)
- (byte) 0x30, (byte) 0x0f, // GeneralSubtree
- (byte) 0xa0, (byte) 0x0a, // GeneralName
- // OtherName:
- (byte) 0x06, (byte) 0x03, // type-id (OID)
- (byte) 0x00, (byte) 0x01, (byte) 0x02, // oid
- (byte) 0xA0, (byte) 0x03, // value (raw)
- 1, 1, (byte) 0xff, // boolean
- (byte) 0x80, (byte) 0x01, (byte) 0x00 // minimum
- };
- NameConstraints.ASN1.decode(encoding);
- }
-
- /**
- * getSignatureAlgorithm() method testing.
- */
- public void testGetSignatureAlgorithm() {
- }
-
- /**
- * getSignatureValue() method testing.
- */
- public void testGetSignatureValue() {
- }
-
- /**
- * getValue() method testing.
- */
- public void testGetValue() {
- }
-
- public static Test suite() {
- return new TestSuite(CertificateTest.class);
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/DistributionPointTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/DistributionPointTest.java
deleted file mode 100644
index cb1b327..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/DistributionPointTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.x509;
-
-import org.apache.harmony.security.x509.DistributionPoint;
-
-import junit.framework.TestCase;
-
-public class DistributionPointTest extends TestCase {
-
- public void test_Ctor() {
- // no exceptions
- new DistributionPoint();
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java
deleted file mode 100644
index 04a21f9..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.x509;
-
-import java.util.Arrays;
-
-import org.apache.harmony.security.x509.EDIPartyName;
-import org.apache.harmony.security.x509.GeneralName;
-import org.apache.harmony.security.x509.GeneralNames;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class EDIPartyNameTest extends TestCase {
-
- public static void printAsHex(int perLine, String prefix,
- String delimiter, byte[] data) {
- for (int i = 0; i < data.length; i++) {
- String tail = Integer.toHexString(0x000000ff & data[i]);
- if (tail.length() == 1) {
- tail = "0" + tail;
- }
- System.out.print(prefix + "0x" + tail + delimiter);
-
- if (((i + 1) % perLine) == 0) {
- System.out.println();
- }
- }
- System.out.println();
- }
-
- /**
- * EDIPartyName(String nameAssigner, String partyName) method testing.
- */
- public void _testEDIPartyName1() {
- boolean pass = true;
-
- EDIPartyName ediPN = new EDIPartyName("nameAssigner", "partyName");
- byte[] encoded = ediPN.getEncoded();
- // manually derived data:
- byte[] _encoded = {
- (byte) 0x30, (byte) 0x1d, (byte) 0x80, (byte) 0x0e,
- (byte) 0x13, (byte) 0x0c, (byte) 0x6e, (byte) 0x61,
- (byte) 0x6d, (byte) 0x65, (byte) 0x41, (byte) 0x73,
- (byte) 0x73, (byte) 0x69, (byte) 0x67, (byte) 0x6e,
- (byte) 0x65, (byte) 0x72, (byte) 0x81, (byte) 0x0b,
- (byte) 0x13, (byte) 0x09, (byte) 0x70, (byte) 0x61,
- (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x4e,
- (byte) 0x61, (byte) 0x6d, (byte) 0x65
- };
- if (!Arrays.equals(encoded, _encoded)) {
- System.out.println("Got encoded form of EDIPartyName is:");
- printAsHex(16, "", " ", encoded);
- System.out.println("But should be like this:");
- printAsHex(16, "", " ", _encoded);
- System.out.println("");
- pass = false;
- }
-
- GeneralName gName = new GeneralName(ediPN);
- encoded = gName.getEncoded();
- // manually derived data:
- _encoded = new byte[] {
- (byte) 0xa5, (byte) 0x1d, (byte) 0x80, (byte) 0x0e,
- (byte) 0x13, (byte) 0x0c, (byte) 0x6e, (byte) 0x61,
- (byte) 0x6d, (byte) 0x65, (byte) 0x41, (byte) 0x73,
- (byte) 0x73, (byte) 0x69, (byte) 0x67, (byte) 0x6e,
- (byte) 0x65, (byte) 0x72, (byte) 0x81, (byte) 0x0b,
- (byte) 0x13, (byte) 0x09, (byte) 0x70, (byte) 0x61,
- (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x4e,
- (byte) 0x61, (byte) 0x6d, (byte) 0x65
- };
- if (!Arrays.equals(encoded, _encoded)) {
- System.out.println("Got encoded form of GeneralName is:");
- printAsHex(16, "", " ", encoded);
- System.out.println("But should be like this:");
- printAsHex(16, "", " ", _encoded);
- System.out.println("");
- pass = false;
- }
-
- GeneralNames gNames = new GeneralNames();
- gNames.addName(gName);
- encoded = gNames.getEncoded();
- // manually derived data:
- _encoded = new byte[] {
- (byte) 0x30, (byte) 0x1f, (byte) 0xa5, (byte) 0x1d,
- (byte) 0x80, (byte) 0x0e, (byte) 0x13, (byte) 0x0c,
- (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65,
- (byte) 0x41, (byte) 0x73, (byte) 0x73, (byte) 0x69,
- (byte) 0x67, (byte) 0x6e, (byte) 0x65, (byte) 0x72,
- (byte) 0x81, (byte) 0x0b, (byte) 0x13, (byte) 0x09,
- (byte) 0x70, (byte) 0x61, (byte) 0x72, (byte) 0x74,
- (byte) 0x79, (byte) 0x4e, (byte) 0x61, (byte) 0x6d,
- (byte) 0x65
- };
- if (!Arrays.equals(encoded, _encoded)) {
- System.out.println("Got encoded form of GeneralNames is:");
- printAsHex(16, "", " ", encoded);
- System.out.println("But should be like this:");
- printAsHex(16, "", " ", _encoded);
- System.out.println("");
- pass = false;
- }
-
- assertTrue("Some problems occured.", pass);
- }
-
- /**
- * EDIPartyName(String nameAssigner, String partyName, byte[] encoding)
- * method testing.
- */
- public void testEDIPartyName2() throws Exception {
- EDIPartyName ediName = new EDIPartyName("assigner", "party");
- byte[] encoding = EDIPartyName.ASN1.encode(ediName);
- EDIPartyName.ASN1.decode(encoding);
- new GeneralName(5, encoding);
-
- GeneralName gn = new GeneralName(ediName);
-
- new GeneralName(5, gn.getEncodedName());
- }
-
- /**
- * getNameAssigner() method testing.
- */
- public void testGetNameAssigner() {
- }
-
- /**
- * getPartyName() method testing.
- */
- public void testGetPartyName() {
- }
-
- /**
- * getEncoded() method testing.
- */
- public void testGetEncoded() {
- }
-
- /**
- * getEncoder() method testing.
- */
- public void testGetEncoder() {
- }
-
- /**
- * DerEncoder(String nameAssigner, String partyName) method testing.
- */
- public void testDerEncoder() {
- }
-
- /**
- * getDirStrAlternatives() method testing.
- */
- public void testGetDirStrAlternatives() {
- }
-
- /**
- * DerDecoder() method testing.
- */
- public void testDerDecoder() {
- }
-
- /**
- * getValue(byte[] encoding) method testing.
- */
- public void testGetValue1() {
- }
-
- /**
- * getValue() method testing.
- */
- public void testGetValue2() {
- }
-
- public static Test suite() {
- return new TestSuite(EDIPartyNameTest.class);
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNameTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNameTest.java
deleted file mode 100644
index 23115eb..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNameTest.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.x509;
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.x501.Name;
-import org.apache.harmony.security.x509.EDIPartyName;
-import org.apache.harmony.security.x509.GeneralName;
-import org.apache.harmony.security.x509.GeneralNames;
-import org.apache.harmony.security.x509.ORAddress;
-import org.apache.harmony.security.x509.OtherName;
-
-
-/**
- * GeneralNameTest
- */
-public class GeneralNameTest extends TestCase {
-
- public void testGeneralName() {
- try {
- GeneralName san0 =
- new GeneralName(new OtherName("1.2.3.4.5", new byte[] { 1, 2, 0, 1 }));
- GeneralName san1 = new GeneralName(1, "rfc@822.Name");
- GeneralName san2 = new GeneralName(2, "dNSName");
- GeneralName san3 = new GeneralName(new ORAddress());
- GeneralName san4 = new GeneralName(new Name("O=Organization"));
- GeneralName san5 =
- new GeneralName(new EDIPartyName("assigner", "party"));
- GeneralName san6 = new GeneralName(6, "http://uniform.Resource.Id");
- GeneralName san7 = new GeneralName(7, "1.1.1.1");
- GeneralName san8 = new GeneralName(8, "1.2.3.4444.55555");
-
- GeneralNames sans_1 = new GeneralNames();
- sans_1.addName(san0);
- sans_1.addName(san1);
- sans_1.addName(san2);
- sans_1.addName(san3);
- sans_1.addName(san4);
- sans_1.addName(san5);
- sans_1.addName(san6);
- sans_1.addName(san7);
- sans_1.addName(san8);
-
- byte[] encoding = GeneralNames.ASN1.encode(sans_1);
- GeneralNames.ASN1.decode(encoding);
- } catch (Exception e) {
- // should not be thrown:
- // provided string representations are correct
- e.printStackTrace();
- }
- }
-
- public void testGeneralName1() throws Exception {
- OtherName on =
- new OtherName("1.2.3.4.5", new byte[] { 1, 2, 0, 1 });
- byte[] encoding = OtherName.ASN1.encode(on);
- new GeneralName(0, encoding);
- OtherName.ASN1.decode(encoding);
- GeneralName gn = new GeneralName(on);
- new GeneralName(0, gn.getEncodedName());
- assertEquals(gn, new GeneralName(0, gn.getEncodedName()));
- }
-
- /**
- * ipStrToBytes method testing.
- */
- public void testIpStrToBytes() throws Exception {
- // Regression for HARMONY-727
- Object[][] positives = {
- { "010a:020b:3337:1000:FFFA:ABCD:9999:0000",
- new int[] { 0x01, 0x0a, 0x02, 0x0b, 0x33, 0x37, 0x10, 0x00, 0xFF,
- 0xFA, 0xAB, 0xCD, 0x99, 0x99, 0x00, 0x00 } },
- { "010a:020b:3337:1000:FFFA:ABCD:9999:0000/0102:0304:0506:0708:090A:0b0c:0D0e:0f10",
- new int[] { 0x01, 0x0a, 0x02, 0x0b, 0x33, 0x37, 0x10, 0x00, 0xFF,
- 0xFA, 0xAB, 0xCD, 0x99, 0x99, 0x00, 0x00, 0x01, 0x02, 0x03,
- 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0b, 0x0c, 0x0D,
- 0x0e, 0x0f, 0x10 } },
- { "010a:020b:1133:1000:FFFA:ABCD:9999:0000/0102:0304:0506:0708:090A:0b0c:0D0e:0f10",
- new int[] { 0x01, 0x0a, 0x02, 0x0b, 0x11, 0x33, 0x10, 0x00, 0xFF,
- 0xFA, 0xAB, 0xCD, 0x99, 0x99, 0x00, 0x00, 0x01, 0x02, 0x03,
- 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0b, 0x0c, 0x0D,
- 0x0e, 0x0f, 0x10 } },
- { "010a:020b:1133:1000:FFFA:ABCD:9999:0000/0102:0304:0506:0708:090A:0b0c:0D0e:0f10",
- new int[] { 0x01, 0x0a, 0x02, 0x0b, 0x11, 0x33, 0x10, 0x00, 0xFF,
- 0xFA, 0xAB, 0xCD, 0x99, 0x99, 0x00, 0x00, 0x01, 0x02, 0x03,
- 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0b, 0x0c, 0x0D,
- 0x0e, 0x0f, 0x10 } },
- { "100.2.35.244",
- new int[] { 100, 2, 35, 244 } },
- { "100.2.35.244/51.6.79.118",
- new int[] { 100, 2, 35, 244, 51, 6, 79, 118 } },
- };
- String[] negatives = {
- "010a:0000:3333:1000:FFFA:ABCD:9999:0000/0102:0304:0506:0708:090A:0b0c:0D0e:0",
- "010a:020b:3:1000:FFFA:ABCD:9999:0000/0102:0304:0506:0708:090A:0b0c:0D0e:0f10",
- "010a:020b:33:1000:FFFA:ABCD:9999:0000/0102:0304:0506:0708:090A:0b0c:0D0e:0f10",
- "010a:020b:333:1000:FFFA:ABCD:9999:0000/0102:0304:0506:0708:090A:0b0c:0D0e:0f10",
- "010a:020b:1133:10V0:FFFA:ABCD:9999:0000/0102:0304:0506:0708:090A:0b0c:0D0e:0f10",
- "010a:020b:1133:1000-FFFA:ABCD:9999:0000/0102:0304:0506:0708:090A:0b0c:0D0e:0f10",
- "010a:020b:1133:1000:FFFA:ABCD:9999",
- "010a:020b:1133:1000:FFFA:ABCD:9999/0000:0102:0304:0506:0708:090A:0b0c:0D0e:0f10",
- "010a:020b:1133:1000:FFFA:ABCD:9999:0000:0102/0304:0506:0708:090A:0b0c:0D0e:0f10",
- "010a:020b:1133:1000:FFFA:ABCD:9999:0000/0102:0304:0506:0708:090A:0b0c:0D0e:0f10:1234",
- "100.2.35.244/51.6.79.118.119",
- "100.2.35.244.115/79.118.119",
- "100.2.35.244/79.118.119.1167",
- "100.2.35.244/79.118.119.116.7",
- "100.2.35.244.79/118.119.116.7",
- "100.2.35/79/118.119.116.7",
- "100.2.35.79/118/119.116.7",
- "100.2..35.79/118/119.116.7",
- "100.2.a.35.79/118/119.116.7",
- "100.2.35.79/119.116.7-1",
- "100.2.35.244.111",
- "100.2.35.244/111",
- "010a:020b:1133:1000:FFFA:ABCD:9999:0000/0102:0304:0506:0708:090A:0b0c:0D0e0f10",
- "010a:020b:1133:1000:FFFA:ABCD:9999:0000/0102:0304:0506:0708:090A:0b0c:0D0e0f:10",
- "010a:020b:1133:1000:FFFA:ABCD:9999:0000/0102/0304:0506:0708:090A:0b0c:0D0e0f:10",
- "010a:020b:1133:1000:FFFA:ABCD:9999:0000/0102030405060708090A0b0c:0D0e:0f10:ffff",
- "010a:020b:1133:1000:FFFA:ABCD:9999:00000102030405060708090A/0b0c:0D0e:0f10:ffff",
- };
- for (int i = 0; i < positives.length; i++) {
- byte[] res = GeneralName.ipStrToBytes((String) positives[i][0]);
- int[] ref = (int[]) positives[i][1];
- assertEquals("Length differs for " + positives[i][0], ref.length, res.length);
- for (int j = 0; j < res.length; j++) {
- assertEquals("Element differs for " + positives[i][0], (byte) ref[j], res[j]);
- }
- }
- for (int n = 0; n < negatives.length; n++) {
- String ip = negatives[n];
- try {
- byte[] bts = GeneralName.ipStrToBytes(ip);
- for (int i = 0; i < bts.length; i++) {
- System.out.print((bts[i] & 0xFF) + " ");
- }
- System.out.println("");
- System.out.println(ip);
- fail("No expected IOException was thrown for " + n);
- } catch (IOException e) {
- // expected
- }
- }
- }
-
- /**
- * oidStrToInts method testing
- */
- public void testOidStrToInts() throws Exception {
- // Regression for HARMONY-727
- Object[][] positives = {
- { "1.2", new int[] { 1, 2 } },
- { "1.2.3.4.5", new int[] { 1, 2, 3, 4, 5 } },
- { "123.456.7890.1234567890",
- new int[] { 123, 456, 7890, 1234567890 } }, };
- String[] negatives = { ".1.2", "1.2.", "11-22.44.22", "111..222" };
- for (int i = 0; i < positives.length; i++) {
- int[] res = GeneralName.oidStrToInts((String) positives[i][0]);
- int[] ref = (int[]) positives[i][1];
- assertEquals("Length differs for " + positives[i][0], ref.length,
- res.length);
- for (int j = 0; j < res.length; j++) {
- if (res[j] != ref[j]) {
- assertEquals("Element differs for " + positives[i][0],
- (byte) ref[j], res[j]);
- }
- }
- }
- for (int i = 0; i < negatives.length; i++) {
- try {
- GeneralName.oidStrToInts(negatives[i]);
- fail("Expected IOException was not thrown for " + negatives[i]);
- } catch (IOException e) {
- // expected
- }
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNamesTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNamesTest.java
deleted file mode 100644
index 8021cce..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNamesTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.x509;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.apache.harmony.security.x509.GeneralName;
-import org.apache.harmony.security.x509.GeneralNames;
-
-import junit.framework.TestCase;
-
-/**
- * TODO Put your class description here
- */
-
-public class GeneralNamesTest extends TestCase {
-
- public void test_EncodeDecode() throws IOException {
-
- GeneralNames subj_alt_names = new GeneralNames(Arrays
- .asList(new GeneralName[] { new GeneralName(1, "rfc@822.Name"),
- new GeneralName(2, "dNSName"),
- new GeneralName(4, "O=Organization"),
- new GeneralName(6, "http://uniform.Resource.Id"),
- new GeneralName(7, "255.255.255.0"),
- new GeneralName(8, "1.2.3.4444.55555") }));
-
- byte[] encoding = GeneralNames.ASN1.encode(subj_alt_names);
-
- GeneralNames gnames = (GeneralNames) GeneralNames.ASN1.decode(encoding);
-
- assertEquals("Names: ", subj_alt_names.getNames(), gnames.getNames());
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java
deleted file mode 100644
index 20298b3..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.x509;
-
-import org.apache.harmony.security.x509.GeneralName;
-import org.apache.harmony.security.x509.GeneralNames;
-import org.apache.harmony.security.x509.ORAddress;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * ORAddressTest
- */
-public class ORAddressTest extends TestCase {
-
- public static void printAsHex(int perLine, String prefix,
- String delimiter, byte[] data) {
- for (int i = 0; i < data.length; i++) {
- String tail = Integer.toHexString(0x000000ff & data[i]);
- if (tail.length() == 1) {
- tail = "0" + tail;
- }
- System.out.print(prefix + "0x" + tail + delimiter);
-
- if (((i + 1) % perLine) == 0) {
- System.out.println();
- }
- }
- System.out.println();
- }
-
- /**
- * ORAddress() method testing.
- */
- public void testORAddress() {
- ORAddress ora = new ORAddress();
- System.out.println("");
- System.out.println("ORAddress:");
- printAsHex(8, "", " ", ora.getEncoded());
- System.out.println("");
-
- GeneralName gName = new GeneralName(ora);
- System.out.println("GeneralName:");
- printAsHex(8, "", " ", gName.getEncoded());
- System.out.println("");
-
- GeneralNames gNames = new GeneralNames();
- gNames.addName(gName);
- System.out.println("GeneralNames:");
- printAsHex(8, "", " ", gNames.getEncoded());
- System.out.println("");
- }
-
- public static Test suite() {
- return new TestSuite(ORAddressTest.class);
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/PolicyQualifierInfoTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/PolicyQualifierInfoTest.java
deleted file mode 100644
index 66202ac..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/PolicyQualifierInfoTest.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.x509;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import junit.framework.TestCase;
-
-/**
- * Test for thread safety of the PolicyQualifierInfo DER decoder
- * ("DER" stands for "Distinguished Encoding Rules",
- * see ITU-T Recommendation X.690,
- * http://asn1.elibel.tm.fr)
- */
-public class PolicyQualifierInfoTest extends TestCase {
- // Number of test working threads (may be set externally)
- private static int workersNumber;
- // Number of test iterations performed by each thread
- // (may be set externally)
- private static int iterationsNumber;
-
- static {
- try {
- workersNumber = Integer.parseInt(
- System.getProperty("PolicyQualifierInfoTest.workersNumber",
- "10"));
- iterationsNumber = Integer.parseInt(
- System.getProperty("PolicyQualifierInfoTest.iterationsNumber",
- "10000"));
- } catch (Exception e) {
- workersNumber = 10;
- iterationsNumber = 10000;
- }
- }
-
- // Holder for thread-specific PolicyQualifier DER encodings
- private static final byte[][] enc = new byte[workersNumber][];
-
- private volatile boolean arrayPassed = true;
- private volatile boolean inpstPassed = true;
-
- // "Valid" reference DER encoding
- // (generated by own encoder during test development)
- private static final byte[] encoding = {
- (byte) 0x30, (byte) 0x26, // tag Seq, length
- (byte) 0x06, (byte) 0x08, // tag OID, length
- (byte) 0x2b, (byte) 0x06, (byte) 0x01, (byte) 0x05, // oid value
- (byte) 0x05, (byte) 0x07, (byte) 0x02, (byte) 0x01, // oid value
- (byte) 0x16, (byte) 0x1a, // tag IA5String, length
- (byte) 0x68, (byte) 0x74, (byte) 0x74, (byte) 0x70, // IA5String value
- (byte) 0x3a, (byte) 0x2f, (byte) 0x2f, (byte) 0x77, // IA5String value
- (byte) 0x77, (byte) 0x77, (byte) 0x2e, (byte) 0x71, // IA5String value
- (byte) 0x71, (byte) 0x2e, (byte) 0x63, (byte) 0x6f, // IA5String value
- (byte) 0x6d, (byte) 0x2f, (byte) 0x73, (byte) 0x74, // IA5String value
- (byte) 0x6d, (byte) 0x74, (byte) 0x2e, (byte) 0x74, // IA5String value
- (byte) 0x78, (byte) 0x74 // IA5String value
- };
-
-
- // Test worker for decoding from byte array
- private class TestWorker1 extends Thread {
-
- private final int myIntValue;
-
- public TestWorker1(int num) {
- super("Worker_" + num);
- myIntValue = num;
- }
-
- public void run() {
- for (int i = 0; i < iterationsNumber; i++) {
- try {
- // Perform DER decoding:
- Object[] decoded =
- (Object[]) org.apache.harmony.security.x509.
- PolicyQualifierInfo.ASN1.decode(
- getDerEncoding(myIntValue));
- // check OID value
- assertEquals(this.getName() + "(OID)",
- myIntValue, ((int[]) decoded[0])[8]);
- // check qualifier
- assertEquals(this.getName() + "(QA)",
- (byte) myIntValue, ((byte[]) decoded[1])[2]);
- } catch (Throwable e) {
- System.err.println(e);
- arrayPassed = false;
- return;
- }
- }
- }
- }
-
- // Test worker for decoding from InputStream
- private class TestWorker2 extends Thread {
-
- private final int myIntValue;
-
- public TestWorker2(int num) {
- super("Worker_" + num);
- myIntValue = num;
- }
-
- public void run() {
- for (int i = 0; i < iterationsNumber; i++) {
- try {
- // Perform DER decoding:
- Object[] decoded =
- (Object[]) org.apache.harmony.security.x509.
- PolicyQualifierInfo.ASN1.decode(
- getDerInputStream(myIntValue));
- // check OID value
- assertEquals(this.getName() + "(OID)",
- myIntValue, ((int[]) decoded[0])[8]);
- // check qualifier
- assertEquals(this.getName() + "(QA)",
- (byte) myIntValue, ((byte[]) decoded[1])[2]);
- } catch (Throwable e) {
- System.err.println(e);
- inpstPassed = false;
- return;
- }
- }
- }
- }
-
- /**
- * Test 1
- *
- * @throws InterruptedException
- */
- public final void testMtByteArray() throws InterruptedException {
- Thread[] workers = new Thread[workersNumber];
- for (int i = 0; i < workersNumber; i++) {
- workers[i] = new TestWorker1(i);
- }
- for (int i = 0; i < workersNumber; i++) {
- workers[i].start();
- }
- for (int i = 0; i < workersNumber; i++) {
- workers[i].join();
- }
- assertTrue(arrayPassed);
- }
-
- /**
- * Test 2
- *
- * @throws InterruptedException
- */
- public final void testMtInputStream() throws InterruptedException {
- Thread[] workers = new Thread[workersNumber];
- for (int i = 0; i < workersNumber; i++) {
- workers[i] = new TestWorker2(i);
- }
- for (int i = 0; i < workersNumber; i++) {
- workers[i].start();
- }
- for (int i = 0; i < workersNumber; i++) {
- workers[i].join();
- }
- assertTrue(inpstPassed);
- }
-
- //
- // Generates unique (based on parameter) DER encoding
- // @param intVal value to be incorporated into the resulting encoding
- // @return PolicyQualifier DER encoding
- //
- private static final byte[] getDerEncoding(int intVal) {
- setEncArray(intVal);
- return enc[intVal];
- }
-
- //
- // Generates unique (based on parameter) DER encoding
- // @param intVal value to be incorporated into the resulting encoding
- // @return PolicyQualifier DER encoding
- //
- private static final InputStream getDerInputStream(int intVal) {
- setEncArray(intVal);
- return new ByteArrayInputStream(enc[intVal]);
- }
-
- //
- // Init thread specific data
- // @param intVal worker thread number
- //
- private static void setEncArray(int intVal) {
- if (enc[intVal] == null) {
- // make encoding thread-specific
- byte[] a = encoding.clone();
- a[11] = (byte) intVal;
- a[14] = (byte) intVal;
- enc[intVal] = a;
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/PrivateKeyUsagePeriodTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/PrivateKeyUsagePeriodTest.java
deleted file mode 100644
index 67e1f80..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/PrivateKeyUsagePeriodTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.x509;
-
-import java.util.Date;
-
-import org.apache.harmony.security.x509.PrivateKeyUsagePeriod;
-
-import junit.framework.TestCase;
-
-public class PrivateKeyUsagePeriodTest extends TestCase {
-
- public void testEncodeDecode() throws Exception {
-
- Date notBeforeDate = new Date(200000000);
- Date notAfterDate = new Date(300000000);
-
- PrivateKeyUsagePeriod pkup = new PrivateKeyUsagePeriod(notBeforeDate,
- notAfterDate);
-
- byte[] encoded = pkup.getEncoded();
-
- pkup = (PrivateKeyUsagePeriod) PrivateKeyUsagePeriod.ASN1
- .decode(encoded);
-
- assertEquals("notBeforeDate", notBeforeDate, pkup.getNotBefore());
- assertEquals("notAfterDate", notAfterDate, pkup.getNotAfter());
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/TimeTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/TimeTest.java
deleted file mode 100644
index 8b3a9ec..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/TimeTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.x509;
-
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.asn1.ASN1Constants;
-import org.apache.harmony.security.x509.Time;
-
-/**
- * Time test
- */
-public class TimeTest extends TestCase {
-
- /**
- * Tests the result of encoding work on the data before and after 2050.
- */
- public void test_Encoding() throws Exception {
-
- long march2006 = 1143115180000L;
- long march2332 = 11431151800000L;
-
- // verify that date before 2050 encoded as UTCTime
- byte[] enc = Time.ASN1.encode(new Date(march2006));
- assertEquals("UTCTime", ASN1Constants.TAG_UTCTIME, enc[0]);
-
- // verify that date after 2050 encoded as GeneralizedTime
- enc = Time.ASN1.encode(new Date(march2332));
- assertEquals("GeneralizedTime", ASN1Constants.TAG_GENERALIZEDTIME,
- enc[0]);
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/PKIStatusInfoTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/PKIStatusInfoTest.java
deleted file mode 100644
index f7ab2da..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/PKIStatusInfoTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.x509.tsp;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.harmony.security.x509.tsp.PKIFailureInfo;
-import org.apache.harmony.security.x509.tsp.PKIStatus;
-import org.apache.harmony.security.x509.tsp.PKIStatusInfo;
-
-import junit.framework.TestCase;
-
-public class PKIStatusInfoTest extends TestCase {
-
- /**
- * @throws IOException
- * @tests 'org.apache.harmony.security.x509.tsp.PKIStatusInfo.getEncoded()'
- */
- public void testGetEncoded() throws IOException {
- ArrayList statusStr = new ArrayList(2);
- statusStr.add("one");
- statusStr.add("two");
- PKIStatusInfo info = new PKIStatusInfo(PKIStatus.REJECTION, statusStr,
- PKIFailureInfo.BAD_DATA_FORMAT);
- byte[] encoding = PKIStatusInfo.ASN1.encode(info);
- PKIStatusInfo decoded = (PKIStatusInfo) PKIStatusInfo.ASN1
- .decode(encoding);
-
- assertEquals(info.getStatus(), decoded.getStatus());
- List decodedStString = decoded.getStatusString();
- assertNotNull(decodedStString);
- assertEquals("one", decodedStString.get(0));
- assertEquals("two", decodedStString.get(1));
- assertEquals(info.getFailInfo(), decoded.getFailInfo());
- }
-}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/TSTInfoTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/TSTInfoTest.java
deleted file mode 100644
index b5a0305..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/TSTInfoTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.x509.tsp;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.x501.Name;
-import org.apache.harmony.security.x509.AlgorithmIdentifier;
-import org.apache.harmony.security.x509.Extension;
-import org.apache.harmony.security.x509.Extensions;
-import org.apache.harmony.security.x509.GeneralName;
-import org.apache.harmony.security.x509.tsp.MessageImprint;
-import org.apache.harmony.security.x509.tsp.TSTInfo;
-
-public class TSTInfoTest extends TestCase {
-
- /**
- * @throws IOException
- * @tests 'org.apache.harmony.security.x509.tsp.TSTInfo.getEncoded()'
- */
- public void testGetEncoded() throws IOException {
- // Unizeto CETRUM policy
- String policy = "1.2.3.4.5";
- // SHA1 OID as defined in RFC 3161
- String sha1 = "1.3.14.3.2.26";
- MessageImprint msgImprint = new MessageImprint(new AlgorithmIdentifier(
- sha1), new byte[20]);
- Date genTime = new Date();
- BigInteger nonce = BigInteger.valueOf(1234567890L);
- int[] accuracy = new int[] { 1, 0, 0 };
- GeneralName tsa = new GeneralName(new Name("CN=AnAuthority"));
- Extensions exts = new Extensions();
- // Time-Stamping extension OID: as defined in RFC 3161
- int[] timeStampingExtOID = new int[] { 1, 3, 6, 1, 5, 5, 7, 3, 8 };
- byte[] timeStampingExtValue = new byte[] { (byte) 1, (byte) 2, (byte) 3 };
- Extension ext = new Extension(timeStampingExtOID, true,
- timeStampingExtValue);
- exts.addExtension(ext);
-
- TSTInfo info = new TSTInfo(1, policy, msgImprint, BigInteger.TEN,
- genTime, accuracy, Boolean.FALSE, nonce, tsa, exts);
-
- byte[] encoding = TSTInfo.ASN1.encode(info);
- TSTInfo decoded = (TSTInfo) TSTInfo.ASN1.decode(encoding);
-
- assertEquals("Decoded version is incorrect", info.getVersion(), decoded
- .getVersion());
- assertEquals("Decoded policy is incorrect", policy, decoded.getPolicy());
- assertTrue("Decoded messageImprint is incorrect", Arrays.equals(
- MessageImprint.ASN1.encode(msgImprint), MessageImprint.ASN1
- .encode(decoded.getMessageImprint())));
- assertEquals("Decoded serialNumber is incorrect", BigInteger.TEN,
- decoded.getSerialNumber());
- assertEquals("Decoded genTime is incorrect", genTime, decoded
- .getGenTime());
- assertTrue("Decoded accuracy is incorrect", Arrays.equals(accuracy,
- decoded.getAccuracy()));
- assertFalse("Decoded ordering is incorrect", decoded.getOrdering()
- .booleanValue());
- assertEquals("Decoded nonce is incorrect", nonce, decoded.getNonce());
- assertEquals("Decoded tsa is incorrect", tsa, decoded.getTsa());
- assertEquals("Decoded extensions is incorrect", exts, decoded
- .getExtensions());
- }
-}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/TimeStampReqTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/TimeStampReqTest.java
deleted file mode 100644
index a0fc1bc..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/TimeStampReqTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.x509.tsp;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.x509.AlgorithmIdentifier;
-import org.apache.harmony.security.x509.Extension;
-import org.apache.harmony.security.x509.Extensions;
-import org.apache.harmony.security.x509.tsp.MessageImprint;
-import org.apache.harmony.security.x509.tsp.TimeStampReq;
-
-public class TimeStampReqTest extends TestCase {
-
- /**
- * @throws IOException
- * @tests 'org.apache.harmony.security.x509.tsp.TimeStampReq.getEncoded()'
- */
- public void testTimeStampReq() throws IOException {
- // SHA1 OID
- MessageImprint msgImprint = new MessageImprint(new AlgorithmIdentifier(
- "1.3.14.3.2.26"), new byte[20]);
- String reqPolicy = "1.2.3.4.5";
- BigInteger nonce = BigInteger.valueOf(1234567890L);
- Extensions exts = new Extensions();
- int[] extOID = new int[] { 1, 2, 3, 2, 1 };
- byte[] extValue = new byte[] { (byte) 1, (byte) 2, (byte) 3 };
- Extension ext = new Extension(extOID, false, extValue);
- exts.addExtension(ext);
-
- TimeStampReq req = new TimeStampReq(1, msgImprint, reqPolicy,
- nonce, Boolean.FALSE, exts);
- byte[] encoding = req.getEncoded();
- TimeStampReq decoded = (TimeStampReq) TimeStampReq.ASN1
- .decode(encoding);
- assertEquals("Decoded version is incorrect", req.getVersion(), decoded
- .getVersion());
- assertTrue("Decoded messageImprint is incorrect", Arrays.equals(
- MessageImprint.ASN1.encode(msgImprint), MessageImprint.ASN1
- .encode(decoded.getMessageImprint())));
- assertEquals("Decoded reqPolicy is incorrect", reqPolicy, decoded
- .getReqPolicy());
- assertEquals("Decoded nonce is incorrect", nonce, decoded.getNonce());
- assertFalse("Decoded certReq is incorrect", decoded.getCertReq()
- .booleanValue());
- assertEquals("Decoded extensions is incorrect", exts, decoded
- .getExtensions());
- }
-}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/TimeStampRespTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/TimeStampRespTest.java
deleted file mode 100644
index 80375b6..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/tsp/TimeStampRespTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.x509.tsp;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.asn1.ASN1OctetString;
-import org.apache.harmony.security.pkcs7.ContentInfo;
-import org.apache.harmony.security.pkcs7.SignedData;
-import org.apache.harmony.security.pkcs7.SignerInfo;
-import org.apache.harmony.security.x501.Name;
-import org.apache.harmony.security.x509.AlgorithmIdentifier;
-import org.apache.harmony.security.x509.Extension;
-import org.apache.harmony.security.x509.Extensions;
-import org.apache.harmony.security.x509.GeneralName;
-import org.apache.harmony.security.x509.tsp.MessageImprint;
-import org.apache.harmony.security.x509.tsp.PKIFailureInfo;
-import org.apache.harmony.security.x509.tsp.PKIStatus;
-import org.apache.harmony.security.x509.tsp.PKIStatusInfo;
-import org.apache.harmony.security.x509.tsp.TSTInfo;
-import org.apache.harmony.security.x509.tsp.TimeStampResp;
-
-public class TimeStampRespTest extends TestCase {
-
- /**
- * @throws IOException
- * @tests 'org.apache.harmony.security.x509.tsp.TimeStampResp.getEncoded()'
- */
- public void testGetEncoded() throws IOException {
- String statusString = "statusString";
- PKIStatusInfo status = new PKIStatusInfo(PKIStatus.REJECTION,
- Collections.singletonList(statusString),
- PKIFailureInfo.BAD_REQUEST);
-
-
- // creating TimeStampToken
- String policy = "1.2.3.4.5";
- String sha1 = "1.3.14.3.2.26";
- MessageImprint msgImprint = new MessageImprint(new AlgorithmIdentifier(
- sha1), new byte[20]);
- Date genTime = new Date();
- BigInteger nonce = BigInteger.valueOf(1234567890L);
- // accuracy is 1 second
- int[] accuracy = new int[] { 1, 0, 0 };
- GeneralName tsa = new GeneralName(new Name("CN=AnAuthority"));
- Extensions exts = new Extensions();
- // Time-Stamping extension OID: as defined in RFC 3161
- int[] timeStampingExtOID = new int[] { 1, 3, 6, 1, 5, 5, 7, 3, 8 };
- byte[] timeStampingExtValue = new byte[] { (byte) 1, (byte) 2, (byte) 3 };
- Extension ext = new Extension(timeStampingExtOID, true,
- timeStampingExtValue);
- exts.addExtension(ext);
-
- TSTInfo tSTInfo = new TSTInfo(1, policy, msgImprint, BigInteger.TEN,
- genTime, accuracy, Boolean.FALSE, nonce, tsa, exts);
-
- Object[] issuerAndSerialNumber = new Object[] { new Name("CN=issuer"),
- ASN1Integer.fromIntValue(12345) };
- // SHA1withDSA OID
- String sha1dsa = "1.2.840.10040.4.3";
- SignerInfo sigInfo = new SignerInfo(1, issuerAndSerialNumber,
- new AlgorithmIdentifier(sha1), null, new AlgorithmIdentifier(
- sha1dsa), new byte[20], null);
- // TSTInfo OID according to RFC 3161
- int[] tSTInfoOid = new int[] { 1, 2, 840, 113549, 1, 9, 16, 1, 4 };
- ContentInfo tSTInfoEncoded = new ContentInfo(tSTInfoOid,
- ASN1OctetString.getInstance().encode(
- TSTInfo.ASN1.encode(tSTInfo)));
- SignedData tokenContent = new SignedData(1, Collections
- .singletonList(new AlgorithmIdentifier(sha1)), tSTInfoEncoded,
- null, null, Collections.singletonList(sigInfo));
- ContentInfo timeStampToken = new ContentInfo(ContentInfo.SIGNED_DATA,
- tokenContent);
-
- TimeStampResp response = new TimeStampResp(status, timeStampToken);
-
- byte[] encoding = TimeStampResp.ASN1.encode(response);
- TimeStampResp decoded = (TimeStampResp) TimeStampResp.ASN1
- .decode(encoding);
-
- // deeper checks are performed in the corresponding unit tests
- assertTrue("Decoded status is incorrect", Arrays.equals(
- PKIStatusInfo.ASN1.encode(status), PKIStatusInfo.ASN1
- .encode(decoded.getStatus())));
- assertTrue("Decoded timeStampToken is incorrect", Arrays.equals(
- timeStampToken.getEncoded(), decoded.getTimeStampToken()
- .getEncoded()));
- }
-}
-
diff --git a/security/src/test/resources/AuthenticatedAttributesTest.dat b/security/src/test/resources/AuthenticatedAttributesTest.dat
deleted file mode 100644
index 57491b8..0000000
--- a/security/src/test/resources/AuthenticatedAttributesTest.dat
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/PermissionCollection/keystore.bks b/security/src/test/resources/PermissionCollection/keystore.bks
deleted file mode 100644
index b5129b8..0000000
--- a/security/src/test/resources/PermissionCollection/keystore.bks
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/PermissionCollection/mypermissionBKS.jar b/security/src/test/resources/PermissionCollection/mypermissionBKS.jar
deleted file mode 100644
index 23aa9fb..0000000
--- a/security/src/test/resources/PermissionCollection/mypermissionBKS.jar
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/PermissionCollection/signedBKS.jar b/security/src/test/resources/PermissionCollection/signedBKS.jar
deleted file mode 100644
index 0695e54..0000000
--- a/security/src/test/resources/PermissionCollection/signedBKS.jar
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/PolicyTest.txt b/security/src/test/resources/PolicyTest.txt
deleted file mode 100644
index b765919..0000000
--- a/security/src/test/resources/PolicyTest.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-grant codeBase "file:${test.bin.dir}" {
- permission java.security.SecurityPermission "codeBaseForPolicyTest";
-};
diff --git a/security/src/test/resources/hyts_badpem.cer b/security/src/test/resources/hyts_badpem.cer
deleted file mode 100644
index cc663de..0000000
--- a/security/src/test/resources/hyts_badpem.cer
+++ /dev/null
@@ -1,31 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIFATCCA+mg^wIBAgIBADANBgkqhkiG9w0BAQQFADB/MQswCQYDVQQGEwJkZTEg
-MB4GA1UEChMXSW5zZWN1cmVUZXN0Q2VydGlmaWNhdGUxJzAlBgNVBAMTHkZvciBU
-ZXN0cyBPbmx5IG5leHQgZ2VuZXJhdGlvbjElMCMGCSqGSIb3DQEJARYWaW5zZWN1
-cmVAdGVzdC5pbnNlY3VyZTAeFw0wMjA2MjcxMjE2MzJaFw0xMjA2MjQxMjE2MzJa
-MH8xCzAJBgNVBAYTAmRlMSAwHgYDVQQKExdJbnNlY3VyZVRlc3RDZXJ0aWZpY2F0
-ZTEnMCUGA1UEAxMeRm9yIFRlc3RzIE9ubHkgbmV4dCBnZW5lcmF0aW9uMSUwIwYJ
-KoZIhvcNAQkBFhZpbnNlY3VyZUB0ZXN0Lmluc2VjdXJlMIIBIjANBgkqhkiG9w0B
-AQEFAAOCAQ8AMIIBCgKCAQEApU/ZjFU69b1kOa7R14gUA+fK4W2fiG5Rl7l1Y9Oa
-ykDRQXOXzb2Jtqru0R8wdYHpKDDfJMnf0NkNbsMT9/EPztuEXhxgRM/V1+GxlZqR
-w3B7vDg41wjBuq8/9xOfd8WqdeXID5/JSo/z0Q2v0ifBgCP60DbCFtPneIdElGSY
-tCpNd2qG06CNJz5gvaHDIpQbjgQ2KiGSJStH+cYlwf24JdZgslXqo6JVg3/7SMHq
-mY2A/MIFZRvUEwataZxtmOkba2AhwFesKq1V4DeIvH7VD29Ub0dB4O9r7LHTjxzG
-j4nRrkNi6L4R4HN8q4CtxbJNaoMvFAuMKTIdiBDjEB5G7QIDAQABo4IBhjCCAYIw
-DwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAeYwHQYDVR0OBBYEFI8IT5xTwVzI
-5gzXEy7LUjwjlgIUMIGrBgNVHSMEgaMwgaCAFI8IT5xTwVzI5gzXEy7LUjwjlgIU
-oYGEpIGBMH8xCzAJBgNVBAYTAmRlMSAwHgYDVQQKExdJbnNlY3VyZVRlc3RDZXJ0
-aWZpY2F0ZTEnMCUGA1UEAxMeRm9yIFRlc3RzIE9ubHkgbmV4dCBnZW5lcmF0aW9u
-MSUwIwYJKoZIhvcNAQkBFhZpbnNlY3VyZUB0ZXN0Lmluc2VjdXJlggEAMCEGA1Ud
-EQQaMBiBFmluc2VjdXJlQHRlc3QuaW5zZWN1cmUwIQYDVR0SBBowGIEWaW5zZWN1
-cmVAdGVzdC5pbnNlY3VyZTARBglghkgBhvhCAQEEBAMCAAcwPAYJYIZIAYb4QgEN
-BC8WLVRoaXMgY2VydGlmaWNhdGUgd2FzIGlzc3VlZCBmb3IgdGVzdGluZyBvbmx5
-ITANBgkqhkiG9w0BAQQFAAOCAQEAKG4CjdQ60pskcVVS9batPkOr3HR+20jgxtaW
-Cul+QmepJCZTj2XjmspLlw00ZVcjxTuxsBVKQoSPA0V7xrNU6GVYQtfnYWoQ1Lw+
-c2+J6XZ5iV58uyz4IJVgdq+kyXjopMiJV/cHqDX5fPeLT35L3UNZy8TdhHW+tj7X
-sZelbK6kig9mzOBV2g0Pa86DwctHxL/eRDqX0+Mkvy9YAsBVhHDhVRWBpVMmQFMd
-NbEiGRB0FEKTM+ztlb0QyBrhrjHI9a+P2Q5iap7HuiUrD7BRQ8YWEOUWI8jEdRaI
-kC/K0U+WTB6e32XidjR7GCqFULLCE45of5JWJ/eV9gL5znhbEg==
------END CERTIFICATE-----
-
-
diff --git a/security/src/test/resources/hyts_certificate_PEM.txt b/security/src/test/resources/hyts_certificate_PEM.txt
deleted file mode 100644
index 260645b..0000000
--- a/security/src/test/resources/hyts_certificate_PEM.txt
+++ /dev/null
@@ -1,16 +0,0 @@
------BEGIN CERTIFICATE-----
-MIICpjCCAmSgAwIBAgIBKjALBgcqhkjOOAQDBQAwFDESMBAGA1UEAxMJbW9zdEJvZ3Vz
-MB4XDTAyMDkxMjA1MTQxNFoXDTEyMDkwOTA1MTQxNFowFDESMBAGA1UEAxMJbW9zdEJv
-Z3VzMIIBtjCCASsGByqGSM44BAEwggEeAoGBAJ1FcaWl9WQueeB6znF2UwCLpUUWd4Bx
-sUQMa3gKlac9Aa8CzWZQfv/GHzVByCoqZDgsNlYtdvYtDHyyh6aXwSL3ffFPawdOzSBz
-NsbyLP7DBECvhXp1sYy9LbotnI6J2hIGZxg6D0LY87AZTGWtlxZwiZ4fjYpWeWcNLhC9
-LyZ1AhUAyimlZ8Iyr4ePL8bxaDbrCixlDb8CgYA0xqckl79n0IaYtcbN7SqNA/kUkjVG
-9LjLpUMOTBiOPMWjKbgiZ1jnmINgFy9ZZEvq/F1hjqdE2hAI2arBczmZXD9L2p5LX7sJ
-f+Dqf5jpzwhLFMdFJoANylHCGsUW13rEP+Rr5RYsl4N6WreaKipZIofpZEk8Alqj3qxc
-OWPXmgOBhAACgYAeDfo0hMcW4uUpBRfbhq4CAxDQQeanE6K1bdF9+CqQhkFRPj0Mdso5
-T06WxfqdoMCruHR6BaRprX5TDuxv/EGkK3FgxTxjBOTuCD4+8+pYiycrWjrDFS4rpx5P
-c5wKq2E4AnJ15j7QI6vE0GMDrP5GbDe6+UrGYkvaIfJ9afefvKNHMEUwEgYDVR0TAQH/
-BAgwBgEB/wIBAjAPBgNVHQ8BAf8EBQMDB/4AMB4GA1UdDgQXBBVhbiBvY3RldC1zdHJp
-bmcgdmFsdWUwCwYHKoZIzjgEAwUAAy8AMCwCFDvuHX267Kg6zbIUOeIFsWDFWQnzAhRM
-Nlv0ZVWhYxlyK4iVS2WCw2SV6A==
------END CERTIFICATE-----
diff --git a/security/src/test/resources/hyts_ks.bks b/security/src/test/resources/hyts_ks.bks
deleted file mode 100644
index a1b58a8..0000000
--- a/security/src/test/resources/hyts_ks.bks
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/java/security/Provider.prop.dat b/security/src/test/resources/java/security/Provider.prop.dat
deleted file mode 100644
index 3ee69a0..0000000
--- a/security/src/test/resources/java/security/Provider.prop.dat
+++ /dev/null
@@ -1,8 +0,0 @@
-Property\ 1 = value 1
-serviceName.algName=className
-serviceName.algName\ attrName= attrValue
-Alg.Alias.engineClassName.aliasName=standardName
-Provider.id\ name = NEW NAME
-Provider.id\ version = 333
-Provider.id\ info=newInfo
-Provider.id\ className=aaa.bbb.ccc
diff --git a/security/src/test/resources/java/security/cert/CertPath.PkiPath b/security/src/test/resources/java/security/cert/CertPath.PkiPath
deleted file mode 100644
index 7d415c0..0000000
--- a/security/src/test/resources/java/security/cert/CertPath.PkiPath
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.0.ser
deleted file mode 100644
index a1bdc3e..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.1.ser
deleted file mode 100644
index a1bdc3e..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.2.ser
deleted file mode 100644
index 1efe2e6..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.3.ser
deleted file mode 100644
index d0b45c7..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.4.ser
deleted file mode 100644
index 9addbbe..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.5.ser
deleted file mode 100644
index bfab9c7..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.0.ser
deleted file mode 100644
index e06c8b9..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.1.ser
deleted file mode 100644
index e06c8b9..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.2.ser
deleted file mode 100644
index e319e4c..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.3.ser
deleted file mode 100644
index be10ae1..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.4.ser
deleted file mode 100644
index c23c71d..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.5.ser
deleted file mode 100644
index a38eaa5..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.golden.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.golden.ser
deleted file mode 100644
index c7aff84..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.0.ser
deleted file mode 100644
index 36bc896..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.1.ser
deleted file mode 100644
index 36bc896..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.2.ser
deleted file mode 100644
index 28df335..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.3.ser
deleted file mode 100644
index 3996601..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.4.ser
deleted file mode 100644
index 70c4305..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.5.ser
deleted file mode 100644
index 1d4926e..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.6.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.6.ser
deleted file mode 100644
index 1d4926e..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.golden.6.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.0.ser
deleted file mode 100644
index 7d35485..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.1.ser
deleted file mode 100644
index 7d35485..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.2.ser
deleted file mode 100644
index 285502d..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.3.ser
deleted file mode 100644
index 89f5f00..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.4.ser
deleted file mode 100644
index 1798f04..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.5.ser
deleted file mode 100644
index 1c7d1c1..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.0.ser
deleted file mode 100644
index 7a0cffa..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.1.ser
deleted file mode 100644
index 7a0cffa..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.2.ser
deleted file mode 100644
index 6dac2f1..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.3.ser
deleted file mode 100644
index c6d3570..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.4.ser
deleted file mode 100644
index 4dc454c..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.5.ser
deleted file mode 100644
index 09e9e00..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.0.ser
deleted file mode 100644
index 87a2194..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.1.ser
deleted file mode 100644
index 87a2194..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.2.ser
deleted file mode 100644
index 6e1c28f..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.3.ser
deleted file mode 100644
index 3c85e89..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.4.ser
deleted file mode 100644
index 2d24844..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.5.ser
deleted file mode 100644
index 2bf8762..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.golden.0.ser
deleted file mode 100644
index 62088c0..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.golden.1.ser
deleted file mode 100644
index 62088c0..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.golden.2.ser
deleted file mode 100644
index 41b6cd5..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.0.ser
deleted file mode 100644
index d04a498..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.1.ser
deleted file mode 100644
index d04a498..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.2.ser
deleted file mode 100644
index c8acaf5..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.0.ser
deleted file mode 100644
index 8830fe7..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.1.ser
deleted file mode 100644
index 8830fe7..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.2.ser
deleted file mode 100644
index 6d5d0ea..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.3.ser
deleted file mode 100644
index 4c78972..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.4.ser
deleted file mode 100644
index 7d44a50..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.5.ser
deleted file mode 100644
index 2fd5b23..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.golden.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.golden.ser
deleted file mode 100644
index 1de3c91..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.0.ser
deleted file mode 100644
index fba679c..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.1.ser
deleted file mode 100644
index 29a9a4f..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.2.ser
deleted file mode 100644
index fba679c..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.3.ser
deleted file mode 100644
index fc86eb6..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.golden.0.ser
deleted file mode 100644
index 6efd1b1..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.golden.1.ser
deleted file mode 100644
index 5e63409..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.0.ser
deleted file mode 100644
index 4968d55..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.1.ser
deleted file mode 100644
index 4968d55..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.2.ser
deleted file mode 100644
index a7b6a62..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.3.ser
deleted file mode 100644
index 9f70661..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.4.ser
deleted file mode 100644
index 1792f4f..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.5.ser
deleted file mode 100644
index 123ed8f..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.0.ser
deleted file mode 100644
index b89d1d5..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.1.ser
deleted file mode 100644
index b89d1d5..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.2.ser
deleted file mode 100644
index b1f4a29..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.3.ser
deleted file mode 100644
index 40005f8..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.4.ser
deleted file mode 100644
index 518c59d..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.5.ser
deleted file mode 100644
index b7c8c79..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.golden.0.ser
deleted file mode 100644
index f310ff3..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.golden.1.ser
deleted file mode 100644
index 78a7f0e..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.golden.2.ser
deleted file mode 100644
index 3b32f4d..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/GuardedObjectTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.0.ser
deleted file mode 100644
index 2e5ec11..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.1.ser
deleted file mode 100644
index 2e5ec11..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.2.ser
deleted file mode 100644
index 3edb61d..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.3.ser
deleted file mode 100644
index d7a2404..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.4.ser
deleted file mode 100644
index 91b1de1..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.5.ser
deleted file mode 100644
index f423f82..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.0.ser
deleted file mode 100644
index 3af8fb1..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.1.ser
deleted file mode 100644
index 3af8fb1..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.2.ser
deleted file mode 100644
index e687939..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.3.ser
deleted file mode 100644
index b253c3a..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.4.ser
deleted file mode 100644
index 150b2dc..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.5.ser
deleted file mode 100644
index a6755d2..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.golden.0.ser
deleted file mode 100644
index 8dd87b1..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.golden.1.ser
deleted file mode 100644
index 8dd87b1..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.golden.2.ser
deleted file mode 100644
index 22ab420..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.0.ser
deleted file mode 100644
index 60e1896..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.1.ser
deleted file mode 100644
index 60e1896..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.2.ser
deleted file mode 100644
index 365998c..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.3.ser
deleted file mode 100644
index fbe4430..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.4.ser
deleted file mode 100644
index d78207a..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.5.ser
deleted file mode 100644
index ebf71f5..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.0.ser
deleted file mode 100644
index e36b9cf..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.1.ser
deleted file mode 100644
index e36b9cf..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.2.ser
deleted file mode 100644
index 63ac483..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.3.ser
deleted file mode 100644
index fb64ff6..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.4.ser
deleted file mode 100644
index 629e21b..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.5.ser
deleted file mode 100644
index ea029cb..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyPairTest.golden.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyPairTest.golden.ser
deleted file mode 100644
index c6ad378..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyPairTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.0.ser
deleted file mode 100644
index 5403676..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.1.ser
deleted file mode 100644
index 5403676..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.2.ser
deleted file mode 100644
index f2cc38c..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.3.ser
deleted file mode 100644
index d51d2ae..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.4.ser
deleted file mode 100644
index 244c084..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.5.ser
deleted file mode 100644
index 893237e..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.0.ser
deleted file mode 100644
index 631a3e2..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.1.ser
deleted file mode 100644
index 631a3e2..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.2.ser
deleted file mode 100644
index b492339..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.3.ser
deleted file mode 100644
index 37e40f7..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.4.ser
deleted file mode 100644
index b8aead8..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.5.ser
deleted file mode 100644
index 79c2514..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.golden.0.ser
deleted file mode 100644
index cb26a80..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.golden.1.ser
deleted file mode 100644
index cb26a80..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.golden.2.ser
deleted file mode 100644
index 12f2349..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.golden.0.ser
deleted file mode 100644
index 45cfb39..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.golden.1.ser
deleted file mode 100644
index 5dcd97f..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.golden.2.ser
deleted file mode 100644
index 10253ac..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.0.ser
deleted file mode 100644
index ccca26b..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.1.ser
deleted file mode 100644
index ccca26b..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.2.ser
deleted file mode 100644
index 67c85fa..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.3.ser
deleted file mode 100644
index 827b5f9..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.4.ser
deleted file mode 100644
index 6340ec7..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.5.ser
deleted file mode 100644
index 131378a..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.0.ser
deleted file mode 100644
index 0fe6399..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.1.ser
deleted file mode 100644
index 0fe6399..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.2.ser
deleted file mode 100644
index 0a755fa..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.3.ser
deleted file mode 100644
index b7d4294..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.4.ser
deleted file mode 100644
index a7c1081..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.5.ser
deleted file mode 100644
index 47989cc..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignedObjectTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignedObjectTest.golden.0.ser
deleted file mode 100644
index 4bfc3d2..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SignedObjectTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/TimestampTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/TimestampTest.golden.0.ser
deleted file mode 100644
index 14a3909..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/TimestampTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.golden.0.ser
deleted file mode 100644
index b862824..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.golden.1.ser
deleted file mode 100644
index b862824..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.golden.2.ser
deleted file mode 100644
index 288c4ba..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.golden.0.ser
deleted file mode 100644
index f9a97a5..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.golden.1.ser
deleted file mode 100644
index f9a97a5..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.golden.2.ser
deleted file mode 100644
index 5463e7c..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.0.ser
deleted file mode 100644
index e8cb9c1..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.1.ser
deleted file mode 100644
index e8cb9c1..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.2.ser
deleted file mode 100644
index 64daddc..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.3.ser
deleted file mode 100644
index c784a24..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.4.ser
deleted file mode 100644
index 8347049..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.5.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.5.ser
deleted file mode 100644
index e9cc9af..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.golden.5.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.golden.0.ser
deleted file mode 100644
index 6907772..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.golden.1.ser
deleted file mode 100644
index 6907772..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.golden.2.ser
deleted file mode 100644
index 30e6a55..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.0.ser
deleted file mode 100644
index 34436a8..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.1.ser
deleted file mode 100644
index 34436a8..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.2.ser
deleted file mode 100644
index d3cfeb9..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.3.ser
deleted file mode 100644
index af082b9..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.0.ser
deleted file mode 100644
index 2e6a163..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.1.ser
deleted file mode 100644
index 2e6a163..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.2.ser
deleted file mode 100644
index 9c97030..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.3.ser
deleted file mode 100644
index 1a94257..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.golden.0.ser
deleted file mode 100644
index 340f474..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.golden.1.ser
deleted file mode 100644
index 340f474..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.golden.2.ser
deleted file mode 100644
index 4486486..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.0.ser
deleted file mode 100644
index 8b8470f..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.1.ser
deleted file mode 100644
index 8b8470f..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.2.ser
deleted file mode 100644
index 07978dc..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.0.ser
deleted file mode 100644
index 9017f70..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.1.ser
deleted file mode 100644
index 9017f70..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.2.ser
deleted file mode 100644
index 88892ee..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.3.ser
deleted file mode 100644
index 88892ee..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.0.ser
deleted file mode 100644
index e32b978..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.1.ser
deleted file mode 100644
index 837b6b8..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.2.ser
deleted file mode 100644
index c0ada25..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.3.ser
deleted file mode 100644
index 1a6c21a..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.4.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.4.ser
deleted file mode 100644
index 240c367..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/test.BKS.ks1 b/security/src/test/resources/test.BKS.ks1
deleted file mode 100644
index 0bde726..0000000
--- a/security/src/test/resources/test.BKS.ks1
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/test.BKS.ks2 b/security/src/test/resources/test.BKS.ks2
deleted file mode 100644
index b55861f..0000000
--- a/security/src/test/resources/test.BKS.ks2
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/test.BKS.ks3 b/security/src/test/resources/test.BKS.ks3
deleted file mode 100644
index 4312fd4..0000000
--- a/security/src/test/resources/test.BKS.ks3
+++ /dev/null
Binary files differ
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/CertificateStub.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/CertificateStub.java
deleted file mode 100644
index f394acf..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/CertificateStub.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Aleksei Y. Semenov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.Certificate;
-import java.security.KeyException;
-import java.security.Principal;
-import java.security.PublicKey;
-
-/**
- * Stub for interface Certificate, necessary for testing
- */
-
-public class CertificateStub implements Certificate {
-
- String format;
- Principal guarantor;
- Principal principal;
- PublicKey key;
-
- public CertificateStub(String format, Principal guarantor, Principal principal, PublicKey key) {
- this.format = format;
- this.guarantor = guarantor;
- this.principal = principal;
- this.key = key;
- }
-
- /**
- * Stub - does nothing
- *
- * @see java.security.Certificate#decode(java.io.InputStream)
- */
- public void decode(InputStream stream) throws KeyException,
- IOException {
-
-
- }
-
- /**
- * Stub - does nothing
- *
- * @see java.security.Certificate#encode(java.io.OutputStream)
- */
- public void encode(OutputStream stream) throws KeyException,
- IOException {
-
-
- }
-
- /**
- * @see java.security.Certificate#getFormat()
- */
- public String getFormat() {
-
- return format;
- }
-
- /**
- * @see java.security.Certificate#getGuarantor()
- */
- public Principal getGuarantor() {
-
- return guarantor;
- }
-
- /**
- * @see java.security.Certificate#getPrincipal()
- */
- public Principal getPrincipal() {
- return principal;
- }
-
- /**
- * @see java.security.Certificate#getPublicKey()
- */
- public PublicKey getPublicKey() {
- return key;
- }
-
- /**
- * Stub - returns <code>null</code>
- *
- * @see java.security.Certificate#toString(boolean)
- */
- public String toString(boolean detailed) {
- return null;
- }
-
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/IdentityScopeStub.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/IdentityScopeStub.java
deleted file mode 100644
index e57c152..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/IdentityScopeStub.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Aleksei Y. Semenov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.Identity;
-import java.security.IdentityScope;
-import java.security.KeyManagementException;
-import java.security.PublicKey;
-import java.util.Enumeration;
-
-/**
- * This is stub implementation of IdentityScope for testing purposes
- */
-
-public class IdentityScopeStub extends IdentityScope {
-
-
- /**
- * Stub constructor
- */
- public IdentityScopeStub() {
- super();
- }
-
- /**
- * Stub constructor
- *
- * @param name
- */
- public IdentityScopeStub(String name) {
- super(name);
- }
-
- /**
- * Stub constructor
- *
- * @param name
- * @param scope
- * @throws KeyManagementException
- */
- public IdentityScopeStub(String name, IdentityScope scope)
- throws KeyManagementException {
- super(name, scope);
- }
-
- /**
- * Stub - returns 0
- *
- * @see java.security.IdentityScope#size()
- */
- public int size() {
-
- return 0;
- }
-
- /**
- * Stub - returns <code>this</code>
- *
- * @see java.security.IdentityScope#getIdentity(java.lang.String)
- */
- public Identity getIdentity(String name) {
-
- return this;
- }
-
- /**
- * Stub - returns <code>this</code>
- *
- * @see java.security.IdentityScope#getIdentity(java.security.PublicKey)
- */
- public Identity getIdentity(PublicKey key) {
- return this;
- }
-
- /**
- * Stub - does nothing
- *
- * @see java.security.IdentityScope#addIdentity(java.security.Identity)
- */
- public void addIdentity(Identity identity) throws KeyManagementException {
-
-
- }
-
- /**
- * Stub - does nothing
- *
- * @see java.security.IdentityScope#removeIdentity(java.security.Identity)
- */
- public void removeIdentity(Identity identity) throws KeyManagementException {
-
-
- }
-
- /**
- * Stub - returns <code>null</code>
- *
- * @see java.security.IdentityScope#identities()
- */
- public Enumeration identities() {
- return null;
- }
-
- /**
- * Sets the system's identity scope
- *
- * @param scope
- */
- public static void mySetSystemScope(IdentityScope scope) {
-
- IdentityScope.setSystemScope(scope);
- }
-
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/IdentityStub.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/IdentityStub.java
deleted file mode 100644
index 979b84e..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/IdentityStub.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Aleksei Y. Semenov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.Identity;
-import java.security.IdentityScope;
-import java.security.KeyManagementException;
-import java.security.PublicKey;
-
-/**
- * Stub for abstract class Identity
- */
-
-public class IdentityStub extends Identity {
-
- /**
- * Default constructor
- */
- public IdentityStub() {
- super();
- }
-
- /**
- * TODO Put ctor description here
- *
- * @param name
- */
- public IdentityStub(String name) {
- super(name);
- }
-
- /**
- * TODO Put ctor description here
- *
- * @param name
- * @param scope
- * @throws KeyManagementException
- */
- public IdentityStub(String name, IdentityScope scope)
- throws KeyManagementException {
- super(name, scope);
- }
-
- /**
- * Auxiliary constructor
- *
- * @param name
- * @param key
- * @throws KeyManagementException
- */
-
- public IdentityStub(String name, PublicKey key) throws KeyManagementException {
- this(name);
- setPublicKey(key);
- }
-
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/KeyStoreTestSupport.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/KeyStoreTestSupport.java
deleted file mode 100644
index f4e8f21..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/KeyStoreTestSupport.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.InvalidKeyException;
-import java.security.KeyStore;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-
-import javax.crypto.SecretKey;
-
-/**
- * Support class for KeyStore tests
- */
-
-public class KeyStoreTestSupport {
-
- public static final String srvKeyStore = "KeyStore";
-
- public static String[] validValues = { "bks", "BKS", "bKS", "Bks", "bKs",
- "BkS" };
-
- public static String defaultType = "bks";
-
- public static boolean JKSSupported = false;
-
- public static String defaultProviderName = null;
-
- public static Provider defaultProvider = null;
-
- static {
- defaultProvider = SpiEngUtils.isSupport(defaultType, srvKeyStore);
- JKSSupported = (defaultProvider != null);
- defaultProviderName = (JKSSupported ? defaultProvider.getName() : null);
- }
-
- /**
- * Additional class to create SecretKey object
- */
- public static class SKey implements SecretKey {
- private String type;
-
- private byte[] encoded;
-
- public SKey(String type, byte[] encoded) {
- this.type = type;
- this.encoded = encoded;
- }
-
- public String getAlgorithm() {
- return type;
- }
-
- public byte[] getEncoded() {
- return encoded;
- }
-
- public String getFormat() {
- return "test";
- }
- }
-
- /**
- * Additional class to create PrivateKey object
- */
- public static class MyPrivateKey implements PrivateKey {
- private String algorithm;
-
- private String format;
-
- private byte[] encoded;
-
- public MyPrivateKey(String algorithm, String format, byte[] encoded) {
- this.algorithm = algorithm;
- this.format = format;
- this.encoded = encoded;
- }
-
- public String getAlgorithm() {
- return algorithm;
- }
-
- public String getFormat() {
- return format;
- }
-
- public byte[] getEncoded() {
- return encoded;
- }
- }
-
- /**
- * Additional class to create Certificate and Key objects
- */
- public static class MCertificate extends Certificate {
- private final byte[] encoding;
-
- private final String type;
-
- public MCertificate(String type, byte[] encoding) {
- super(type);
- this.encoding = encoding;
- this.type = type;
- }
-
- public byte[] getEncoded() throws CertificateEncodingException {
- return encoding.clone();
- }
-
- public void verify(PublicKey key) throws CertificateException,
- NoSuchAlgorithmException, InvalidKeyException,
- NoSuchProviderException, SignatureException {
- }
-
- public void verify(PublicKey key, String sigProvider)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- }
-
- public String toString() {
- return "[MCertificate, type: " + getType() + "]";
- }
-
- public PublicKey getPublicKey() {
- return new PublicKey() {
- public String getAlgorithm() {
- return type;
- }
-
- public byte[] getEncoded() {
- return encoding;
- }
-
- public String getFormat() {
- return "test";
- }
- };
- }
- }
-
- /**
- * Additional class to create ProtectionParameter object
- */
- public static class ProtPar implements KeyStore.ProtectionParameter {
- }
-
- /**
- * Additional class to create KeyStore.Entry object
- */
- public static class AnotherEntry implements KeyStore.Entry {
- }
-}
-
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MDGoldenData.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MDGoldenData.java
deleted file mode 100644
index d6236cd..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MDGoldenData.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.util.HashMap;
-
-/**
- * Golden data for Message Digest related tests.<br>
- * Encapsulates the following data:<br>
- * - reference message<br>
- * - reference message digests calculated using
- * BEA JRockit j2sdk1.4.2_04 (http://www.bea.com)
- * for various MD algorithms:
- * SHA-1, SHA-256, SHA-384, SHA-512, MD-5.
- * Standard algorithm names are defined in
- * "JavaTM Cryptography Architecture API Specification & Reference"
- */
-public class MDGoldenData {
- // The length of test message
- private static final int MY_MESSAGE_LEN = 1024;
- // Test message for digest computations
- private static final byte[] myMessage = new byte[MY_MESSAGE_LEN];
- // Reference digests for various algorithms calculated
- // for <code>myMessage</code>
- private static final HashMap goldenData = new HashMap();
-
- static {
- // fill myMessage
- for (int i = 0; i < myMessage.length; i++) {
- myMessage[i] = (byte) i;
- }
- // fill goldenData
- // digest updated with myMessage bytes
- goldenData.put("SHA-1", new byte[] {
- (byte) 0x5b, (byte) 0x00, (byte) 0x66, (byte) 0x9c,
- (byte) 0x48, (byte) 0x0d, (byte) 0x5c, (byte) 0xff,
- (byte) 0xbd, (byte) 0xfa, (byte) 0x8b, (byte) 0xdb,
- (byte) 0xa9, (byte) 0x95, (byte) 0x61, (byte) 0x16,
- (byte) 0x0f, (byte) 0x2d, (byte) 0x1b, (byte) 0x77
- });
- // digest without updates at all;
- // use MD algorithm name + "_NU" if not updated MD value is needed
- goldenData.put("SHA-1_NU", new byte[] {
- (byte) 0xda, (byte) 0x39, (byte) 0xa3, (byte) 0xee,
- (byte) 0x5e, (byte) 0x6b, (byte) 0x4b, (byte) 0x0d,
- (byte) 0x32, (byte) 0x55, (byte) 0xbf, (byte) 0xef,
- (byte) 0x95, (byte) 0x60, (byte) 0x18, (byte) 0x90,
- (byte) 0xaf, (byte) 0xd8, (byte) 0x07, (byte) 0x09
- });
-
- goldenData.put("SHA", goldenData.get("SHA-1"));
- goldenData.put("SHA_NU", goldenData.get("SHA-1_NU"));
-
- goldenData.put("SHA1", goldenData.get("SHA-1"));
- goldenData.put("SHA1_NU", goldenData.get("SHA-1_NU"));
-
- goldenData.put("SHA-256", new byte[] {
- (byte) 0x78, (byte) 0x5b, (byte) 0x07, (byte) 0x51,
- (byte) 0xfc, (byte) 0x2c, (byte) 0x53, (byte) 0xdc,
- (byte) 0x14, (byte) 0xa4, (byte) 0xce, (byte) 0x3d,
- (byte) 0x80, (byte) 0x0e, (byte) 0x69, (byte) 0xef,
- (byte) 0x9c, (byte) 0xe1, (byte) 0x00, (byte) 0x9e,
- (byte) 0xb3, (byte) 0x27, (byte) 0xcc, (byte) 0xf4,
- (byte) 0x58, (byte) 0xaf, (byte) 0xe0, (byte) 0x9c,
- (byte) 0x24, (byte) 0x2c, (byte) 0x26, (byte) 0xc9
- });
- goldenData.put("SHA-256_NU", new byte[] {
- (byte) 0xe3, (byte) 0xb0, (byte) 0xc4, (byte) 0x42,
- (byte) 0x98, (byte) 0xfc, (byte) 0x1c, (byte) 0x14,
- (byte) 0x9a, (byte) 0xfb, (byte) 0xf4, (byte) 0xc8,
- (byte) 0x99, (byte) 0x6f, (byte) 0xb9, (byte) 0x24,
- (byte) 0x27, (byte) 0xae, (byte) 0x41, (byte) 0xe4,
- (byte) 0x64, (byte) 0x9b, (byte) 0x93, (byte) 0x4c,
- (byte) 0xa4, (byte) 0x95, (byte) 0x99, (byte) 0x1b,
- (byte) 0x78, (byte) 0x52, (byte) 0xb8, (byte) 0x55
- });
- goldenData.put("SHA-384", new byte[] {
- (byte) 0x55, (byte) 0xfd, (byte) 0x17, (byte) 0xee,
- (byte) 0xb1, (byte) 0x61, (byte) 0x1f, (byte) 0x91,
- (byte) 0x93, (byte) 0xf6, (byte) 0xac, (byte) 0x60,
- (byte) 0x02, (byte) 0x38, (byte) 0xce, (byte) 0x63,
- (byte) 0xaa, (byte) 0x29, (byte) 0x8c, (byte) 0x2e,
- (byte) 0x33, (byte) 0x2f, (byte) 0x04, (byte) 0x2b,
- (byte) 0x80, (byte) 0xc8, (byte) 0xf6, (byte) 0x91,
- (byte) 0xf8, (byte) 0x00, (byte) 0xe4, (byte) 0xc7,
- (byte) 0x50, (byte) 0x5a, (byte) 0xf2, (byte) 0x0c,
- (byte) 0x1a, (byte) 0x86, (byte) 0xa3, (byte) 0x1f,
- (byte) 0x08, (byte) 0x50, (byte) 0x45, (byte) 0x87,
- (byte) 0x39, (byte) 0x5f, (byte) 0x08, (byte) 0x1f
- });
- goldenData.put("SHA-384_NU", new byte[] {
- (byte) 0x38, (byte) 0xb0, (byte) 0x60, (byte) 0xa7,
- (byte) 0x51, (byte) 0xac, (byte) 0x96, (byte) 0x38,
- (byte) 0x4c, (byte) 0xd9, (byte) 0x32, (byte) 0x7e,
- (byte) 0xb1, (byte) 0xb1, (byte) 0xe3, (byte) 0x6a,
- (byte) 0x21, (byte) 0xfd, (byte) 0xb7, (byte) 0x11,
- (byte) 0x14, (byte) 0xbe, (byte) 0x07, (byte) 0x43,
- (byte) 0x4c, (byte) 0x0c, (byte) 0xc7, (byte) 0xbf,
- (byte) 0x63, (byte) 0xf6, (byte) 0xe1, (byte) 0xda,
- (byte) 0x27, (byte) 0x4e, (byte) 0xde, (byte) 0xbf,
- (byte) 0xe7, (byte) 0x6f, (byte) 0x65, (byte) 0xfb,
- (byte) 0xd5, (byte) 0x1a, (byte) 0xd2, (byte) 0xf1,
- (byte) 0x48, (byte) 0x98, (byte) 0xb9, (byte) 0x5b
- });
- goldenData.put("SHA-512", new byte[] {
- (byte) 0x37, (byte) 0xf6, (byte) 0x52, (byte) 0xbe,
- (byte) 0x86, (byte) 0x7f, (byte) 0x28, (byte) 0xed,
- (byte) 0x03, (byte) 0x32, (byte) 0x69, (byte) 0xcb,
- (byte) 0xba, (byte) 0x20, (byte) 0x1a, (byte) 0xf2,
- (byte) 0x11, (byte) 0x2c, (byte) 0x2b, (byte) 0x3f,
- (byte) 0xd3, (byte) 0x34, (byte) 0xa8, (byte) 0x9f,
- (byte) 0xd2, (byte) 0xf7, (byte) 0x57, (byte) 0x93,
- (byte) 0x8d, (byte) 0xde, (byte) 0xe8, (byte) 0x15,
- (byte) 0x78, (byte) 0x7c, (byte) 0xc6, (byte) 0x1d,
- (byte) 0x6e, (byte) 0x24, (byte) 0xa8, (byte) 0xa3,
- (byte) 0x33, (byte) 0x40, (byte) 0xd0, (byte) 0xf7,
- (byte) 0xe8, (byte) 0x6f, (byte) 0xfc, (byte) 0x05,
- (byte) 0x88, (byte) 0x16, (byte) 0xb8, (byte) 0x85,
- (byte) 0x30, (byte) 0x76, (byte) 0x6b, (byte) 0xa6,
- (byte) 0xe2, (byte) 0x31, (byte) 0x62, (byte) 0x0a,
- (byte) 0x13, (byte) 0x0b, (byte) 0x56, (byte) 0x6c
- });
- goldenData.put("SHA-512_NU", new byte[] {
- (byte) 0xcf, (byte) 0x83, (byte) 0xe1, (byte) 0x35,
- (byte) 0x7e, (byte) 0xef, (byte) 0xb8, (byte) 0xbd,
- (byte) 0xf1, (byte) 0x54, (byte) 0x28, (byte) 0x50,
- (byte) 0xd6, (byte) 0x6d, (byte) 0x80, (byte) 0x07,
- (byte) 0xd6, (byte) 0x20, (byte) 0xe4, (byte) 0x05,
- (byte) 0x0b, (byte) 0x57, (byte) 0x15, (byte) 0xdc,
- (byte) 0x83, (byte) 0xf4, (byte) 0xa9, (byte) 0x21,
- (byte) 0xd3, (byte) 0x6c, (byte) 0xe9, (byte) 0xce,
- (byte) 0x47, (byte) 0xd0, (byte) 0xd1, (byte) 0x3c,
- (byte) 0x5d, (byte) 0x85, (byte) 0xf2, (byte) 0xb0,
- (byte) 0xff, (byte) 0x83, (byte) 0x18, (byte) 0xd2,
- (byte) 0x87, (byte) 0x7e, (byte) 0xec, (byte) 0x2f,
- (byte) 0x63, (byte) 0xb9, (byte) 0x31, (byte) 0xbd,
- (byte) 0x47, (byte) 0x41, (byte) 0x7a, (byte) 0x81,
- (byte) 0xa5, (byte) 0x38, (byte) 0x32, (byte) 0x7a,
- (byte) 0xf9, (byte) 0x27, (byte) 0xda, (byte) 0x3e
- });
- goldenData.put("MD5", new byte[] {
- (byte) 0xb2, (byte) 0xea, (byte) 0x9f, (byte) 0x7f,
- (byte) 0xce, (byte) 0xa8, (byte) 0x31, (byte) 0xa4,
- (byte) 0xa6, (byte) 0x3b, (byte) 0x21, (byte) 0x3f,
- (byte) 0x41, (byte) 0xa8, (byte) 0x85, (byte) 0x5b
- });
- goldenData.put("MD5_NU", new byte[] {
- (byte) 0xd4, (byte) 0x1d, (byte) 0x8c, (byte) 0xd9,
- (byte) 0x8f, (byte) 0x00, (byte) 0xb2, (byte) 0x04,
- (byte) 0xe9, (byte) 0x80, (byte) 0x09, (byte) 0x98,
- (byte) 0xec, (byte) 0xf8, (byte) 0x42, (byte) 0x7e
- });
- }
-
- // No need to instantiate
- private MDGoldenData() {
- }
-
- /**
- * Returns reference message
- *
- * @return reference message
- */
- public static byte[] getMessage() {
- return myMessage.clone();
- }
-
- /**
- * Returns digest golden data
- *
- * @param key MD algorithm name or MD algorithm name + "_NU" if
- * not updated MD value requested
- * @return reference digest for specified MD algorithm name
- */
- public static byte[] getDigest(String key) {
- return ((byte[]) goldenData.get(key)).clone();
- }
-
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyAlgorithmParameterGeneratorSpi.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyAlgorithmParameterGeneratorSpi.java
deleted file mode 100644
index 41cebf4..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyAlgorithmParameterGeneratorSpi.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.AlgorithmParameterGeneratorSpi;
-import java.security.AlgorithmParameters;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * Additional class for verification AlgorithmParameterGeneratorSpi and
- * AlgorithmParameterGenerator classes
- */
-
-public class MyAlgorithmParameterGeneratorSpi
- extends AlgorithmParameterGeneratorSpi {
-
- protected void engineInit(int keysize, SecureRandom random) {
- if (keysize < 0) {
- throw new IllegalArgumentException("keysize < 0");
- }
- }
-
- protected void engineInit(AlgorithmParameterSpec genParamSpec,
- SecureRandom random) {
- if (random == null) {
- throw new IllegalArgumentException("random is null");
- }
- }
-
- protected AlgorithmParameters engineGenerateParameters() {
- return null;
- }
-} \ No newline at end of file
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyBasicPermission.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyBasicPermission.java
deleted file mode 100644
index d0e409a..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyBasicPermission.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.BasicPermission;
-
-public class MyBasicPermission extends BasicPermission {
-
- private static final long serialVersionUID = -4220730623258019258L;
-
- public MyBasicPermission(String name) {
- super(name);
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyGuard.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyGuard.java
deleted file mode 100644
index 073c928..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyGuard.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.io.Serializable;
-import java.security.Guard;
-
-public class MyGuard implements Guard, Serializable {
-
- private static final long serialVersionUID = 5767944725614823373L;
-
- final boolean enabled;
-
- public MyGuard(boolean state) {
- enabled = state;
- }
-
- public void checkGuard(Object object) {
- if (!enabled) {
- throw new SecurityException();
- }
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator1.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator1.java
deleted file mode 100644
index cc85cf8..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator1.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidParameterException;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * Additional class extends KeyPairGenerator
- */
-
-public class MyKeyPairGenerator1 extends KeyPairGenerator {
- public int keySize;
-
- public SecureRandom secureRandom;
-
- public AlgorithmParameterSpec paramSpec;
-
- public MyKeyPairGenerator1() {
- super("MyKeyPairGenerator1");
- }
-
- public MyKeyPairGenerator1(String pp) {
- super(pp);
- }
-
- public String getAlgorithm() {
- return "MyKeyPairGenerator1";
- }
-
- public static final String getResAlgorithm() {
- return "MyKeyPairGenerator1";
- }
-
- public void initialize(int keysize, SecureRandom random) {
- if ((keysize < 0) || ((keysize % 100) != 0)) {
- throw new InvalidParameterException("Incorrect keysize parameter");
- }
- if (random == null) {
- throw new InvalidParameterException("Incorrect random");
- }
- keySize = keysize;
- secureRandom = random;
- }
-
- public KeyPair generateKeyPair() {
- try {
- return new KeyPair(new PubKey(), new PrivKey());
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public void initialize(AlgorithmParameterSpec param, SecureRandom random)
- throws InvalidAlgorithmParameterException {
- if (random == null) {
- throw new InvalidParameterException("Incorrect random");
- }
- if (param == null) {
- throw new InvalidAlgorithmParameterException("Incorrect param");
- }
- paramSpec = param;
- secureRandom = random;
- }
-
- public class PubKey implements PublicKey {
- private String algorithm;
-
- private String format;
-
- private byte[] encoded;
-
- public PubKey() {
- this.algorithm = "MyKeyPairGenerator1";
- this.format = "test1";
- this.encoded = new byte[10];
- }
-
- public String getAlgorithm() {
- return algorithm;
- }
-
- public String getFormat() {
- return format;
- }
-
- public byte[] getEncoded() {
- return encoded;
- }
- }
-
- public class PrivKey implements PrivateKey {
- private String algorithm;
-
- private String format;
-
- private byte[] encoded;
-
- public PrivKey() {
- this.algorithm = "MyKeyPairGenerator1";
- this.format = "test1";
- this.encoded = new byte[10];
- }
-
- public String getAlgorithm() {
- return algorithm;
- }
-
- public String getFormat() {
- return format;
- }
-
- public byte[] getEncoded() {
- return encoded;
- }
- }
-
-} \ No newline at end of file
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator2.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator2.java
deleted file mode 100644
index 3e6bfbb..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator2.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.InvalidParameterException;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.SecureRandom;
-
-/**
- * Additional class extends KeyPairGenerator
- */
-
-public class MyKeyPairGenerator2 extends KeyPairGenerator {
- int keySize;
-
- SecureRandom secureRandom;
-
- public MyKeyPairGenerator2() {
- super("MyKeyPairGenerator2");
- }
-
- public String getAlgorithm() {
- return "MyKeyPairGenerator2";
- }
-
- public static final String getResAlgorithm() {
- return "MyKeyPairGenerator2";
- }
-
- public MyKeyPairGenerator2(String pp) {
- super(pp);
- }
-
- public void initialize(int keysize, SecureRandom random) {
- if (keysize < 64) {
- throw new InvalidParameterException("Incorrect keysize parameter");
- }
- keySize = keysize;
- secureRandom = random;
- }
-
- public KeyPair generateKeyPair() {
- return null;
- }
-}
-
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator3.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator3.java
deleted file mode 100644
index ac26c6f..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator3.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-
-/**
- * Additional class extends KeyPairGenerator
- */
-
-public class MyKeyPairGenerator3 extends KeyPairGenerator {
- public MyKeyPairGenerator3() {
- super("KPGen_3");
- }
-
- public MyKeyPairGenerator3(String s) {
- super(s);
- }
-
- public KeyPair generateKeyPair() {
- PublicKey pubK = (new MyKeyPairGenerator1()).new PubKey();
- PrivateKey priK = (new MyKeyPairGenerator1()).new PrivKey();
- return new KeyPair(pubK, priK);
- }
-
-}
-
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGeneratorSpi.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGeneratorSpi.java
deleted file mode 100644
index b412202..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGeneratorSpi.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidParameterException;
-import java.security.KeyPair;
-import java.security.KeyPairGeneratorSpi;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * Additional class for verification of KeyPairGeneratorSpi and KeyPairGenerator
- */
-
-public class MyKeyPairGeneratorSpi extends KeyPairGeneratorSpi {
-
- public void initialize(int keysize, SecureRandom random) {
- if (keysize < 100) {
- throw new InvalidParameterException(
- "Invalid keysize: less than 100");
- }
- if (random == null) {
- throw new IllegalArgumentException("Invalid random");
- }
- }
-
- public KeyPair generateKeyPair() {
- return null;
- }
-
- public void initialize(AlgorithmParameterSpec params, SecureRandom random)
- throws InvalidAlgorithmParameterException {
- if (random == null) {
- throw new UnsupportedOperationException(
- "Not supported for null random");
- }
- }
-} \ No newline at end of file
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyStore.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyStore.java
deleted file mode 100644
index cf31761..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyStore.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.Key;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.KeyStoreSpi;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-/**
- * Additional class for KeyStoreSpi and KeyStore verification
- */
-
-public class MyKeyStore extends KeyStoreSpi {
- private Hashtable Keys = new Hashtable();
-
- private Hashtable Cert = new Hashtable();
-
- private Hashtable Chain = new Hashtable();
-
- private Hashtable Dates = new Hashtable();
-
- private Hashtable KeysSL = new Hashtable();
-
- private Hashtable CertSL = new Hashtable();
-
- private Hashtable ChainSL = new Hashtable();
-
- private Hashtable DatesSL = new Hashtable();
-
- public Key engineGetKey(String alias, char[] password)
- throws NoSuchAlgorithmException, UnrecoverableKeyException {
- if (Keys.containsKey(alias)) {
- return (Key) Keys.get(alias);
- }
- return null;
- }
-
- public Certificate[] engineGetCertificateChain(String alias) {
- if (Chain.containsKey(alias)) {
- return (Certificate[]) Chain.get(alias);
- }
- return null;
- }
-
- public Certificate engineGetCertificate(String alias) {
- if (Cert.containsKey(alias)) {
- return (Certificate) Cert.get(alias);
- }
- return null;
- }
-
- public Date engineGetCreationDate(String alias) {
- if (Dates.containsKey(alias)) {
- return (Date) Dates.get(alias);
- }
- return null;
- }
-
- public void engineSetKeyEntry(String alias, Key key, char[] password,
- Certificate[] chain) throws KeyStoreException {
- if (Cert.containsKey(alias)) {
- Cert.remove(alias);
- }
- Keys.put(alias, key);
- if (chain != null) {
- Chain.put(alias, chain);
- }
- Dates.put(alias, new Date());
- }
-
- public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain)
- throws KeyStoreException {
- if (key == null) {
- throw new KeyStoreException("Not Supported for null key");
- }
- if (Cert.containsKey(alias)) {
- Cert.remove(alias);
- }
- if (Chain.containsKey(alias)) {
- Chain.remove(alias);
- }
- KeyStoreTestSupport.MyPrivateKey keyK = new KeyStoreTestSupport.MyPrivateKey(
- alias, alias, key);
- Keys.put(alias, keyK);
- if (chain != null) {
- Chain.put(alias, chain);
- }
- Dates.put(alias, new Date());
-
- }
-
- public void engineSetCertificateEntry(String alias, Certificate cert)
- throws KeyStoreException {
- Cert.put(alias, cert);
- Dates.put(alias, new Date());
- }
-
- public void engineDeleteEntry(String alias) throws KeyStoreException {
- if (Keys.containsKey(alias)) {
- Keys.remove(alias);
- Chain.remove(alias);
- return;
- }
- if (Cert.containsKey(alias)) {
- Cert.remove(alias);
- }
- }
-
- public Enumeration engineAliases() {
- return null;
- }
-
- public boolean engineContainsAlias(String alias) {
- if (Keys.containsKey(alias)) {
- return true;
- }
- if (Cert.containsKey(alias)) {
- return true;
- }
- return false;
- }
-
- public int engineSize() {
- return (Keys.size() + Cert.size());
- }
-
- public boolean engineIsKeyEntry(String alias) {
- if (Keys.containsKey(alias)) {
- return true;
- }
- return false;
- }
-
- public boolean engineIsCertificateEntry(String alias) {
- if (Cert.containsKey(alias)) {
- return true;
- }
- return false;
- }
-
- public String engineGetCertificateAlias(Certificate cert) {
- return "";
- }
-
- public void engineStore(OutputStream stream, char[] password)
- throws IOException, NoSuchAlgorithmException, CertificateException {
- if (!(stream instanceof ByteArrayOutputStream)) {
- throw new IOException("Incorrect stream");
- }
- String alias;
- Enumeration e = Keys.keys();
- while (e.hasMoreElements()) {
- alias = (String) e.nextElement();
- KeysSL.put(alias, Keys.get(alias));
- DatesSL.put(alias, Dates.get(alias));
- if (Chain.containsKey(alias)) {
- ChainSL.put(alias, Chain.get(alias));
- }
- }
- e = Cert.keys();
- while (e.hasMoreElements()) {
- alias = (String) e.nextElement();
- CertSL.put(alias, Cert.get(alias));
- DatesSL.put(alias, Dates.get(alias));
- }
- }
-
- public void engineLoad(InputStream stream, char[] password)
- throws IOException, NoSuchAlgorithmException, CertificateException {
- Keys.clear();
- Cert.clear();
- Chain.clear();
- Dates.clear();
- String alias;
- Enumeration e = KeysSL.keys();
- while (e.hasMoreElements()) {
- alias = (String) e.nextElement();
- Keys.put(alias, KeysSL.get(alias));
- Dates.put(alias, DatesSL.get(alias));
- if (ChainSL.containsKey(alias)) {
- Chain.put(alias, ChainSL.get(alias));
- }
- }
- e = CertSL.keys();
- while (e.hasMoreElements()) {
- alias = (String) e.nextElement();
- Cert.put(alias, CertSL.get(alias));
- Dates.put(alias, DatesSL.get(alias));
- }
- }
-
- public void engineStore(KeyStore.LoadStoreParameter param)
- throws IOException, NoSuchAlgorithmException, CertificateException {
- if (param == null) {
- throw new IOException("param is null");
- }
- }
-
- public void engineLoad(KeyStore.LoadStoreParameter param)
- throws IOException, NoSuchAlgorithmException, CertificateException {
- if (!(param instanceof MyLoadStoreParams)) {
- throw new IllegalArgumentException("param is not MyLoadStoreParams: " + param);
- }
- }
-} \ No newline at end of file
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyStoreSpi.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyStoreSpi.java
deleted file mode 100644
index 7712a7e..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyStoreSpi.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.Key;
-import java.security.KeyStoreException;
-import java.security.KeyStoreSpi;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.util.Date;
-import java.util.Enumeration;
-
-/**
- * Additional class for KeyStoreSpi and KeyStore verification
- */
-
-public class MyKeyStoreSpi extends KeyStoreSpi {
-
- public Key engineGetKey(String alias, char[] password)
- throws NoSuchAlgorithmException, UnrecoverableKeyException {
- return null;
- }
-
- public Certificate[] engineGetCertificateChain(String alias) {
- return null;
- }
-
- public Certificate engineGetCertificate(String alias) {
- return null;
- }
-
- public Date engineGetCreationDate(String alias) {
- return new Date(0);
- }
-
- public void engineSetKeyEntry(String alias, Key key, char[] password,
- Certificate[] chain) throws KeyStoreException {
- throw new KeyStoreException(
- "engineSetKeyEntry is not supported in myKeyStoreSpi");
- }
-
- public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain)
- throws KeyStoreException {
- throw new KeyStoreException(
- "engineSetKeyEntry is not supported in myKeyStoreSpi");
- }
-
- public void engineSetCertificateEntry(String alias, Certificate cert)
- throws KeyStoreException {
- throw new KeyStoreException(
- "engineSetCertificateEntry is not supported in myKeyStoreSpi");
- }
-
- public void engineDeleteEntry(String alias) throws KeyStoreException {
- throw new KeyStoreException(
- "engineDeleteEntry is not supported in myKeyStoreSpi");
- }
-
- public Enumeration engineAliases() {
- return null;
- }
-
- public boolean engineContainsAlias(String alias) {
- return false;
- }
-
- public int engineSize() {
- return 0;
- }
-
- public boolean engineIsKeyEntry(String alias) {
- return false;
- }
-
- public boolean engineIsCertificateEntry(String alias) {
- return false;
- }
-
- public String engineGetCertificateAlias(Certificate cert) {
- return "";
- }
-
- public void engineStore(OutputStream stream, char[] password)
- throws IOException, NoSuchAlgorithmException, CertificateException {
- if (!(stream instanceof ByteArrayOutputStream)) {
- throw new IOException("Incorrect stream");
- }
- if (((ByteArrayOutputStream) stream).size() == 0) {
- throw new IOException("Incorrect stream size ");
-
- }
-
- }
-
- public void engineLoad(InputStream stream, char[] password)
- throws IOException, NoSuchAlgorithmException, CertificateException {
- }
-} \ No newline at end of file
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyLoadStoreParams.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyLoadStoreParams.java
deleted file mode 100644
index 5647bc5..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyLoadStoreParams.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.KeyStore;
-
-/**
- * Additional class extends KeyStore.LoadStoreParameter
- */
-public class MyLoadStoreParams implements
- KeyStore.LoadStoreParameter {
-
- KeyStore.ProtectionParameter protPar;
-
- public MyLoadStoreParams(KeyStore.ProtectionParameter p) {
- this.protPar = p;
- }
-
- public KeyStore.ProtectionParameter getProtectionParameter() {
- return protPar;
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java
deleted file mode 100644
index 230c9d3..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.MessageDigest;
-
-/**
- * Tests implementation of MessageDigest
- */
-public class MyMessageDigest1 extends MessageDigest {
-
- public boolean runEngineReset = false;
- public boolean runEngineDigest = false;
- public boolean runEngineUpdate1 = false;
- public boolean runEngineUpdate2 = false;
-
- public MyMessageDigest1() {
- super(null);
- }
-
- /**
- * @param algorithm
- */
- public MyMessageDigest1(String algorithm) {
- super(algorithm);
- }
-
- /**
- *
- */
- public void engineReset() {
- runEngineReset = true;
- }
-
- /**
- *
- */
- public byte[] engineDigest() {
- runEngineDigest = true;
- return new byte[0];
- }
-
- /**
- *
- */
- public void engineUpdate(byte arg0) {
- runEngineUpdate1 = true;
- }
-
- /**
- *
- */
- public void engineUpdate(byte[] arg0, int arg1, int arg2) {
- runEngineUpdate2 = true;
- }
-
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java
deleted file mode 100644
index 86cc5c0..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.MessageDigestSpi;
-
-/**
- * Tests implementation of MessageDigest
- */
-public class MyMessageDigest2 extends MessageDigestSpi {
-
- public static boolean runEngineReset = false;
- public static boolean runEngineDigest = false;
- public static boolean runEngineUpdate1 = false;
- public static boolean runEngineUpdate2 = false;
-
- /**
- *
- */
- public void engineReset() {
- runEngineReset = true;
- }
-
- /**
- *
- */
- public byte[] engineDigest() {
- runEngineDigest = true;
- return new byte[0];
- }
-
- /**
- *
- */
- public void engineUpdate(byte arg0) {
- runEngineUpdate1 = true;
- }
-
- /**
- *
- */
- public void engineUpdate(byte[] arg0, int arg1, int arg2) {
- runEngineUpdate2 = true;
- }
-
- /**
- * The implementation is not cloneable
- */
- public Object clone() throws CloneNotSupportedException {
- throw new CloneNotSupportedException();
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyPermission.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyPermission.java
deleted file mode 100644
index b52bea9..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyPermission.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.Permission;
-
-public final class MyPermission extends Permission {
-
- private static final long serialVersionUID = 4208595188308189251L;
-
- public MyPermission(String name) {
- super(name);
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof MyPermission) {
- String name = ((MyPermission) obj).getName();
- if (name == null) {
- return getName() == null;
- }
- return name.equals(getName());
- }
- return false;
- }
-
- public String getActions() {
- return null;
- }
-
- public int hashCode() {
- return 0;
- }
-
- public boolean implies(Permission permission) {
- return false;
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyPermissionCollection.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyPermissionCollection.java
deleted file mode 100644
index c6e7f15..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyPermissionCollection.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-public class MyPermissionCollection extends PermissionCollection {
-
- private static final long serialVersionUID = -8462474212761656528L;
-
- public MyPermissionCollection(boolean readOnly) {
- if (readOnly) {
- setReadOnly();
- }
- }
-
- public void add(Permission permission) {
- }
-
- public Enumeration<Permission> elements() {
-
- return new Enumeration<Permission>() {
- public boolean hasMoreElements() {
- return false;
- }
-
- public Permission nextElement() {
- throw new NoSuchElementException();
- }
- };
- }
-
- public boolean implies(Permission permission) {
- return false;
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature1.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature1.java
deleted file mode 100644
index 007d432..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature1.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.InvalidKeyException;
-import java.security.InvalidParameterException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.Signature;
-import java.security.SignatureException;
-
-/**
- * Tests implementation of Signature
- */
-public class MySignature1 extends Signature {
-
- public boolean runEngineInitVerify = false;
- public boolean runEngineInitSign = false;
- public boolean runEngineUpdate1 = false;
- public boolean runEngineUpdate2 = false;
- public boolean runEngineSign = false;
- public boolean runEngineVerify = false;
- public boolean runEngineSetParameter = false;
- public boolean runEngineGetParameter = false;
-
- /**
- *
- *
- */
- public MySignature1() {
- super(null);
- }
-
- /**
- * @param algorithm
- */
- public MySignature1(String algorithm) {
- super(algorithm);
- }
-
- protected void engineInitVerify(PublicKey publicKey)
- throws InvalidKeyException {
- runEngineInitVerify = true;
- }
-
- protected void engineInitSign(PrivateKey privateKey)
- throws InvalidKeyException {
- runEngineInitSign = true;
- }
-
- protected void engineUpdate(byte b) throws SignatureException {
- runEngineUpdate1 = true;
- }
-
- protected void engineUpdate(byte[] b, int off, int len)
- throws SignatureException {
- runEngineUpdate2 = true;
- }
-
- protected byte[] engineSign() throws SignatureException {
- runEngineSign = true;
- return null;
- }
-
- protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
- runEngineVerify = true;
- return false;
- }
-
- protected void engineSetParameter(String param, Object value)
- throws InvalidParameterException {
- runEngineSetParameter = true;
- }
-
- protected Object engineGetParameter(String param)
- throws InvalidParameterException {
- runEngineGetParameter = true;
- return null;
- }
-
- public int getState() {
- return state;
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature2.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature2.java
deleted file mode 100644
index 59227a1..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature2.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.InvalidKeyException;
-import java.security.InvalidParameterException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.SignatureSpi;
-
-/**
- * Tests implementation of Signature
- */
-public class MySignature2 extends SignatureSpi {
-
- public static boolean runEngineInitVerify = false;
- public static boolean runEngineInitSign = false;
- public static boolean runEngineUpdate1 = false;
- public static boolean runEngineUpdate2 = false;
- public static boolean runEngineSign = false;
- public static boolean runEngineVerify = false;
- public static boolean runEngineSetParameter = false;
- public static boolean runEngineGetParameter = false;
-
- protected void engineInitVerify(PublicKey publicKey)
- throws InvalidKeyException {
- runEngineInitVerify = true;
- }
-
- protected void engineInitSign(PrivateKey privateKey)
- throws InvalidKeyException {
- runEngineInitSign = true;
- }
-
- protected void engineUpdate(byte b) throws SignatureException {
- runEngineUpdate1 = true;
- }
-
- protected void engineUpdate(byte[] b, int off, int len)
- throws SignatureException {
- runEngineUpdate2 = true;
- }
-
- protected byte[] engineSign() throws SignatureException {
- runEngineSign = true;
- return null;
- }
-
- protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
- runEngineVerify = true;
- return false;
- }
-
- protected void engineSetParameter(String param, Object value)
- throws InvalidParameterException {
- runEngineSetParameter = true;
- }
-
- protected Object engineGetParameter(String param)
- throws InvalidParameterException {
- runEngineGetParameter = true;
- return null;
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PrivateKeyStub.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PrivateKeyStub.java
deleted file mode 100644
index f0723c6..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PrivateKeyStub.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Aleksei Y. Semenov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.PrivateKey;
-
-/**
- * Stub for interface PrivateKey tests
- */
-
-public class PrivateKeyStub implements PrivateKey {
-
- private static final long serialVersionUID = 111111111L;
-
- String algorithm = null;
- String format = null;
- byte[] encoded = null;
-
-
- /**
- * Constructor
- *
- * @param algorithm
- * @param format
- * @param encoded
- */
- public PrivateKeyStub(String algorithm, String format, byte[] encoded) {
- this.algorithm = algorithm;
- this.format = format;
- this.encoded = encoded;
- }
-
- /**
- * Returns algorithm
- *
- * @see java.security.Key#getAlgorithm()
- */
- public String getAlgorithm() {
- return algorithm;
- }
-
- /**
- * Returns format
- *
- * @see java.security.Key#getFormat()
- */
- public String getFormat() {
- return format;
- }
-
- /**
- * Returns encoded form
- *
- * @see java.security.Key#getEncoded()
- */
- public byte[] getEncoded() {
- return encoded;
- }
-
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PublicKeyStub.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PublicKeyStub.java
deleted file mode 100644
index 95be77a..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PublicKeyStub.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Aleksei Y. Semenov
- */
-
-package org.apache.harmony.security.tests.support;
-
-
-import java.security.PublicKey;
-
-
-/**
- * Stub implements interface PublicKey
- */
-
-public class PublicKeyStub implements PublicKey {
-
- private static final long serialVersionUID = 333333333L;
-
- String algorithm = null;
- String format = null;
- byte[] encoded = null;
-
- /**
- * constructor
- */
- public PublicKeyStub(String algorithm, String format, byte[] encoded) {
- this.algorithm = algorithm;
- this.format = format;
- this.encoded = encoded;
- }
-
- /**
- * returns algorithm
- */
- public String getAlgorithm() {
- return algorithm;
- }
-
- /**
- * returns format
- *
- * @see java.security.Key#getFormat()
- */
- public String getFormat() {
- return format;
- }
-
- /**
- * returns encoded
- *
- * @see java.security.Key#getEncoded()
- */
- public byte[] getEncoded() {
- return encoded;
- }
-} \ No newline at end of file
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/RandomImpl.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/RandomImpl.java
deleted file mode 100644
index 651cf18..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/RandomImpl.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @author Boris V. Kuznetsov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.SecureRandomSpi;
-
-/**
- * Test implementation of SecureRandom
- */
-public class RandomImpl extends SecureRandomSpi {
-
- public static boolean runEngineGenerateSeed = false;
- public static boolean runEngineNextBytes = false;
- public static boolean runEngineSetSeed = false;
-
- protected void engineSetSeed(byte[] seed) {
- runEngineSetSeed = true;
- }
-
- protected void engineNextBytes(byte[] bytes) {
- runEngineNextBytes = true;
- for (int i = 0; i < bytes.length; i++) {
- bytes[i] = (byte) (i + 0xF1);
- }
- }
-
- protected byte[] engineGenerateSeed(int numBytes) {
- runEngineGenerateSeed = true;
- byte[] b = new byte[numBytes];
- for (int i = 0; i < b.length; i++) {
- b[i] = (byte) i;
- }
- return b;
- }
-
-}
-
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SignerStub.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SignerStub.java
deleted file mode 100644
index 258301e..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SignerStub.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Aleksei Y. Semenov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.IdentityScope;
-import java.security.KeyManagementException;
-import java.security.Signer;
-
-/**
- * Stub for abstract class Signer, necessary for testing purposes
- */
-
-public class SignerStub extends Signer {
-
- /**
- * Default constructor
- */
- public SignerStub() {
- super();
- }
-
- /**
- * Constructor, sets given name
- *
- * @param name
- */
- public SignerStub(String name) {
- super(name);
- }
-
- /**
- * Constructor, sets given name and scope
- *
- * @param name
- * @param scope
- * @throws KeyManagementException
- */
- public SignerStub(String name, IdentityScope scope)
- throws KeyManagementException {
- super(name, scope);
- }
-
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SpiEngUtils.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SpiEngUtils.java
deleted file mode 100644
index 5e9ed99..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SpiEngUtils.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.io.File;
-import java.security.Security;
-import java.security.Provider;
-import java.util.StringTokenizer;
-
-/**
- * Additional class for verification spi-engine classes
- */
-
-public class SpiEngUtils {
-
- public static final String[] invalidValues = {
- "",
- "BadAlgorithm",
- "Long message Long message Long message Long message Long message Long message Long message Long message Long message Long message Long message Long message Long message" };
-
- /**
- * Verification: is algorithm supported or not
- *
- * @param algorithm
- * @param service
- * @return
- */
- public static Provider isSupport(String algorithm, String service) {
- try {
- Provider[] provs = Security.getProviders(service.concat(".")
- .concat(algorithm));
- if (provs == null) {
- return null;
- }
- return (provs.length == 0 ? null : provs[0]);
- } catch (Exception e) {
- return null;
- }
- }
-
- public class MyProvider extends Provider {
-
- public MyProvider(String name, String info, String key, String clName) {
- super(name, 1.0, info);
- put(key, clName);
- }
-
- }
-
-} \ No newline at end of file
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/TestCertUtils.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/TestCertUtils.java
deleted file mode 100644
index e8e9e82..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/TestCertUtils.java
+++ /dev/null
@@ -1,828 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander V. Astapchuk
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.io.StreamCorruptedException;
-import java.math.BigInteger;
-
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Principal;
-import java.security.Provider;
-import java.security.PublicKey;
-import java.security.Security;
-import java.security.SignatureException;
-
-import java.security.cert.*;
-import java.util.*;
-
-import javax.security.auth.x500.X500Principal;
-
-/**
- * The class contains various utility methods used during the java.security
- * classes testing.
- */
-
-public final class TestCertUtils {
-
- private TestCertUtils() {
- throw new Error("statics only");
- }
-
- /**
- * Returns new instance of test certificate each time the method is called.
- *
- * @return test certificate
- */
- public static Certificate getCert() {
- return new TestCertificate();
- }
-
- /**
- * Returns an array of 3 test certificates. IMP: The array returned is not
- * real chain of certificates, it's just an array of 3 certs. The method
- * returns new array each time it's called. The number of 3 was chosen
- * arbitrarily and is subject to change.
- *
- * @return an array of 3 certificates
- */
- public static Certificate[] getCertChain() {
- Certificate[] chain = { new TestCertificate(), new TestCertificate(),
- new TestCertificate() };
- return chain;
- }
-
- /**
- * Returns a test CertPath, which uses getCertChain() to obtain a list of
- * certificates to store.
- *
- * @return test cert path
- */
- public static CertPath getCertPath() {
- return new TestCertPath();
- }
-
- /**
- * Generates and returns an instance of TestCertPath.<br>
- * TestCertificate-s included in the CertPath will be uniq (will have
- * different numbers passed to their ctor-s).<br>
- * The second arguments shows which number will have the first Certificate
- * in the CertPath. The second certificate will have (startID+1) number
- * and so on.
- *
- * @param howMany - shows how many TestCerts must contain the CertPath generated
- * @param startID - specifies the starting ID which the first certificate will have
- * @return TestCertPath
- */
- public static CertPath genCertPath(int howMany, int startID) {
- Certificate[] certs = new Certificate[howMany];
- for (int i = 0; i < howMany; i++) {
- certs[i] = new TestCertificate(Integer.toString(startID + i));
- }
- return new TestCertPath(certs);
- }
-
- private static Provider provider = null;
-
- private static final String providerName = "TstPrvdr";
-
- /**
- * A Principal used to form rootCA's certificate
- */
- public static final X500Principal rootPrincipal = new X500Principal(
- UniGen.rootName);
-
- /**
- * Some fake rootCA's certificate.
- */
- public static final X509Certificate rootCA = new TestX509Certificate(
- rootPrincipal, rootPrincipal);
-
- public static void install_test_x509_factory() {
- if (provider == null) {
- provider = new TestProvider(providerName, 0.01,
- "Test provider for serialization testing");
- Security.insertProviderAt(provider, 1);
- }
- }
-
- public static void uninstall_test_x509_factory() {
- if (provider != null) {
- Security.removeProvider(providerName);
- provider = null;
- }
- }
-
- /**
- * The class represents test certificate path.
- */
-
- public static final class TestCertPath extends CertPath implements
- Serializable {
-
- private static final byte[] encoded = new byte[] { 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF };
-
- private static final String serializedData = "Just a dummy string to be serialized instead of real data";
-
- private Certificate[] certs;
-
- /**
- * Default ctor for TestCertPath. Uses {@link TestCertUtils#getCertChain()}
- * to obtain list of certificates.<br>
- * All TestCertPath-s constructed via this ctor will be equals() to each
- * other.
- */
- public TestCertPath() {
- super("testCertPath");
- certs = getCertChain();
- }
-
- /**
- * Constructs TestCertPath and keeps the given array of certificates.<br>
- * The TestCertPaths constructed via this ctor may be different (if they
- * have different set of certificates)<br>
- *
- * @param certs
- * @see TestCertUtils#genCertPath(int, int)
- */
- public TestCertPath(Certificate[] certs) {
- super("testCertPath");
- this.certs = certs;
- }
-
- /**
- * @see java.security.cert.CertPath#getCertificates()
- */
- public List getCertificates() {
- return Arrays.asList(certs);
- }
-
- /**
- * @see java.security.cert.CertPath#getEncoded()
- */
- public byte[] getEncoded() throws CertificateEncodingException {
- return encoded.clone();
- }
-
- /**
- * @see java.security.cert.CertPath#getEncoded(java.lang.String)
- */
- public byte[] getEncoded(String encoding)
- throws CertificateEncodingException {
- return encoded.clone();
- }
-
- /**
- * @see java.security.cert.CertPath#getEncodings()
- */
- public Iterator getEncodings() {
- Vector v = new Vector();
- v.add("myTestEncoding");
- return v.iterator();
- }
-
- public String toString() {
- StringBuffer buf = new StringBuffer(200);
- buf.append("TestCertPath. certs count=");
- if (certs == null) {
- buf.append("0\n");
- } else {
- buf.append(certs.length).append("\n");
- for (int i = 0; i < certs.length; i++) {
- buf.append("\t").append(i).append(" ");
- buf.append(certs[i]).append("\n");
- }
- }
- return buf.toString();
- }
-
- /**
- * Writes<br>
- * (String) serializedData<br>
- * (int) number of certificates in this CertPath<br>
- * <array of certificates>
- *
- * @param out
- * @throws IOException
- */
- private void writeObject(ObjectOutputStream out) throws IOException {
- out.writeUTF(serializedData);
- if (certs == null) {
- out.writeInt(0);
- } else {
- out.writeInt(certs.length);
- for (int i = 0; i < certs.length; i++) {
- out.writeObject(certs[i]);
- }
- }
- }
-
- private void readObject(ObjectInputStream in) throws IOException,
- ClassNotFoundException {
- String s = in.readUTF();
- if (!serializedData.equals(s)) {
- throw new StreamCorruptedException("expect [" + serializedData
- + "] got [" + s + "]");
- }
- int count = in.readInt();
- certs = new Certificate[count];
- for (int i = 0; i < count; i++) {
- certs[i] = (Certificate) in.readObject();
- }
- }
-
- protected Object writeReplace() {
- return this;
- }
-
- protected Object readResolve() {
- return this;
- }
- }
-
- /**
- * The class represents empty PublicKey.
- */
-
- public static final class TestPublicKey implements PublicKey {
- private static final String algo = "testPublicKeyAlgorithm";
-
- private static final byte[] encoded = new byte[] { 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF };
-
- private static final String format = "testPublicKeyFormat";
-
- public String getAlgorithm() {
- return algo;
- }
-
- public byte[] getEncoded() {
- return encoded.clone();
- }
-
- public String getFormat() {
- return format;
- }
- }
-
- /**
- * The class represents test certificate.
- */
-
- public static class TestCertificate extends Certificate implements
- Serializable {
-
- private static final byte[] encoded = new byte[] { 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF };
-
- public static final String TYPE = "Test";
-
- //
- // A String that makes different TestCertificates to be different.
- //
- private String diff = null;
-
- /**
- * Default ctor. All the TestCertificate-s created with this ctor are equals() to each other.
- * Use TestCertificate(String) if you need non equal TestCertificate-s.
- */
- public TestCertificate() {
- super(TYPE);
- }
-
- /**
- * A special purpose ctor. Pass different String-s to have different TestCertificates.
- * TestCertificate-s with the same String passed to this ctor are considered equal.
- */
- public TestCertificate(String diff) {
- super(TYPE);
- this.diff = diff;
- }
-
- /**
- * A ctor that allows to specify both the TYPE of certificate and the
- * diff. Leave the <code>diff</code> null when no difference needed.
- *
- * @param diff
- * @param type
- */
- public TestCertificate(String diff, String type) {
- super(type);
- this.diff = diff;
- }
-
- public byte[] getEncoded() throws CertificateEncodingException {
- return encoded.clone();
- }
-
- public void verify(PublicKey key) throws CertificateException,
- NoSuchAlgorithmException, InvalidKeyException,
- NoSuchProviderException, SignatureException {
- // do nothing
- }
-
- public void verify(PublicKey key, String sigProvider)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- // do nothing
-
- }
-
- public String toString() {
- return "Test certificate - for unit testing only";
- }
-
- public boolean equals(Object obj) {
- if (obj == null || !(obj instanceof TestCertificate)) {
- return false;
- }
- TestCertificate that = (TestCertificate) obj;
- if (this == that) {
- return true;
- }
- if (this.diff == null) {
- return that.diff == null;
- }
- return this.diff.equals(that.diff);
- }
-
- public PublicKey getPublicKey() {
- return new TestPublicKey();
- }
-
- /**
- * Writes:<br>
- * boolean - true if this certificate has a diff string,
- * false otherwise, followed by <br>
- * writeUTF() of string (if presented)
- *
- * @param out
- * @throws IOException
- */
- private void writeObject(ObjectOutputStream out) throws IOException {
- if (diff == null) {
- out.writeBoolean(false);
- } else {
- out.writeBoolean(false);
- out.writeUTF(diff);
- }
- }
-
- private void readObject(ObjectInputStream in) throws IOException,
- ClassNotFoundException {
- boolean hasDiffString = in.readBoolean();
- if (hasDiffString) {
- diff = in.readUTF();
- }
- }
-
- protected Object writeReplace() {
- return this;
- }
-
- protected Object readResolve() {
- return this;
- }
- }
-
- public static class TestInvalidX509Certificate extends TestX509Certificate {
- public TestInvalidX509Certificate(X500Principal subj,
- X500Principal issuer) {
- super(subj, issuer);
- }
- }
-
- /**
- * TestX509CErtificate.<br>
- * Does nothing interesting, but<br>
- * a) is not abstract, so it can be instantiated<br>
- * b) returns Encoded form<br>
- */
- public static class TestX509Certificate extends X509Certificate {
- private X500Principal subject;
-
- private X500Principal issuer;
-
- public TestX509Certificate(X500Principal subj, X500Principal issuer) {
- this.subject = subj;
- this.issuer = issuer;
- }
-
- public X500Principal getIssuerX500Principal() {
- return issuer;
- }
-
- public X500Principal getSubjectX500Principal() {
- return subject;
- }
-
- /**
- * The encoded for of this X509Certificate is a byte array where
- * first are bytes of encoded form of Subject (as X500Principal),
- * followed by one zero byte
- * and followed by the encoded form of Issuer (as X500Principal)
- */
- public byte[] getEncoded() throws CertificateEncodingException {
- byte[] asubj = subject.getEncoded();
- byte[] aissuer = issuer.getEncoded();
- byte[] data = new byte[asubj.length + aissuer.length + 1];
-
- System.arraycopy(asubj, 0, data, 0, asubj.length);
- //data[asubj.length] = 0;
- System
- .arraycopy(aissuer, 0, data, asubj.length + 1,
- aissuer.length);
- return data;
- }
-
- public void checkValidity() throws CertificateExpiredException,
- CertificateNotYetValidException {
- }
-
- public void checkValidity(Date date)
- throws CertificateExpiredException,
- CertificateNotYetValidException {
- }
-
- public int getBasicConstraints() {
- return 0;
- }
-
- public Principal getIssuerDN() {
- return null;
- }
-
- public boolean[] getIssuerUniqueID() {
- return null;
- }
-
- public boolean[] getKeyUsage() {
- return null;
- }
-
- public Date getNotAfter() {
- return null;
- }
-
- public Date getNotBefore() {
- return null;
- }
-
- public BigInteger getSerialNumber() {
- return null;
- }
-
- public String getSigAlgName() {
- return null;
- }
-
- public String getSigAlgOID() {
- return null;
- }
-
- public byte[] getSigAlgParams() {
- return null;
- }
-
- public byte[] getSignature() {
- return null;
- }
-
- public Principal getSubjectDN() {
- return null;
- }
-
- public boolean[] getSubjectUniqueID() {
- return null;
- }
-
- public byte[] getTBSCertificate() throws CertificateEncodingException {
- return null;
- }
-
- public int getVersion() {
- return 0;
- }
-
- public Set getCriticalExtensionOIDs() {
- return null;
- }
-
- public byte[] getExtensionValue(String oid) {
- return null;
- }
-
- public Set getNonCriticalExtensionOIDs() {
- return null;
- }
-
- public boolean hasUnsupportedCriticalExtension() {
- return false;
- }
-
- public PublicKey getPublicKey() {
- return null;
- }
-
- public String toString() {
- return null;
- }
-
- public void verify(PublicKey key, String sigProvider)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
-
- }
-
- public void verify(PublicKey key) throws CertificateException,
- NoSuchAlgorithmException, InvalidKeyException,
- NoSuchProviderException, SignatureException {
-
- }
- }
-
- /**
- * TestProvider. Does nothing, but pretends to
- * implement X.509 CertificateFactory.
- */
- public static class TestProvider extends Provider {
-
- private Provider.Service serv;
-
- public TestProvider(String name, double version, String info) {
- super(name, version, info);
- serv = new Provider.Service(this, "CertificateFactory", "X.509",
- TestFactorySpi.class.getName(), new ArrayList(), null);
- }
-
- public synchronized Set getServices() {
- HashSet s = new HashSet();
- s.add(serv);
- return s;
- }
- }
-
- /**
- * Some kind of Certificate Factory, used during unit testing.
- */
- public static class TestFactorySpi extends CertificateFactorySpi {
-
- /**
- * Tries to create an instance of TestX509Certificate, basing
- * on the presumption that its {@link TestX509Certificate#getEncoded()
- * encoded} form is stored.<br>
- *
- * @throws CertificateException is the presumption is not met or if
- * any IO problem occurs.
- */
- public Certificate engineGenerateCertificate(InputStream is)
- throws CertificateException {
- byte[] data = new byte[0];
- byte[] chunk = new byte[1024];
- int len;
- try {
- while ((len = is.read(chunk)) > 0) {
- byte[] tmp = new byte[data.length + len];
- System.arraycopy(data, 0, tmp, 0, data.length);
- System.arraycopy(chunk, 0, tmp, data.length, len);
- data = tmp;
- }
- } catch (IOException ex) {
- throw new CertificateException("IO problem", ex);
- }
- int pos = Arrays.binarySearch(data, (byte) 0);
- if (pos < 0) {
- throw new CertificateException("invalid format");
- }
- byte[] subjNameData = new byte[pos];
- System.arraycopy(data, 0, subjNameData, 0, subjNameData.length);
- byte[] issNameData = new byte[data.length - pos - 1];
- System.arraycopy(data, pos + 1, issNameData, 0, issNameData.length);
- X500Principal subjName = new X500Principal(subjNameData);
- X500Principal issName = new X500Principal(issNameData);
- return new TestX509Certificate(subjName, issName);
- }
-
- /**
- * Not supported yet.
- *
- * @throws UnsupportedOperationException
- */
- public Collection engineGenerateCertificates(InputStream inStream)
- throws CertificateException {
- throw new UnsupportedOperationException("not yet.");
- }
-
- /**
- * Not supported yet.
- *
- * @throws UnsupportedOperationException
- */
- public CRL engineGenerateCRL(InputStream inStream) throws CRLException {
- throw new UnsupportedOperationException("not yet.");
- }
-
- /**
- * Not supported yet.
- *
- * @throws UnsupportedOperationException
- */
- public Collection engineGenerateCRLs(InputStream inStream)
- throws CRLException {
- throw new UnsupportedOperationException("not yet.");
- }
-
- /**
- * Returns an instance of TestCertPath.<br>
- *
- * @throws CertificateException if
- * a) any of Certificates passed is not an instance of X509Certificate
- * b) any of Certificates passed is an instance of TestInvalidX509Certificate
- */
- public CertPath engineGenerateCertPath(List certs)
- throws CertificateException {
- ArrayList validCerts = new ArrayList();
- for (Iterator i = certs.iterator(); i.hasNext(); ) {
- Certificate c = (Certificate) i.next();
- if (!(c instanceof X509Certificate)) {
- throw new CertificateException("Not X509: " + c);
- }
- if (c instanceof TestInvalidX509Certificate) {
- throw new CertificateException("Invalid (test) X509: " + c);
- }
- validCerts.add(c);
- }
- Certificate[] acerts = new Certificate[validCerts.size()];
- validCerts.toArray(acerts);
- return new TestCertPath(acerts);
- }
- }
-
- /**
- * Utility class used to generate some amount of uniq names.
- */
- public static class UniGen {
- public static final String rootName = "CN=Alex Astapchuk, OU=SSG, O=Intel ZAO, C=RU";
-
- private static final String datasNames[] = { "CN", "OU", "O", "C" };
-
- private static final String datas[][] = {
- // Names database
- { "Alex Astapchuk", null, null, null },
- { "John Doe", null, null, null },
- // 'organisation unit'-s
- { null, "SSG", null, null }, { null, "SSG/DRL", null, null },
- // organizations
- { null, null, "Intel ZAO", null },
- { null, null, "Intel Inc", null },
- // countries
- { null, null, null, "RU" }, { null, null, null, "US" },
- { null, null, null, "GB" }, { null, null, null, "JA" },
- { null, null, null, "KO" }, { null, null, null, "TW" }, };
-
- //
- // Returns a string from <code>data</code> from a given column and
- // position. The positions are looked for first non-null entry. If there
- // are no non empty items left, then it scans column starting from the
- // beginning.
- //
- // @param col
- // @param startRow
- // @return
- //
- private static String getData(int col, int startRow) {
- startRow = startRow % datas.length;
- for (int i = startRow; i < datas.length; i++) {
- if (datas[i][col] != null) {
- return datas[i][col];
- }
- }
- // no non-null entries left, check from the beginning
- for (int i = 0; i < datas.length; i++) {
- if (datas[i][col] != null) {
- return datas[i][col];
- }
- }
- // can't be
- throw new Error();
- }
-
- //
- // Increments a num.<br>
- // <code>num</code> is interpreted as a number with a base of
- // <code>base</code> and each digit of this number is stored as a
- // separate num's element.
- //
- // @param num
- // @param base
- // @return <b>true</b> if overflow happened
- //
- private static boolean inc(int[] num, int base) {
- for (int i = 0; i < num.length; i++) {
- if ((++num[i]) >= base) {
- num[i] = 0;
- } else {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Generates some amount of uniq names, none of which is equals to
- * {@link #rootName}.
- *
- * @param howMany
- * @return
- */
- public static String[] genNames(int howMany) {
- int counts[] = new int[datasNames.length];
- ArrayList al = new ArrayList();
-
- // not really the thrifty algorithm...
- for (int i = 0; i < howMany; ) {
-
- // System.out.print("#"+i+": ");
- // for( int j=0; j<counts.length; j++) {
- // System.out.print(""+counts[j]+"|");
- // }
- // System.out.println();
-
- StringBuffer buf = new StringBuffer();
- int j = 0;
- for (; j < datasNames.length - 1; j++) {
- String name = datasNames[j];
- String val = getData(j, counts[j]);
- buf.append(name).append('=').append(val).append(",");
- }
- String name = datasNames[j];
- String val = getData(j, counts[j]);
- buf.append(name).append('=').append(val);
-
- name = buf.toString();
-
- if (!(rootName.equals(name) || al.contains(name))) {
- ++i;
- al.add(name);
- // System.out.println("generated: "+name);
- } else {
- // System.out.println("rejected: "+name);
- }
-
- if (inc(counts, datas.length)) {
- // if this happened, then just add some data into 'datas'
- throw new Error(
- "cant generate so many uniq names. sorry. add some more data.");
- }
- }
- return (String[]) al.toArray(new String[al.size()]);
- }
-
- /**
- * Generates some amount of uniq X500Principals, none of which is equals
- * has a string equals to {@link #rootName}.
- *
- * @param howMany
- * @return
- */
- public static X500Principal[] genX500s(int howMany) {
- String names[] = genNames(howMany);
- X500Principal[] ps = new X500Principal[howMany];
- for (int i = 0; i < howMany; i++) {
- ps[i] = new X500Principal(names[i]);
- }
- return ps;
- }
-
- }
-
-}
-
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/TestKeyPair.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/TestKeyPair.java
deleted file mode 100644
index 596b9f1..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/TestKeyPair.java
+++ /dev/null
@@ -1,602 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.HashMap;
-
-/**
- * Generates key pairs based on their encodings for some algorithms.
- * Encodings generated using
- * BEA JRockit j2sdk1.4.2_04 (http://www.bea.com)
- */
-public class TestKeyPair {
- private static final HashMap privateKeyEncoding = new HashMap();
- private static final HashMap publicKeyEncoding = new HashMap();
- private final String algorithmName;
- private final KeyFactory kf;
-
- static {
- privateKeyEncoding.put("RSA", new byte[] {
- (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0x77,
- (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0x30,
- (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a,
- (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7,
- (byte) 0x0d, (byte) 0x01, (byte) 0x01, (byte) 0x01,
- (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x82,
- (byte) 0x02, (byte) 0x61, (byte) 0x30, (byte) 0x82,
- (byte) 0x02, (byte) 0x5d, (byte) 0x02, (byte) 0x01,
- (byte) 0x00, (byte) 0x02, (byte) 0x81, (byte) 0x81,
- (byte) 0x00, (byte) 0xb2, (byte) 0x4a, (byte) 0x9b,
- (byte) 0x5b, (byte) 0xba, (byte) 0x01, (byte) 0xc0,
- (byte) 0xcd, (byte) 0x65, (byte) 0x09, (byte) 0x63,
- (byte) 0x70, (byte) 0x0b, (byte) 0x5a, (byte) 0x1b,
- (byte) 0x92, (byte) 0x08, (byte) 0xf8, (byte) 0x55,
- (byte) 0x5e, (byte) 0x7c, (byte) 0x1b, (byte) 0x50,
- (byte) 0x17, (byte) 0xec, (byte) 0x44, (byte) 0x4c,
- (byte) 0x58, (byte) 0x42, (byte) 0x2b, (byte) 0x41,
- (byte) 0x09, (byte) 0x59, (byte) 0xf2, (byte) 0xe1,
- (byte) 0x5d, (byte) 0x43, (byte) 0x71, (byte) 0x4d,
- (byte) 0x92, (byte) 0x03, (byte) 0x1d, (byte) 0xb6,
- (byte) 0x6c, (byte) 0x7f, (byte) 0x5d, (byte) 0x48,
- (byte) 0xcd, (byte) 0x17, (byte) 0xec, (byte) 0xd7,
- (byte) 0x4c, (byte) 0x39, (byte) 0xb1, (byte) 0x7b,
- (byte) 0xe2, (byte) 0xbf, (byte) 0x96, (byte) 0x77,
- (byte) 0xbe, (byte) 0xd0, (byte) 0xa0, (byte) 0xf0,
- (byte) 0x2d, (byte) 0x6b, (byte) 0x24, (byte) 0xaa,
- (byte) 0x14, (byte) 0xba, (byte) 0x82, (byte) 0x79,
- (byte) 0x10, (byte) 0x9b, (byte) 0x16, (byte) 0x68,
- (byte) 0x47, (byte) 0x81, (byte) 0x54, (byte) 0xa2,
- (byte) 0xfa, (byte) 0x91, (byte) 0x9e, (byte) 0x0a,
- (byte) 0x2a, (byte) 0x53, (byte) 0xa6, (byte) 0xe7,
- (byte) 0x9e, (byte) 0x7d, (byte) 0x29, (byte) 0x33,
- (byte) 0xd8, (byte) 0x05, (byte) 0xfc, (byte) 0x02,
- (byte) 0x3f, (byte) 0xbd, (byte) 0xc7, (byte) 0x6e,
- (byte) 0xed, (byte) 0xaa, (byte) 0x30, (byte) 0x6c,
- (byte) 0x5f, (byte) 0x52, (byte) 0xed, (byte) 0x35,
- (byte) 0x65, (byte) 0x4b, (byte) 0x0e, (byte) 0xc8,
- (byte) 0xa7, (byte) 0x12, (byte) 0x10, (byte) 0x56,
- (byte) 0x37, (byte) 0xaf, (byte) 0x11, (byte) 0xfa,
- (byte) 0x21, (byte) 0x0e, (byte) 0x99, (byte) 0xff,
- (byte) 0xfa, (byte) 0x8c, (byte) 0x65, (byte) 0x8e,
- (byte) 0x6d, (byte) 0x02, (byte) 0x03, (byte) 0x01,
- (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x81,
- (byte) 0x80, (byte) 0x78, (byte) 0x41, (byte) 0x72,
- (byte) 0x40, (byte) 0x90, (byte) 0x59, (byte) 0x96,
- (byte) 0x5d, (byte) 0xf3, (byte) 0x84, (byte) 0x3d,
- (byte) 0x99, (byte) 0xd9, (byte) 0x4e, (byte) 0x51,
- (byte) 0xc2, (byte) 0x52, (byte) 0x62, (byte) 0x8d,
- (byte) 0xd2, (byte) 0x49, (byte) 0x0b, (byte) 0x73,
- (byte) 0x1e, (byte) 0x6f, (byte) 0xb2, (byte) 0x31,
- (byte) 0x7c, (byte) 0x66, (byte) 0x45, (byte) 0x1e,
- (byte) 0x7c, (byte) 0xdc, (byte) 0x3a, (byte) 0xc2,
- (byte) 0x5f, (byte) 0x51, (byte) 0x9a, (byte) 0x1e,
- (byte) 0xa4, (byte) 0x19, (byte) 0x8d, (byte) 0xf4,
- (byte) 0xf9, (byte) 0x81, (byte) 0x7e, (byte) 0xbe,
- (byte) 0x17, (byte) 0xf7, (byte) 0xc7, (byte) 0x3c,
- (byte) 0x00, (byte) 0xa1, (byte) 0xf9, (byte) 0x60,
- (byte) 0x82, (byte) 0x34, (byte) 0x8f, (byte) 0x9c,
- (byte) 0xfd, (byte) 0x0b, (byte) 0x63, (byte) 0x42,
- (byte) 0x1b, (byte) 0x7f, (byte) 0x45, (byte) 0xf1,
- (byte) 0x31, (byte) 0xc3, (byte) 0x63, (byte) 0x47,
- (byte) 0x5c, (byte) 0xc1, (byte) 0xb2, (byte) 0x5f,
- (byte) 0x57, (byte) 0xee, (byte) 0x02, (byte) 0x9f,
- (byte) 0x5e, (byte) 0x08, (byte) 0x48, (byte) 0xba,
- (byte) 0x74, (byte) 0xba, (byte) 0x81, (byte) 0xb7,
- (byte) 0x30, (byte) 0xac, (byte) 0x4c, (byte) 0x01,
- (byte) 0x35, (byte) 0xce, (byte) 0x46, (byte) 0x47,
- (byte) 0x8c, (byte) 0xe4, (byte) 0x62, (byte) 0x36,
- (byte) 0x1a, (byte) 0x65, (byte) 0x0e, (byte) 0x33,
- (byte) 0x56, (byte) 0xf9, (byte) 0xb7, (byte) 0xa0,
- (byte) 0xc4, (byte) 0xb6, (byte) 0x82, (byte) 0x55,
- (byte) 0x7d, (byte) 0x36, (byte) 0x55, (byte) 0xc0,
- (byte) 0x52, (byte) 0x5e, (byte) 0x35, (byte) 0x54,
- (byte) 0xbd, (byte) 0x97, (byte) 0x01, (byte) 0x00,
- (byte) 0xbf, (byte) 0x10, (byte) 0xdc, (byte) 0x1b,
- (byte) 0x51, (byte) 0x02, (byte) 0x41, (byte) 0x00,
- (byte) 0xe7, (byte) 0x68, (byte) 0x03, (byte) 0x3e,
- (byte) 0x21, (byte) 0x64, (byte) 0x68, (byte) 0x24,
- (byte) 0x7b, (byte) 0xd0, (byte) 0x31, (byte) 0xa0,
- (byte) 0xa2, (byte) 0xd9, (byte) 0x87, (byte) 0x6d,
- (byte) 0x79, (byte) 0x81, (byte) 0x8f, (byte) 0x8f,
- (byte) 0x2d, (byte) 0x7a, (byte) 0x95, (byte) 0x2e,
- (byte) 0x55, (byte) 0x9f, (byte) 0xd7, (byte) 0x86,
- (byte) 0x29, (byte) 0x93, (byte) 0xbd, (byte) 0x04,
- (byte) 0x7e, (byte) 0x4f, (byte) 0xdb, (byte) 0x56,
- (byte) 0xf1, (byte) 0x75, (byte) 0xd0, (byte) 0x4b,
- (byte) 0x00, (byte) 0x3a, (byte) 0xe0, (byte) 0x26,
- (byte) 0xf6, (byte) 0xab, (byte) 0x9e, (byte) 0x0b,
- (byte) 0x2a, (byte) 0xf4, (byte) 0xa8, (byte) 0xd7,
- (byte) 0xff, (byte) 0xbe, (byte) 0x01, (byte) 0xeb,
- (byte) 0x9b, (byte) 0x81, (byte) 0xc7, (byte) 0x5f,
- (byte) 0x02, (byte) 0x73, (byte) 0xe1, (byte) 0x2b,
- (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xc5,
- (byte) 0x3d, (byte) 0x78, (byte) 0xab, (byte) 0xe6,
- (byte) 0xab, (byte) 0x3e, (byte) 0x29, (byte) 0xfd,
- (byte) 0x98, (byte) 0xd0, (byte) 0xa4, (byte) 0x3e,
- (byte) 0x58, (byte) 0xee, (byte) 0x48, (byte) 0x45,
- (byte) 0xa3, (byte) 0x66, (byte) 0xac, (byte) 0xe9,
- (byte) 0x4d, (byte) 0xbd, (byte) 0x60, (byte) 0xea,
- (byte) 0x24, (byte) 0xff, (byte) 0xed, (byte) 0x0c,
- (byte) 0x67, (byte) 0xc5, (byte) 0xfd, (byte) 0x36,
- (byte) 0x28, (byte) 0xea, (byte) 0x74, (byte) 0x88,
- (byte) 0xd1, (byte) 0xd1, (byte) 0xad, (byte) 0x58,
- (byte) 0xd7, (byte) 0xf0, (byte) 0x67, (byte) 0x20,
- (byte) 0xc1, (byte) 0xe3, (byte) 0xb3, (byte) 0xdb,
- (byte) 0x52, (byte) 0xad, (byte) 0xf3, (byte) 0xc4,
- (byte) 0x21, (byte) 0xd8, (byte) 0x8c, (byte) 0x4c,
- (byte) 0x41, (byte) 0x27, (byte) 0xdb, (byte) 0xd0,
- (byte) 0x35, (byte) 0x92, (byte) 0xc7, (byte) 0x02,
- (byte) 0x41, (byte) 0x00, (byte) 0xe0, (byte) 0x99,
- (byte) 0x42, (byte) 0xb4, (byte) 0x76, (byte) 0x02,
- (byte) 0x97, (byte) 0x55, (byte) 0xf9, (byte) 0xda,
- (byte) 0x3b, (byte) 0xa0, (byte) 0xd7, (byte) 0x0e,
- (byte) 0xdc, (byte) 0xf4, (byte) 0x33, (byte) 0x7f,
- (byte) 0xbd, (byte) 0xcf, (byte) 0xd0, (byte) 0xeb,
- (byte) 0x6e, (byte) 0x89, (byte) 0xf7, (byte) 0x4f,
- (byte) 0x5a, (byte) 0x07, (byte) 0x7c, (byte) 0xa9,
- (byte) 0x49, (byte) 0x47, (byte) 0x68, (byte) 0x35,
- (byte) 0xa8, (byte) 0x05, (byte) 0x3d, (byte) 0xfd,
- (byte) 0x04, (byte) 0x7b, (byte) 0x17, (byte) 0x31,
- (byte) 0x0d, (byte) 0xc8, (byte) 0xa3, (byte) 0x98,
- (byte) 0x34, (byte) 0xa0, (byte) 0x50, (byte) 0x44,
- (byte) 0x00, (byte) 0xf1, (byte) 0x0c, (byte) 0xe6,
- (byte) 0xe5, (byte) 0xc4, (byte) 0x41, (byte) 0x3d,
- (byte) 0xf8, (byte) 0x3d, (byte) 0x4e, (byte) 0x0b,
- (byte) 0x1c, (byte) 0xdb, (byte) 0x02, (byte) 0x41,
- (byte) 0x00, (byte) 0x82, (byte) 0x9b, (byte) 0x8a,
- (byte) 0xfd, (byte) 0xa1, (byte) 0x98, (byte) 0x41,
- (byte) 0x68, (byte) 0xc2, (byte) 0xd1, (byte) 0xdf,
- (byte) 0x4e, (byte) 0xf3, (byte) 0x2e, (byte) 0x26,
- (byte) 0x53, (byte) 0x5b, (byte) 0x31, (byte) 0xb1,
- (byte) 0x7a, (byte) 0xcc, (byte) 0x5e, (byte) 0xbb,
- (byte) 0x09, (byte) 0xa2, (byte) 0xe2, (byte) 0x6f,
- (byte) 0x4a, (byte) 0x04, (byte) 0x0d, (byte) 0xef,
- (byte) 0x90, (byte) 0x15, (byte) 0xbe, (byte) 0x10,
- (byte) 0x4a, (byte) 0xac, (byte) 0x92, (byte) 0xeb,
- (byte) 0xda, (byte) 0x72, (byte) 0xdb, (byte) 0x43,
- (byte) 0x08, (byte) 0xb7, (byte) 0x2b, (byte) 0x4c,
- (byte) 0xe1, (byte) 0xbb, (byte) 0x58, (byte) 0xcb,
- (byte) 0x71, (byte) 0x80, (byte) 0xad, (byte) 0xbc,
- (byte) 0xdc, (byte) 0x62, (byte) 0x5e, (byte) 0x3e,
- (byte) 0xcb, (byte) 0x92, (byte) 0xda, (byte) 0xf6,
- (byte) 0xdf, (byte) 0x02, (byte) 0x40, (byte) 0x4d,
- (byte) 0x81, (byte) 0x90, (byte) 0xc5, (byte) 0x77,
- (byte) 0x30, (byte) 0xb7, (byte) 0x29, (byte) 0x00,
- (byte) 0xa8, (byte) 0xf1, (byte) 0xb4, (byte) 0xae,
- (byte) 0x52, (byte) 0x63, (byte) 0x00, (byte) 0xb2,
- (byte) 0x2d, (byte) 0x3e, (byte) 0x7d, (byte) 0xd6,
- (byte) 0x4d, (byte) 0xf9, (byte) 0x8a, (byte) 0xc1,
- (byte) 0xb1, (byte) 0x98, (byte) 0x89, (byte) 0x52,
- (byte) 0x40, (byte) 0x14, (byte) 0x1b, (byte) 0x0e,
- (byte) 0x61, (byte) 0x8f, (byte) 0xf4, (byte) 0xbe,
- (byte) 0x59, (byte) 0x79, (byte) 0x79, (byte) 0x95,
- (byte) 0x19, (byte) 0x5c, (byte) 0x51, (byte) 0x08,
- (byte) 0x66, (byte) 0xc1, (byte) 0x42, (byte) 0x30,
- (byte) 0xb3, (byte) 0x7a, (byte) 0x86, (byte) 0x9f,
- (byte) 0x3e, (byte) 0xf5, (byte) 0x19, (byte) 0xa3,
- (byte) 0xae, (byte) 0x64, (byte) 0x69, (byte) 0x14,
- (byte) 0x07, (byte) 0x50, (byte) 0x97
- });
- publicKeyEncoding.put("RSA", new byte[] {
- (byte) 0x30, (byte) 0x81, (byte) 0x9f, (byte) 0x30,
- (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a,
- (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7,
- (byte) 0x0d, (byte) 0x01, (byte) 0x01, (byte) 0x01,
- (byte) 0x05, (byte) 0x00, (byte) 0x03, (byte) 0x81,
- (byte) 0x8d, (byte) 0x00, (byte) 0x30, (byte) 0x81,
- (byte) 0x89, (byte) 0x02, (byte) 0x81, (byte) 0x81,
- (byte) 0x00, (byte) 0xb2, (byte) 0x4a, (byte) 0x9b,
- (byte) 0x5b, (byte) 0xba, (byte) 0x01, (byte) 0xc0,
- (byte) 0xcd, (byte) 0x65, (byte) 0x09, (byte) 0x63,
- (byte) 0x70, (byte) 0x0b, (byte) 0x5a, (byte) 0x1b,
- (byte) 0x92, (byte) 0x08, (byte) 0xf8, (byte) 0x55,
- (byte) 0x5e, (byte) 0x7c, (byte) 0x1b, (byte) 0x50,
- (byte) 0x17, (byte) 0xec, (byte) 0x44, (byte) 0x4c,
- (byte) 0x58, (byte) 0x42, (byte) 0x2b, (byte) 0x41,
- (byte) 0x09, (byte) 0x59, (byte) 0xf2, (byte) 0xe1,
- (byte) 0x5d, (byte) 0x43, (byte) 0x71, (byte) 0x4d,
- (byte) 0x92, (byte) 0x03, (byte) 0x1d, (byte) 0xb6,
- (byte) 0x6c, (byte) 0x7f, (byte) 0x5d, (byte) 0x48,
- (byte) 0xcd, (byte) 0x17, (byte) 0xec, (byte) 0xd7,
- (byte) 0x4c, (byte) 0x39, (byte) 0xb1, (byte) 0x7b,
- (byte) 0xe2, (byte) 0xbf, (byte) 0x96, (byte) 0x77,
- (byte) 0xbe, (byte) 0xd0, (byte) 0xa0, (byte) 0xf0,
- (byte) 0x2d, (byte) 0x6b, (byte) 0x24, (byte) 0xaa,
- (byte) 0x14, (byte) 0xba, (byte) 0x82, (byte) 0x79,
- (byte) 0x10, (byte) 0x9b, (byte) 0x16, (byte) 0x68,
- (byte) 0x47, (byte) 0x81, (byte) 0x54, (byte) 0xa2,
- (byte) 0xfa, (byte) 0x91, (byte) 0x9e, (byte) 0x0a,
- (byte) 0x2a, (byte) 0x53, (byte) 0xa6, (byte) 0xe7,
- (byte) 0x9e, (byte) 0x7d, (byte) 0x29, (byte) 0x33,
- (byte) 0xd8, (byte) 0x05, (byte) 0xfc, (byte) 0x02,
- (byte) 0x3f, (byte) 0xbd, (byte) 0xc7, (byte) 0x6e,
- (byte) 0xed, (byte) 0xaa, (byte) 0x30, (byte) 0x6c,
- (byte) 0x5f, (byte) 0x52, (byte) 0xed, (byte) 0x35,
- (byte) 0x65, (byte) 0x4b, (byte) 0x0e, (byte) 0xc8,
- (byte) 0xa7, (byte) 0x12, (byte) 0x10, (byte) 0x56,
- (byte) 0x37, (byte) 0xaf, (byte) 0x11, (byte) 0xfa,
- (byte) 0x21, (byte) 0x0e, (byte) 0x99, (byte) 0xff,
- (byte) 0xfa, (byte) 0x8c, (byte) 0x65, (byte) 0x8e,
- (byte) 0x6d, (byte) 0x02, (byte) 0x03, (byte) 0x01,
- (byte) 0x00, (byte) 0x01
- });
- privateKeyEncoding.put("DSA", new byte[] {
- (byte) 0x30, (byte) 0x82, (byte) 0x01, (byte) 0x4a,
- (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0x30,
- (byte) 0x82, (byte) 0x01, (byte) 0x2b, (byte) 0x06,
- (byte) 0x07, (byte) 0x2a, (byte) 0x86, (byte) 0x48,
- (byte) 0xce, (byte) 0x38, (byte) 0x04, (byte) 0x01,
- (byte) 0x30, (byte) 0x82, (byte) 0x01, (byte) 0x1e,
- (byte) 0x02, (byte) 0x81, (byte) 0x81, (byte) 0x00,
- (byte) 0xca, (byte) 0x84, (byte) 0x1d, (byte) 0xa3,
- (byte) 0xab, (byte) 0xb9, (byte) 0x98, (byte) 0xf4,
- (byte) 0x61, (byte) 0x8b, (byte) 0x66, (byte) 0xdb,
- (byte) 0x4e, (byte) 0x3a, (byte) 0xb2, (byte) 0x11,
- (byte) 0x4e, (byte) 0xa9, (byte) 0xda, (byte) 0x35,
- (byte) 0x91, (byte) 0xc9, (byte) 0x4e, (byte) 0xc3,
- (byte) 0x16, (byte) 0xa7, (byte) 0xed, (byte) 0xb8,
- (byte) 0x8f, (byte) 0xd7, (byte) 0xea, (byte) 0xea,
- (byte) 0xdb, (byte) 0x77, (byte) 0xe1, (byte) 0x77,
- (byte) 0x7a, (byte) 0xc9, (byte) 0xf3, (byte) 0x37,
- (byte) 0x33, (byte) 0x01, (byte) 0x72, (byte) 0xbc,
- (byte) 0xd0, (byte) 0x89, (byte) 0x9b, (byte) 0x18,
- (byte) 0xfd, (byte) 0x84, (byte) 0xd6, (byte) 0xe9,
- (byte) 0xbf, (byte) 0x13, (byte) 0x35, (byte) 0x5e,
- (byte) 0x40, (byte) 0xf6, (byte) 0x9d, (byte) 0xd9,
- (byte) 0x1a, (byte) 0xba, (byte) 0xa9, (byte) 0xc3,
- (byte) 0x8c, (byte) 0xe3, (byte) 0x95, (byte) 0xc8,
- (byte) 0xdf, (byte) 0x2e, (byte) 0x41, (byte) 0xa1,
- (byte) 0xbf, (byte) 0xde, (byte) 0x5d, (byte) 0xad,
- (byte) 0x21, (byte) 0xcc, (byte) 0x0d, (byte) 0x42,
- (byte) 0x56, (byte) 0xa0, (byte) 0x32, (byte) 0xc0,
- (byte) 0x90, (byte) 0x73, (byte) 0x3e, (byte) 0xa4,
- (byte) 0x0e, (byte) 0x58, (byte) 0xe4, (byte) 0x64,
- (byte) 0x00, (byte) 0xa3, (byte) 0x27, (byte) 0x49,
- (byte) 0x56, (byte) 0xb2, (byte) 0x43, (byte) 0xbc,
- (byte) 0x72, (byte) 0xa8, (byte) 0xd2, (byte) 0x26,
- (byte) 0x89, (byte) 0x35, (byte) 0x37, (byte) 0x29,
- (byte) 0x8d, (byte) 0x21, (byte) 0xb5, (byte) 0x8e,
- (byte) 0x59, (byte) 0xfa, (byte) 0x9e, (byte) 0xdf,
- (byte) 0x37, (byte) 0x0d, (byte) 0x9e, (byte) 0xab,
- (byte) 0xfd, (byte) 0xbf, (byte) 0x1a, (byte) 0x9e,
- (byte) 0xf3, (byte) 0xe8, (byte) 0x3a, (byte) 0xfb,
- (byte) 0x02, (byte) 0x15, (byte) 0x00, (byte) 0xa2,
- (byte) 0x4e, (byte) 0x5d, (byte) 0xe3, (byte) 0x10,
- (byte) 0x5d, (byte) 0xa9, (byte) 0x3a, (byte) 0x6a,
- (byte) 0x4d, (byte) 0x07, (byte) 0x3b, (byte) 0xab,
- (byte) 0xca, (byte) 0x7d, (byte) 0x09, (byte) 0xd6,
- (byte) 0x06, (byte) 0x79, (byte) 0x49, (byte) 0x02,
- (byte) 0x81, (byte) 0x80, (byte) 0x5a, (byte) 0x91,
- (byte) 0x83, (byte) 0x1c, (byte) 0x04, (byte) 0x33,
- (byte) 0xca, (byte) 0x25, (byte) 0xb0, (byte) 0x68,
- (byte) 0xb3, (byte) 0xb3, (byte) 0xab, (byte) 0x55,
- (byte) 0x29, (byte) 0x33, (byte) 0x4d, (byte) 0xa9,
- (byte) 0x33, (byte) 0x39, (byte) 0xef, (byte) 0x71,
- (byte) 0xca, (byte) 0x95, (byte) 0xf3, (byte) 0xd8,
- (byte) 0x27, (byte) 0x56, (byte) 0x5f, (byte) 0x42,
- (byte) 0xda, (byte) 0x36, (byte) 0x83, (byte) 0xc5,
- (byte) 0xf1, (byte) 0x53, (byte) 0x62, (byte) 0xa5,
- (byte) 0xdc, (byte) 0xe6, (byte) 0x4e, (byte) 0x69,
- (byte) 0x45, (byte) 0x71, (byte) 0x1a, (byte) 0x4a,
- (byte) 0xc3, (byte) 0xf4, (byte) 0x7f, (byte) 0x0a,
- (byte) 0xd1, (byte) 0x78, (byte) 0xed, (byte) 0xbe,
- (byte) 0x6e, (byte) 0xa6, (byte) 0x36, (byte) 0x34,
- (byte) 0x4e, (byte) 0xc3, (byte) 0x1b, (byte) 0x17,
- (byte) 0xaa, (byte) 0xa4, (byte) 0x76, (byte) 0x44,
- (byte) 0x46, (byte) 0xaf, (byte) 0x26, (byte) 0x16,
- (byte) 0x14, (byte) 0xfb, (byte) 0x9f, (byte) 0x5d,
- (byte) 0x08, (byte) 0xaf, (byte) 0x92, (byte) 0xdb,
- (byte) 0xba, (byte) 0xd0, (byte) 0xcb, (byte) 0x8b,
- (byte) 0x1e, (byte) 0xc3, (byte) 0x8b, (byte) 0x36,
- (byte) 0x3b, (byte) 0x4c, (byte) 0x02, (byte) 0xc3,
- (byte) 0x66, (byte) 0x28, (byte) 0x69, (byte) 0xd0,
- (byte) 0x74, (byte) 0x4f, (byte) 0x1c, (byte) 0x4f,
- (byte) 0x97, (byte) 0x75, (byte) 0x7f, (byte) 0x9e,
- (byte) 0x89, (byte) 0x80, (byte) 0xcf, (byte) 0xb2,
- (byte) 0x17, (byte) 0xd6, (byte) 0x66, (byte) 0x91,
- (byte) 0x12, (byte) 0x3a, (byte) 0xb0, (byte) 0x3c,
- (byte) 0x3c, (byte) 0xc2, (byte) 0x31, (byte) 0xd1,
- (byte) 0x31, (byte) 0x2a, (byte) 0x35, (byte) 0xbe,
- (byte) 0x9d, (byte) 0x54, (byte) 0x71, (byte) 0x03,
- (byte) 0xcb, (byte) 0xcc, (byte) 0x04, (byte) 0x16,
- (byte) 0x02, (byte) 0x14, (byte) 0x52, (byte) 0xfb,
- (byte) 0xf9, (byte) 0x12, (byte) 0x40, (byte) 0x05,
- (byte) 0x59, (byte) 0x8f, (byte) 0xde, (byte) 0x9d,
- (byte) 0xac, (byte) 0xa1, (byte) 0xe2, (byte) 0xed,
- (byte) 0x56, (byte) 0x62, (byte) 0x5f, (byte) 0x56,
- (byte) 0x67, (byte) 0x74
- });
- publicKeyEncoding.put("DSA", new byte[] {
- (byte) 0x30, (byte) 0x82, (byte) 0x01, (byte) 0xb7,
- (byte) 0x30, (byte) 0x82, (byte) 0x01, (byte) 0x2b,
- (byte) 0x06, (byte) 0x07, (byte) 0x2a, (byte) 0x86,
- (byte) 0x48, (byte) 0xce, (byte) 0x38, (byte) 0x04,
- (byte) 0x01, (byte) 0x30, (byte) 0x82, (byte) 0x01,
- (byte) 0x1e, (byte) 0x02, (byte) 0x81, (byte) 0x81,
- (byte) 0x00, (byte) 0xca, (byte) 0x84, (byte) 0x1d,
- (byte) 0xa3, (byte) 0xab, (byte) 0xb9, (byte) 0x98,
- (byte) 0xf4, (byte) 0x61, (byte) 0x8b, (byte) 0x66,
- (byte) 0xdb, (byte) 0x4e, (byte) 0x3a, (byte) 0xb2,
- (byte) 0x11, (byte) 0x4e, (byte) 0xa9, (byte) 0xda,
- (byte) 0x35, (byte) 0x91, (byte) 0xc9, (byte) 0x4e,
- (byte) 0xc3, (byte) 0x16, (byte) 0xa7, (byte) 0xed,
- (byte) 0xb8, (byte) 0x8f, (byte) 0xd7, (byte) 0xea,
- (byte) 0xea, (byte) 0xdb, (byte) 0x77, (byte) 0xe1,
- (byte) 0x77, (byte) 0x7a, (byte) 0xc9, (byte) 0xf3,
- (byte) 0x37, (byte) 0x33, (byte) 0x01, (byte) 0x72,
- (byte) 0xbc, (byte) 0xd0, (byte) 0x89, (byte) 0x9b,
- (byte) 0x18, (byte) 0xfd, (byte) 0x84, (byte) 0xd6,
- (byte) 0xe9, (byte) 0xbf, (byte) 0x13, (byte) 0x35,
- (byte) 0x5e, (byte) 0x40, (byte) 0xf6, (byte) 0x9d,
- (byte) 0xd9, (byte) 0x1a, (byte) 0xba, (byte) 0xa9,
- (byte) 0xc3, (byte) 0x8c, (byte) 0xe3, (byte) 0x95,
- (byte) 0xc8, (byte) 0xdf, (byte) 0x2e, (byte) 0x41,
- (byte) 0xa1, (byte) 0xbf, (byte) 0xde, (byte) 0x5d,
- (byte) 0xad, (byte) 0x21, (byte) 0xcc, (byte) 0x0d,
- (byte) 0x42, (byte) 0x56, (byte) 0xa0, (byte) 0x32,
- (byte) 0xc0, (byte) 0x90, (byte) 0x73, (byte) 0x3e,
- (byte) 0xa4, (byte) 0x0e, (byte) 0x58, (byte) 0xe4,
- (byte) 0x64, (byte) 0x00, (byte) 0xa3, (byte) 0x27,
- (byte) 0x49, (byte) 0x56, (byte) 0xb2, (byte) 0x43,
- (byte) 0xbc, (byte) 0x72, (byte) 0xa8, (byte) 0xd2,
- (byte) 0x26, (byte) 0x89, (byte) 0x35, (byte) 0x37,
- (byte) 0x29, (byte) 0x8d, (byte) 0x21, (byte) 0xb5,
- (byte) 0x8e, (byte) 0x59, (byte) 0xfa, (byte) 0x9e,
- (byte) 0xdf, (byte) 0x37, (byte) 0x0d, (byte) 0x9e,
- (byte) 0xab, (byte) 0xfd, (byte) 0xbf, (byte) 0x1a,
- (byte) 0x9e, (byte) 0xf3, (byte) 0xe8, (byte) 0x3a,
- (byte) 0xfb, (byte) 0x02, (byte) 0x15, (byte) 0x00,
- (byte) 0xa2, (byte) 0x4e, (byte) 0x5d, (byte) 0xe3,
- (byte) 0x10, (byte) 0x5d, (byte) 0xa9, (byte) 0x3a,
- (byte) 0x6a, (byte) 0x4d, (byte) 0x07, (byte) 0x3b,
- (byte) 0xab, (byte) 0xca, (byte) 0x7d, (byte) 0x09,
- (byte) 0xd6, (byte) 0x06, (byte) 0x79, (byte) 0x49,
- (byte) 0x02, (byte) 0x81, (byte) 0x80, (byte) 0x5a,
- (byte) 0x91, (byte) 0x83, (byte) 0x1c, (byte) 0x04,
- (byte) 0x33, (byte) 0xca, (byte) 0x25, (byte) 0xb0,
- (byte) 0x68, (byte) 0xb3, (byte) 0xb3, (byte) 0xab,
- (byte) 0x55, (byte) 0x29, (byte) 0x33, (byte) 0x4d,
- (byte) 0xa9, (byte) 0x33, (byte) 0x39, (byte) 0xef,
- (byte) 0x71, (byte) 0xca, (byte) 0x95, (byte) 0xf3,
- (byte) 0xd8, (byte) 0x27, (byte) 0x56, (byte) 0x5f,
- (byte) 0x42, (byte) 0xda, (byte) 0x36, (byte) 0x83,
- (byte) 0xc5, (byte) 0xf1, (byte) 0x53, (byte) 0x62,
- (byte) 0xa5, (byte) 0xdc, (byte) 0xe6, (byte) 0x4e,
- (byte) 0x69, (byte) 0x45, (byte) 0x71, (byte) 0x1a,
- (byte) 0x4a, (byte) 0xc3, (byte) 0xf4, (byte) 0x7f,
- (byte) 0x0a, (byte) 0xd1, (byte) 0x78, (byte) 0xed,
- (byte) 0xbe, (byte) 0x6e, (byte) 0xa6, (byte) 0x36,
- (byte) 0x34, (byte) 0x4e, (byte) 0xc3, (byte) 0x1b,
- (byte) 0x17, (byte) 0xaa, (byte) 0xa4, (byte) 0x76,
- (byte) 0x44, (byte) 0x46, (byte) 0xaf, (byte) 0x26,
- (byte) 0x16, (byte) 0x14, (byte) 0xfb, (byte) 0x9f,
- (byte) 0x5d, (byte) 0x08, (byte) 0xaf, (byte) 0x92,
- (byte) 0xdb, (byte) 0xba, (byte) 0xd0, (byte) 0xcb,
- (byte) 0x8b, (byte) 0x1e, (byte) 0xc3, (byte) 0x8b,
- (byte) 0x36, (byte) 0x3b, (byte) 0x4c, (byte) 0x02,
- (byte) 0xc3, (byte) 0x66, (byte) 0x28, (byte) 0x69,
- (byte) 0xd0, (byte) 0x74, (byte) 0x4f, (byte) 0x1c,
- (byte) 0x4f, (byte) 0x97, (byte) 0x75, (byte) 0x7f,
- (byte) 0x9e, (byte) 0x89, (byte) 0x80, (byte) 0xcf,
- (byte) 0xb2, (byte) 0x17, (byte) 0xd6, (byte) 0x66,
- (byte) 0x91, (byte) 0x12, (byte) 0x3a, (byte) 0xb0,
- (byte) 0x3c, (byte) 0x3c, (byte) 0xc2, (byte) 0x31,
- (byte) 0xd1, (byte) 0x31, (byte) 0x2a, (byte) 0x35,
- (byte) 0xbe, (byte) 0x9d, (byte) 0x54, (byte) 0x71,
- (byte) 0x03, (byte) 0xcb, (byte) 0xcc, (byte) 0x03,
- (byte) 0x81, (byte) 0x85, (byte) 0x00, (byte) 0x02,
- (byte) 0x81, (byte) 0x81, (byte) 0x00, (byte) 0x95,
- (byte) 0xcc, (byte) 0x11, (byte) 0xd4, (byte) 0x53,
- (byte) 0x3d, (byte) 0x9c, (byte) 0x5c, (byte) 0x73,
- (byte) 0xf4, (byte) 0x70, (byte) 0xf0, (byte) 0xe1,
- (byte) 0xac, (byte) 0xe3, (byte) 0x2c, (byte) 0x32,
- (byte) 0x16, (byte) 0x1d, (byte) 0x34, (byte) 0x1a,
- (byte) 0x38, (byte) 0x63, (byte) 0x69, (byte) 0x1a,
- (byte) 0x72, (byte) 0x39, (byte) 0x4e, (byte) 0x41,
- (byte) 0x50, (byte) 0xfa, (byte) 0xdc, (byte) 0x78,
- (byte) 0xa4, (byte) 0xb8, (byte) 0x17, (byte) 0x5a,
- (byte) 0xe4, (byte) 0xf9, (byte) 0xa2, (byte) 0x52,
- (byte) 0x41, (byte) 0x85, (byte) 0xab, (byte) 0x3f,
- (byte) 0xf4, (byte) 0x73, (byte) 0x2e, (byte) 0xae,
- (byte) 0xa9, (byte) 0x21, (byte) 0x8b, (byte) 0x5e,
- (byte) 0x95, (byte) 0x15, (byte) 0xa2, (byte) 0x86,
- (byte) 0x63, (byte) 0x0d, (byte) 0xba, (byte) 0x01,
- (byte) 0xcb, (byte) 0xe3, (byte) 0x68, (byte) 0xc6,
- (byte) 0xaf, (byte) 0x56, (byte) 0x51, (byte) 0x7b,
- (byte) 0xa8, (byte) 0x85, (byte) 0x3f, (byte) 0x01,
- (byte) 0x80, (byte) 0x8b, (byte) 0x1f, (byte) 0xb4,
- (byte) 0x4c, (byte) 0x93, (byte) 0x6b, (byte) 0x42,
- (byte) 0xa6, (byte) 0xbd, (byte) 0x67, (byte) 0x2a,
- (byte) 0x95, (byte) 0x05, (byte) 0xff, (byte) 0x03,
- (byte) 0x2e, (byte) 0x6f, (byte) 0xd4, (byte) 0xd3,
- (byte) 0xf0, (byte) 0x17, (byte) 0xde, (byte) 0xcb,
- (byte) 0x7d, (byte) 0xd9, (byte) 0x42, (byte) 0x4d,
- (byte) 0x97, (byte) 0x2c, (byte) 0x53, (byte) 0xe6,
- (byte) 0x39, (byte) 0x61, (byte) 0xd2, (byte) 0x69,
- (byte) 0xd1, (byte) 0x1c, (byte) 0x9a, (byte) 0x8b,
- (byte) 0x5b, (byte) 0x9c, (byte) 0xfa, (byte) 0xfa,
- (byte) 0x50, (byte) 0x50, (byte) 0xbb, (byte) 0xe4,
- (byte) 0x2e, (byte) 0x83, (byte) 0x06, (byte) 0x08,
- (byte) 0x96, (byte) 0x2a, (byte) 0x68
- });
- privateKeyEncoding.put("DH", new byte[] {
- (byte) 0x30, (byte) 0xffffff81, (byte) 0xffffffe1, (byte) 0x2,
- (byte) 0x1, (byte) 0x0, (byte) 0x30, (byte) 0xffffff81,
- (byte) 0xffffff97, (byte) 0x6, (byte) 0x9, (byte) 0x2a,
- (byte) 0xffffff86, (byte) 0x48, (byte) 0xffffff86,
- (byte) 0xfffffff7, (byte) 0xd, (byte) 0x1, (byte) 0x3,
- (byte) 0x1, (byte) 0x30, (byte) 0xffffff81, (byte) 0xffffff89,
- (byte) 0x2, (byte) 0x41, (byte) 0x0, (byte) 0xfffffff0,
- (byte) 0xffffffaa, (byte) 0x22, (byte) 0x5a, (byte) 0x29,
- (byte) 0xffffffb2, (byte) 0x3f, (byte) 0xffffffc9, (byte) 0xb,
- (byte) 0xffffff87, (byte) 0x5d, (byte) 0xffffff91, (byte) 0x51,
- (byte) 0x1, (byte) 0xffffffa4, (byte) 0xffffffb9, (byte) 0x4e,
- (byte) 0x1e, (byte) 0xffffff85, (byte) 0xfffffffc,
- (byte) 0xffffffa6, (byte) 0x5a, (byte) 0xffffff96,
- (byte) 0xffffffb1, (byte) 0xffffffcb, (byte) 0xffffff81,
- (byte) 0xffffffa3, (byte) 0x6e, (byte) 0xffffff90,
- (byte) 0xffffffbd, (byte) 0xffffffa2, (byte) 0xe,
- (byte) 0xffffffb4, (byte) 0xffffffba, (byte) 0x2c, (byte) 0x45,
- (byte) 0x9, (byte) 0x1c, (byte) 0xffffff98, (byte) 0x39,
- (byte) 0x26, (byte) 0x24, (byte) 0x40, (byte) 0xffffff80,
- (byte) 0xffffffce, (byte) 0x15, (byte) 0xffffff8b,
- (byte) 0xffffffe1, (byte) 0x67, (byte) 0x48, (byte) 0xfffffff3,
- (byte) 0x70, (byte) 0xffffff98, (byte) 0xffffffca,
- (byte) 0xffffffa7, (byte) 0x71, (byte) 0x33, (byte) 0xffffffb6,
- (byte) 0x4, (byte) 0x13, (byte) 0xffffffe5, (byte) 0x61,
- (byte) 0x3c, (byte) 0x1f, (byte) 0x2, (byte) 0x40, (byte) 0x1e,
- (byte) 0xffffffd8, (byte) 0x6f, (byte) 0xffffffce, (byte) 0x23,
- (byte) 0x71, (byte) 0x6a, (byte) 0x2a, (byte) 0xffffffa3,
- (byte) 0x4d, (byte) 0x62, (byte) 0xffffffe9, (byte) 0x5f,
- (byte) 0x17, (byte) 0xffffffa8, (byte) 0xffffffe8,
- (byte) 0xffffffaa, (byte) 0xffffff8a, (byte) 0xffffff95,
- (byte) 0x26, (byte) 0x7c, (byte) 0x38, (byte) 0xffffffa9,
- (byte) 0x2b, (byte) 0x48, (byte) 0x5a, (byte) 0x16,
- (byte) 0x19, (byte) 0xfffffffa, (byte) 0xffffff83,
- (byte) 0xffffffb8, (byte) 0x76, (byte) 0xffffffaf,
- (byte) 0xffffffb8, (byte) 0x62, (byte) 0x72, (byte) 0x45,
- (byte) 0xffffff9f, (byte) 0xffffff95, (byte) 0x1e, (byte) 0x62,
- (byte) 0x36, (byte) 0xffffff97, (byte) 0xffffffbf,
- (byte) 0xffffffab, (byte) 0x20, (byte) 0xffffffb0, (byte) 0x61,
- (byte) 0xffffffc5, (byte) 0x21, (byte) 0xffffff9e,
- (byte) 0xffffffe4, (byte) 0xffffffde, (byte) 0xffffff91,
- (byte) 0x1c, (byte) 0x6a, (byte) 0x7, (byte) 0x48, (byte) 0x77,
- (byte) 0x70, (byte) 0x1d, (byte) 0xffffffff, (byte) 0x58,
- (byte) 0x23, (byte) 0x2, (byte) 0x2, (byte) 0x1,
- (byte) 0xffffffff, (byte) 0x4, (byte) 0x42, (byte) 0x2,
- (byte) 0x40, (byte) 0x69, (byte) 0xffffff86, (byte) 0x48,
- (byte) 0x57, (byte) 0xffffffbf, (byte) 0xffffffde, (byte) 0x8,
- (byte) 0xffffffc6, (byte) 0x24, (byte) 0x6d, (byte) 0xf,
- (byte) 0x20, (byte) 0xffffff94, (byte) 0x4a, (byte) 0x22,
- (byte) 0x6e, (byte) 0x24, (byte) 0x60, (byte) 0xffffffd9,
- (byte) 0xffffffa9, (byte) 0xffffffbd, (byte) 0x1e, (byte) 0x64,
- (byte) 0xffffff89, (byte) 0xffffff83, (byte) 0x3c,
- (byte) 0xffffffe7, (byte) 0x70, (byte) 0x24, (byte) 0xffffffe1,
- (byte) 0xffffff8f, (byte) 0x3c, (byte) 0x4d, (byte) 0x39,
- (byte) 0x5f, (byte) 0xffffff9e, (byte) 0xffffff93, (byte) 0x13,
- (byte) 0xffffff86, (byte) 0xffffffe9, (byte) 0xffffff80,
- (byte) 0xf, (byte) 0xffffffc4, (byte) 0x41, (byte) 0xffffff8b,
- (byte) 0xfffffff4, (byte) 0xffffff8b, (byte) 0x65,
- (byte) 0xffffffa4, (byte) 0x1b, (byte) 0xd, (byte) 0x4,
- (byte) 0x48, (byte) 0x40, (byte) 0xffffffd6, (byte) 0xffffffa2,
- (byte) 0x0, (byte) 0xffffff85, (byte) 0xffffffe9,
- (byte) 0xffffffc4, (byte) 0x77, (byte) 0xffffffb2, (byte) 0x25,
- (byte) 0xffffffd8
- });
- publicKeyEncoding.put("DH", new byte[] {
- (byte) 0x30, (byte) 0xffffff81, (byte) 0xffffffe0, (byte) 0x30,
- (byte) 0xffffff81, (byte) 0xffffff97, (byte) 0x6, (byte) 0x9,
- (byte) 0x2a, (byte) 0xffffff86, (byte) 0x48, (byte) 0xffffff86,
- (byte) 0xfffffff7, (byte) 0xd, (byte) 0x1, (byte) 0x3,
- (byte) 0x1, (byte) 0x30, (byte) 0xffffff81, (byte) 0xffffff89,
- (byte) 0x2, (byte) 0x41, (byte) 0x0, (byte) 0xfffffff0,
- (byte) 0xffffffaa, (byte) 0x22, (byte) 0x5a, (byte) 0x29,
- (byte) 0xffffffb2, (byte) 0x3f, (byte) 0xffffffc9, (byte) 0xb,
- (byte) 0xffffff87, (byte) 0x5d, (byte) 0xffffff91, (byte) 0x51,
- (byte) 0x1, (byte) 0xffffffa4, (byte) 0xffffffb9, (byte) 0x4e,
- (byte) 0x1e, (byte) 0xffffff85, (byte) 0xfffffffc,
- (byte) 0xffffffa6, (byte) 0x5a, (byte) 0xffffff96,
- (byte) 0xffffffb1, (byte) 0xffffffcb, (byte) 0xffffff81,
- (byte) 0xffffffa3, (byte) 0x6e, (byte) 0xffffff90,
- (byte) 0xffffffbd, (byte) 0xffffffa2, (byte) 0xe,
- (byte) 0xffffffb4, (byte) 0xffffffba, (byte) 0x2c, (byte) 0x45,
- (byte) 0x9, (byte) 0x1c, (byte) 0xffffff98, (byte) 0x39,
- (byte) 0x26, (byte) 0x24, (byte) 0x40, (byte) 0xffffff80,
- (byte) 0xffffffce, (byte) 0x15, (byte) 0xffffff8b,
- (byte) 0xffffffe1, (byte) 0x67, (byte) 0x48, (byte) 0xfffffff3,
- (byte) 0x70, (byte) 0xffffff98, (byte) 0xffffffca,
- (byte) 0xffffffa7, (byte) 0x71, (byte) 0x33, (byte) 0xffffffb6,
- (byte) 0x4, (byte) 0x13, (byte) 0xffffffe5, (byte) 0x61,
- (byte) 0x3c, (byte) 0x1f, (byte) 0x2, (byte) 0x40, (byte) 0x1e,
- (byte) 0xffffffd8, (byte) 0x6f, (byte) 0xffffffce, (byte) 0x23,
- (byte) 0x71, (byte) 0x6a, (byte) 0x2a, (byte) 0xffffffa3,
- (byte) 0x4d, (byte) 0x62, (byte) 0xffffffe9, (byte) 0x5f,
- (byte) 0x17, (byte) 0xffffffa8, (byte) 0xffffffe8,
- (byte) 0xffffffaa, (byte) 0xffffff8a, (byte) 0xffffff95,
- (byte) 0x26, (byte) 0x7c, (byte) 0x38, (byte) 0xffffffa9,
- (byte) 0x2b, (byte) 0x48, (byte) 0x5a, (byte) 0x16,
- (byte) 0x19, (byte) 0xfffffffa, (byte) 0xffffff83,
- (byte) 0xffffffb8, (byte) 0x76, (byte) 0xffffffaf,
- (byte) 0xffffffb8, (byte) 0x62, (byte) 0x72, (byte) 0x45,
- (byte) 0xffffff9f, (byte) 0xffffff95, (byte) 0x1e, (byte) 0x62,
- (byte) 0x36, (byte) 0xffffff97, (byte) 0xffffffbf,
- (byte) 0xffffffab, (byte) 0x20, (byte) 0xffffffb0, (byte) 0x61,
- (byte) 0xffffffc5, (byte) 0x21, (byte) 0xffffff9e,
- (byte) 0xffffffe4, (byte) 0xffffffde, (byte) 0xffffff91,
- (byte) 0x1c, (byte) 0x6a, (byte) 0x7, (byte) 0x48, (byte) 0x77,
- (byte) 0x70, (byte) 0x1d, (byte) 0xffffffff, (byte) 0x58,
- (byte) 0x23, (byte) 0x2, (byte) 0x2, (byte) 0x1,
- (byte) 0xffffffff, (byte) 0x3, (byte) 0x44, (byte) 0x0,
- (byte) 0x2, (byte) 0x41, (byte) 0x0, (byte) 0xffffff9d,
- (byte) 0xffffffc4, (byte) 0xffffffcd, (byte) 0x10,
- (byte) 0xffffffdf, (byte) 0x66, (byte) 0xffffff92,
- (byte) 0xffffffe1, (byte) 0x33, (byte) 0xffffffb1,
- (byte) 0xffffffc9, (byte) 0xffffff9f, (byte) 0xffffffb7,
- (byte) 0xffffffdd, (byte) 0xffffff84, (byte) 0x4b,
- (byte) 0xffffffe5, (byte) 0xffffff86, (byte) 0xfffffff0,
- (byte) 0x53, (byte) 0x2a, (byte) 0xffffffd5, (byte) 0xffffffc6,
- (byte) 0x15, (byte) 0xffffff94, (byte) 0xffffffae, (byte) 0x13,
- (byte) 0x7b, (byte) 0xffffff9d, (byte) 0x37, (byte) 0xffffff8b,
- (byte) 0xffffffc6, (byte) 0xffffffc6, (byte) 0x78,
- (byte) 0xffffff9c, (byte) 0x60, (byte) 0xffffff8a, (byte) 0x6f,
- (byte) 0x35, (byte) 0x39, (byte) 0xffffffe0, (byte) 0x78,
- (byte) 0x33, (byte) 0x60, (byte) 0xffffff89, (byte) 0x30,
- (byte) 0x61, (byte) 0xffffff84, (byte) 0xffffff8a,
- (byte) 0xffffffbc, (byte) 0xffffff80, (byte) 0x6c, (byte) 0x1c,
- (byte) 0x55, (byte) 0xffffff96, (byte) 0x50, (byte) 0xffffffb1,
- (byte) 0xffffff96, (byte) 0x5, (byte) 0x21, (byte) 0x65,
- (byte) 0x55, (byte) 0xffffffbb, (byte) 0xffffffa4
- });
- }
-
- public TestKeyPair(String algorithmName) throws
- NoSuchAlgorithmException {
- this.algorithmName = algorithmName;
- if (!privateKeyEncoding.containsKey(this.algorithmName)) {
- throw new NoSuchAlgorithmException("Encoded form not available for " +
- this.algorithmName);
- }
- kf = KeyFactory.getInstance(this.algorithmName);
- }
-
- public PublicKey getPublic() throws
- InvalidKeySpecException {
- return kf.generatePublic(
- new X509EncodedKeySpec(
- (byte[]) publicKeyEncoding.get(algorithmName)));
- }
-
- public PrivateKey getPrivate() throws
- InvalidKeySpecException {
- return kf.generatePrivate(
- new PKCS8EncodedKeySpec(
- (byte[]) privateKeyEncoding.get(algorithmName)));
- }
-
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/TestUtils.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/TestUtils.java
deleted file mode 100644
index 9f9dfd5..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/TestUtils.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.util.Properties;
-
-/**
- * Test utility class
- */
-public class TestUtils {
-
- /**
- * No need to instantiate
- */
- private TestUtils() {
- }
-
- /**
- * Prints byte array <code>data</code> as hex to the
- * <code>System.out</code> in the customizable form.
- *
- * @param perLine how many numbers put on single line
- * @param prefix custom output number prefix
- * @param delimiter custom output number delimiter
- * @param data data to be printed
- */
- public static void printAsHex(int perLine,
- String prefix,
- String delimiter,
- byte[] data) {
- for (int i = 0; i < data.length; i++) {
- String tail = Integer.toHexString(0x000000ff & data[i]);
- if (tail.length() == 1) {
- tail = "0" + tail;
- }
- System.out.print(prefix + "0x" + tail + delimiter);
-
- if (((i + 1) % perLine) == 0) {
- System.out.println("");
- }
- }
- System.out.println("");
- }
-
- /**
- * Sets system property
- *
- * @param key - the name of the system property.
- * @param value - the value to be set
- */
- public static void setSystemProperty(String key, String value) {
- Properties properties = System.getProperties();
- if (value == null) {
- properties.remove(key);
- } else {
- properties.setProperty(key, value);
- }
- System.setProperties(properties);
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCRL.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCRL.java
deleted file mode 100644
index b0bf388..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCRL.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.support.cert;
-
-import java.security.cert.CRL;
-import java.security.cert.Certificate;
-
-/**
- * Stub class for <code>java.security.cert.CRL</code> tests
- */
-public class MyCRL extends CRL {
-
- /**
- * Constructor
- *
- * @param type
- */
- public MyCRL(String type) {
- super(type);
- }
-
- /**
- * @return <code>String</code> representation
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return "MyCRL: [" + getType() + "]";
- }
-
- /**
- * @param cert <code>Certificate</code> to be checked
- * @return always <code>false</code>
- * @see java.security.cert.CRL#isRevoked(java.security.cert.Certificate)
- */
- public boolean isRevoked(Certificate cert) {
- return false;
- }
-
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPath.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPath.java
deleted file mode 100644
index 100afe4..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPath.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.support.cert;
-
-import java.security.cert.CertPath;
-import java.security.cert.CertificateEncodingException;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-
-/**
- * Stub class for <code>java.security.cert.CertPath</code> tests
- */
-public class MyCertPath extends CertPath {
- /**
- * my certificates list
- */
- private final Vector certificates;
- /**
- * List of encodings supported
- */
- private final Vector encodingNames;
- /**
- * my cert path the only encoding
- */
- private final byte[] encoding;
-
- /**
- * Constructs new instance of <code>MyCertPath</code>
- *
- * @param type
- * @param encoding
- */
- public MyCertPath(byte[] encoding) {
- super("MyEncoding");
- this.encoding = encoding;
- certificates = new Vector();
- certificates.add(new MyCertificate("MyEncoding", encoding));
- encodingNames = new Vector();
- encodingNames.add("MyEncoding");
- }
-
- /**
- * @return certificates list
- * @see java.security.cert.CertPath#getCertificates()
- */
- public List getCertificates() {
- return Collections.unmodifiableList(certificates);
- }
-
- /**
- * @return default encoded form of this cert path
- * @see java.security.cert.CertPath#getEncoded()
- */
- public byte[] getEncoded() throws CertificateEncodingException {
- return encoding.clone();
- }
-
- /**
- * @return encoded form of this cert path as specified by
- * <code>encoding</code> parameter
- * @throws CertificateEncodingException if <code>encoding</code>
- * not equals "MyEncoding"
- * @see java.security.cert.CertPath#getEncoded(java.lang.String)
- */
- public byte[] getEncoded(String encoding)
- throws CertificateEncodingException {
- if (getType().equals(encoding)) {
- return this.encoding.clone();
- }
- throw new CertificateEncodingException("Encoding not supported: " +
- encoding);
- }
-
- /**
- * @return iterator through encodings supported
- * @see java.security.cert.CertPath#getEncodings()
- */
- public Iterator getEncodings() {
- return Collections.unmodifiableCollection(encodingNames).iterator();
- }
-
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathBuilderSpi.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathBuilderSpi.java
deleted file mode 100644
index 9b1e33b..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathBuilderSpi.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.cert.CertPathBuilderException;
-import java.security.cert.CertPathBuilderResult;
-import java.security.cert.CertPathBuilderSpi;
-import java.security.cert.CertPathParameters;
-
-/**
- * Additional class for verification CertPathBuilderSpi
- * and CertPathBuilder
- */
-
-public class MyCertPathBuilderSpi extends CertPathBuilderSpi {
- private int swi = 0;
-
- public CertPathBuilderResult engineBuild(CertPathParameters params)
- throws CertPathBuilderException, InvalidAlgorithmParameterException {
- swi++;
- if ((params == null) && ((swi % 2) != 0)) {
- throw new CertPathBuilderException("Null parameter");
- }
- return null;
- }
-} \ No newline at end of file
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathValidatorSpi.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathValidatorSpi.java
deleted file mode 100644
index 7e58168..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathValidatorSpi.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.cert.CertPath;
-import java.security.cert.CertPathParameters;
-import java.security.cert.CertPathValidatorException;
-import java.security.cert.CertPathValidatorResult;
-import java.security.cert.CertPathValidatorSpi;
-
-/**
- * Additional class for verification of CertPathValidatorSpi
- * and CertPathValidator
- */
-
-public class MyCertPathValidatorSpi extends CertPathValidatorSpi {
- private int sw = 0;
-
- public CertPathValidatorResult engineValidate(CertPath certPath,
- CertPathParameters params) throws CertPathValidatorException,
- InvalidAlgorithmParameterException {
- ++sw;
- if (certPath == null) {
- if ((sw % 2) == 0) {
- throw new CertPathValidatorException("certPath null");
- }
- }
- if (params == null) {
- if ((sw % 3) == 0) {
- throw new InvalidAlgorithmParameterException("params null");
- }
- }
- return null;
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreParameters.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreParameters.java
deleted file mode 100644
index af8072c..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreParameters.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support.cert;
-
-import java.security.cert.CertStoreParameters;
-
-/**
- * Class for verification of CertStore and CertStoreSpi
- */
-
-public class MyCertStoreParameters implements CertStoreParameters {
- public MyCertStoreParameters() {
- super();
- }
-
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreSpi.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreSpi.java
deleted file mode 100644
index d0f6d09..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreSpi.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.cert.CRLSelector;
-import java.security.cert.CertSelector;
-import java.security.cert.CertStoreException;
-import java.security.cert.CertStoreParameters;
-import java.security.cert.CertStoreSpi;
-import java.util.Collection;
-
-/**
- * Additional class for verification CertStoreSpi
- * and CertStore
- */
-
-public class MyCertStoreSpi extends CertStoreSpi {
-
- public MyCertStoreSpi(CertStoreParameters params)
- throws InvalidAlgorithmParameterException {
- super(params);
- if (!(params instanceof MyCertStoreParameters)) {
- throw new InvalidAlgorithmParameterException("Invalid params");
- }
- }
-
- public Collection engineGetCertificates(CertSelector selector)
- throws CertStoreException {
- if (selector == null) {
- throw new CertStoreException("Parameter is null");
- }
- return null;
- }
-
- public Collection engineGetCRLs(CRLSelector selector)
- throws CertStoreException {
- if (selector == null) {
- throw new CertStoreException("Parameter is null");
- }
- return null;
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertificate.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertificate.java
deleted file mode 100644
index c9250db..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertificate.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.support.cert;
-
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-
-/**
- * Stub class for <code>java.security.cert.Certificate</code> tests
- */
-public class MyCertificate extends Certificate {
-
- // MyCertificate encoding
- private final byte[] encoding;
-
- /**
- * Constructs new object of class <code>MyCertificate</code>
- *
- * @param type
- * @param encoding
- */
- public MyCertificate(String type, byte[] encoding) {
- super(type);
- // don't copy to allow null parameter in test
- this.encoding = encoding;
- }
-
- /**
- * Returns <code>MyCertificate</code> encoding
- */
- public byte[] getEncoded() throws CertificateEncodingException {
- // do copy to force NPE in test
- return encoding.clone();
- }
-
- /**
- * Does nothing
- */
- public void verify(PublicKey key) throws CertificateException,
- NoSuchAlgorithmException, InvalidKeyException,
- NoSuchProviderException, SignatureException {
- }
-
- /**
- * Does nothing
- */
- public void verify(PublicKey key, String sigProvider)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException, SignatureException {
- }
-
- /**
- * Returns formatted <code>String</code>
- * describing <code>MyCertificate</code> object
- */
- public String toString() {
- return "[My test Certificate, type: " + getType() + "]";
- }
-
- /**
- * Returns public key (stub) from <code>MyCertificate</code> object
- */
- public PublicKey getPublicKey() {
- return new PublicKey() {
- public String getAlgorithm() {
- return "TEST";
- }
-
- public byte[] getEncoded() {
- return new byte[] { (byte) 1, (byte) 2, (byte) 3 };
- }
-
- public String getFormat() {
- return "TEST_FORMAT";
- }
- };
- }
-
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertificateFactorySpi.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertificateFactorySpi.java
deleted file mode 100644
index aa9b1f4..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertificateFactorySpi.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support.cert;
-
-import java.io.DataInputStream;
-import java.io.InputStream;
-import java.security.cert.CRL;
-import java.security.cert.CRLException;
-import java.security.cert.CertPath;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactorySpi;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Additional class for verification CertificateFactorySpi and
- * CertificateFactory classes
- */
-
-public class MyCertificateFactorySpi extends CertificateFactorySpi {
- // Variants of execution:
- // mode: false - list of encodings is empty
- // mode: true - list of encodings consists of 2 elements
- // some exceptions are thrown when
- private static boolean mode;
-
- private Set list;
-
- public MyCertificateFactorySpi() {
- super();
- mode = true;
- list = new HashSet();
- list.add("aa");
- list.add("bb");
- }
-
- public static void putMode(boolean newMode) {
- mode = newMode;
- }
-
- public Certificate engineGenerateCertificate(InputStream inStream)
- throws CertificateException {
- if (!(inStream instanceof DataInputStream)) {
- throw new CertificateException("Incorrect inputstream");
- }
- return null;
- }
-
- public Collection engineGenerateCertificates(InputStream inStream)
- throws CertificateException {
- if (!(inStream instanceof DataInputStream)) {
- throw new CertificateException("Incorrect inputstream");
- }
- return null;
- }
-
- public CRL engineGenerateCRL(InputStream inStream) throws CRLException {
- if (!(inStream instanceof DataInputStream)) {
- throw new CRLException("Incorrect inputstream");
- }
- return null;
- }
-
- public Collection engineGenerateCRLs(InputStream inStream)
- throws CRLException {
- if (!(inStream instanceof DataInputStream)) {
- throw new CRLException("Incorrect inputstream");
- }
- return null;
- }
-
- public CertPath engineGenerateCertPath(InputStream inStream)
- throws CertificateException {
- if (!(inStream instanceof DataInputStream)) {
- throw new CertificateException("Incorrect inputstream");
- }
- Iterator it = engineGetCertPathEncodings();
- if (!it.hasNext()) {
- throw new CertificateException("There are no CertPath encodings");
- }
- return engineGenerateCertPath(inStream, (String) it.next());
- }
-
- public CertPath engineGenerateCertPath(InputStream inStream, String encoding)
- throws CertificateException {
- if (!(inStream instanceof DataInputStream)) {
- throw new CertificateException("Incorrect inputstream");
- }
- if (encoding.length() == 0) {
- if (mode) {
- throw new IllegalArgumentException("Encoding is empty");
- }
- }
- return null;
- }
-
- public CertPath engineGenerateCertPath(List certificates)
- throws CertificateException {
- if (certificates == null) {
- if (mode) {
- throw new NullPointerException("certificates is null");
- }
- }
- return null;
- }
-
- public Iterator engineGetCertPathEncodings() {
- if (!mode) {
- list.clear();
- }
- return list.iterator();
- }
-} \ No newline at end of file
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java
deleted file mode 100644
index 91ffd3b..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java
+++ /dev/null
@@ -1,538 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.support.cert;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertPathValidatorException;
-import java.security.cert.CertStore;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.CollectionCertStoreParameters;
-import java.security.cert.PKIXCertPathChecker;
-import java.security.cert.PolicyNode;
-import java.security.cert.TrustAnchor;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import tests.support.resource.Support_Resources;
-
-/**
- * java.security.cert test utilities
- */
-public class TestUtils {
- // Certificate type used during testing
- private static final String certType = "X.509";
- // Key store type used during testing
- private static final String keyStoreType = "BKS";
- // The file name prefix to load keystore from
- private static final String keyStoreFileName = "test." + keyStoreType
- + ".ks";
- //
- // The file name suffixes to load keystore from
- // *.ks1 - keystore containing untrusted certificates only
- // *.ks2 - keystore containing trusted certificates only
- // *.ks3 - keystore containing both trusted and untrusted certificates
- //
- public static final int UNTRUSTED = 1;
- public static final int TRUSTED = 2;
- public static final int TRUSTED_AND_UNTRUSTED = 3;
- //
- // Common passwords for all test keystores
- //
- private final static char[] storepass =
- new char[] { 's', 't', 'o', 'r', 'e', 'p', 'w', 'd' };
-
- /**
- * Creates <code>TrustAnchor</code> instance
- * constructed using self signed test certificate
- *
- * @return <code>TrustAnchor</code> instance
- * @throws CertificateException
- * @throws FileNotFoundException
- */
- public static TrustAnchor getTrustAnchor() {
- CertificateFactory cf = null;
- try {
- cf = CertificateFactory.getInstance(certType);
- } catch (CertificateException e) {
- // requested cert type is not available in the
- // default provider package or any of the other provider packages
- // that were searched
- throw new RuntimeException(e);
- }
- BufferedInputStream bis = null;
- try {
- bis = new BufferedInputStream(new ByteArrayInputStream(
- getEncodedX509Certificate()));
- X509Certificate c1 = (X509Certificate) cf.generateCertificate(bis);
-
- return new TrustAnchor(c1, null);
- } catch (Exception e) {
- // all failures are fatal
- throw new RuntimeException(e);
- } finally {
- if (bis != null) {
- try {
- bis.close();
- } catch (IOException ign) {
- }
- }
- }
- }
-
- /**
- * Creates <code>Set</code> of <code>TrustAnchor</code>s
- * containing single element (self signed test certificate).
- *
- * @return Returns <code>Set</code> of <code>TrustAnchor</code>s
- */
- public static Set getTrustAnchorSet() {
- TrustAnchor ta = getTrustAnchor();
- if (ta == null) {
- return null;
- }
- HashSet set = new HashSet();
- if (!set.add(ta)) {
- throw new RuntimeException("Could not create trust anchor set");
- }
- return set;
- }
-
- /**
- * Creates test <code>KeyStore</code> instance
- *
- * @param initialize Do not initialize returned <code>KeyStore</code> if false
- * @param testKeyStoreType this parameter ignored if <code>initialize</code> is false;
- * The following types supported:<br>
- * 1 - <code>KeyStore</code> with untrusted certificates only<br>
- * 2 - <code>KeyStore</code> with trusted certificates only<br>
- * 3 - <code>KeyStore</code> with both trusted and untrusted certificates
- * @return Returns test <code>KeyStore</code> instance
- */
- public static KeyStore getKeyStore(boolean initialize,
- int testKeyStoreType) {
- BufferedInputStream bis = null;
- try {
- KeyStore ks = KeyStore.getInstance(keyStoreType);
- if (initialize) {
- String fileName = keyStoreFileName + testKeyStoreType;
- ks.load(Support_Resources.getResourceStream(fileName),
- storepass);
- }
- return ks;
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- if (initialize && bis != null) {
- try {
- bis.close();
- } catch (IOException ign) {
- }
- }
- }
- }
-
- /**
- * Creates <code>List</code> of <code>CollectionCertStores</code>
- *
- * @return The list created
- * @throws InvalidAlgorithmParameterException
- *
- * @throws NoSuchAlgorithmException
- */
- public static List getCollectionCertStoresList()
- throws InvalidAlgorithmParameterException,
- NoSuchAlgorithmException {
- CertStore cs = CertStore.getInstance("Collection",
- new CollectionCertStoreParameters());
- ArrayList l = new ArrayList();
- if (!l.add(cs)) {
- throw new RuntimeException("Could not create cert stores list");
- }
- return l;
- }
-
- /**
- * Creates stub implementation of the <code>PKIXCertPathChecker</code>
- *
- * @return Stub implementation of the <code>PKIXCertPathChecker</code>
- */
- public static PKIXCertPathChecker getTestCertPathChecker() {
- // stub implementation for testing purposes only
- return new PKIXCertPathChecker() {
- private boolean forward = false;
-
- public void check(Certificate arg0, Collection arg1)
- throws CertPathValidatorException {
- }
-
- public Set getSupportedExtensions() {
- return null;
- }
-
- public void init(boolean arg0) throws CertPathValidatorException {
- forward = arg0;
- }
-
- public boolean isForwardCheckingSupported() {
- // just to check this checker state
- return forward;
- }
- };
- }
-
- /**
- * Creates policy tree stub containing two <code>PolicyNode</code>s
- * for testing purposes
- *
- * @return root <code>PolicyNode</code> of the policy tree
- */
- public static PolicyNode getPolicyTree() {
- return new PolicyNode() {
- final PolicyNode parent = this;
-
- public int getDepth() {
- // parent
- return 0;
- }
-
- public boolean isCritical() {
- return false;
- }
-
- public String getValidPolicy() {
- return null;
- }
-
- public PolicyNode getParent() {
- return null;
- }
-
- public Iterator getChildren() {
- PolicyNode child = new PolicyNode() {
- public int getDepth() {
- // child
- return 1;
- }
-
- public boolean isCritical() {
- return false;
- }
-
- public String getValidPolicy() {
- return null;
- }
-
- public PolicyNode getParent() {
- return parent;
- }
-
- public Iterator getChildren() {
- return null;
- }
-
- public Set getExpectedPolicies() {
- return null;
- }
-
- public Set getPolicyQualifiers() {
- return null;
- }
- };
- HashSet s = new HashSet();
- s.add(child);
- return s.iterator();
- }
-
- public Set getExpectedPolicies() {
- return null;
- }
-
- public Set getPolicyQualifiers() {
- return null;
- }
- };
- }
-
- // X.509 encoded certificate
- private static final String ENCODED_X509_CERTIFICATE = "-----BEGIN CERTIFICATE-----\n"
- + "MIIDHTCCAtsCBEFT72swCwYHKoZIzjgEAwUAMHQxCzAJBgNVBAYTAlJVMQwwCgYDVQQIEwNOU08x\n"
- + "FDASBgNVBAcTC05vdm9zaWJpcnNrMQ4wDAYDVQQKEwVJbnRlbDEVMBMGA1UECxMMRFJMIFNlY3Vy\n"
- + "aXR5MRowGAYDVQQDExFWbGFkaW1pciBNb2xvdGtvdjAeFw0wNDA5MjQwOTU2NTlaFw0wNjA1MTcw\n"
- + "OTU2NTlaMHQxCzAJBgNVBAYTAlJVMQwwCgYDVQQIEwNOU08xFDASBgNVBAcTC05vdm9zaWJpcnNr\n"
- + "MQ4wDAYDVQQKEwVJbnRlbDEVMBMGA1UECxMMRFJMIFNlY3VyaXR5MRowGAYDVQQDExFWbGFkaW1p\n"
- + "ciBNb2xvdGtvdjCCAbgwggEsBgcqhkjOOAQBMIIBHwKBgQD9f1OBHXUSKVLfSpwu7OTn9hG3Ujzv\n"
- + "RADDHj+AtlEmaUVdQCJR+1k9jVj6v8X1ujD2y5tVbNeBO4AdNG/yZmC3a5lQpaSfn+gEexAiwk+7\n"
- + "qdf+t8Yb+DtX58aophUPBPuD9tPFHsMCNVQTWhaRMvZ1864rYdcq7/IiAxmd0UgBxwIVAJdgUI8V\n"
- + "IwvMspK5gqLrhAvwWBz1AoGBAPfhoIXWmz3ey7yrXDa4V7l5lK+7+jrqgvlXTAs9B4JnUVlXjrrU\n"
- + "WU/mcQcQgYC0SRZxI+hMKBYTt88JMozIpuE8FnqLVHyNKOCjrh4rs6Z1kW6jfwv6ITVi8ftiegEk\n"
- + "O8yk8b6oUZCJqIPf4VrlnwaSi2ZegHtVJWQBTDv+z0kqA4GFAAKBgQDiNmj9jgWu1ILYqYWcUhNN\n"
- + "8CjjRitf80yWP/s/565wZz3anb2w72jum63mdShDko9eOOOd1hiVuiBnNhSL7D6JfIYBJvNXr1av\n"
- + "Gw583BBv12OBgg0eAW/GRWBn2Ak2JjsoBc5x2c1HAEufakep7T6RoC+n3lqbKPKyHWVdfqQ9KTAL\n"
- + "BgcqhkjOOAQDBQADLwAwLAIUaRS3C9dXcMbrOAhmidFBr7oMvH0CFEC3LUwfLJX5gY8P6uxpkPx3\n"
- + "JDSM\n" + "-----END CERTIFICATE-----\n";
-
- public static byte[] getEncodedX509Certificate() {
- byte cert[];
- try {
- cert = ENCODED_X509_CERTIFICATE.getBytes("UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e.getMessage());
- }
- return cert;
- }
-
- /**
- * Returns X.509 certificate encoding corresponding to version v1.
- * <p/>
- * Certificate encoding was created by hands according to X.509 Certificate
- * ASN.1 notation. The certificate encoding has the following encoded
- * field values:<br>
- * - version: 1<br>
- * - serialNumber: 5<br>
- * - issuer: CN=Z<br>
- * - notBefore: 13 Dec 1999 14:15:16<br>
- * - notAfter: 01 Jan 2000 00:00:00<br>
- * - subject: CN=Y<br>
- *
- * @return X.509 certificate encoding corresponding to version v1.
- */
- public static byte[] getX509Certificate_v1() {
- return new byte[] {
- // Certificate: SEQUENCE
- 0x30, 0x6B,
-
- //
- // TBSCertificate: SEQUENCE {
- //
- 0x30, 0x5C,
-
- // version: [0] EXPLICIT Version DEFAULT v1
- (byte) 0xA0, 0x03, 0x02, 0x01, 0x00,
-
- // serialNumber: CertificateSerialNumber
- 0x02, 0x01, 0x05,
-
- // signature: AlgorithmIdentifier
- 0x30, 0x07, // SEQUENCE
- 0x06, 0x02, 0x03, 0x05,//OID
- 0x01, 0x01, 0x07, //ANY
-
- //issuer: Name
- 0x30, 0x0C, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03,
- 0x13, 0x01, 0x5A, // CN=Z
-
- //validity: Validity
- 0x30, 0x1E, // SEQUENCE
- // notBefore: UTCTime
- 0x17, 0x0D, 0x39, 0x39, 0x31, 0x32, 0x31, 0x33, 0x31, 0x34, 0x31,
- 0x35, 0x31, 0x36, 0x5A, // 13 Dec 1999 14:15:16
- // notAfter: UTCTime
- 0x17, 0x0D, 0x30, 0x30, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30,
- 0x30, 0x30, 0x30, 0x5A, // 01 Jan 2000 00:00:00
-
- //subject: Name
- 0x30, 0x0C, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03,
- 0x13, 0x01, 0x59, // CN=Y
- //SubjectPublicKeyInfo ::= SEQUENCE {
- // algorithm AlgorithmIdentifier,
- // subjectPublicKey BIT STRING }
- 0x30, 0x0D, // SEQUENCE
- 0x30, 0x07, // SEQUENCE
- 0x06, 0x02, 0x03, 0x05,//OID
- 0x01, 0x01, 0x07, //ANY
- 0x03, 0x02, 0x00, 0x01, // subjectPublicKey
-
- // issuerUniqueID - missed
- // subjectUniqueID - missed
- // extensions - missed
-
- // } end TBSCertificate
-
- //
- // signatureAlgorithm: AlgorithmIdentifier
- //
- 0x30, 0x07, // SEQUENCE
- 0x06, 0x02, 0x03, 0x05,//OID
- 0x01, 0x01, 0x07, //ANY
-
- //
- // signature: BIT STRING
- //
- 0x03, 0x02, 0x00, 0x01 };
- }
-
- /**
- * Returns X.509 certificate encoding corresponding to version v3.
- * <p/>
- * Certificate encoding was created by hands according to X.509 Certificate
- * ASN.1 notation. The certificate encoding has the following encoded
- * field values:<br>
- * - version: 3<br>
- * - serialNumber: 5<br>
- * - issuer: CN=Z<br>
- * - notBefore: 13 Dec 1999 14:15:16<br>
- * - notAfter: 01 Jan 2000 00:00:00<br>
- * - subject: CN=Y<br>
- * - extensions:
- * 1) AuthorityKeyIdentifier(OID=2.5.29.35): no values in it(empty sequence)
- *
- * @return X.509 certificate encoding corresponding to version v3.
- */
- public static byte[] getX509Certificate_v3() {
- return new byte[] {
- // Certificate: SEQUENCE
- 0x30, 0x7D,
-
- //
- // TBSCertificate: SEQUENCE {
- //
- 0x30, 0x6E,
-
- // version: [0] EXPLICIT Version DEFAULT v1
- (byte) 0xA0, 0x03, 0x02, 0x01, 0x02,
-
- // serialNumber: CertificateSerialNumber
- 0x02, 0x01, 0x05,
-
- // signature: AlgorithmIdentifier
- 0x30, 0x07, // SEQUENCE
- 0x06, 0x02, 0x03, 0x05,//OID
- 0x01, 0x01, 0x07, //ANY
-
- //issuer: Name
- 0x30, 0x0C, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03,
- 0x13, 0x01, 0x5A, // CN=Z
-
- //validity: Validity
- 0x30, 0x1E, // SEQUENCE
- // notBefore: UTCTime
- 0x17, 0x0D, 0x39, 0x39, 0x31, 0x32, 0x31, 0x33, 0x31, 0x34, 0x31,
- 0x35, 0x31, 0x36, 0x5A, // 13 Dec 1999 14:15:16
- // notAfter: UTCTime
- 0x17, 0x0D, 0x30, 0x30, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30,
- 0x30, 0x30, 0x30, 0x5A, // 01 Jan 2000 00:00:00
-
- //subject: Name
- 0x30, 0x0C, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03,
- 0x13, 0x01, 0x59, // CN=Y
- //SubjectPublicKeyInfo ::= SEQUENCE {
- // algorithm AlgorithmIdentifier,
- // subjectPublicKey BIT STRING }
- 0x30, 0x0D, // SEQUENCE
- 0x30, 0x07, // SEQUENCE
- 0x06, 0x02, 0x03, 0x05,//OID
- 0x01, 0x01, 0x07, //ANY
- 0x03, 0x02, 0x00, 0x01, // subjectPublicKey
-
- // issuerUniqueID - missed
- // subjectUniqueID - missed
- // extensions : [3] EXPLICIT Extensions OPTIONAL
- (byte) 0xA3, 0x10,
- // Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
- 0x30, 0x0E,
- // Extension ::= SEQUENCE {
- // extnID OBJECT IDENTIFIER,
- // critical BOOLEAN DEFAULT FALSE,
- // extnValue OCTET STRING }
-
- // 1) AuthorityKeyIdentifier extension (see HARMONY-3384)
- 0x30, 0x0C,
- 0x06, 0x03, 0x55, 0x1D, 0x23, // OID = 2.5.29.35
- 0x01, 0x01, 0x00, // critical = FALSE
- 0x04, 0x02, 0x30, 0x00, // extnValue: MUST be empty sequence
- // missed: keyIdentifier
- // missed: authorityCertIssuer
- // missed" authorityCertSerialNumber
-
- // } end TBSCertificate
-
- //
- // signatureAlgorithm: AlgorithmIdentifier
- //
- 0x30, 0x07, // SEQUENCE
- 0x06, 0x02, 0x03, 0x05,//OID
- 0x01, 0x01, 0x07, //ANY
-
- //
- // signature: BIT STRING
- //
- 0x03, 0x02, 0x00, 0x01 };
- }
-
- /**
- * Returns X.509 CRL encoding corresponding to version v1.
- * <p/>
- * CRL encoding was created by hands according to X.509 CRL ASN.1
- * notation. The CRL encoding has the following encoded field values:<br>
- * - version: 1<br>
- * - issuer: CN=Z<br>
- * - thisUpdate: 01 Jan 2001 01:02:03<br>
- *
- * @return X.509 CRL encoding corresponding to version v1.
- */
- public static byte[] getX509CRL_v1() {
- return new byte[] {
- //CertificateList: SEQUENCE
- 0x30, 0x35,
-
- // TBSCertList: SEQUENCE
- 0x30, 0x27,
- // Version: INTEGER OPTIONAL
- // 0x02, 0x01, 0x01, - missed here cause it is v1
- // signature: AlgorithmIdentifier
- 0x30, 0x06, // SEQUENCE
- 0x06, 0x01, 0x01, // OID
- 0x01, 0x01, 0x11, // ANY
- // issuer: Name
- 0x30, 0x0C, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04,
- 0x03, 0x13, 0x01, 0x5A, // CN=Z
- // thisUpdate: ChoiceOfTime
- // GeneralizedTime: 01 Jan 2001 01:02:03
- 0x18, 0x0F, 0x32, 0x30, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31,
- 0x30, 0x31, 0x30, 0x32, 0x30, 0x33, 0x5A,
-
- // nextUpdate - missed
- // revokedCertificates - missed
- // crlExtensions - missed
-
- // signatureAlgorithm: AlgorithmIdentifier
- 0x30, 0x06, // SEQUENCE
- 0x06, 0x01, 0x01, //OID
- 0x01, 0x01, 0x11, //ANY
- // signature: BIT STRING
- 0x03, 0x02, 0x00, 0x01 };
- }
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/provider/cert/CertFactoryTestData.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/provider/cert/CertFactoryTestData.java
deleted file mode 100644
index 875350c..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/provider/cert/CertFactoryTestData.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- */
-
-package org.apache.harmony.security.tests.support.provider.cert;
-
-import java.io.UnsupportedEncodingException;
-// Android-changed: Don't use Harmony's Base64 class
-// import org.apache.harmony.luni.util.Base64;
-import java.util.Base64;
-
-/**
- * Class contains the base 64 encodings of X.509 certificates,
- * CRLs, and Certification Paths.
- */
-public class CertFactoryTestData {
-
- // All the testing data was generated by using of classes
- // from org.apache.harmony.security.asn1 package and encoded
- // by org.apache.harmony.misc.Base64 class.
-
- private static String certPathPKCS7Base64 =
- "MIIJXQYJKoZIhvcNAQcCoIIJTjCCCUoCAQExADALBgkqhkiG9w" +
- "0BBwGgggkyMIIElTCCBFKgAwIBAgICAiswDAYHKoZIzjgEAwEB" +
- "ADAdMRswGQYDVQQKExJDZXJ0aWZpY2F0ZSBJc3N1ZXIwHhcNNz" +
- "AwMTEyMTM0NjQwWhcNNzAwMTI0MDMzMzIwWjAfMR0wGwYDVQQK" +
- "ExRTdWJqZWN0IE9yZ2FuaXphdGlvbjCCAbcwggEsBgcqhkjOOA" +
- "QBMIIBHwKBgQD9f1OBHXUSKVLfSpwu7OTn9hG3UjzvRADDHj+A" +
- "tlEmaUVdQCJR+1k9jVj6v8X1ujD2y5tVbNeBO4AdNG/yZmC3a5" +
- "lQpaSfn+gEexAiwk+7qdf+t8Yb+DtX58aophUPBPuD9tPFHsMC" +
- "NVQTWhaRMvZ1864rYdcq7/IiAxmd0UgBxwIVAJdgUI8VIwvMsp" +
- "K5gqLrhAvwWBz1AoGBAPfhoIXWmz3ey7yrXDa4V7l5lK+7+jrq" +
- "gvlXTAs9B4JnUVlXjrrUWU/mcQcQgYC0SRZxI+hMKBYTt88JMo" +
- "zIpuE8FnqLVHyNKOCjrh4rs6Z1kW6jfwv6ITVi8ftiegEkO8yk" +
- "8b6oUZCJqIPf4VrlnwaSi2ZegHtVJWQBTDv+z0kqA4GEAAKBgB" +
- "DIG+uTY/ABkBHadFyFnYoqaxprR5U6bZVMPmCBdnxh1dGmiah6" +
- "x2f+lmvEyPha1oNkdesDIBNId1Akkt/sQnCA6C9q038VyfmMPb" +
- "6khvtlZ9mCEiV4D72zieYhbiHzBmJsPKC8JQ/xFJwSU0e//2bl" +
- "uF+UGjbA4/WMLi3+Vf9hgQIAqoICAFWjggIUMIICEDAPBgNVHQ" +
- "8BAf8EBQMDAaqAMBIGA1UdEwEB/wQIMAYBAf8CAQUwFAYDVR0g" +
- "AQH/BAowCDAGBgRVHSAAMGcGA1UdEQEB/wRdMFuBDHJmY0A4Mj" +
- "IuTmFtZYIHZE5TTmFtZaQXMRUwEwYDVQQKEwxPcmdhbml6YXRp" +
- "b26GGmh0dHA6Ly91bmlmb3JtLlJlc291cmNlLklkhwT///8AiA" +
- "cqA6Jcg7IDMAwGA1UdHgEB/wQCMAAwDAYDVR0kAQH/BAIwADCB" +
- "mQYDVR0lAQH/BIGOMIGLBgRVHSUABggrBgEFBQcDAQYIKwYBBQ" +
- "UHAwEGCCsGAQUFBwMCBggrBgEFBQcDAwYIKwYBBQUHAwQGCCsG" +
- "AQUFBwMFBggrBgEFBQcDBgYIKwYBBQUHAwcGCCsGAQUFBwMIBg" +
- "grBgEFBQcDCQYIKwYBBQUIAgIGCisGAQQBgjcKAwMGCWCGSAGG" +
- "+EIEATANBgNVHTYBAf8EAwIBATAOBgQqTYYJAQH/BAMBAQEwZA" +
- "YDVR0SBF0wW4EMcmZjQDgyMi5OYW1lggdkTlNOYW1lpBcxFTAT" +
- "BgNVBAoTDE9yZ2FuaXphdGlvboYaaHR0cDovL3VuaWZvcm0uUm" +
- "Vzb3VyY2UuSWSHBP///wCIByoDolyDsgMwCQYDVR0fBAIwADAK" +
- "BgNVHSMEAwEBATAKBgNVHQ4EAwEBATAKBgNVHSEEAwEBATAMBg" +
- "cqhkjOOAQDAQEAAy8AMCwCFDTTeOfOqTwbBYYP3bPIKY6ctqxb" +
- "AhQq7Qv07HsN3LJQCUPoQdMTx6GjyDCCBJUwggRSoAMCAQICAg" +
- "IrMAwGByqGSM44BAMBAQAwHTEbMBkGA1UEChMSQ2VydGlmaWNh" +
- "dGUgSXNzdWVyMB4XDTcwMDExMjEzNDY0MFoXDTcwMDEyNDAzMz" +
- "MyMFowHzEdMBsGA1UEChMUU3ViamVjdCBPcmdhbml6YXRpb24w" +
- "ggG3MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11EilS30qcLu" +
- "zk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9sub" +
- "VWzXgTuAHTRv8mZgt2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+" +
- "fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/yIgMZndFI" +
- "AccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93s" +
- "u8q1w2uFe5eZSvu/o66oL5V0wLPQeCZ1FZV4661FlP5nEHEIGA" +
- "tEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7OmdZFuo3" +
- "8L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVk" +
- "AUw7/s9JKgOBhAACgYAQyBvrk2PwAZAR2nRchZ2KKmsaa0eVOm" +
- "2VTD5ggXZ8YdXRpomoesdn/pZrxMj4WtaDZHXrAyATSHdQJJLf" +
- "7EJwgOgvatN/Fcn5jD2+pIb7ZWfZghIleA+9s4nmIW4h8wZibD" +
- "ygvCUP8RScElNHv/9m5bhflBo2wOP1jC4t/lX/YYECAKqCAgBV" +
- "o4ICFDCCAhAwDwYDVR0PAQH/BAUDAwGqgDASBgNVHRMBAf8ECD" +
- "AGAQH/AgEFMBQGA1UdIAEB/wQKMAgwBgYEVR0gADBnBgNVHREB" +
- "Af8EXTBbgQxyZmNAODIyLk5hbWWCB2ROU05hbWWkFzEVMBMGA1" +
- "UEChMMT3JnYW5pemF0aW9uhhpodHRwOi8vdW5pZm9ybS5SZXNv" +
- "dXJjZS5JZIcE////AIgHKgOiXIOyAzAMBgNVHR4BAf8EAjAAMA" +
- "wGA1UdJAEB/wQCMAAwgZkGA1UdJQEB/wSBjjCBiwYEVR0lAAYI" +
- "KwYBBQUHAwEGCCsGAQUFBwMBBggrBgEFBQcDAgYIKwYBBQUHAw" +
- "MGCCsGAQUFBwMEBggrBgEFBQcDBQYIKwYBBQUHAwYGCCsGAQUF" +
- "BwMHBggrBgEFBQcDCAYIKwYBBQUHAwkGCCsGAQUFCAICBgorBg" +
- "EEAYI3CgMDBglghkgBhvhCBAEwDQYDVR02AQH/BAMCAQEwDgYE" +
- "Kk2GCQEB/wQDAQEBMGQGA1UdEgRdMFuBDHJmY0A4MjIuTmFtZY" +
- "IHZE5TTmFtZaQXMRUwEwYDVQQKEwxPcmdhbml6YXRpb26GGmh0" +
- "dHA6Ly91bmlmb3JtLlJlc291cmNlLklkhwT///8AiAcqA6Jcg7" +
- "IDMAkGA1UdHwQCMAAwCgYDVR0jBAMBAQEwCgYDVR0OBAMBAQEw" +
- "CgYDVR0hBAMBAQEwDAYHKoZIzjgEAwEBAAMvADAsAhQ003jnzq" +
- "k8GwWGD92zyCmOnLasWwIUKu0L9Ox7DdyyUAlD6EHTE8eho8gx" +
- "AA==";
-
- private static String certPathPkiPathBase64 =
- "MIIJNjCCBJcwggRToAMCAQICAgIrMAwGByqGSM44BAMBAQAwHT" +
- "EbMBkGA1UEChMSQ2VydGlmaWNhdGUgSXNzdWVyMB4XDTcwMDEx" +
- "MjEzNDY0MFoXDTcwMDEyNDAzMzMyMFowHzEdMBsGA1UEChMUU3" +
- "ViamVjdCBPcmdhbml6YXRpb24wggG4MIIBLAYHKoZIzjgEATCC" +
- "AR8CgYEA/X9TgR11EilS30qcLuzk5/YRt1I870QAwx4/gLZRJm" +
- "lFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZgt2uZUKWk" +
- "n5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1" +
- "oWkTL2dfOuK2HXKu/yIgMZndFIAccCFQCXYFCPFSMLzLKSuYKi" +
- "64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o66oL5V0" +
- "wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbh" +
- "PBZ6i1R8jSjgo64eK7OmdZFuo38L+iE1YvH7YnoBJDvMpPG+qF" +
- "GQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEAzhsi" +
- "Nfq3U9RAWhut8YDmRbHJTXMHTytGsK0iRZqg47JllyWbHwSmS8" +
- "T2k4Dk4FYxQzxgOxW/PbZ5c06P9BYPlazQTcPIwAWSlKTaoTfn" +
- "WzHnp75hbbPc8HmrSIEHVPr5hHS0DQl5Fu45b5U2KG5cx2Bb3l" +
- "k17n0y/RqFXFYTv+OBAgCqggIAVaOCAhQwggIQMA8GA1UdDwEB" +
- "/wQFAwMBqoAwEgYDVR0TAQH/BAgwBgEB/wIBBTAUBgNVHSABAf" +
- "8ECjAIMAYGBFUdIAAwZwYDVR0RAQH/BF0wW4EMcmZjQDgyMi5O" +
- "YW1lggdkTlNOYW1lpBcxFTATBgNVBAoTDE9yZ2FuaXphdGlvbo" +
- "YaaHR0cDovL3VuaWZvcm0uUmVzb3VyY2UuSWSHBP///wCIByoD" +
- "olyDsgMwDAYDVR0eAQH/BAIwADAMBgNVHSQBAf8EAjAAMIGZBg" +
- "NVHSUBAf8EgY4wgYsGBFUdJQAGCCsGAQUFBwMBBggrBgEFBQcD" +
- "AQYIKwYBBQUHAwIGCCsGAQUFBwMDBggrBgEFBQcDBAYIKwYBBQ" +
- "UHAwUGCCsGAQUFBwMGBggrBgEFBQcDBwYIKwYBBQUHAwgGCCsG" +
- "AQUFBwMJBggrBgEFBQgCAgYKKwYBBAGCNwoDAwYJYIZIAYb4Qg" +
- "QBMA0GA1UdNgEB/wQDAgEBMA4GBCpNhgkBAf8EAwEBATBkBgNV" +
- "HRIEXTBbgQxyZmNAODIyLk5hbWWCB2ROU05hbWWkFzEVMBMGA1" +
- "UEChMMT3JnYW5pemF0aW9uhhpodHRwOi8vdW5pZm9ybS5SZXNv" +
- "dXJjZS5JZIcE////AIgHKgOiXIOyAzAJBgNVHR8EAjAAMAoGA1" +
- "UdIwQDAQEBMAoGA1UdDgQDAQEBMAoGA1UdIQQDAQEBMAwGByqG" +
- "SM44BAMBAQADMAAwLQIVAIu6VjdQkOyX3jwUCvZk7i8ascXxAh" +
- "Qb4oUMkiRQ1/ThtGvgtiuQUzHBZDCCBJcwggRToAMCAQICAgIr" +
- "MAwGByqGSM44BAMBAQAwHTEbMBkGA1UEChMSQ2VydGlmaWNhdG" +
- "UgSXNzdWVyMB4XDTcwMDExMjEzNDY0MFoXDTcwMDEyNDAzMzMy" +
- "MFowHzEdMBsGA1UEChMUU3ViamVjdCBPcmdhbml6YXRpb24wgg" +
- "G4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11EilS30qcLuzk" +
- "5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVW" +
- "zXgTuAHTRv8mZgt2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fG" +
- "qKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/yIgMZndFIAc" +
- "cCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8" +
- "q1w2uFe5eZSvu/o66oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtE" +
- "kWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7OmdZFuo38L" +
- "+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAU" +
- "w7/s9JKgOBhQACgYEAzhsiNfq3U9RAWhut8YDmRbHJTXMHTytG" +
- "sK0iRZqg47JllyWbHwSmS8T2k4Dk4FYxQzxgOxW/PbZ5c06P9B" +
- "YPlazQTcPIwAWSlKTaoTfnWzHnp75hbbPc8HmrSIEHVPr5hHS0" +
- "DQl5Fu45b5U2KG5cx2Bb3lk17n0y/RqFXFYTv+OBAgCqggIAVa" +
- "OCAhQwggIQMA8GA1UdDwEB/wQFAwMBqoAwEgYDVR0TAQH/BAgw" +
- "BgEB/wIBBTAUBgNVHSABAf8ECjAIMAYGBFUdIAAwZwYDVR0RAQ" +
- "H/BF0wW4EMcmZjQDgyMi5OYW1lggdkTlNOYW1lpBcxFTATBgNV" +
- "BAoTDE9yZ2FuaXphdGlvboYaaHR0cDovL3VuaWZvcm0uUmVzb3" +
- "VyY2UuSWSHBP///wCIByoDolyDsgMwDAYDVR0eAQH/BAIwADAM" +
- "BgNVHSQBAf8EAjAAMIGZBgNVHSUBAf8EgY4wgYsGBFUdJQAGCC" +
- "sGAQUFBwMBBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMD" +
- "BggrBgEFBQcDBAYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEFBQ" +
- "cDBwYIKwYBBQUHAwgGCCsGAQUFBwMJBggrBgEFBQgCAgYKKwYB" +
- "BAGCNwoDAwYJYIZIAYb4QgQBMA0GA1UdNgEB/wQDAgEBMA4GBC" +
- "pNhgkBAf8EAwEBATBkBgNVHRIEXTBbgQxyZmNAODIyLk5hbWWC" +
- "B2ROU05hbWWkFzEVMBMGA1UEChMMT3JnYW5pemF0aW9uhhpodH" +
- "RwOi8vdW5pZm9ybS5SZXNvdXJjZS5JZIcE////AIgHKgOiXIOy" +
- "AzAJBgNVHR8EAjAAMAoGA1UdIwQDAQEBMAoGA1UdDgQDAQEBMA" +
- "oGA1UdIQQDAQEBMAwGByqGSM44BAMBAQADMAAwLQIVAIu6VjdQ" +
- "kOyX3jwUCvZk7i8ascXxAhQb4oUMkiRQ1/ThtGvgtiuQUzHBZA" +
- "==";
-
- // 2 consecutively encoded X.509 certificates
- private static String certEncodingBase64 =
- "MIIC+jCCAragAwIBAgICAiswDAYHKoZIzjgEAwEBADAdMRswGQ" +
- "YDVQQKExJDZXJ0aWZpY2F0ZSBJc3N1ZXIwIhgPMTk3MDAxMTIx" +
- "MzQ2NDBaGA8xOTcwMDEyNDAzMzMyMFowHzEdMBsGA1UEChMUU3" +
- "ViamVjdCBPcmdhbml6YXRpb24wGTAMBgcqhkjOOAQDAQEAAwkA" +
- "AQIDBAUGBwiBAgCqggIAVaOCAhQwggIQMA8GA1UdDwEB/wQFAw" +
- "MBqoAwEgYDVR0TAQH/BAgwBgEB/wIBBTAUBgNVHSABAf8ECjAI" +
- "MAYGBFUdIAAwZwYDVR0RAQH/BF0wW4EMcmZjQDgyMi5OYW1lgg" +
- "dkTlNOYW1lpBcxFTATBgNVBAoTDE9yZ2FuaXphdGlvboYaaHR0" +
- "cDovL3VuaWZvcm0uUmVzb3VyY2UuSWSHBP///wCIByoDolyDsg" +
- "MwDAYDVR0eAQH/BAIwADAMBgNVHSQBAf8EAjAAMIGZBgNVHSUB" +
- "Af8EgY4wgYsGBFUdJQAGCCsGAQUFBwMBBggrBgEFBQcDAQYIKw" +
- "YBBQUHAwIGCCsGAQUFBwMDBggrBgEFBQcDBAYIKwYBBQUHAwUG" +
- "CCsGAQUFBwMGBggrBgEFBQcDBwYIKwYBBQUHAwgGCCsGAQUFBw" +
- "MJBggrBgEFBQgCAgYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0G" +
- "A1UdNgEB/wQDAgEBMA4GBCpNhgkBAf8EAwEBATBkBgNVHRIEXT" +
- "BbgQxyZmNAODIyLk5hbWWCB2ROU05hbWWkFzEVMBMGA1UEChMM" +
- "T3JnYW5pemF0aW9uhhpodHRwOi8vdW5pZm9ybS5SZXNvdXJjZS" +
- "5JZIcE////AIgHKgOiXIOyAzAJBgNVHR8EAjAAMAoGA1UdIwQD" +
- "AQEBMAoGA1UdDgQDAQEBMAoGA1UdIQQDAQEBMAwGByqGSM44BA" +
- "MBAQADMAAwLQIUAL4QvoazNWP7jrj84/GZlhm09DsCFQCBKGKC" +
- "GbrP64VtUt4JPmLjW1VxQDCCAvowggK2oAMCAQICAgIrMAwGBy" +
- "qGSM44BAMBAQAwHTEbMBkGA1UEChMSQ2VydGlmaWNhdGUgSXNz" +
- "dWVyMCIYDzE5NzAwMTEyMTM0NjQwWhgPMTk3MDAxMjQwMzMzMj" +
- "BaMB8xHTAbBgNVBAoTFFN1YmplY3QgT3JnYW5pemF0aW9uMBkw" +
- "DAYHKoZIzjgEAwEBAAMJAAECAwQFBgcIgQIAqoICAFWjggIUMI" +
- "ICEDAPBgNVHQ8BAf8EBQMDAaqAMBIGA1UdEwEB/wQIMAYBAf8C" +
- "AQUwFAYDVR0gAQH/BAowCDAGBgRVHSAAMGcGA1UdEQEB/wRdMF" +
- "uBDHJmY0A4MjIuTmFtZYIHZE5TTmFtZaQXMRUwEwYDVQQKEwxP" +
- "cmdhbml6YXRpb26GGmh0dHA6Ly91bmlmb3JtLlJlc291cmNlLk" +
- "lkhwT///8AiAcqA6Jcg7IDMAwGA1UdHgEB/wQCMAAwDAYDVR0k" +
- "AQH/BAIwADCBmQYDVR0lAQH/BIGOMIGLBgRVHSUABggrBgEFBQ" +
- "cDAQYIKwYBBQUHAwEGCCsGAQUFBwMCBggrBgEFBQcDAwYIKwYB" +
- "BQUHAwQGCCsGAQUFBwMFBggrBgEFBQcDBgYIKwYBBQUHAwcGCC" +
- "sGAQUFBwMIBggrBgEFBQcDCQYIKwYBBQUIAgIGCisGAQQBgjcK" +
- "AwMGCWCGSAGG+EIEATANBgNVHTYBAf8EAwIBATAOBgQqTYYJAQ" +
- "H/BAMBAQEwZAYDVR0SBF0wW4EMcmZjQDgyMi5OYW1lggdkTlNO" +
- "YW1lpBcxFTATBgNVBAoTDE9yZ2FuaXphdGlvboYaaHR0cDovL3" +
- "VuaWZvcm0uUmVzb3VyY2UuSWSHBP///wCIByoDolyDsgMwCQYD" +
- "VR0fBAIwADAKBgNVHSMEAwEBATAKBgNVHQ4EAwEBATAKBgNVHS" +
- "EEAwEBATAMBgcqhkjOOAQDAQEAAzAAMC0CFAC+EL6GszVj+464" +
- "/OPxmZYZtPQ7AhUAgShighm6z+uFbVLeCT5i41tVcUA=";
-
- private static String base64certEncoding =
- "-----BEGIN CERTIFICATE-----\n" +
- "MIIC+jCCAragAwIBAgICAiswDAYHKoZIzjgEAwEBADAdMRswGQYDVQQKExJDZXJ0a" +
- "WZpY2F0ZSBJc3N1ZXIwIhgPMTk3MDAxMTIxMzQ2NDBaGA8xOTcwMDEyNDAzMzMyMF" +
- "owHzEdMBsGA1UEChMUU3ViamVjdCBPcmdhbml6YXRpb24wGTAMBgcqhkjOOAQDAQE" +
- "AAwkAAQIDBAUGBwiBAgCqggIAVaOCAhQwggIQMA8GA1UdDwEB/wQFAwMBqoAwEgYD" +
- "VR0TAQH/BAgwBgEB/wIBBTAUBgNVHSABAf8ECjAIMAYGBFUdIAAwZwYDVR0RAQH/B" +
- "F0wW4EMcmZjQDgyMi5OYW1lggdkTlNOYW1lpBcxFTATBgNVBAoTDE9yZ2FuaXphdG" +
- "lvboYaaHR0cDovL3VuaWZvcm0uUmVzb3VyY2UuSWSHBP///wCIByoDolyDsgMwDAY" +
- "DVR0eAQH/BAIwADAMBgNVHSQBAf8EAjAAMIGZBgNVHSUBAf8EgY4wgYsGBFUdJQAG" +
- "CCsGAQUFBwMBBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMDBggrBgEFBQcDB" +
- "AYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEFBQcDBwYIKwYBBQUHAwgGCCsGAQUFBw" +
- "MJBggrBgEFBQgCAgYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GA1UdNgEB/wQDAgE" +
- "BMA4GBCpNhgkBAf8EAwEBATBkBgNVHRIEXTBbgQxyZmNAODIyLk5hbWWCB2ROU05h" +
- "bWWkFzEVMBMGA1UEChMMT3JnYW5pemF0aW9uhhpodHRwOi8vdW5pZm9ybS5SZXNvd" +
- "XJjZS5JZIcE////AIgHKgOiXIOyAzAJBgNVHR8EAjAAMAoGA1UdIwQDAQEBMAoGA1" +
- "UdDgQDAQEBMAoGA1UdIQQDAQEBMAwGByqGSM44BAMBAQADMAAwLQIUAL4QvoazNWP" +
- "7jrj84/GZlhm09DsCFQCBKGKCGbrP64VtUt4JPmLjW1VxQA==\n" +
- "-----END CERTIFICATE-----\n" +
- "-----BEGIN CERTIFICATE-----\n" +
- "MIIC+jCCAragAwIBAgICAiswDAYHKoZIzjgEAwEBADAdMRswGQYDVQQKExJDZXJ0a" +
- "WZpY2F0ZSBJc3N1ZXIwIhgPMTk3MDAxMTIxMzQ2NDBaGA8xOTcwMDEyNDAzMzMyMF" +
- "owHzEdMBsGA1UEChMUU3ViamVjdCBPcmdhbml6YXRpb24wGTAMBgcqhkjOOAQDAQE" +
- "AAwkAAQIDBAUGBwiBAgCqggIAVaOCAhQwggIQMA8GA1UdDwEB/wQFAwMBqoAwEgYD" +
- "VR0TAQH/BAgwBgEB/wIBBTAUBgNVHSABAf8ECjAIMAYGBFUdIAAwZwYDVR0RAQH/B" +
- "F0wW4EMcmZjQDgyMi5OYW1lggdkTlNOYW1lpBcxFTATBgNVBAoTDE9yZ2FuaXphdG" +
- "lvboYaaHR0cDovL3VuaWZvcm0uUmVzb3VyY2UuSWSHBP///wCIByoDolyDsgMwDAY" +
- "DVR0eAQH/BAIwADAMBgNVHSQBAf8EAjAAMIGZBgNVHSUBAf8EgY4wgYsGBFUdJQAG" +
- "CCsGAQUFBwMBBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMDBggrBgEFBQcDB" +
- "AYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEFBQcDBwYIKwYBBQUHAwgGCCsGAQUFBw" +
- "MJBggrBgEFBQgCAgYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GA1UdNgEB/wQDAgE" +
- "BMA4GBCpNhgkBAf8EAwEBATBkBgNVHRIEXTBbgQxyZmNAODIyLk5hbWWCB2ROU05h" +
- "bWWkFzEVMBMGA1UEChMMT3JnYW5pemF0aW9uhhpodHRwOi8vdW5pZm9ybS5SZXNvd" +
- "XJjZS5JZIcE////AIgHKgOiXIOyAzAJBgNVHR8EAjAAMAoGA1UdIwQDAQEBMAoGA1" +
- "UdDgQDAQEBMAoGA1UdIQQDAQEBMAwGByqGSM44BAMBAQADMAAwLQIUAL4QvoazNWP" +
- "7jrj84/GZlhm09DsCFQCBKGKCGbrP64VtUt4JPmLjW1VxQA==\n" +
- "-----END CERTIFICATE-----\n";
-
- private static String crlEncodingBase64 =
- "MIIBNDCB8gIBATAMBgcqhkjOOAQDAQEAMBUxEzARBgNVBAoTCk" +
- "NSTCBJc3N1ZXIXDTA1MDcxMzA5NDkzMFoXDTA1MDcxMzA5NTEx" +
- "MFowgZgwEwICAisXDTA1MDcxMzA5NDkzMVowbAICAjcXDTA1MD" +
- "cxMzA5NDkzMVowVzAKBgNVHRUEAwoBATAcBgNVHRgEFRgTMjAw" +
- "NTA3MTMwOTQ5MzAuNTYyWjArBgNVHR0BAf8EITAfpB0xGzAZBg" +
- "NVBAoTEkNlcnRpZmljYXRlIElzc3VlcjATAgIDCRcNMDUwNzEz" +
- "MDk0OTMxWqAPMA0wCwYDVR0UBAQCAhFcMAwGByqGSM44BAMBAQ" +
- "ADLwAwLAIUYp/1MGXvQ1a/wF+WvmRGnQHJ+nQCFBJ4JFNfcCN7" +
- "wNUpSOnUYHEC8uInMIIBNDCB8gIBATAMBgcqhkjOOAQDAQEAMB" +
- "UxEzARBgNVBAoTCkNSTCBJc3N1ZXIXDTA1MDcxMzA5NDkzMFoX" +
- "DTA1MDcxMzA5NTExMFowgZgwEwICAisXDTA1MDcxMzA5NDkzMV" +
- "owbAICAjcXDTA1MDcxMzA5NDkzMVowVzAKBgNVHRUEAwoBATAc" +
- "BgNVHRgEFRgTMjAwNTA3MTMwOTQ5MzAuNTYyWjArBgNVHR0BAf" +
- "8EITAfpB0xGzAZBgNVBAoTEkNlcnRpZmljYXRlIElzc3VlcjAT" +
- "AgIDCRcNMDUwNzEzMDk0OTMxWqAPMA0wCwYDVR0UBAQCAhFcMA" +
- "wGByqGSM44BAMBAQADLwAwLAIUYp/1MGXvQ1a/wF+WvmRGnQHJ" +
- "+nQCFBJ4JFNfcCN7wNUpSOnUYHEC8uIn";
-
- private static String crlEncodingPEM =
- "-----BEGIN X509 CRL-----\n" +
- "MIIBNDCB8gIBATAMBgcqhkjOOAQDAQEAMBUxEzARBgNVBAoTCk" +
- "NSTCBJc3N1ZXIXDTA1MDcxMzA5NDkzMFoXDTA1MDcxMzA5NTEx" +
- "MFowgZgwEwICAisXDTA1MDcxMzA5NDkzMVowbAICAjcXDTA1MD" +
- "cxMzA5NDkzMVowVzAKBgNVHRUEAwoBATAcBgNVHRgEFRgTMjAw" +
- "NTA3MTMwOTQ5MzAuNTYyWjArBgNVHR0BAf8EITAfpB0xGzAZBg" +
- "NVBAoTEkNlcnRpZmljYXRlIElzc3VlcjATAgIDCRcNMDUwNzEz" +
- "MDk0OTMxWqAPMA0wCwYDVR0UBAQCAhFcMAwGByqGSM44BAMBAQ" +
- "ADLwAwLAIUYp/1MGXvQ1a/wF+WvmRGnQHJ+nQCFBJ4JFNfcCN7" +
- "wNUpSOnUYHEC8uIm\n" +
- "-----END X509 CRL-----\n" +
- "-----BEGIN X509 CRL-----\n" +
- "MIIBNDCB8gIBATAMBgcqhkjOOAQDAQEAMB" +
- "UxEzARBgNVBAoTCkNSTCBJc3N1ZXIXDTA1MDcxMzA5NDkzMFoX" +
- "DTA1MDcxMzA5NTExMFowgZgwEwICAisXDTA1MDcxMzA5NDkzMV" +
- "owbAICAjcXDTA1MDcxMzA5NDkzMVowVzAKBgNVHRUEAwoBATAc" +
- "BgNVHRgEFRgTMjAwNTA3MTMwOTQ5MzAuNTYyWjArBgNVHR0BAf" +
- "8EITAfpB0xGzAZBgNVBAoTEkNlcnRpZmljYXRlIElzc3VlcjAT" +
- "AgIDCRcNMDUwNzEzMDk0OTMxWqAPMA0wCwYDVR0UBAQCAhFcMA" +
- "wGByqGSM44BAMBAQADLwAwLAIUYp/1MGXvQ1a/wF+WvmRGnQHJ" +
- "+nQCFBJ4JFNfcCN7wNUpSOnUYHEC8uIo\n" +
- "-----END X509 CRL-----\n";
-
-
- public static byte[] getCertPathPKCS7Encoding() throws UnsupportedEncodingException {
- // Android-changed: Don't use Harmony's Base64 class
- // return Base64.decode(certPathPKCS7Base64.getBytes("UTF-8"));
- return Base64.getDecoder().decode(certPathPKCS7Base64.getBytes("UTF-8"));
- }
-
- public static byte[] getCertPathPkiPathEncoding() throws UnsupportedEncodingException {
- // Android-changed: Don't use Harmony's Base64 class
- // return Base64.decode(certPathPkiPathBase64.getBytes("UTF-8"));
- return Base64.getDecoder().decode(certPathPkiPathBase64.getBytes("UTF-8"));
- }
-
- public static byte[] getCertEncoding() throws UnsupportedEncodingException {
- // Android-changed: Don't use Harmony's Base64 class
- // return Base64.decode(certEncodingBase64.getBytes("UTF-8"));
- return Base64.getDecoder().decode(certEncodingBase64.getBytes("UTF-8"));
- }
-
- public static byte[] getBase64CertEncoding() throws UnsupportedEncodingException {
- return base64certEncoding.getBytes("UTF-8");
- }
-
- public static byte[] getBase64CRLEncoding() throws UnsupportedEncodingException {
- return crlEncodingPEM.getBytes("UTF-8");
- }
-
- public static byte[] getCRLEncoding() throws UnsupportedEncodingException {
- // Android-changed: Don't use Harmony's Base64 class
- // return Base64.decode(crlEncodingBase64.getBytes("UTF-8"));
- return Base64.getDecoder().decode(crlEncodingBase64.getBytes("UTF-8"));
- }
-}
-
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/spec/MyEncodedKeySpec.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/spec/MyEncodedKeySpec.java
deleted file mode 100644
index 12f37c8..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/spec/MyEncodedKeySpec.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vladimir N. Molotkov
- */
-
-package org.apache.harmony.security.tests.support.spec;
-
-import java.security.spec.EncodedKeySpec;
-
-/**
- * Support class for abstract base class testing
- */
-
-public class MyEncodedKeySpec extends EncodedKeySpec {
-
- /**
- * Constructor
- *
- * @param encodedKey
- */
- public MyEncodedKeySpec(byte[] encodedKey) {
- super(encodedKey);
- }
-
- /**
- * Returns format - "My"
- *
- * @see java.security.spec.EncodedKeySpec#getFormat()
- */
- public String getFormat() {
- return "My";
- }
-
-}
diff --git a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/tmpCallbackHandler.java b/security/src/test/support/common/java/org/apache/harmony/security/tests/support/tmpCallbackHandler.java
deleted file mode 100644
index 8191536..0000000
--- a/security/src/test/support/common/java/org/apache/harmony/security/tests/support/tmpCallbackHandler.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.security.tests.support;
-
-import java.io.IOException;
-
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
-
-/**
- * Additional class for creating CallBackHandler object
- */
-
-public class tmpCallbackHandler implements CallbackHandler {
- public void handle(Callback[] callback) throws IOException,
- UnsupportedCallbackException {
- if (callback == null) {
- throw new UnsupportedCallbackException(null, "callback is null");
- }
- if (callback.length == 0) {
- throw new UnsupportedCallbackException(null, "callback is empty");
- }
- }
-} \ No newline at end of file
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/CertPathTrustManagerParametersTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/CertPathTrustManagerParametersTest.java
deleted file mode 100644
index 3932a3e..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/CertPathTrustManagerParametersTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.security.cert.CertPathParameters;
-import javax.net.ssl.CertPathTrustManagerParameters;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertPathTrustManagerParameters</code> class constructors
- * and methods.
- */
-public class CertPathTrustManagerParametersTest extends TestCase {
-
- public void testCertPathTrustManagerParameters() {
- CertPathParameters parameters = new MyCertPathParameters();
- CertPathTrustManagerParameters p = new CertPathTrustManagerParameters(
- parameters);
- if (!(p.getParameters() instanceof MyCertPathParameters)) {
- fail("incorrect parameters");
- }
- }
-}
-
-class MyCertPathParameters implements CertPathParameters {
- @Override
- public Object clone() {
- return new MyCertPathParameters();
- }
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/HandshakeCompletedEventTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/HandshakeCompletedEventTest.java
deleted file mode 100644
index 229194d..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/HandshakeCompletedEventTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.security.cert.Certificate;
-
-import javax.net.ssl.HandshakeCompletedEvent;
-import javax.net.ssl.SSLPeerUnverifiedException;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.SSLSocketFactory;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>HandshakeCompletedEvent</code> class constructors and methods.
- */
-public class HandshakeCompletedEventTest extends TestCase {
-
- int port;
-
- ServerSocket ss;
-
- SSLSocket soc;
-
- boolean noFreePort = false;
- boolean noSocket = false;
-
- /*
- * @see TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- SSLSocketFactory sf = (SSLSocketFactory) SSLSocketFactory.getDefault();
- try {
- ss = new ServerSocket(0);
- port = ss.getLocalPort();
- } catch (Exception e) {
- e.printStackTrace();
- noFreePort = true;
- return;
- }
- try {
- soc = (SSLSocket) sf.createSocket("localhost", port);
- } catch (IOException e) {
- noSocket = true;
- }
-
- }
-
- /*
- * @see TestCase#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- if (ss != null) {
- ss.close();
- }
- if (soc != null) {
- soc.close();
- }
- }
-
- public final void testGetCipherSuite() {
- if (noFreePort || noSocket) {
- return;
- }
- SSLSession ses = new MySSLSession();
-
- HandshakeCompletedEvent event = new HandshakeCompletedEvent(soc, ses);
-
- assertEquals(event.getCipherSuite(), ses.getCipherSuite());
- }
-
- public final void testGetLocalCertificates() {
- if (noFreePort || noSocket) {
- return;
- }
- SSLSession ses = new MySSLSession();
- HandshakeCompletedEvent event = new HandshakeCompletedEvent(soc, ses);
-
- Certificate[] certs = event.getLocalCertificates();
- Certificate[] ses_certs = ses.getLocalCertificates();
- if (certs == null && ses_certs == null) {
- return;
- }
- if (certs == null || ses_certs == null) {
- fail("incorrect LocalCertificates");
- }
- for (int i = 0; i < certs.length; i++) {
- if (certs[i] != ses_certs[i]) {
- fail("incorrect LocalCertificates");
- }
- }
- }
-
- public final void testGetPeerCertificates() {
- if (noFreePort || noSocket) {
- return;
- }
- SSLSession ses = new MySSLSession();
- HandshakeCompletedEvent event = new HandshakeCompletedEvent(soc, ses);
- try {
- event.getPeerCertificates();
- fail("No excpected SSLPeerUnverifiedException");
- } catch (SSLPeerUnverifiedException e) {
- }
- }
-
- public final void testGetPeerCertificateChain() {
- if (noFreePort || noSocket) {
- return;
- }
- SSLSession ses = new MySSLSession();
- HandshakeCompletedEvent event = new HandshakeCompletedEvent(soc, ses);
- try {
- event.getPeerCertificateChain();
- fail("No excpected SSLPeerUnverifiedException");
- } catch (SSLPeerUnverifiedException e) {
- }
- }
-
- public final void testHandshakeCompletedEvent() {
- if (noFreePort || noSocket) {
- return;
- }
- SSLSession ses = new MySSLSession();
- HandshakeCompletedEvent event = new HandshakeCompletedEvent(soc, ses);
-
- assertEquals(ses, event.getSession());
- assertEquals(soc, event.getSocket());
- }
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/HttpsURLConnectionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/HttpsURLConnectionTest.java
deleted file mode 100644
index 3a0f153..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/HttpsURLConnectionTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.io.IOException;
-import java.net.URL;
-import java.security.cert.Certificate;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLPeerUnverifiedException;
-import javax.net.ssl.SSLSocketFactory;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>HttpsURLConnection</code> class constructors and methods.
- */
-public class HttpsURLConnectionTest extends TestCase {
-
- public final void testGetPeerPrincipal() throws Exception {
- HttpsURLConnection con = new MyHttpsURLConnection(new URL(
- "http://foo.com"));
- try {
- con.getPeerPrincipal();
- fail("No expected SSLPeerUnverifiedException");
- } catch (SSLPeerUnverifiedException e) {
- }
- }
-
- public final void testGetLocalPrincipal() {
- HttpsURLConnection con = new MyHttpsURLConnection(null);
- if (con.getLocalPrincipal() != null) {
- fail("Non null result");
- }
- }
-
- public final void testSetDefaultHostnameVerifier() {
- try {
- HttpsURLConnection.setDefaultHostnameVerifier(null);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- public final void testSetHostnameVerifier() {
- HttpsURLConnection con = new MyHttpsURLConnection(null);
- try {
- con.setHostnameVerifier(null);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- public final void testGetDefaultSSLSocketFactory() {
- SSLSocketFactory sf = HttpsURLConnection.getDefaultSSLSocketFactory();
- if (!sf.equals(SSLSocketFactory.getDefault())) {
- fail("incorrect DefaultSSLSocketFactory");
- }
- }
-
- public final void testGetSSLSocketFactory() {
- HttpsURLConnection con = new MyHttpsURLConnection(null);
- SSLSocketFactory sf = con.getSSLSocketFactory();
- if (!sf.equals(SSLSocketFactory.getDefault())) {
- fail("incorrect DefaultSSLSocketFactory");
- }
- }
-
- public final void testSetDefaultSSLSocketFactory() {
- try {
- HttpsURLConnection.setDefaultSSLSocketFactory(null);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- public final void testSetSSLSocketFactory() {
- HttpsURLConnection con = new MyHttpsURLConnection(null);
- try {
- con.setSSLSocketFactory(null);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-}
-
-class MyHttpsURLConnection extends HttpsURLConnection {
-
- public MyHttpsURLConnection(URL url) {
- super(url);
- }
-
- /*
- * @see javax.net.ssl.HttpsURLConnection#getCipherSuite()
- */
- @Override
- public String getCipherSuite() {
- return null;
- }
-
- /*
- * @see javax.net.ssl.HttpsURLConnection#getLocalCertificates()
- */
- @Override
- public Certificate[] getLocalCertificates() {
- return null;
- }
-
- /*
- * @see javax.net.ssl.HttpsURLConnection#getServerCertificates()
- */
- @Override
- public Certificate[] getServerCertificates()
- throws SSLPeerUnverifiedException {
- return null;
- }
-
- /*
- * @see java.net.HttpURLConnection#disconnect()
- */
- @Override
- public void disconnect() {
- }
-
- /*
- * @see java.net.HttpURLConnection#usingProxy()
- */
- @Override
- public boolean usingProxy() {
- return false;
- }
-
- /*
- * @see java.net.URLConnection#connect()
- */
- @Override
- public void connect() throws IOException {
- }
-
-}
-
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/KeyManagerFactory1Test.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/KeyManagerFactory1Test.java
deleted file mode 100644
index e06e860..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/KeyManagerFactory1Test.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.UnrecoverableKeyException;
-
-import javax.net.ssl.ManagerFactoryParameters;
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.KeyManagerFactorySpi;
-
-import org.apache.harmony.xnet.tests.support.SpiEngUtils;
-import org.apache.harmony.xnet.tests.support.MyKeyManagerFactorySpi;
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyManagerFactory</code> class constructors and methods.
- */
-
-public class KeyManagerFactory1Test extends TestCase {
-
- private static final String srvKeyManagerFactory = "KeyManagerFactory";
-
- private static String defaultAlgorithm = null;
-
- private static String defaultProviderName = null;
-
- private static Provider defaultProvider = null;
-
- private static boolean DEFSupported = false;
-
- private static final String NotSupportedMsg = "There is no suitable provider for KeyManagerFactory";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static String[] validValues = new String[3];
-
- static {
- defaultAlgorithm = Security
- .getProperty("ssl.KeyManagerFactory.algorithm");
- if (defaultAlgorithm != null) {
- defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm,
- srvKeyManagerFactory);
- DEFSupported = (defaultProvider != null);
- defaultProviderName = (DEFSupported ? defaultProvider.getName()
- : null);
- validValues[0] = defaultAlgorithm;
- validValues[1] = defaultAlgorithm.toUpperCase();
- validValues[2] = defaultAlgorithm.toLowerCase();
- }
- }
-
- protected KeyManagerFactory[] createKMFac() {
- if (!DEFSupported) {
- fail(defaultAlgorithm + " algorithm is not supported");
- return null;
- }
- KeyManagerFactory[] kMF = new KeyManagerFactory[3];
- try {
- kMF[0] = KeyManagerFactory.getInstance(defaultAlgorithm);
- kMF[1] = KeyManagerFactory.getInstance(defaultAlgorithm,
- defaultProvider);
- kMF[2] = KeyManagerFactory.getInstance(defaultAlgorithm,
- defaultProviderName);
- return kMF;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- /**
- * Test for <code>getDefaultAlgorithm()</code> method
- * Assertion: returns value which is specifoed in security property
- */
- public void testGetDefaultAlgorithm() {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- String def = KeyManagerFactory.getDefaultAlgorithm();
- if (defaultAlgorithm == null) {
- assertNull("DefaultAlgorithm must be null", def);
- } else {
- assertEquals("Invalid default algorithm", def, defaultAlgorithm);
- }
- String defA = "Proba.keymanagerfactory.defaul.type";
- Security.setProperty("ssl.KeyManagerFactory.algorithm", defA);
- assertEquals("Incorrect defaultAlgorithm",
- KeyManagerFactory.getDefaultAlgorithm(), defA);
- if (def == null) {
- def = "";
- }
- Security.setProperty("ssl.KeyManagerFactory.algorithm", def);
- assertEquals("Incorrect defaultAlgorithm",
- KeyManagerFactory.getDefaultAlgorithm(), def);
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions:
- * returns security property "ssl.KeyManagerFactory.algorithm";
- * returns instance of KeyManagerFactory
- */
- public void testKeyManagerFactory01() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- KeyManagerFactory keyMF;
- for (int i = 0; i < validValues.length; i++) {
- keyMF = KeyManagerFactory.getInstance(validValues[i]);
- assertTrue("Not KeyManagerFactory object",
- keyMF instanceof KeyManagerFactory);
- assertEquals("Invalid algorithm", keyMF.getAlgorithm(),
- validValues[i]);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- */
- public void testKeyManagerFactory02() {
- try {
- KeyManagerFactory.getInstance(null);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyManagerFactory.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException was not thrown as expected for algorithm: "
- .concat(invalidValues[i]));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion: throws IllegalArgumentException when provider is null or empty
- */
- public void testKeyManagerFactory03() throws NoSuchProviderException,
- NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- String provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyManagerFactory.getInstance(validValues[i], provider);
- fail("Expected IllegalArgumentException was not thrown for null provider");
- } catch (IllegalArgumentException e) {
- }
- try {
- KeyManagerFactory.getInstance(validValues[i], "");
- fail("Expected IllegalArgumentException was not thrown for empty provider");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- */
- public void testKeyManagerFactory04() throws NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- try {
- KeyManagerFactory.getInstance(null, defaultProviderName);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyManagerFactory.getInstance(invalidValues[i],
- defaultProviderName);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion: throws NoSuchProviderException when provider has
- * invalid value
- */
- public void testKeyManagerFactory05() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- KeyManagerFactory.getInstance(validValues[i],
- invalidValues[j]);
- fail("NuSuchProviderException must be thrown (algorithm: "
- + validValues[i] + " provider: " + invalidValues[j]
- + ")");
- } catch (NoSuchProviderException e) {
- }
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method Assertion: returns instance of KeyManagerFactory
- */
- public void testKeyManagerFactory06() throws NoSuchProviderException,
- NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- KeyManagerFactory kMF;
- for (int i = 0; i < validValues.length; i++) {
- kMF = KeyManagerFactory.getInstance(validValues[i],
- defaultProviderName);
- assertTrue("Not KeyManagerFactory object",
- kMF instanceof KeyManagerFactory);
- assertEquals("Incorrect algorithm", kMF.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", kMF.getProvider().getName(),
- defaultProviderName);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion: throws IllegalArgumentException when provider is null
- */
- public void testKeyManagerFactory07() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Provider provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyManagerFactory.getInstance(validValues[i], provider);
- fail("Expected IllegalArgumentException was not thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- */
- public void testKeyManagerFactory08() {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- try {
- KeyManagerFactory.getInstance(null, defaultProvider);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyManagerFactory
- .getInstance(invalidValues[i], defaultProvider);
- fail("Expected NuSuchAlgorithmException was not thrown");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion: returns instance of KeyManagerFactory
- */
- public void testKeyManagerFactory09() throws NoSuchAlgorithmException,
- IllegalArgumentException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- KeyManagerFactory kMF;
- for (int i = 0; i < validValues.length; i++) {
- kMF = KeyManagerFactory
- .getInstance(validValues[i], defaultProvider);
- assertTrue(kMF instanceof KeyManagerFactory);
- assertEquals(kMF.getAlgorithm(), validValues[i]);
- assertEquals(kMF.getProvider(), defaultProvider);
- }
- }
-
- /**
- * Test for <code>KeyManagerFactory</code> constructor
- * Assertion: returns KeyManagerFactory object
- */
- public void testKeyManagerFactory10() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- KeyManagerFactorySpi spi = new MyKeyManagerFactorySpi();
- KeyManagerFactory keyMF = new myKeyManagerFactory(spi, defaultProvider,
- defaultAlgorithm);
- assertTrue("Not CertStore object", keyMF instanceof KeyManagerFactory);
- assertEquals("Incorrect algorithm", keyMF.getAlgorithm(),
- defaultAlgorithm);
- assertEquals("Incorrect provider", keyMF.getProvider(), defaultProvider);
- try {
- keyMF.init(null, new char[1]);
- fail("UnrecoverableKeyException must be thrown");
- } catch (UnrecoverableKeyException e) {
- // Expected
- }
-
- keyMF = new myKeyManagerFactory(null, null, null);
- assertTrue("Not CertStore object", keyMF instanceof KeyManagerFactory);
- assertNull("Aalgorithm must be null", keyMF.getAlgorithm());
- assertNull("Provider must be null", keyMF.getProvider());
- try {
- keyMF.getKeyManagers();
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test for <code>init(KeyStore keyStore, char[] password)</code> and
- * <code>getKeyManagers()</code>
- * Assertion: returns not empty KeyManager array
- */
- public void testKeyManagerFactory11() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- KeyManagerFactory[] keyMF = createKMFac();
- assertNotNull("KeyManagerFactory object were not created", keyMF);
- KeyStore ksNull = null;
- KeyManager[] km;
- for (int i = 0; i < keyMF.length; i++) {
- keyMF[i].init(ksNull, new char[10]);
- km = keyMF[i].getKeyManagers();
- assertNotNull("Result should not be null", km);
- assertTrue("Length of result KeyManager array should not be 0",
- (km.length > 0));
- }
- KeyStore ks;
- ks = KeyStore.getInstance(KeyStore.getDefaultType());
- ks.load(null, null);
-
- for (int i = 0; i < keyMF.length; i++) {
- try {
- keyMF[i].init(ks, new char[10]);
- } catch (KeyStoreException e) {
- }
- km = keyMF[i].getKeyManagers();
- assertNotNull("Result has not be null", km);
- assertTrue("Length of result KeyManager array should not be 0",
- (km.length > 0));
- }
- }
-
- /**
- * Test for <code>init(ManagerFactoryParameters params)</code>
- * Assertion:
- * throws InvalidAlgorithmParameterException when params is null
- */
- public void testKeyManagerFactory12() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- ManagerFactoryParameters par = null;
- KeyManagerFactory[] keyMF = createKMFac();
- assertNotNull("KeyManagerFactory object were not created", keyMF);
- for (int i = 0; i < keyMF.length; i++) {
- try {
- keyMF[i].init(par);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
- }
-
-}
-
-/**
- * Additional class for KeyManagerFactory constructor verification
- */
-class myKeyManagerFactory extends KeyManagerFactory {
- public myKeyManagerFactory(KeyManagerFactorySpi spi, Provider prov,
- String alg) {
- super(spi, prov, alg);
- }
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/KeyManagerFactory2Test.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/KeyManagerFactory2Test.java
deleted file mode 100644
index 58fae21..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/KeyManagerFactory2Test.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.UnrecoverableKeyException;
-
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.ManagerFactoryParameters;
-
-import org.apache.harmony.xnet.tests.support.SpiEngUtils;
-import org.apache.harmony.xnet.tests.support.MyKeyManagerFactorySpi;
-import junit.framework.TestCase;
-
-/**
- * Tests for KeyManagerFactory class constructors and methods
- */
-
-public class KeyManagerFactory2Test extends TestCase {
- private static final String srvKeyManagerFactory = "KeyManagerFactory";
-
- private static final String defaultAlg = "KeyMF";
-
- private static final String KeyManagerFactoryProviderClass = "org.apache.harmony.xnet.tests.support.MyKeyManagerFactorySpi";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "Keymf";
- validValues[3] = "kEYMF";
- }
-
- Provider mProv;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyKMFProvider",
- "Provider for testing", srvKeyManagerFactory.concat(".")
- .concat(defaultAlg), KeyManagerFactoryProviderClass);
- Security.insertProviderAt(mProv, 2);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- private void checkResult(KeyManagerFactory keyMF)
- throws Exception {
- KeyStore kStore = null;
- ManagerFactoryParameters mfp = null;
-
- char[] pass = { 'a', 'b', 'c' };
-
- try {
- keyMF.init(kStore, null);
- fail("KeyStoreException must be thrown");
- } catch (KeyStoreException e) {
- }
- try {
- keyMF.init(kStore, pass);
- fail("UnrecoverableKeyException must be thrown");
- } catch (UnrecoverableKeyException e) {
- }
- try {
- keyMF.init(mfp);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- assertNull("getKeyManagers() should return null object", keyMF
- .getKeyManagers());
-
- try {
- kStore = KeyStore.getInstance(KeyStore.getDefaultType());
- kStore.load(null, null);
- } catch (KeyStoreException e) {
- fail("default keystore is not supported");
- return;
- }
- keyMF.init(kStore, pass);
-
- mfp = (ManagerFactoryParameters) new MyKeyManagerFactorySpi.Parameters(kStore, null);
- try {
- keyMF.init(mfp);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- mfp = (ManagerFactoryParameters) new MyKeyManagerFactorySpi.Parameters(kStore, pass);
- keyMF.init(mfp);
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- * returns KeyManagerFactory object
- */
- public void testGetInstance01() throws Exception {
- try {
- KeyManagerFactory.getInstance(null);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyManagerFactory.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- KeyManagerFactory keyMF;
- for (int i = 0; i < validValues.length; i++) {
- keyMF = KeyManagerFactory.getInstance(validValues[i]);
- assertTrue("Not instanceof KeyManagerFactory object",
- keyMF instanceof KeyManagerFactory);
- assertEquals("Incorrect algorithm", keyMF.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyMF.getProvider(), mProv);
- checkResult(keyMF);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- * throws IllegalArgumentException when provider is null or empty;
- * throws NoSuchProviderException when provider is available;
- * returns KeyManagerFactory object
- */
- public void testGetInstance02() throws Exception {
- try {
- KeyManagerFactory.getInstance(null, mProv.getName());
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyManagerFactory
- .getInstance(invalidValues[i], mProv.getName());
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyManagerFactory.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- try {
- KeyManagerFactory.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- KeyManagerFactory.getInstance(validValues[i],
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- KeyManagerFactory keyMF;
- for (int i = 0; i < validValues.length; i++) {
- keyMF = KeyManagerFactory.getInstance(validValues[i], mProv
- .getName());
- assertTrue("Not instanceof KeyManagerFactory object",
- keyMF instanceof KeyManagerFactory);
- assertEquals("Incorrect algorithm", keyMF.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyMF.getProvider().getName(),
- mProv.getName());
- checkResult(keyMF);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- * throws IllegalArgumentException when provider is null;
- * returns KeyManagerFactory object
- */
- public void testGetInstance03() throws Exception {
- try {
- KeyManagerFactory.getInstance(null, mProv);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- KeyManagerFactory.getInstance(invalidValues[i], mProv);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- KeyManagerFactory.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- KeyManagerFactory keyMF;
- for (int i = 0; i < validValues.length; i++) {
- keyMF = KeyManagerFactory.getInstance(validValues[i], mProv);
- assertTrue("Not instanceof KeyManagerFactory object",
- keyMF instanceof KeyManagerFactory);
- assertEquals("Incorrect algorithm", keyMF.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", keyMF.getProvider(), mProv);
- checkResult(keyMF);
- }
- }
-} \ No newline at end of file
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/KeyStoreBuilderParametersTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/KeyStoreBuilderParametersTest.java
deleted file mode 100644
index 0a6c307..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/KeyStoreBuilderParametersTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.KeyStore.Builder;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.net.ssl.KeyStoreBuilderParameters;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyStoreBuilderParameters</code> class constructors and
- * methods.
- */
-public class KeyStoreBuilderParametersTest extends TestCase {
-
- class EmptyBuilder extends KeyStore.Builder {
- @Override
- public KeyStore getKeyStore() throws KeyStoreException {
- return null;
- }
-
- @Override
- public KeyStore.ProtectionParameter getProtectionParameter(String alias)
- throws KeyStoreException {
- return null;
- }
- }
-
- /*
- * Class under test for void KeyStoreBuilderParameters(KeyStore.Builder)
- */
- public final void testKeyStoreBuilderParametersBuilder() {
- try {
- new KeyStoreBuilderParameters((KeyStore.Builder) null);
- } catch (NullPointerException e) {
- // javadoc says this should throw NPE, but it doesn't
- fail("no NPE expected");
- }
- }
-
- /*
- * Class under test for void KeyStoreBuilderParameters(List)
- */
- public final void testKeyStoreBuilderParametersList() {
- try {
- new KeyStoreBuilderParameters((List<?>) null);
- fail("expected a NPE");
- } catch (NullPointerException e) {
- }
-
- try {
- new KeyStoreBuilderParameters(new ArrayList<Builder>());
- fail("expected a IAE");
- } catch (IllegalArgumentException e) {
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public final void testGetParameters() {
- List<Builder> ksbuilders;
- KeyStore.Builder builder = new EmptyBuilder();
- List<Object> result;
- KeyStoreBuilderParameters param = new KeyStoreBuilderParameters(builder);
- result = param.getParameters();
- try {
- result.add(new EmptyBuilder());
- fail("The list is modifiable");
- } catch (UnsupportedOperationException e) {
- }
- assertEquals("incorrect size", 1, result.size());
- assertTrue("incorrect list", result.contains(builder));
-
- ksbuilders = new ArrayList<Builder>();
- ksbuilders.add(builder);
- ksbuilders.add(new EmptyBuilder());
- param = new KeyStoreBuilderParameters(ksbuilders);
- result = param.getParameters();
- try {
- result.add(new Object());
- fail("The list is modifiable");
- } catch (UnsupportedOperationException e) {
- }
- assertEquals("incorrect size", 2, result.size());
- assertTrue("incorrect list", result.containsAll(ksbuilders));
- }
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext1Test.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext1Test.java
deleted file mode 100644
index 9297542..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext1Test.java
+++ /dev/null
@@ -1,505 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.Security;
-import java.security.UnrecoverableKeyException;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLContextSpi;
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLParameters;
-import javax.net.ssl.SSLPermission;
-import javax.net.ssl.SSLSessionContext;
-import javax.net.ssl.SSLServerSocketFactory;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-
-import org.apache.harmony.security.fortress.Services;
-import org.apache.harmony.xnet.tests.support.SpiEngUtils;
-import org.apache.harmony.xnet.tests.support.MySSLContextSpi;
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>SSLContext</code> class constructors and methods.
- */
-
-public class SSLContext1Test extends TestCase {
-
- private static String srvSSLContext = "SSLContext";
-
- public static String defaultProtocol = "TLS";
-
- private static final String NotSupportMsg = "Default protocol is not supported";
-
- private static String defaultProviderName = null;
-
- private static Provider defaultProvider = null;
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static boolean DEFSupported = false;
-
- private static final String NotSupportedMsg = "There is no suitable provider for SSLContext";
-
- private static String[] validValues = new String[3];
-
- static {
- defaultProvider = SpiEngUtils.isSupport(defaultProtocol, srvSSLContext);
- DEFSupported = (defaultProvider != null);
- if (DEFSupported) {
- defaultProviderName = (DEFSupported ? defaultProvider.getName()
- : null);
- validValues[0] = defaultProtocol;
- validValues[1] = defaultProtocol.toUpperCase();
- validValues[2] = defaultProtocol.toLowerCase();
- } else {
- defaultProtocol = null;
- }
-
- SSLParameters staticSupportSSLParameter = new SSLParameters(new String[] {
- "TLS_RSA_WITH_RC4_128_MD5", "TLS_RSA_WITH_RC4_128_SHA" },
- new String[] { "TLSv1", "SSLv3" });
-
- SSLParameters staticDefaultSSLParameter = new SSLParameters(new String[] {
- "TLS_RSA_WITH_RC4_128_MD5", "TLS_RSA_WITH_RC4_128_SHA" },
- new String[] { "TLSv1", "SSLv3" });
- }
-
- protected SSLContext[] createSSLCon() {
- if (!DEFSupported) {
- fail(defaultProtocol + " protocol is not supported");
- return null;
- }
- SSLContext[] sslC = new SSLContext[3];
- try {
- sslC[0] = SSLContext.getInstance(defaultProtocol);
- sslC[1] = SSLContext.getInstance(defaultProtocol, defaultProvider);
- sslC[2] = SSLContext.getInstance(defaultProtocol,
- defaultProviderName);
- return sslC;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- /**
- * Test for <code>getInstance(String protocol)</code> method Assertion:
- * returns SSLContext object
- */
- public void testSSLContext01() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- SSLContext sslContext;
- for (int i = 0; i < validValues.length; i++) {
- sslContext = SSLContext.getInstance(validValues[i]);
- assertTrue("Not SSLContext object",
- sslContext instanceof SSLContext);
- assertEquals("Invalid protocol", sslContext.getProtocol(),
- validValues[i]);
- }
- }
-
- /**
- * Test for <code>getInstance(String protocol)</code> method Assertion:
- * throws NullPointerException when protocol is null; throws
- * NoSuchAlgorithmException when protocol is not correct;
- */
- public void testSSLContext02() {
- try {
- SSLContext.getInstance(null);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (protocol is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- SSLContext.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException was not thrown as expected for provider: "
- .concat(invalidValues[i]));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String protocol, String provider)</code>
- * method Assertion: throws IllegalArgumentException when provider is null
- * or empty
- */
- public void testSSLContext03() throws NoSuchProviderException,
- NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- String provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- SSLContext.getInstance(defaultProtocol, provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- try {
- SSLContext.getInstance(defaultProtocol, "");
- fail("IllegalArgumentException must be thrown when provider is empty");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String protocol, String provider)</code>
- * method Assertion: throws NullPointerException when protocol is null;
- * throws NoSuchAlgorithmException when protocol is not correct;
- */
- public void testSSLContext04() throws NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- try {
- SSLContext.getInstance(null, defaultProviderName);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (protocol is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- SSLContext.getInstance(invalidValues[i], defaultProviderName);
- fail("NoSuchAlgorithmException was not thrown as expected (protocol: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String protocol, String provider)</code>
- * method Assertion: throws NoSuchProviderException when provider has
- * invalid value
- */
- public void testSSLContext05() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- for (int i = 1; i < invalidValues.length; i++) {
- for (int j = 0; j < validValues.length; j++) {
- try {
- SSLContext.getInstance(validValues[j], invalidValues[i]);
- fail("NuSuchProviderException must be thrown (protocol: "
- .concat(validValues[j]).concat(" provider: ")
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String protocol, String provider)</code>
- * method Assertion: returns instance of SSLContext
- */
- public void testSSLContext06() throws NoSuchAlgorithmException,
- NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- SSLContext sslContext;
- for (int i = 0; i < validValues.length; i++) {
- sslContext = SSLContext.getInstance(validValues[i],
- defaultProviderName);
- assertTrue("Not SSLContext object",
- sslContext instanceof SSLContext);
- assertEquals("Invalid protocol", sslContext.getProtocol(),
- validValues[i]);
- assertEquals("Invalid provider", sslContext.getProvider(),
- defaultProvider);
- }
- }
-
- /**
- * Test for <code>getInstance(String protocol, Provider provider)</code>
- * method Assertion: throws IllegalArgumentException when provider is null
- */
- public void testSSLContext07() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- Provider provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- SSLContext.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String protocol, Provider provider)</code>
- * method Assertion: throws NullPointerException when protocol is null;
- * throws NoSuchAlgorithmException when protocol is not correct;
- */
- public void testSSLContext08() {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- try {
- SSLContext.getInstance(null, defaultProvider);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (protocol is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- SSLContext.getInstance(invalidValues[i], defaultProvider);
- fail("Expected NoSuchAlgorithmException was not thrown as expected");
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String protocol, Provider provider)</code>
- * method Assertion: returns instance of SSLContext
- */
- public void testSSLContext09() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- SSLContext sslContext;
- for (int i = 0; i < validValues.length; i++) {
- sslContext = SSLContext
- .getInstance(validValues[i], defaultProvider);
- assertTrue("Not SSLContext object",
- sslContext instanceof SSLContext);
- assertEquals("Invalid protocol", sslContext.getProtocol(),
- validValues[i]);
- assertEquals("Invalid provider", sslContext.getProvider(),
- defaultProvider);
- }
- }
-
- /**
- * Test for <code>getClientSessionContext()</code>
- * <code>getServiceSessionContext()</code>
- * methods Assertion: returns correspondent object
- */
- public void testSSLContext10() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- SSLContext[] sslC = createSSLCon();
- assertNotNull("SSLContext objects were not created", sslC);
- for (int i = 0; i < sslC.length; i++) {
- assertTrue(sslC[i].getClientSessionContext() instanceof SSLSessionContext);
- assertTrue(sslC[i].getServerSessionContext() instanceof SSLSessionContext);
- }
- }
-
- /**
- * Test for <code>getServerSocketFactory()</code>
- * <code>getSocketFactory()</code>
- * <code>init(KeyManager[] km, TrustManager[] tm, SecureRandom random)</code>
- * methods Assertion: returns correspondent object
- */
-
- public void testSSLContext11() throws NoSuchAlgorithmException,
- KeyManagementException, KeyStoreException,
- UnrecoverableKeyException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- SSLContext[] sslC = createSSLCon();
- assertNotNull("SSLContext objects were not created", sslC);
- String tAlg = TrustManagerFactory.getDefaultAlgorithm();
- String kAlg = KeyManagerFactory.getDefaultAlgorithm();
- if (tAlg == null) {
- fail("TrustManagerFactory default algorithm is not defined");
- return;
- }
- if (kAlg == null) {
- fail("KeyManagerFactory default algorithm is not defined");
- return;
- }
- KeyManagerFactory kmf = KeyManagerFactory.getInstance(kAlg);
- KeyStore ks = null;
- kmf.init(ks, new char[10]);
- KeyManager[] kms = kmf.getKeyManagers();
- TrustManagerFactory tmf = TrustManagerFactory.getInstance(tAlg);
- tmf.init(ks);
- TrustManager[] tms = tmf.getTrustManagers();
- for (int i = 0; i < sslC.length; i++) {
- sslC[i].init(kms, tms, new SecureRandom());
- assertTrue(sslC[i].getServerSocketFactory() instanceof SSLServerSocketFactory);
- assertTrue(sslC[i].getSocketFactory() instanceof SSLSocketFactory);
- }
- }
-
- /**
- * Test for <code>SSLContext</code> constructor Assertion: returns
- * SSLContext object
- */
- public void testSSLContext12() throws NoSuchAlgorithmException,
- KeyManagementException {
- if (!DEFSupported) {
- fail(NotSupportMsg);
- return;
- }
- SSLContextSpi spi = new MySSLContextSpi();
- SSLContext sslContext = new MySSLContext(spi, defaultProvider,
- defaultProtocol);
- assertTrue("Not CertStore object", sslContext instanceof SSLContext);
- assertEquals("Incorrect protocol", sslContext.getProtocol(),
- defaultProtocol);
- assertEquals("Incorrect provider", sslContext.getProvider(),
- defaultProvider);
- TrustManager[] tm = null;
- KeyManager[] km = null;
- sslContext.init(km, tm, new SecureRandom());
- assertTrue(sslContext.createSSLEngine() instanceof SSLEngine);
- assertTrue(sslContext.createSSLEngine("host host", 8888) instanceof SSLEngine);
- try {
- sslContext.init(km, tm, null);
- fail("KeyManagementException should be thrown for null SEcureRandom");
- } catch (KeyManagementException e) {
- }
-
- sslContext = new MySSLContext(null, null, null);
- assertTrue("Not CertStore object", sslContext instanceof SSLContext);
- assertNull("Incorrect protocol", sslContext.getProtocol());
- assertNull("Incorrect provider", sslContext.getProvider());
- try {
- sslContext.createSSLEngine();
- fail("NullPointerException should be thrown");
- } catch (NullPointerException e) {
- }
- try {
- sslContext.getSocketFactory();
- fail("NullPointerException should be thrown");
- } catch (NullPointerException e) {
- }
- }
-
- public void testGetDefault() throws Exception {
- //TODO: Need evaluation
- class PrivateClassLoader extends ClassLoader {
- }
- try {
- // register my provider and its service.
- Security.addProvider(new MyProvider());
- // FIXME
- ClassLoader privateClassLoader = new PrivateClassLoader();
- Class class1 = privateClassLoader
- .loadClass("org.apache.harmony.xnet.tests.javax.net.ssl.MySSLContext");
- SSLContext sslContext = (SSLContext) class1.newInstance();
- System.out.println(SSLContext.getInstance("Default"));
- assertTrue((sslContext.getDefault()) instanceof SSLContext);
- } catch (NoSuchAlgorithmException e) {
- // expected
- }
- }
-
-
- public void testGetDefaultSSLParameters() throws Exception {
- SSLContext[] sslContexts = createSSLCon();
- assertNotNull("SSLContext objects were not created", sslContexts);
-
- for (int i = 0; i < sslContexts.length; i++) {
- sslContexts[i].init(null, null, null);
- SSLParameters defaultSSLParameters = sslContexts[i]
- .getDefaultSSLParameters();
- SSLSocket sslSocket = (SSLSocket) (sslContexts[i]
- .getSocketFactory().createSocket());
-
- String[] enabledCipherSuites = sslSocket.getEnabledCipherSuites();
- String[] enabledProtocols = sslSocket.getEnabledProtocols();
-
- for (int j = 0; j < enabledCipherSuites.length; j++)
- assertEquals((defaultSSLParameters.getCipherSuites())[j],
- enabledCipherSuites[j]);
- for (int k = 0; k < enabledProtocols.length; k++)
- assertEquals((defaultSSLParameters.getProtocols())[k],
- enabledProtocols[k]);
- }
- }
-
- public void testGetSupportedSSLParameters() throws Exception {
- SSLContext[] sslContexts = createSSLCon();
- assertNotNull("SSLContext objects were not created", sslContexts);
-
- for (int i = 0; i < sslContexts.length; i++) {
- sslContexts[i].init(null, null, null);
- SSLParameters defaultSSLParameters = sslContexts[i]
- .getSupportedSSLParameters();
- SSLSocket sslSocket = (SSLSocket) (sslContexts[i]
- .getSocketFactory().createSocket());
- String[] supportedCipherSuites = sslSocket.getSupportedCipherSuites();
- String[] supportedProtocols = sslSocket.getSupportedProtocols();
-
- for (int j = 0; j < supportedCipherSuites.length; j++)
- assertEquals((defaultSSLParameters.getCipherSuites())[j],
- supportedCipherSuites[j]);
- for (int k = 0; k < supportedProtocols.length; k++)
- assertEquals((defaultSSLParameters.getProtocols())[k],
- supportedProtocols[k]);
- }
- }
-}
-
-/**
- * Addifional class to verify SSLContext constructor
- */
-class MyProvider extends Provider {
- MyProvider() {
- super("MyProviderForSSLContextTest", 1.0, "Provider for testing");
- put("SSLContext.Default", "org.apache.harmony.xnet.tests.javax.net.ssl.MySSLContext");
- }
-}
-
-class MySSLContext extends SSLContext {
- public MySSLContext(SSLContextSpi spi, Provider prov, String alg) {
- super(spi, prov, alg);
- }
-
- public MySSLContext() {
- super(null, null, null);
- }
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext2Test.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext2Test.java
deleted file mode 100644
index 6e807de..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext2Test.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.Security;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.TrustManager;
-
-import org.apache.harmony.xnet.tests.support.SpiEngUtils;
-import org.apache.harmony.xnet.tests.support.MySSLContextSpi;
-import junit.framework.TestCase;
-
-/**
- * Tests for SSLContext class constructors and methods
- */
-
-public class SSLContext2Test extends TestCase {
-
- private static String srvSSLContext = "SSLContext";
-
- private static final String defaultProtocol = "S+S+L";
-
- public static final String SSLContextProviderClass = "org.apache.harmony.xnet.tests.support.MySSLContextSpi";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultProtocol;
- validValues[1] = defaultProtocol.toLowerCase();
- validValues[2] = "s+S+L";
- validValues[3] = "S+s+L";
- }
-
- Provider mProv;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MySSLContextProvider", "Provider for testing",
- srvSSLContext.concat(".").concat(defaultProtocol),
- SSLContextProviderClass);
- Security.insertProviderAt(mProv, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- private void checkSSLContext(SSLContext sslC)
- throws KeyManagementException {
-
- try {
- sslC.getSocketFactory();
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertEquals("Incorrect message", "Not initialiazed", e.getMessage());
- }
- try {
- sslC.getServerSocketFactory();
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertEquals("Incorrect message", "Not initialiazed", e.getMessage());
- }
- try {
- sslC.getServerSessionContext();
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertEquals("Incorrect message", "Not initialiazed", e.getMessage());
- }
- try {
- sslC.getClientSessionContext();
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertEquals("Incorrect message", "Not initialiazed", e.getMessage());
- }
- try {
- sslC.createSSLEngine();
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertEquals("Incorrect message", "Not initialiazed", e.getMessage());
- }
- try {
- sslC.createSSLEngine("host", 1);
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertEquals("Incorrect message", "Not initialiazed", e.getMessage());
- }
- TrustManager[] tm = new TManager[10];
- KeyManager[] km = new KManager[5];
- try {
- sslC.init(km, tm, null);
- fail("KeyManagementException must be thrown");
- } catch (KeyManagementException e) {
- }
- sslC.init(km, tm, new SecureRandom());
-
- SSLEngine sslE = sslC.createSSLEngine();
- assertTrue("Not null result", sslE instanceof SSLEngine);
- assertNull("Incorrect host", sslE.getPeerHost());
- assertEquals("Incorrect port", 0, sslE.getPeerPort());
- String host = "ZZZ";
- int port = 8080;
- sslE = sslC.createSSLEngine(host, port);
- assertTrue("Not null result", sslE instanceof SSLEngine);
- assertEquals("Incorrect host", sslE.getPeerHost(), host);
- assertEquals("Incorrect port", sslE.getPeerPort(), port);
- try {
- assertNull("Not null result", sslC.getServerSessionContext());
- } catch (NullPointerException e) {
- }
- try {
- assertNull("Not null result", sslC.getClientSessionContext());
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test for <code>getInstance(String protocol)</code> method
- * Assertions:
- * throws NullPointerException when protocol is null;
- * throws NoSuchAlgorithmException when protocol is not correct;
- * returns SSLContext object
- */
- public void testGetInstance01() throws NoSuchAlgorithmException,
- KeyManagementException {
- try {
- SSLContext.getInstance(null);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (protocol is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- SSLContext.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown (protocol: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- SSLContext sslC;
- for (int i = 0; i < validValues.length; i++) {
- sslC = SSLContext.getInstance(validValues[i]);
- assertTrue("Not instanceof SSLContext object",
- sslC instanceof SSLContext);
- assertEquals("Incorrect protocol", sslC.getProtocol(),
- validValues[i]);
- assertEquals("Incorrect provider", sslC.getProvider(), mProv);
- checkSSLContext(sslC);
- }
- }
-
- /**
- * Test for <code>getInstance(String protocol, String provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when protocol is null;
- * throws NoSuchAlgorithmException when protocol is not correct;
- * throws IllegalArgumentException when provider is null or empty;
- * throws NoSuchProviderException when provider is available;
- * returns SSLContext object
- */
- public void testGetInstance02() throws NoSuchAlgorithmException,
- NoSuchProviderException, IllegalArgumentException,
- KeyManagementException {
- try {
- SSLContext.getInstance(null, mProv.getName());
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (protocol is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- SSLContext.getInstance(invalidValues[i], mProv.getName());
- fail("NoSuchAlgorithmException must be thrown (protocol: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- SSLContext.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (protocol: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- try {
- SSLContext.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty (protocol: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- SSLContext.getInstance(validValues[i], invalidValues[j]);
- fail("NoSuchProviderException must be thrown (protocol: "
- .concat(invalidValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- SSLContext sslC;
- for (int i = 0; i < validValues.length; i++) {
- sslC = SSLContext.getInstance(validValues[i], mProv.getName());
- assertTrue("Not instanceof SSLContext object",
- sslC instanceof SSLContext);
- assertEquals("Incorrect protocol", sslC.getProtocol(),
- validValues[i]);
- assertEquals("Incorrect provider", sslC.getProvider().getName(),
- mProv.getName());
- checkSSLContext(sslC);
- }
- }
-
- /**
- * Test for <code>getInstance(String protocol, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when protocol is null;
- * throws NoSuchAlgorithmException when protocol is not correct;
- * throws IllegalArgumentException when provider is null;
- * returns SSLContext object
- */
- public void testGetInstance03() throws NoSuchAlgorithmException,
- IllegalArgumentException, KeyManagementException {
- try {
- SSLContext.getInstance(null, mProv);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (protocol is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- SSLContext.getInstance(invalidValues[i], mProv);
- fail("NoSuchAlgorithmException must be thrown (protocol: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- SSLContext.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (protocol: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- SSLContext sslC;
- for (int i = 0; i < validValues.length; i++) {
- sslC = SSLContext.getInstance(validValues[i], mProv);
- assertTrue("Not instanceof SSLContext object",
- sslC instanceof SSLContext);
- assertEquals("Incorrect protocol", sslC.getProtocol(),
- validValues[i]);
- assertEquals("Incorrect provider", sslC.getProvider(), mProv);
- checkSSLContext(sslC);
- }
- }
-
- class TManager implements TrustManager {
-
- }
-
- class KManager implements KeyManager {
-
- }
-} \ No newline at end of file
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineResultTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineResultTest.java
deleted file mode 100644
index 3084d40..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineResultTest.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import javax.net.ssl.SSLEngineResult;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for SSLEngineResult class
- */
-public class SSLEngineResultTest extends TestCase {
-
- /**
- * Test for <code>SSLEngineResult(SSLEngineResult.Status status,
- * SSLEngineResult.HandshakeStatus handshakeStatus,
- * int bytesConsumed,
- * int bytesProduced) </code> constructor and
- * <code>getHandshakeStatus()</code>
- * <code>getStatus()</code>
- * <code>bytesConsumed()</code>
- * <code>bytesProduced()</code>
- * <code>toString()</code>
- * methods
- * Assertions:
- * constructor throws IllegalArgumentException when bytesConsumed
- * or bytesProduced is negative or when status or handshakeStatus
- * is null
- */
- public void testSSLEngineResultConstructor() {
-
- int[] neg = { -1, -10, -1000, Integer.MIN_VALUE,
- (Integer.MIN_VALUE + 1) };
- int[] pos = { 0, 1, 1000, Integer.MAX_VALUE, (Integer.MAX_VALUE - 1) };
- try {
- new SSLEngineResult(null, SSLEngineResult.HandshakeStatus.FINISHED,
- 1, 1);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- try {
- new SSLEngineResult(SSLEngineResult.Status.BUFFER_OVERFLOW, null,
- 1, 1);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- for (int i = 0; i < neg.length; i++) {
- try {
- new SSLEngineResult(SSLEngineResult.Status.BUFFER_OVERFLOW,
- SSLEngineResult.HandshakeStatus.FINISHED, neg[i], 1);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < neg.length; i++) {
- try {
- new SSLEngineResult(SSLEngineResult.Status.BUFFER_OVERFLOW,
- SSLEngineResult.HandshakeStatus.FINISHED, 1, neg[i]);
- fail("IllegalArgumentException must be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- SSLEngineResult.Status[] enS = SSLEngineResult.Status.values();
- SSLEngineResult.HandshakeStatus[] enHS = SSLEngineResult.HandshakeStatus
- .values();
- SSLEngineResult res;
- String toS;
- for (int i = 0; i < enS.length; i++) {
- for (int j = 0; j < enHS.length; j++) {
- for (int n = 0; n < pos.length; n++) {
- for (int l = 0; l < pos.length; l++) {
- res = new SSLEngineResult(enS[i], enHS[j], pos[n],
- pos[l]);
-
- assertEquals("Incorrect bytesProduced", res
- .bytesProduced(), pos[l]);
- assertEquals("Incorrect bytesConsumed", res
- .bytesConsumed(), pos[n]);
- assertEquals("Incorrect HandshakeStatus", res
- .getHandshakeStatus(), enHS[j]);
- assertEquals("Incorrect Status", res.getStatus(),
- enS[i]);
- toS = res.toString();
- assertNotNull("Result of toSring() method is null", toS);
- }
- }
- }
- }
-
- }
-
- /**
- * Test for <code>SSLEngineResult.Status.values()</code> method
- */
-
- public void testStatus01() {
- SSLEngineResult.Status[] enS = SSLEngineResult.Status.values();
- assertTrue("Incorrect array of Status objects", enS.length > 0);
- assertTrue("OK object does not define", findEl(enS,
- SSLEngineResult.Status.OK));
- assertTrue("CLOSED object does not define", findEl(enS,
- SSLEngineResult.Status.CLOSED));
- assertTrue("BUFFER_OVERFLOW object does not define", findEl(enS,
- SSLEngineResult.Status.BUFFER_OVERFLOW));
- assertTrue("BUFFER_UNDERFLOW object does not define", findEl(enS,
- SSLEngineResult.Status.BUFFER_UNDERFLOW));
- }
-
- /**
- * Test for <code>SSLEngineResult.Status.valueOf(String name)</code> method
- * Assertion:
- * throws IllegalArgumentException when there is no constan with specified
- * name
- */
-
- public void testStatus02() {
- String[] invalid = { "", "OK1", "BUFFER_overflow", "BUFFER_UND",
- "CLOSED_CLOSED", "Bad string for verification valueOf method"
- };
- assertEquals(SSLEngineResult.Status.valueOf("BUFFER_OVERFLOW"),
- SSLEngineResult.Status.BUFFER_OVERFLOW);
- assertEquals(SSLEngineResult.Status.valueOf("BUFFER_UNDERFLOW"),
- SSLEngineResult.Status.BUFFER_UNDERFLOW);
- assertEquals(SSLEngineResult.Status.valueOf("CLOSED"),
- SSLEngineResult.Status.CLOSED);
- assertEquals(SSLEngineResult.Status.valueOf("OK"),
- SSLEngineResult.Status.OK);
- for (int i = 0; i < invalid.length; i++) {
- try {
- SSLEngineResult.Status.valueOf(invalid[i]);
- fail("IllegalArgumentException must be thrown for name: " + invalid[i]);
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>SSLEngineResult.HandshakeStatus.values()</code> method
- */
-
- public void testHandshakeStatus01() {
- SSLEngineResult.HandshakeStatus[] enHS = SSLEngineResult.HandshakeStatus
- .values();
- assertTrue("Incorrect array of HandshakeStatus objects",
- enHS.length > 0);
- assertTrue("FINISHED object does not define", findEl(enHS,
- SSLEngineResult.HandshakeStatus.FINISHED));
- assertTrue("NEED_UNWRAP object does not define", findEl(enHS,
- SSLEngineResult.HandshakeStatus.NEED_UNWRAP));
- assertTrue("NEED_WRAP object does not define", findEl(enHS,
- SSLEngineResult.HandshakeStatus.NEED_WRAP));
- assertTrue("NEED_TASK object does not define", findEl(enHS,
- SSLEngineResult.HandshakeStatus.NEED_TASK));
- assertTrue("NOT_HANDSHAKING object does not define", findEl(enHS,
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING));
- }
-
- /**
- * Test for <code>SSLEngineResult.HandshakeStatus.valueOf(String name)</code> method
- * Assertion:
- * throws IllegalArgumentException when there is no constan with specified
- * name
- */
-
- public void testHandshakeStatus02() {
- String[] invalid = { "", "FINISHED1", "NEED_task", "NEED_UN",
- "NEED_WRAP_WRAP", "not_HANDSHAKING", "Bad string for verification valueOf method"
- };
- assertEquals(SSLEngineResult.HandshakeStatus.valueOf("NOT_HANDSHAKING"),
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING);
- assertEquals(SSLEngineResult.HandshakeStatus.valueOf("NEED_WRAP"),
- SSLEngineResult.HandshakeStatus.NEED_WRAP);
- assertEquals(SSLEngineResult.HandshakeStatus.valueOf("NEED_UNWRAP"),
- SSLEngineResult.HandshakeStatus.NEED_UNWRAP);
- assertEquals(SSLEngineResult.HandshakeStatus.valueOf("FINISHED"),
- SSLEngineResult.HandshakeStatus.FINISHED);
- assertEquals(SSLEngineResult.HandshakeStatus.valueOf("NEED_TASK"),
- SSLEngineResult.HandshakeStatus.NEED_TASK);
- for (int i = 0; i < invalid.length; i++) {
- try {
- SSLEngineResult.HandshakeStatus.valueOf(invalid[i]);
- fail("IllegalArgumentException must be thrown for name: " + invalid[i]);
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- private boolean findEl(Object[] arr, Object el) {
- boolean ok = false;
- for (int i = 0; i < arr.length; i++) {
- if (arr[i].equals(el)) {
- ok = true;
- break;
- }
- }
- return ok;
- }
-
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java
deleted file mode 100644
index c671938..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.nio.ByteBuffer;
-import java.nio.ReadOnlyBufferException;
-
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLParameters;
-import javax.net.ssl.SSLEngineResult.HandshakeStatus;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLEngineResult;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for SSLEngine class
- */
-
-public class SSLEngineTest extends TestCase {
-
- /**
- * Test for <code>SSLEngine()</code> constructor Assertion: creates
- * SSLEngine object with null host and -1 port
- */
- public void test01() {
- SSLEngine e = new mySSLEngine();
- assertNull(e.getPeerHost());
- assertEquals(-1, e.getPeerPort());
- String[] suites = { "a", "b", "c" };
- e.setEnabledCipherSuites(suites);
- assertEquals(e.getEnabledCipherSuites().length, suites.length);
- }
-
- /**
- * Test for <code>SSLEngine(String host, int port)</code> constructor
- */
- public void test02() throws SSLException {
- int port = 1010;
- SSLEngine e = new mySSLEngine(null, port);
- assertNull(e.getPeerHost());
- assertEquals(e.getPeerPort(), port);
- try {
- e.beginHandshake();
- } catch (SSLException ex) {
- }
- }
-
- /**
- * Test for <code>SSLEngine(String host, int port)</code> constructor
- */
- public void test03() {
- String host = "new host";
- int port = 8080;
- SSLEngine e = new mySSLEngine(host, port);
- assertEquals(e.getPeerHost(), host);
- assertEquals(e.getPeerPort(), port);
- String[] suites = { "a", "b", "c" };
- e.setEnabledCipherSuites(suites);
- assertEquals(e.getEnabledCipherSuites().length, suites.length);
- e.setUseClientMode(true);
- assertTrue(e.getUseClientMode());
- }
-
- /**
- * Test for <code>wrap(ByteBuffer src, ByteBuffer dst)</code> method
- * Assertions:
- * throws IllegalArgumentException when src or dst is null
- * throws ReadOnlyBufferException when dst is ReadOnly byte buffer
- * <p/>
- * Check that implementation behavior follows RI:
- * jdk 1.5 does not throw IllegalArgumentException when parameters are null
- * and does not throw ReadOnlyBufferException if dst is read only byte buffer
- */
- public void testWrap01() throws SSLException {
- String host = "new host";
- int port = 8080;
- ByteBuffer bbN = null;
- ByteBuffer bb = ByteBuffer.allocate(10);
- SSLEngine e = new mySSLEngine(host, port);
-
- e.wrap(bbN, bb);
- e.wrap(bb, bbN);
-
- ByteBuffer roBb = bb.asReadOnlyBuffer();
- assertTrue("Not read only byte buffer", roBb.isReadOnly());
- e.wrap(bb, roBb);
-
- }
-
- /**
- * Test for <code>wrap(ByteBuffer[] srcs, ByteBuffer dst)</code> method
- * <p/>
- * Assertions: throws IllegalArgumentException when srcs or dst is null or
- * srcs contains null byte buffer; throws ReadOnlyBufferException when dst
- * is read only byte buffer
- * <p/>
- * Check that implementation behavior follows RI:
- * jdk 1.5 does not throw IllegalArgumentException when dst is null or
- * if srcs contains null elements It does not throw ReadOnlyBufferException
- * for read only dst
- */
- public void testWrap02() throws SSLException {
- String host = "new host";
- int port = 8080;
- ByteBuffer[] bbNA = null;
- ByteBuffer[] bbA = { null, ByteBuffer.allocate(10), null };
-
- ByteBuffer bb = ByteBuffer.allocate(10);
- ByteBuffer bbN = null;
- SSLEngine e = new mySSLEngine(host, port);
- try {
- e.wrap(bbNA, bb);
- fail("IllegalArgumentException must be thrown for null srcs byte buffer array");
- } catch (IllegalArgumentException ex) {
- }
-
- e.wrap(bbA, bb);
- e.wrap(bbA, bbN);
-
- ByteBuffer roBb = bb.asReadOnlyBuffer();
- bbA[0] = ByteBuffer.allocate(100);
- bbA[2] = ByteBuffer.allocate(20);
- assertTrue("Not read only byte buffer", roBb.isReadOnly());
-
- e.wrap(bbA, roBb);
-
- }
-
- /**
- * Test for <code>wrap(ByteBuffer src, ByteBuffer dst)</code> and
- * <code>wrap(ByteBuffer[] srcs, ByteBuffer dst)</code> methods
- * <p/>
- * Assertion: these methods throw SSLException
- */
- public void testWrap03() throws SSLException {
- String host = "new host";
- int port = 8080;
- ByteBuffer bbs = ByteBuffer.allocate(100);
- ByteBuffer bbd = ByteBuffer.allocate(10);
- SSLEngine e = new mySSLEngine1(host, port);
- try {
- e.wrap(bbs, bbd);
- fail("SSLException must be thrown");
- } catch (SSLException ex) {
- }
- SSLEngineResult res = e.wrap(bbd, bbs);
- assertEquals(10, res.bytesConsumed());
- assertEquals(20, res.bytesProduced());
-
- try {
- e.wrap(new ByteBuffer[] { bbs }, bbd);
- fail("SSLException must be thrown");
- } catch (SSLException ex) {
- }
- res = e.wrap(new ByteBuffer[] { bbd }, bbs);
- assertEquals(10, res.bytesConsumed());
- assertEquals(20, res.bytesProduced());
- }
-
- /**
- * Test for <code>wrap(ByteBuffer src, ByteBuffer dst)</code> method
- * <p/>
- * Assertion: encodes a buffer data into network data.
- */
- public void testWrap04() throws SSLException {
- String host = "new host";
- int port = 8080;
- ByteBuffer bb = ByteBuffer.allocate(10);
- SSLEngine e = new mySSLEngine(host, port);
-
- SSLEngineResult res = e.wrap(bb, ByteBuffer.allocate(10));
- assertEquals(10, res.bytesConsumed());
- assertEquals(20, res.bytesProduced());
- }
-
- /**
- * Test for <code>wrap(ByteBuffer[] srcs, ByteBuffer dst)</code> method
- * <p/>
- * Assertion: encodes datas from buffers into network data.
- */
- public void testWrap05() throws SSLException {
- String host = "new host";
- int port = 8080;
-
- ByteBuffer bb = ByteBuffer.allocate(10);
- ByteBuffer[] bbA = { ByteBuffer.allocate(5), ByteBuffer.allocate(10), ByteBuffer.allocate(5) };
-
- SSLEngine e = new mySSLEngine(host, port);
-
- SSLEngineResult res = e.wrap(bbA, bb);
- assertEquals(10, res.bytesConsumed());
- assertEquals(20, res.bytesProduced());
- }
-
- /**
- * Test for <code>unwrap(ByteBuffer src, ByteBuffer dst)</code> method
- * <p/>
- * Assertions:
- * throws IllegalArgumentException when src or dst is null
- * throws ReadOnlyBufferException when dst is read only byte buffer
- * <p/>
- * Check that implementation behavior follows RI:
- * jdk 1.5 does not throw IllegalArgumentException when parameters are null
- * and does not throw ReadOnlyBufferException if dst is read only byte buffer
- */
- public void testUnwrap01() throws SSLException {
- String host = "new host";
- int port = 8080;
- ByteBuffer bbN = null;
- ByteBuffer bb = ByteBuffer.allocate(10);
- SSLEngine e = new mySSLEngine(host, port);
-
- e.unwrap(bbN, bb);
- e.unwrap(bb, bbN);
-
- ByteBuffer roBb = bb.asReadOnlyBuffer();
- assertTrue("Not read only byte buffer", roBb.isReadOnly());
-
- e.unwrap(bb, roBb);
- }
-
- /**
- * Test for <code>unwrap(ByteBuffer src, ByteBuffer[] dsts)</code> method
- * <p/>
- * Assertions: throws IllegalArgumentException if parameters are null or
- * when dsts contains null elements throws ReadOnlyBufferException when dsts
- * contains read only elements
- * <p/>
- * Check that implementation behavior follows RI:
- * jdk 1.5 does not throw IllegalArgumentException when src is null or
- * if dsts contains null elements It does not throw ReadOnlyBufferException
- * when dsts contains read only elements
- */
- public void testUnwrap02() throws SSLException {
- String host = "new host";
- int port = 8080;
- ByteBuffer[] bbNA = null;
- ByteBuffer[] bbA = { null, ByteBuffer.allocate(10), null };
-
- ByteBuffer bb = ByteBuffer.allocate(10);
- ByteBuffer bbN = null;
- SSLEngine e = new mySSLEngine(host, port);
- try {
- e.unwrap(bb, bbNA);
- fail("IllegalArgumentException must be thrown for null dsts byte buffer array");
- } catch (IllegalArgumentException ex) {
- }
-
- e.unwrap(bb, bbA);
- e.unwrap(bbN, bbA);
-
- ByteBuffer bb1 = ByteBuffer.allocate(100);
- ByteBuffer roBb = bb1.asReadOnlyBuffer();
- bbA[0] = bb1;
- bbA[2] = roBb;
- assertTrue("Not read only byte buffer", bbA[2].isReadOnly());
-
- e.unwrap(bb, bbA);
-
- }
-
- /**
- * Test for <code>unwrap(ByteBuffersrc, ByteBuffer dst)</code> and
- * <code>unwrap(ByteBuffer src, ByteBuffer[] dsts)</code> methods
- * <p/>
- * Assertion: these methods throw SSLException
- */
- public void testUnwrap03() throws SSLException {
- ByteBuffer bbs = ByteBuffer.allocate(100);
- ByteBuffer bbd = ByteBuffer.allocate(10);
- SSLEngine e = new mySSLEngine1();
- try {
- e.unwrap(bbs, bbd);
- fail("SSLException must be thrown");
- } catch (SSLException ex) {
- }
- SSLEngineResult res = e.unwrap(bbd, bbs);
- assertEquals(1, res.bytesConsumed());
- assertEquals(2, res.bytesProduced());
-
- try {
- e.unwrap(bbs, new ByteBuffer[] { bbd });
- fail("SSLException must be thrown");
- } catch (SSLException ex) {
- }
- res = e.unwrap(bbd, new ByteBuffer[] { bbs });
- assertEquals(1, res.bytesConsumed());
- assertEquals(2, res.bytesProduced());
- }
-
- /**
- * Test for <code>unwrap(ByteBuffer src, ByteBuffer dst)</code> method
- * <p/>
- * Assertion: decodes network data into a data buffer.
- */
- public void testUnwrap04() throws SSLException {
- String host = "new host";
- int port = 8080;
- ByteBuffer bb = ByteBuffer.allocate(10);
- SSLEngine e = new mySSLEngine(host, port);
- SSLEngineResult res = e.unwrap(bb, ByteBuffer.allocate(10));
-
- assertEquals(1, res.bytesConsumed());
- assertEquals(2, res.bytesProduced());
- }
-
- /**
- * Test for <code>unwrap(ByteBuffer src, ByteBuffer[] dsts)</code> method
- * <p/>
- * Assertion:
- * decode network data into data buffers.
- */
- public void testUnwrap05() throws SSLException {
- String host = "new host";
- int port = 8080;
- ByteBuffer[] bbA = { ByteBuffer.allocate(100), ByteBuffer.allocate(10), ByteBuffer.allocate(100) };
-
- ByteBuffer bb = ByteBuffer.allocate(10);
- SSLEngine e = new mySSLEngine(host, port);
-
- SSLEngineResult res = e.unwrap(bb, bbA);
- assertEquals(1, res.bytesConsumed());
- assertEquals(2, res.bytesProduced());
- }
-}
-
-/*
- * Additional class for verification SSLEngine constructors
- */
-
-class mySSLEngine extends SSLEngine {
-
- private boolean useClientMode;
-
- private boolean needClientAuth;
-
- private boolean enableSessionCreation;
-
- private boolean wantClientAuth;
-
- private String[] enabledProtocols;
-
- private String[] enabledCipherSuites;
-
- public mySSLEngine() {
- super();
- }
-
- protected mySSLEngine(String host, int port) {
- super(host, port);
- }
-
- @Override
- public void beginHandshake() throws SSLException {
- String host = super.getPeerHost();
- if ((host == null) || (host.length() == 0)) {
- throw new SSLException("");
- }
- }
-
- @Override
- public void closeInbound() throws SSLException {
- }
-
- @Override
- public void closeOutbound() {
- }
-
- @Override
- public Runnable getDelegatedTask() {
- return null;
- }
-
- @Override
- public String[] getEnabledCipherSuites() {
- return enabledCipherSuites;
- }
-
- @Override
- public String[] getEnabledProtocols() {
- return enabledProtocols;
- }
-
- @Override
- public boolean getEnableSessionCreation() {
- return enableSessionCreation;
- }
-
- @Override
- public SSLEngineResult.HandshakeStatus getHandshakeStatus() {
- return SSLEngineResult.HandshakeStatus.FINISHED;
- }
-
- @Override
- public boolean getNeedClientAuth() {
- return needClientAuth;
- }
-
- @Override
- public SSLSession getSession() {
- return null;
- }
-
- @Override
- public String[] getSupportedCipherSuites() {
- return new String[0];
- }
-
- @Override
- public String[] getSupportedProtocols() {
- return new String[0];
- }
-
- @Override
- public boolean getUseClientMode() {
- return useClientMode;
- }
-
- @Override
- public boolean getWantClientAuth() {
- return wantClientAuth;
- }
-
- @Override
- public boolean isInboundDone() {
- return false;
- }
-
- @Override
- public boolean isOutboundDone() {
- return false;
- }
-
- @Override
- public void setEnabledCipherSuites(String[] suites) {
- enabledCipherSuites = suites;
- }
-
- @Override
- public void setEnabledProtocols(String[] protocols) {
- enabledProtocols = protocols;
- }
-
- @Override
- public void setEnableSessionCreation(boolean flag) {
- enableSessionCreation = flag;
- }
-
- @Override
- public void setNeedClientAuth(boolean need) {
- needClientAuth = need;
- }
-
- @Override
- public void setUseClientMode(boolean mode) {
- useClientMode = mode;
- }
-
- @Override
- public void setWantClientAuth(boolean want) {
- wantClientAuth = want;
- }
-
- @Override
- public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts,
- int offset, int length) throws SSLException {
- return new SSLEngineResult(SSLEngineResult.Status.OK,
- SSLEngineResult.HandshakeStatus.FINISHED, 1, 2);
- }
-
- @Override
- public SSLEngineResult wrap(ByteBuffer[] srcs, int offset, int length,
- ByteBuffer dst) throws SSLException {
- return new SSLEngineResult(SSLEngineResult.Status.OK,
- SSLEngineResult.HandshakeStatus.FINISHED, 10, 20);
- }
-
- @Override
- public SSLParameters getSSLParameters() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setSSLParameters(SSLParameters sslP) {
- // TODO Auto-generated method stub
-
- }
-}
-
-class mySSLEngine1 extends mySSLEngine {
-
- public mySSLEngine1() {
- }
-
- public mySSLEngine1(String host, int port) {
- super(host, port);
- }
-
- @Override
- public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer dst)
- throws SSLException {
- if (src.limit() > dst.limit()) {
- throw new SSLException("incorrect limits");
- }
- return super.unwrap(src, dst);
- }
-
- @Override
- public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts)
- throws SSLException {
- if (src.limit() > dsts[0].limit()) {
- throw new SSLException("incorrect limits");
- }
- return super.unwrap(src, dsts);
- }
-
- @Override
- public SSLEngineResult wrap(ByteBuffer[] srcs, ByteBuffer dst)
- throws SSLException {
- if (srcs[0].limit() > dst.limit()) {
- throw new SSLException("incorrect limits");
- }
- return super.wrap(srcs, dst);
- }
-
- @Override
- public SSLEngineResult wrap(ByteBuffer src, ByteBuffer dst)
- throws SSLException {
- if (src.limit() > dst.limit()) {
- throw new SSLException("incorrect limits");
- }
- return super.wrap(src, dst);
- }
-
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLExceptionTest.java
deleted file mode 100644
index 094726b..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLExceptionTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import javax.net.ssl.SSLException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SSLException</code> class constructors and methods.
- */
-public class SSLExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for SSLExceptionTests.
- *
- * @param arg0
- */
- public SSLExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>SSLException(String)</code> constructor Assertion:
- * constructs SSLException with detail message msg. Parameter
- * <code>msg</code> is not null.
- */
- public void testSSLException01() {
- SSLException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new SSLException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>SSLException(String)</code> constructor Assertion:
- * constructs SSLException when <code>msg</code> is null
- */
- public void testSSLException02() {
- String msg = null;
- SSLException tE = new SSLException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>DigestException(Throwable)</code> constructor Assertion:
- * constructs DigestException when <code>cause</code> is null
- */
- public void testSSLException03() {
- Throwable cause = null;
- SSLException tE = new SSLException(cause);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>SSLException(Throwable)</code> constructor Assertion:
- * constructs SSLException when <code>cause</code> is not null
- */
- public void testSSLException04() {
- SSLException tE = new SSLException(tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() should contain ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- // SSLException is subclass of IOException, but IOException has not
- // constructors with Throwable parameters
- if (tE.getCause() != null) {
- // assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-
- /**
- * Test for <code>SSLException(String, Throwable)</code> constructor
- * Assertion: constructs SSLException when <code>cause</code> is null
- * <code>msg</code> is null
- */
- public void testSSLException05() {
- SSLException tE = new SSLException(null, null);
- assertNull("getMessage() must return null", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-
- /**
- * Test for <code>SSLException(String, Throwable)</code> constructor
- * Assertion: constructs SSLException when <code>cause</code> is null
- * <code>msg</code> is not null
- */
- public void testSSLException06() {
- SSLException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new SSLException(msgs[i], null);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>SSLException(String, Throwable)</code> constructor
- * Assertion: constructs SSLException when <code>cause</code> is not null
- * <code>msg</code> is null
- */
- public void testSSLException07() {
- SSLException tE = new SSLException(null, tCause);
- if (tE.getMessage() != null) {
- String toS = tCause.toString();
- String getM = tE.getMessage();
- assertTrue("getMessage() must should ".concat(toS), (getM
- .indexOf(toS) != -1));
- }
- // SSLException is subclass of IOException, but IOException has not
- // constructors with Throwable parameters
- if (tE.getCause() != null) {
- // assertNotNull("getCause() must not return null", tE.getCause());
- assertEquals("getCause() must return ".concat(tCause.toString()),
- tE.getCause(), tCause);
- }
- }
-
- /**
- * Test for <code>SSLException(String, Throwable)</code> constructor
- * Assertion: constructs SSLException when <code>cause</code> is not null
- * <code>msg</code> is not null
- */
- public void testSSLException08() {
- SSLException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new SSLException(msgs[i], tCause);
- String getM = tE.getMessage();
- String toS = tCause.toString();
- if (msgs[i].length() > 0) {
- assertTrue("getMessage() must contain ".concat(msgs[i]), getM
- .indexOf(msgs[i]) != -1);
- if (!getM.equals(msgs[i])) {
- assertTrue("getMessage() should contain ".concat(toS), getM
- .indexOf(toS) != -1);
- }
- }
- // SSLException is subclass of IOException, but IOException has not
- // constructors with Throwable parameters
- if (tE.getCause() != null) {
- // assertNotNull("getCause() must not return null",
- // tE.getCause());
- assertEquals("getCause() must return "
- .concat(tCause.toString()), tE.getCause(), tCause);
- }
- }
- }
-
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLHandshakeExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLHandshakeExceptionTest.java
deleted file mode 100644
index 5088f6f..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLHandshakeExceptionTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import javax.net.ssl.SSLHandshakeException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SSLHandshakeException</code> class constructors and
- * methods.
- */
-public class SSLHandshakeExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for SSLHandshakeExceptionTests.
- *
- * @param arg0
- */
- public SSLHandshakeExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>SSLHandshakeException(String)</code> constructor
- * Assertion: constructs SSLHandshakeException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testSSLHandshakeException01() {
- SSLHandshakeException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new SSLHandshakeException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>SSLHandshakeException(String)</code> constructor
- * Assertion: constructs SSLHandshakeException when <code>msg</code> is
- * null
- */
- public void testSSLHandshakeException02() {
- String msg = null;
- SSLHandshakeException tE = new SSLHandshakeException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLKeyExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLKeyExceptionTest.java
deleted file mode 100644
index dba7ee9..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLKeyExceptionTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import javax.net.ssl.SSLKeyException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SSLKeyException</code> class constructors and methods.
- */
-public class SSLKeyExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for SSLKeyExceptionTests.
- *
- * @param arg0
- */
- public SSLKeyExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>SSLKeyException(String)</code> constructor Assertion:
- * constructs SSLKeyException with detail message msg. Parameter
- * <code>msg</code> is not null.
- */
- public void testSSLKeyException01() {
- SSLKeyException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new SSLKeyException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>SSLKeyException(String)</code> constructor Assertion:
- * constructs SSLKeyException when <code>msg</code> is null
- */
- public void testSSLKeyException02() {
- String msg = null;
- SSLKeyException tE = new SSLKeyException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLPeerUnverifiedExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLPeerUnverifiedExceptionTest.java
deleted file mode 100644
index bcf934c..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLPeerUnverifiedExceptionTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import javax.net.ssl.SSLPeerUnverifiedException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SSLPeerUnverifiedException</code> class constructors and
- * methods.
- */
-public class SSLPeerUnverifiedExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for SSLPeerUnverifiedExceptionTests.
- *
- * @param arg0
- */
- public SSLPeerUnverifiedExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>SSLPeerUnverifiedException(String)</code> constructor
- * Assertion: constructs SSLPeerUnverifiedException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testSSLPeerUnverifiedException01() {
- SSLPeerUnverifiedException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new SSLPeerUnverifiedException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>SSLPeerUnverifiedException(String)</code> constructor
- * Assertion: constructs SSLPeerUnverifiedException when <code>msg</code>
- * is null
- */
- public void testSSLPeerUnverifiedException02() {
- String msg = null;
- SSLPeerUnverifiedException tE = new SSLPeerUnverifiedException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLProtocolExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLProtocolExceptionTest.java
deleted file mode 100644
index 34d12fd..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLProtocolExceptionTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import javax.net.ssl.SSLProtocolException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SSLProtocolException</code> class constructors and methods.
- */
-public class SSLProtocolExceptionTest extends TestCase {
-
- public static void main(String[] args) {
- }
-
- /**
- * Constructor for SSLProtocolExceptionTests.
- *
- * @param arg0
- */
- public SSLProtocolExceptionTest(String arg0) {
- super(arg0);
- }
-
- static String[] msgs = {
- "",
- "Check new message",
- "Check new message Check new message Check new message Check new message Check new message" };
-
- static Throwable tCause = new Throwable("Throwable for exception");
-
- /**
- * Test for <code>SSLProtocolException(String)</code> constructor
- * Assertion: constructs SSLProtocolException with detail message msg.
- * Parameter <code>msg</code> is not null.
- */
- public void testSSLProtocolException01() {
- SSLProtocolException tE;
- for (int i = 0; i < msgs.length; i++) {
- tE = new SSLProtocolException(msgs[i]);
- assertEquals("getMessage() must return: ".concat(msgs[i]), tE
- .getMessage(), msgs[i]);
- assertNull("getCause() must return null", tE.getCause());
- }
- }
-
- /**
- * Test for <code>SSLProtocolException(String)</code> constructor
- * Assertion: constructs SSLProtocolException when <code>msg</code> is
- * null
- */
- public void testSSLProtocolException02() {
- String msg = null;
- SSLProtocolException tE = new SSLProtocolException(msg);
- assertNull("getMessage() must return null.", tE.getMessage());
- assertNull("getCause() must return null", tE.getCause());
- }
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLServerSocketTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLServerSocketTest.java
deleted file mode 100644
index 15dfcec..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLServerSocketTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.io.IOException;
-import java.net.InetAddress;
-
-import javax.net.ssl.SSLServerSocket;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SSLServerSocket</code> class constructors.
- */
-public class SSLServerSocketTest extends TestCase {
-
- /*
- * Class under test for void SSLServerSocket()
- */
- public void testSSLServerSocket() {
- try {
- new MySSLServerSocket();
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-
- /*
- * Class under test for void SSLServerSocket(int)
- */
- public void testSSLServerSocketint() {
- try {
- new MySSLServerSocket(0);
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-
- /*
- * Class under test for void SSLServerSocket(int, int)
- */
- public void testSSLServerSocketintint() {
- try {
- new MySSLServerSocket(0, 10);
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-
- /*
- * Class under test for void SSLServerSocket(int, int, InetAddress)
- */
- public void testSSLServerSocketintintInetAddress() {
- try {
- new MySSLServerSocket(0, 10, InetAddress.getLocalHost());
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-
-}
-
-class MySSLServerSocket extends SSLServerSocket {
-
- protected MySSLServerSocket() throws IOException {
- super();
- }
-
- protected MySSLServerSocket(int port) throws IOException {
- super(port);
- }
-
- protected MySSLServerSocket(int port, int backlog) throws IOException {
- super(port, backlog);
- }
-
- protected MySSLServerSocket(int port, int backlog, InetAddress address)
- throws IOException {
- super(port, backlog, address);
- }
-
- @Override
- public String[] getEnabledCipherSuites() {
- return null;
- }
-
- @Override
- public void setEnabledCipherSuites(String[] suites) {
- }
-
- @Override
- public String[] getSupportedCipherSuites() {
- return null;
- }
-
- @Override
- public String[] getSupportedProtocols() {
- return null;
- }
-
- @Override
- public String[] getEnabledProtocols() {
- return null;
- }
-
- @Override
- public void setEnabledProtocols(String[] protocols) {
- }
-
- @Override
- public void setNeedClientAuth(boolean need) {
- }
-
- @Override
- public boolean getNeedClientAuth() {
- return false;
- }
-
- @Override
- public void setWantClientAuth(boolean want) {
- }
-
- @Override
- public boolean getWantClientAuth() {
- return false;
- }
-
- @Override
- public void setUseClientMode(boolean mode) {
- }
-
- @Override
- public boolean getUseClientMode() {
- return false;
- }
-
- @Override
- public void setEnableSessionCreation(boolean flag) {
- }
-
- @Override
- public boolean getEnableSessionCreation() {
- return false;
- }
-}
-
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSessionBindingEventTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSessionBindingEventTest.java
deleted file mode 100644
index 7048275..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSessionBindingEventTest.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.security.Principal;
-import java.security.cert.Certificate;
-
-import javax.net.ssl.SSLPeerUnverifiedException;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSessionContext;
-import javax.net.ssl.SSLSessionBindingEvent;
-import javax.security.cert.X509Certificate;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SSLSessionBindingEvent</code> class constructors and methods.
- */
-public class SSLSessionBindingEventTest extends TestCase {
-
- public final void testSSLSessionBindingEvent() {
- SSLSession ses = new MySSLSession();
- SSLSessionBindingEvent event = new SSLSessionBindingEvent(ses, "test");
-
- assertEquals("test", event.getName());
- assertEquals(ses, event.getSession());
- }
-
-}
-
-class MySSLSession implements SSLSession {
- /*
- * @see javax.net.ssl.SSLSession#getApplicationBufferSize()
- */
- public int getApplicationBufferSize() {
- return 0;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getCipherSuite()
- */
- public String getCipherSuite() {
- return "MyTestCipherSuite";
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getCreationTime()
- */
- public long getCreationTime() {
- return 0;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getId()
- */
- public byte[] getId() {
- return null;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getLastAccessedTime()
- */
- public long getLastAccessedTime() {
- return 0;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getLocalCertificates()
- */
- public Certificate[] getLocalCertificates() {
- return null;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getLocalPrincipal()
- */
- public Principal getLocalPrincipal() {
- return null;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getPacketBufferSize()
- */
- public int getPacketBufferSize() {
- return 0;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getPeerCertificateChain()
- */
- public X509Certificate[] getPeerCertificateChain()
- throws SSLPeerUnverifiedException {
- throw new SSLPeerUnverifiedException("test exception");
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getPeerCertificates()
- */
- public Certificate[] getPeerCertificates()
- throws SSLPeerUnverifiedException {
- throw new SSLPeerUnverifiedException("test exception");
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getPeerHost()
- */
- public String getPeerHost() {
- return null;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getPeerPort()
- */
- public int getPeerPort() {
- return 0;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getPeerPrincipal()
- */
- public Principal getPeerPrincipal() throws SSLPeerUnverifiedException {
- return null;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getProtocol()
- */
- public String getProtocol() {
- return null;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getSessionContext()
- */
- public SSLSessionContext getSessionContext() {
- return null;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getValue(java.lang.String)
- */
- public Object getValue(String name) {
- return null;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#getValueNames()
- */
- public String[] getValueNames() {
- return null;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#invalidate()
- */
- public void invalidate() {
- }
-
- /*
- * @see javax.net.ssl.SSLSession#isValid()
- */
- public boolean isValid() {
- return false;
- }
-
- /*
- * @see javax.net.ssl.SSLSession#putValue(java.lang.String,
- * java.lang.Object)
- */
- public void putValue(String name, Object value) {
- }
-
- /*
- * @see javax.net.ssl.SSLSession#removeValue(java.lang.String)
- */
- public void removeValue(String name) {
- }
-
-}
-
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSocketTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSocketTest.java
deleted file mode 100644
index a2d75c8..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSocketTest.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.UnknownHostException;
-
-import javax.net.ssl.SSLParameters;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.HandshakeCompletedListener;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SSLSocket</code> class constructors.
- */
-public class SSLSocketTest extends TestCase {
-
- /*
- * Class under test for void SSLSocket()
- */
- public void testSSLSocket() {
- SSLSocket soc = new MySSLSocket();
- try {
- soc.close();
- } catch (IOException e) {
- }
- }
-
- /*
- * Class under test for void SSLSocket(String, int)
- */
- public void testSSLSocketStringint() throws Exception {
- ServerSocket ss = new ServerSocket(0);
- SSLSocket soc = new MySSLSocket("localhost", ss.getLocalPort());
- ss.close();
- soc.close();
- }
-
- /*
- * Class under test for void SSLSocket(InetAddress, int)
- */
- public void testSSLSocketInetAddressint() throws Exception {
- ServerSocket ss = new ServerSocket(0);
- SSLSocket soc = new MySSLSocket(InetAddress.getLocalHost(), ss
- .getLocalPort());
- ss.close();
- soc.close();
- }
-
- /*
- * Class under test for void SSLSocket(String, int, InetAddress, int)
- */
- public void testSSLSocketStringintInetAddressint() throws Exception {
- try {
- ServerSocket ss1 = new ServerSocket(0);
- ServerSocket ss2 = new ServerSocket(0);
- SSLSocket soc = new MySSLSocket("localhost", ss1.getLocalPort(),
- InetAddress.getLocalHost(), ss2.getLocalPort());
- ss1.close();
- ss2.close();
- soc.close();
- } catch (IOException e) {
- }
- }
-
- /*
- * Class under test for void SSLSocket(InetAddress, int, InetAddress, int)
- */
- public void testSSLSocketInetAddressintInetAddressint() throws Exception {
- try {
- ServerSocket ss1 = new ServerSocket(0);
- ServerSocket ss2 = new ServerSocket(0);
- SSLSocket soc = new MySSLSocket(InetAddress.getLocalHost(), ss1
- .getLocalPort(), InetAddress.getLocalHost(), ss2
- .getLocalPort());
- ss1.close();
- ss2.close();
- soc.close();
- } catch (IOException e) {
- }
- }
-}
-
-class MySSLSocket extends SSLSocket {
-
- public MySSLSocket() {
- super();
- }
-
- public MySSLSocket(String host, int port) throws IOException,
- UnknownHostException {
- super(host, port);
- }
-
- protected MySSLSocket(InetAddress address, int port,
- InetAddress clientAddress, int clientPort) throws IOException {
- super(address, port, clientAddress, clientPort);
- }
-
- public MySSLSocket(InetAddress address, int port) throws IOException {
- super(address, port);
- }
-
- public MySSLSocket(String host, int port, InetAddress clientAddress,
- int clientPort) throws IOException, UnknownHostException {
- super(host, port, clientAddress, clientPort);
- }
-
- @Override
- public String[] getSupportedCipherSuites() {
- return null;
- }
-
- @Override
- public String[] getEnabledCipherSuites() {
- return null;
- }
-
- @Override
- public void setEnabledCipherSuites(String[] suites) {
- }
-
- @Override
- public String[] getSupportedProtocols() {
- return null;
- }
-
- @Override
- public String[] getEnabledProtocols() {
- return null;
- }
-
- @Override
- public void setEnabledProtocols(String[] protocols) {
- }
-
- @Override
- public SSLSession getSession() {
- return null;
- }
-
- @Override
- public void addHandshakeCompletedListener(
- HandshakeCompletedListener listener) {
- }
-
- @Override
- public void removeHandshakeCompletedListener(
- HandshakeCompletedListener listener) {
- }
-
- @Override
- public void startHandshake() throws IOException {
- }
-
- @Override
- public void setUseClientMode(boolean mode) {
- }
-
- @Override
- public boolean getUseClientMode() {
- return false;
- }
-
- @Override
- public void setNeedClientAuth(boolean need) {
- }
-
- @Override
- public boolean getNeedClientAuth() {
- return false;
- }
-
- @Override
- public void setWantClientAuth(boolean want) {
- }
-
- @Override
- public boolean getWantClientAuth() {
- return false;
- }
-
- @Override
- public void setEnableSessionCreation(boolean flag) {
- }
-
- @Override
- public boolean getEnableSessionCreation() {
- return false;
- }
-
- @Override
- public SSLParameters getSSLParameters() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setSSLParameters(SSLParameters sslP) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/TrustManagerFactory1Test.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/TrustManagerFactory1Test.java
deleted file mode 100644
index 2c40732..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/TrustManagerFactory1Test.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-
-import javax.net.ssl.ManagerFactoryParameters;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.TrustManagerFactorySpi;
-
-import org.apache.harmony.xnet.tests.support.SpiEngUtils;
-import org.apache.harmony.xnet.tests.support.MyTrustManagerFactorySpi;
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>TrustManagerFactory</code> class constructors and methods.
- */
-
-public class TrustManagerFactory1Test extends TestCase {
-
- private static final String srvTrustManagerFactory = "TrustManagerFactory";
-
- private static String defaultAlgorithm = null;
-
- private static String defaultProviderName = null;
-
- private static Provider defaultProvider = null;
-
- private static boolean DEFSupported = false;
-
- private static final String NotSupportedMsg = "There is no suitable provider for TrustManagerFactory";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static String[] validValues = new String[3];
-
- static {
- defaultAlgorithm = Security
- .getProperty("ssl.TrustManagerFactory.algorithm");
- if (defaultAlgorithm != null) {
- defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm,
- srvTrustManagerFactory);
- DEFSupported = (defaultProvider != null);
- defaultProviderName = (DEFSupported ? defaultProvider.getName()
- : null);
- validValues[0] = defaultAlgorithm;
- validValues[1] = defaultAlgorithm.toUpperCase();
- validValues[2] = defaultAlgorithm.toLowerCase();
- }
- }
-
- protected TrustManagerFactory[] createTMFac() {
- if (!DEFSupported) {
- fail(defaultAlgorithm + " algorithm is not supported");
- return null;
- }
- TrustManagerFactory[] tMF = new TrustManagerFactory[3];
- try {
- tMF[0] = TrustManagerFactory.getInstance(defaultAlgorithm);
- tMF[1] = TrustManagerFactory.getInstance(defaultAlgorithm,
- defaultProvider);
- tMF[2] = TrustManagerFactory.getInstance(defaultAlgorithm,
- defaultProviderName);
- return tMF;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- /**
- * Test for <code>getDefaultAlgorithm()</code> method
- * Assertion: returns value which is specifoed in security property
- */
- public void testGetDefaultAlgorithm() {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- String def = TrustManagerFactory.getDefaultAlgorithm();
- if (defaultAlgorithm == null) {
- assertNull("DefaultAlgorithm must be null", def);
- } else {
- assertEquals("Invalid default algorithm", def, defaultAlgorithm);
- }
- String defA = "Proba.trustmanagerfactory.defaul.type";
- Security.setProperty("ssl.TrustManagerFactory.algorithm", defA);
- assertEquals("Incorrect defaultAlgorithm",
- TrustManagerFactory.getDefaultAlgorithm(), defA);
- if (def == null) {
- def = "";
- }
- Security.setProperty("ssl.TrustManagerFactory.algorithm", def);
- assertEquals("Incorrect defaultAlgorithm",
- TrustManagerFactory.getDefaultAlgorithm(), def);
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions: returns security property "ssl.TrustManagerFactory.algorithm";
- * returns instance of TrustManagerFactory
- */
- public void testTrustManagerFactory01() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- TrustManagerFactory trustMF;
- for (int i = 0; i < validValues.length; i++) {
- trustMF = TrustManagerFactory.getInstance(validValues[i]);
- assertTrue("Not TrustManagerFactory object",
- trustMF instanceof TrustManagerFactory);
- assertEquals("Invalid algorithm", trustMF.getAlgorithm(),
- validValues[i]);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- */
- public void testTrustManagerFactory02() {
- try {
- TrustManagerFactory.getInstance(null);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- TrustManagerFactory.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException was not thrown as expected for algorithm: "
- .concat(invalidValues[i]));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion: throws IllegalArgumentException when provider is null
- * or empty
- */
- public void testTrustManagerFactory03() throws NoSuchProviderException,
- NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- String provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- TrustManagerFactory.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- try {
- TrustManagerFactory.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- */
- public void testTrustManagerFactory04() throws NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- try {
- TrustManagerFactory.getInstance(null, defaultProviderName);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- TrustManagerFactory.getInstance(invalidValues[i],
- defaultProviderName);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion: throws NoSuchProviderException when provider has
- * invalid value
- */
- public void testTrustManagerFactory05() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- for (int i = 1; i < invalidValues.length; i++) {
- for (int j = 0; j < validValues.length; j++) {
- try {
- TrustManagerFactory.getInstance(validValues[j],
- invalidValues[i]);
- fail("NuSuchProviderException must be thrown (algorithm: "
- .concat(validValues[j]).concat(" provider: ")
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion: returns instance of TrustManagerFactory
- */
- public void testTrustManagerFactory06() throws NoSuchAlgorithmException,
- NoSuchProviderException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- TrustManagerFactory trustMF;
- for (int i = 0; i < validValues.length; i++) {
- trustMF = TrustManagerFactory.getInstance(validValues[i],
- defaultProviderName);
- assertTrue("Not TrustManagerFactory object",
- trustMF instanceof TrustManagerFactory);
- assertEquals("Invalid algorithm", trustMF.getAlgorithm(),
- validValues[i]);
- assertEquals("Invalid provider", trustMF.getProvider(),
- defaultProvider);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion: throws IllegalArgumentException when provider is null
- */
- public void testTrustManagerFactory07() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- Provider provider = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- TrustManagerFactory.getInstance(validValues[i], provider);
- fail("IllegalArgumentException must be thrown when provider is null");
- } catch (IllegalArgumentException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- */
- public void testTrustManagerFactory08() {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- try {
- TrustManagerFactory.getInstance(null, defaultProvider);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- TrustManagerFactory.getInstance(invalidValues[i],
- defaultProvider);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion: returns instance of TrustManagerFactory
- */
- public void testTrustManagerFactory09() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- TrustManagerFactory trustMF;
- for (int i = 0; i < validValues.length; i++) {
- trustMF = TrustManagerFactory.getInstance(validValues[i],
- defaultProvider);
- assertTrue("Not TrustManagerFactory object",
- trustMF instanceof TrustManagerFactory);
- assertEquals("Invalid algorithm", trustMF.getAlgorithm(),
- validValues[i]);
- assertEquals("Invalid provider", trustMF.getProvider(),
- defaultProvider);
- }
- }
-
- /**
- * Test for
- * <code>TrustManagerFactory(TrustManagerFactorySpi impl, Provider prov, String algoriyjm) </code>
- * constructor
- * Assertion: created new TrustManagerFactory object
- */
- public void testTrustManagerFactory10() throws NoSuchAlgorithmException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- TrustManagerFactorySpi spi = new MyTrustManagerFactorySpi();
- TrustManagerFactory tmF = new myTrustManagerFactory(spi, defaultProvider,
- defaultAlgorithm);
- assertTrue("Not CertStore object", tmF instanceof TrustManagerFactory);
- assertEquals("Incorrect algorithm", tmF.getAlgorithm(),
- defaultAlgorithm);
- assertEquals("Incorrect provider", tmF.getProvider(), defaultProvider);
- assertNull("Incorrect result", tmF.getTrustManagers());
-
- tmF = new myTrustManagerFactory(null, null, null);
- assertTrue("Not CertStore object", tmF instanceof TrustManagerFactory);
- assertNull("Provider must be null", tmF.getProvider());
- assertNull("Algorithm must be null", tmF.getAlgorithm());
- try {
- tmF.getTrustManagers();
- fail("NullPointerException must be thrown");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test for <code>init(KeyStore keyStore)</code> and
- * <code>getTrustManagers()</code>
- * Assertion: returns not empty TrustManager array
- */
- public void testTrustManagerFactory11() throws Exception {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- KeyStore ks;
- KeyStore ksNull = null;
- ks = KeyStore.getInstance(KeyStore.getDefaultType());
- ks.load(null, null);
-
- TrustManager[] tm;
- TrustManagerFactory[] trustMF = createTMFac();
- assertNotNull("TrustManagerFactory objects were not created", trustMF);
- for (int i = 0; i < trustMF.length; i++) {
- try {
- trustMF[i].init(ksNull);
- } catch (KeyStoreException e) {
- }
- trustMF[i].init(ks);
- tm = trustMF[i].getTrustManagers();
- assertNotNull("Result has not be null", tm);
- assertTrue("Length of result TrustManager array should not be 0",
- (tm.length > 0));
- }
- }
-
- /**
- * Test for <code>init(ManagerFactoryParameters params)</code>
- * Assertion:
- * throws InvalidAlgorithmParameterException when params is null
- */
- public void testTrustManagerFactory12() throws NoSuchAlgorithmException,
- KeyStoreException, InvalidAlgorithmParameterException {
- if (!DEFSupported) {
- fail(NotSupportedMsg);
- return;
- }
- ManagerFactoryParameters par = null;
- ManagerFactoryParameters par1 = new myManagerFactoryParam();
- TrustManagerFactory[] trustMF = createTMFac();
- assertNotNull("TrustManagerFactory objects were not created", trustMF);
- for (int i = 0; i < trustMF.length; i++) {
- try {
- trustMF[i].init(par);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- try {
- trustMF[i].init(par1);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
- }
-
-}
-
-/**
- * Addifional class to verify TrustManagerFactory constructor
- */
-
-class myTrustManagerFactory extends TrustManagerFactory {
- public myTrustManagerFactory(TrustManagerFactorySpi spi, Provider prov,
- String alg) {
- super(spi, prov, alg);
- }
-}
-
-class myManagerFactoryParam implements ManagerFactoryParameters {
-
-} \ No newline at end of file
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/TrustManagerFactory2Test.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/TrustManagerFactory2Test.java
deleted file mode 100644
index beeac80..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/TrustManagerFactory2Test.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-
-import javax.net.ssl.ManagerFactoryParameters;
-import javax.net.ssl.TrustManagerFactory;
-
-import org.apache.harmony.xnet.tests.support.SpiEngUtils;
-import org.apache.harmony.xnet.tests.support.MyTrustManagerFactorySpi;
-import junit.framework.TestCase;
-
-/**
- * Tests for TrustManagerFactory class constructors and methods
- */
-
-public class TrustManagerFactory2Test extends TestCase {
- private static final String srvTrustManagerFactory = "TrustManagerFactory";
- private static final String defaultAlg = "TMF";
- private static final String TrustManagerFactoryProviderClass = "org.apache.harmony.xnet.tests.support.MyTrustManagerFactorySpi";
-
- private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
- private static final String[] validValues;
-
- static {
- validValues = new String[4];
- validValues[0] = defaultAlg;
- validValues[1] = defaultAlg.toLowerCase();
- validValues[2] = "Tmf";
- validValues[3] = "tMF";
- }
-
- Provider mProv;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mProv = (new SpiEngUtils()).new MyProvider("MyTMFProvider",
- "Provider for testing", srvTrustManagerFactory.concat(".")
- .concat(defaultAlg), TrustManagerFactoryProviderClass);
- Security.insertProviderAt(mProv, 1);
- }
-
- /*
- * @see TestCase#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(mProv.getName());
- }
-
- private void checkResult(TrustManagerFactory tmf) throws Exception {
- KeyStore kStore = null;
- ManagerFactoryParameters mfp = null;
-
- try {
- tmf.init(kStore);
- fail("KeyStoreException must be thrown");
- } catch (KeyStoreException e) {
- }
- try {
- tmf.init(mfp);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- assertNull("getTrustManagers() should return null object", tmf
- .getTrustManagers());
-
- try {
- kStore = KeyStore.getInstance(KeyStore.getDefaultType());
- kStore.load(null, null);
- } catch (KeyStoreException e) {
- fail("default keystore is not supported");
- return;
- }
- tmf.init(kStore);
- mfp = (ManagerFactoryParameters) new MyTrustManagerFactorySpi.Parameters(null);
- try {
- tmf.init(mfp);
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertTrue("Incorrect exception", e.getCause() instanceof KeyStoreException);
- }
- mfp = (ManagerFactoryParameters) new MyTrustManagerFactorySpi.Parameters(kStore);
- tmf.init(mfp);
- }
-
- /**
- * Test for <code>getInstance(String algorithm)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- * returns TrustManagerFactory object
- */
- public void testGetInstance01() throws Exception {
- try {
- TrustManagerFactory.getInstance(null);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- TrustManagerFactory.getInstance(invalidValues[i]);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- TrustManagerFactory tmf;
- for (int i = 0; i < validValues.length; i++) {
- tmf = TrustManagerFactory.getInstance(validValues[i]);
- assertTrue("Not instanceof TrustManagerFactory object",
- tmf instanceof TrustManagerFactory);
- assertEquals("Incorrect algorithm", tmf.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", tmf.getProvider(), mProv);
- checkResult(tmf);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- * throws IllegalArgumentException when provider is null or empty;
- * throws NoSuchProviderException when provider is available;
- * returns TrustManagerFactory object
- */
- public void testGetInstance02() throws Exception {
- try {
- TrustManagerFactory.getInstance(null, mProv.getName());
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- TrustManagerFactory.getInstance(invalidValues[i], mProv
- .getName());
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- String prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- TrustManagerFactory.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- try {
- TrustManagerFactory.getInstance(validValues[i], "");
- fail("IllegalArgumentException must be thrown when provider is empty (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- for (int i = 0; i < validValues.length; i++) {
- for (int j = 1; j < invalidValues.length; j++) {
- try {
- TrustManagerFactory.getInstance(validValues[i],
- invalidValues[j]);
- fail("NoSuchProviderException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(" provider: ")
- .concat(invalidValues[j]).concat(")"));
- } catch (NoSuchProviderException e) {
- }
- }
- }
- TrustManagerFactory tmf;
- for (int i = 0; i < validValues.length; i++) {
- tmf = TrustManagerFactory.getInstance(validValues[i], mProv
- .getName());
- assertTrue("Not instanceof TrustManagerFactory object",
- tmf instanceof TrustManagerFactory);
- assertEquals("Incorrect algorithm", tmf.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", tmf.getProvider().getName(),
- mProv.getName());
- checkResult(tmf);
- }
- }
-
- /**
- * Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null;
- * throws NoSuchAlgorithmException when algorithm is not correct;
- * throws IllegalArgumentException when provider is null;
- * returns TrustManagerFactory object
- */
- public void testGetInstance03() throws Exception {
- try {
- TrustManagerFactory.getInstance(null, mProv);
- fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
- } catch (NoSuchAlgorithmException e) {
- } catch (NullPointerException e) {
- }
- for (int i = 0; i < invalidValues.length; i++) {
- try {
- TrustManagerFactory.getInstance(invalidValues[i], mProv);
- fail("NoSuchAlgorithmException must be thrown (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (NoSuchAlgorithmException e) {
- }
- }
- Provider prov = null;
- for (int i = 0; i < validValues.length; i++) {
- try {
- TrustManagerFactory.getInstance(validValues[i], prov);
- fail("IllegalArgumentException must be thrown when provider is null (algorithm: "
- .concat(invalidValues[i]).concat(")"));
- } catch (IllegalArgumentException e) {
- }
- }
- TrustManagerFactory tmf;
- for (int i = 0; i < validValues.length; i++) {
- tmf = TrustManagerFactory.getInstance(validValues[i], mProv);
- assertTrue("Not instanceof TrustManagerFactory object",
- tmf instanceof TrustManagerFactory);
- assertEquals("Incorrect algorithm", tmf.getAlgorithm(),
- validValues[i]);
- assertEquals("Incorrect provider", tmf.getProvider(), mProv);
- checkResult(tmf);
- }
- }
-} \ No newline at end of file
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/X509ExtendedKeyManagerTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/X509ExtendedKeyManagerTest.java
deleted file mode 100644
index 811b17a..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/X509ExtendedKeyManagerTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl;
-
-import java.net.Socket;
-import java.security.Principal;
-import java.security.PrivateKey;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.X509ExtendedKeyManager;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>X509ExtendedKeyManager</code> class constructors and methods.
- */
-public class X509ExtendedKeyManagerTest extends TestCase {
-
- public final void testChooseEngineClientAlias() {
- X509ExtendedKeyManager km = new MyX509ExtendedKeyManager();
- if (km.chooseEngineClientAlias(null, null, null) != null) {
- fail("non null result");
- }
- }
-
- public final void testChooseEngineServerAlias() {
- X509ExtendedKeyManager km = new MyX509ExtendedKeyManager();
- if (km.chooseEngineServerAlias(null, null, null) != null) {
- fail("non null result");
- }
- }
-
-}
-
-class MyX509ExtendedKeyManager extends X509ExtendedKeyManager {
-
- /*
- * @see javax.net.ssl.X509KeyManager#chooseClientAlias(java.lang.String[],
- * java.security.Principal[], java.net.Socket)
- */
- public String chooseClientAlias(String[] keyType, Principal[] issuers,
- Socket socket) {
- return null;
- }
-
- /*
- * @see javax.net.ssl.X509KeyManager#chooseServerAlias(java.lang.String,
- * java.security.Principal[], java.net.Socket)
- */
- public String chooseServerAlias(String keyType, Principal[] issuers,
- Socket socket) {
- return null;
- }
-
- /*
- * @see javax.net.ssl.X509KeyManager#getCertificateChain(java.lang.String)
- */
- public X509Certificate[] getCertificateChain(String alias) {
- return null;
- }
-
- /*
- * @see javax.net.ssl.X509KeyManager#getClientAliases(java.lang.String,
- * java.security.Principal[])
- */
- public String[] getClientAliases(String keyType, Principal[] issuers) {
- return null;
- }
-
- /*
- * @see javax.net.ssl.X509KeyManager#getServerAliases(java.lang.String,
- * java.security.Principal[])
- */
- public String[] getServerAliases(String keyType, Principal[] issuers) {
- return null;
- }
-
- /*
- * @see javax.net.ssl.X509KeyManager#getPrivateKey(java.lang.String)
- */
- public PrivateKey getPrivateKey(String alias) {
- return null;
- }
-
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/HandshakeCompletedEventTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/HandshakeCompletedEventTest.java
deleted file mode 100644
index 6839ebc..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/HandshakeCompletedEventTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl.serialization;
-
-import java.io.Serializable;
-
-import javax.net.ssl.HandshakeCompletedEvent;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocket;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-/**
- * Test for HandshakeCompletedEvent serialization
- */
-
-public class HandshakeCompletedEventTest extends SerializationTest implements
- SerializationTest.SerializableAssert {
-
- @Override
- protected Object[] getData() {
- try {
- SSLContext cont = SSLContext.getInstance("TLS");
- cont.init(null, null, null);
- SSLSocket soc = (SSLSocket) cont.getSocketFactory().createSocket();
- return new Object[] { new HandshakeCompletedEvent(soc, soc.getSession()) };
- } catch (Exception e) {
- fail("Can not create data: " + e);
- return null;
- }
-
- }
-
- public void assertDeserialized(Serializable oref, Serializable otest) {
- HandshakeCompletedEvent test = (HandshakeCompletedEvent) otest;
- test.getSession();
- test.getSocket();
- }
-} \ No newline at end of file
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.java
deleted file mode 100644
index 518120c..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl.serialization;
-
-import javax.net.ssl.SSLException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for SSLException serialization
- */
-
-public class SSLExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- @Override
- protected Object[] getData() {
- String msg = null;
- Exception cause = new Exception(msgs[1]);
- SSLException excSSL = new SSLException(msgs[0]);
- return new Object[] { new SSLException(msg), new SSLException(msgs[1]),
- new SSLException(excSSL), new SSLException(cause),
- new SSLException(msgs[1], cause) };
- }
-} \ No newline at end of file
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.java
deleted file mode 100644
index f1e16c3..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl.serialization;
-
-import javax.net.ssl.SSLHandshakeException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for SSLHandshakeException seialization
- */
-
-public class SSLHandshakeExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- @Override
- protected Object[] getData() {
- return new Object[] { new SSLHandshakeException(null),
- new SSLHandshakeException(msgs[0]), new SSLHandshakeException(msgs[1]) };
- }
-
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.java
deleted file mode 100644
index 5db4c67..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl.serialization;
-
-import javax.net.ssl.SSLKeyException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for SSLKeyException serialization
- */
-
-public class SSLKeyExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- @Override
- protected Object[] getData() {
- return new Object[] { new SSLKeyException(null),
- new SSLKeyException(msgs[0]), new SSLKeyException(msgs[1]) };
- }
-
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.java
deleted file mode 100644
index ee5f844..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl.serialization;
-
-import javax.net.ssl.SSLPeerUnverifiedException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for SSLPeerUnverifiedException serialization
- */
-
-public class SSLPeerUnverifiedExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- @Override
- protected Object[] getData() {
- return new Object[] { new SSLPeerUnverifiedException(null),
- new SSLPeerUnverifiedException(msgs[0]), new SSLPeerUnverifiedException(msgs[1]) };
- }
-
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.java
deleted file mode 100644
index 999ea0b..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl.serialization;
-
-import javax.net.ssl.SSLProtocolException;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Test for SSLProtocolException serialization
- */
-
-public class SSLProtocolExceptionTest extends SerializationTest {
-
- public static String[] msgs = {
- "New message",
- "Long message for Exception. Long message for Exception. Long message for Exception." };
-
- @Override
- protected Object[] getData() {
- return new Object[] { new SSLProtocolException(null),
- new SSLProtocolException(msgs[0]), new SSLProtocolException(msgs[1]) };
- }
-
-}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLSessionBindingEventTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLSessionBindingEventTest.java
deleted file mode 100644
index d87511a..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLSessionBindingEventTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.javax.net.ssl.serialization;
-
-import java.io.Serializable;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSessionBindingEvent;
-import javax.net.ssl.SSLSocket;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-/**
- * Test for SSLSessionBindingEvent serialization
- */
-
-public class SSLSessionBindingEventTest extends SerializationTest implements
- SerializationTest.SerializableAssert {
-
- @Override
- protected Object[] getData() {
- try {
- SSLContext cont = SSLContext.getInstance("TLS");
- cont.init(null, null, null);
- SSLSocket soc = (SSLSocket) cont.getSocketFactory().createSocket();
- return new Object[] { new SSLSessionBindingEvent(soc.getSession(), "someName") };
- } catch (Exception e) {
- fail("Can not create data: " + e);
- return null;
- }
- }
-
- public void assertDeserialized(Serializable oref, Serializable otest) {
- SSLSessionBindingEvent ref = (SSLSessionBindingEvent) oref;
- SSLSessionBindingEvent test = (SSLSessionBindingEvent) otest;
- assertEquals(ref.getName(), test.getName());
- }
-} \ No newline at end of file
diff --git a/x-net/src/test/impl/java.injected/javax/net/ServerSocketFactoryTest.java b/x-net/src/test/impl/java.injected/javax/net/ServerSocketFactoryTest.java
deleted file mode 100644
index 5843453..0000000
--- a/x-net/src/test/impl/java.injected/javax/net/ServerSocketFactoryTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package javax.net;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>ServerSocketFactory</code> class constructors and methods.
- */
-
-public class ServerSocketFactoryTest extends TestCase {
- /*
- * Class under test for java.net.ServerSocket createServerSocket()
- */
- public final void testCreateServerSocket() {
- ServerSocketFactory sf = new MyServerSocketFactory();
- try {
- sf.createServerSocket();
- fail("No expected SocketException");
- } catch (SocketException e) {
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-
- /*
- * Class under test for javax.net.ServerSocketFactory getDefault()
- */
- public final void testGetDefault() {
- ServerSocketFactory sf = ServerSocketFactory.getDefault();
- ServerSocket s;
- if (!(sf instanceof DefaultServerSocketFactory)) {
- fail("Incorrect class instance");
- }
- try {
- s = sf.createServerSocket(0);
- s.close();
- } catch (IOException e) {
- }
- try {
- s = sf.createServerSocket(0, 50);
- s.close();
- } catch (IOException e) {
- }
- try {
- s = sf.createServerSocket(0, 50, InetAddress.getLocalHost());
- s.close();
- } catch (IOException e) {
- }
- }
-}
-
-class MyServerSocketFactory extends ServerSocketFactory {
- @Override
- public ServerSocket createServerSocket(int port) throws IOException, UnknownHostException {
- throw new IOException();
- }
-
- @Override
- public ServerSocket createServerSocket(int port, int backlog)
- throws IOException, UnknownHostException {
- throw new IOException();
- }
-
- @Override
- public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException {
- throw new IOException();
- }
-}
diff --git a/x-net/src/test/impl/java.injected/javax/net/SocketFactoryTest.java b/x-net/src/test/impl/java.injected/javax/net/SocketFactoryTest.java
deleted file mode 100644
index 54718e4..0000000
--- a/x-net/src/test/impl/java.injected/javax/net/SocketFactoryTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package javax.net;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SocketFactory</code> class methods.
- */
-public class SocketFactoryTest extends TestCase {
-
- /*
- * Class under test for java.net.Socket createSocket()
- */
- public final void testCreateSocket() {
- SocketFactory sf = new MySocketFactory();
- try {
- sf.createSocket();
- fail("No expected SocketException");
- } catch (SocketException e) {
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-
- /*
- * Class under test for javax.net.SocketFactory getDefault()
- */
- public final void testGetDefault() {
- SocketFactory sf = SocketFactory.getDefault();
- Socket s;
- if (!(sf instanceof DefaultSocketFactory)) {
- fail("Incorrect class instance");
- }
- try {
- s = sf.createSocket("localhost", 8082);
- s.close();
- } catch (IOException e) {
- }
- try {
- s = sf.createSocket("localhost", 8081, InetAddress.getLocalHost(), 8082);
- s.close();
- } catch (IOException e) {
- }
- try {
- s = sf.createSocket(InetAddress.getLocalHost(), 8081);
- s.close();
- } catch (IOException e) {
- }
- try {
- s = sf.createSocket(InetAddress.getLocalHost(), 8081, InetAddress.getLocalHost(), 8082);
- s.close();
- } catch (IOException e) {
- }
- }
-}
-
-class MySocketFactory extends SocketFactory {
- @Override
- public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
- throw new IOException();
- }
-
- @Override
- public Socket createSocket(String host, int port, InetAddress localHost, int localPort)
- throws IOException, UnknownHostException {
- throw new IOException();
- }
-
- @Override
- public Socket createSocket(InetAddress host, int port) throws IOException {
- throw new IOException();
- }
-
- @Override
- public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
- throws IOException {
- throw new IOException();
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/javax/net/ssl/DefaultSSLServerSocketFactoryTest.java b/x-net/src/test/impl/java.injected/javax/net/ssl/DefaultSSLServerSocketFactoryTest.java
deleted file mode 100644
index 8260e83..0000000
--- a/x-net/src/test/impl/java.injected/javax/net/ssl/DefaultSSLServerSocketFactoryTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package javax.net.ssl;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.SocketException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>DefaultSSLServerSocketFactory</code> class constructors and methods.
- */
-public class DefaultSSLServerSocketFactoryTest extends TestCase {
-
- /*
- * Class under test for ServerSocket createServerSocket(int)
- */
- public void testCreateServerSocketint() {
- DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR");
- try {
- f.createServerSocket(0);
- fail("No expected SocketException");
- } catch (SocketException e) {
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-
- /*
- * Class under test for ServerSocket createServerSocket(int, int)
- */
- public void testCreateServerSocketintint() {
- DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR");
- try {
- f.createServerSocket(0, 10);
- fail("No expected SocketException");
- } catch (SocketException e) {
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-
- /*
- * Class under test for ServerSocket createServerSocket(int, int, InetAddress)
- */
- public void testCreateServerSocketintintInetAddress() {
- DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR");
- try {
- f.createServerSocket(0, 10, InetAddress.getLocalHost());
- fail("No expected SocketException");
- } catch (SocketException e) {
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-
- public void testGetDefaultCipherSuites() {
- DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR");
- String[] res = f.getDefaultCipherSuites();
- if (res == null || res.length != 0) {
- fail("incorrect result");
- }
- }
-
- public void testGetSupportedCipherSuites() {
- DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR");
- String[] res = f.getSupportedCipherSuites();
- if (res == null || res.length != 0) {
- fail("incorrect result");
- }
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/javax/net/ssl/DefaultSSLSocketFactoryTest.java b/x-net/src/test/impl/java.injected/javax/net/ssl/DefaultSSLSocketFactoryTest.java
deleted file mode 100644
index e7fcec7..0000000
--- a/x-net/src/test/impl/java.injected/javax/net/ssl/DefaultSSLSocketFactoryTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package javax.net.ssl;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.SocketException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>DefaultSSLSocketFactory</code> class constructors and
- * methods.
- */
-public class DefaultSSLSocketFactoryTest extends TestCase {
-
- /*
- * Class under test for Socket createSocket(String, int)
- */
- public void testCreateSocketStringint() {
- DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
- try {
- f.createSocket("localhost", 0);
- fail("No expected SocketException");
- } catch (SocketException e) {
- } catch (IOException e) {
- fail(e.toString());
- }
-
- }
-
- /*
- * Class under test for Socket createSocket(String, int, InetAddress, int)
- */
- public void testCreateSocketStringintInetAddressint() {
- DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
- try {
- f.createSocket("localhost", 0, InetAddress.getLocalHost(), 1);
- fail("No expected SocketException");
- } catch (SocketException e) {
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-
- /*
- * Class under test for Socket createSocket(InetAddress, int)
- */
- public void testCreateSocketInetAddressint() {
- DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
- try {
- f.createSocket(InetAddress.getLocalHost(), 1);
- fail("No expected SocketException");
- } catch (SocketException e) {
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-
- /*
- * Class under test for Socket createSocket(InetAddress, int, InetAddress,
- * int)
- */
- public void testCreateSocketInetAddressintInetAddressint() {
- DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
- try {
- f.createSocket(InetAddress.getLocalHost(), 1, InetAddress
- .getLocalHost(), 2);
- fail("No expected SocketException");
- } catch (SocketException e) {
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-
- public void testGetDefaultCipherSuites() {
- DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
- String[] res = f.getDefaultCipherSuites();
- if (res == null || res.length != 0) {
- fail("incorrect result");
- }
- }
-
- public void testGetSupportedCipherSuites() {
- DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
- String[] res = f.getSupportedCipherSuites();
- if (res == null || res.length != 0) {
- fail("incorrect result");
- }
- }
-
- /*
- * Class under test for Socket createSocket(Socket, String, int, boolean)
- */
- public void testCreateSocketSocketStringintboolean() {
- DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
- try {
- f.createSocket(new Socket(), "localhost", 1, true);
- fail("No expected SocketException");
- } catch (SocketException e) {
- } catch (IOException e) {
- fail(e.toString());
- }
- }
-}
diff --git a/x-net/src/test/impl/java.injected/javax/net/ssl/HttpsURLConnection_ImplTest.java b/x-net/src/test/impl/java.injected/javax/net/ssl/HttpsURLConnection_ImplTest.java
deleted file mode 100644
index 3985544..0000000
--- a/x-net/src/test/impl/java.injected/javax/net/ssl/HttpsURLConnection_ImplTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package javax.net.ssl;
-
-import java.io.IOException;
-import java.net.URL;
-import java.security.cert.Certificate;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>HttpsURLConnection</code> class constructors and methods.
- */
-public class HttpsURLConnection_ImplTest extends TestCase {
-
- public final void testGetDefaultHostnameVerifier() {
-
- HostnameVerifier ver = HttpsURLConnection.getDefaultHostnameVerifier();
- if (!(ver instanceof DefaultHostnameVerifier)) {
- fail("Incorrect instance");
- }
- if (ver.verify("localhost", null)) {
- fail("connection should not be permitted");
- }
- }
-
- public final void testGetHostnameVerifier() {
-
- HttpsURLConnection con = new MyHttpsURLConnection(null);
- HostnameVerifier ver = con.getHostnameVerifier();
- if (!(ver instanceof DefaultHostnameVerifier)) {
- fail("Incorrect instance");
- }
- if (ver.verify("localhost", null)) {
- fail("connection should not be permitted");
- }
- }
-}
-
-class MyHttpsURLConnection extends HttpsURLConnection {
-
- public MyHttpsURLConnection(URL url) {
- super(url);
- }
-
- /*
- * @see javax.net.ssl.HttpsURLConnection#getCipherSuite()
- */
- @Override
- public String getCipherSuite() {
- return null;
- }
-
- /*
- * @see javax.net.ssl.HttpsURLConnection#getLocalCertificates()
- */
- @Override
- public Certificate[] getLocalCertificates() {
- return null;
- }
-
- /*
- * @see javax.net.ssl.HttpsURLConnection#getServerCertificates()
- */
- @Override
- public Certificate[] getServerCertificates()
- throws SSLPeerUnverifiedException {
- return null;
- }
-
- /*
- * @see java.net.HttpURLConnection#disconnect()
- */
- @Override
- public void disconnect() {
- }
-
- /*
- * @see java.net.HttpURLConnection#usingProxy()
- */
- @Override
- public boolean usingProxy() {
- return false;
- }
-
- /*
- * @see java.net.URLConnection#connect()
- */
- @Override
- public void connect() throws IOException {
- }
-}
diff --git a/x-net/src/test/impl/java.injected/javax/net/ssl/SSLServerSocketFactoryTest.java b/x-net/src/test/impl/java.injected/javax/net/ssl/SSLServerSocketFactoryTest.java
deleted file mode 100644
index 9350577..0000000
--- a/x-net/src/test/impl/java.injected/javax/net/ssl/SSLServerSocketFactoryTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package javax.net.ssl;
-
-import java.io.IOException;
-import java.security.Security;
-import java.net.SocketException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SSLSocketFactory</code> class methods.
- */
-public class SSLServerSocketFactoryTest extends TestCase {
-
- private SSLServerSocketFactory customServerSocketFactory;
-
- /*
- * @see TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- String defaultName = Security.getProperty("ssl.ServerSocketFactory.provider");
- if (defaultName != null) {
- try {
- customServerSocketFactory = (SSLServerSocketFactory) Class.forName(
- defaultName, true, ClassLoader.getSystemClassLoader())
- .newInstance();
- } catch (Exception e) {
- }
- }
- if (customServerSocketFactory == null) {
- SSLContext context = DefaultSSLContext.getContext();
- if (context != null) {
- customServerSocketFactory = context.getServerSocketFactory();
- }
- }
- }
-
- /*
- * @see TestCase#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public final void testGetDefault() {
- SSLServerSocketFactory factory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
- if (customServerSocketFactory != null) {
- if (!factory.getClass().getName().equals(customServerSocketFactory.getClass().getName())) {
- fail("incorrect instance: " + factory.getClass() +
- " expected: " + customServerSocketFactory.getClass().getName());
- }
- } else {
- if (!(factory instanceof DefaultSSLServerSocketFactory)) {
- fail("incorrect instance " + factory.getClass());
- }
- if (factory.getDefaultCipherSuites().length != 0) {
- fail("incorrect result: DefaultSSLServerSocketFactory.getDefaultCipherSuites()");
- }
- if (factory.getSupportedCipherSuites().length != 0) {
- fail("incorrect result: DefaultSSLServerSocketFactory.getDefaultCipherSuites()");
- }
- try {
- factory.createServerSocket(0);
- fail("No expected SocketException");
- } catch (SocketException e) {
- } catch (IOException e) {
- fail(e.toString());
- }
- }
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/javax/net/ssl/SSLSocketFactoryTest.java b/x-net/src/test/impl/java.injected/javax/net/ssl/SSLSocketFactoryTest.java
deleted file mode 100644
index 2c1a37b..0000000
--- a/x-net/src/test/impl/java.injected/javax/net/ssl/SSLSocketFactoryTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Boris V. Kuznetsov
- */
-
-package javax.net.ssl;
-
-import java.io.IOException;
-import java.security.Security;
-import java.net.SocketException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SSLSocketFactory</code> class methods.
- */
-public class SSLSocketFactoryTest extends TestCase {
-
- private SSLSocketFactory customSocketFactory;
-
- /*
- * @see TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- String defaultName = Security.getProperty("ssl.SocketFactory.provider");
- if (defaultName != null) {
- try {
- customSocketFactory = (SSLSocketFactory) Class.forName(
- defaultName, true, ClassLoader.getSystemClassLoader())
- .newInstance();
- } catch (Exception e) {
- }
- }
- if (customSocketFactory == null) {
- SSLContext context = DefaultSSLContext.getContext();
- if (context != null) {
- customSocketFactory = context.getSocketFactory();
- }
- }
- }
-
- /*
- * @see TestCase#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public final void testGetDefault() {
- SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
- if (customSocketFactory != null) {
- if (!factory.getClass().getName().equals(customSocketFactory.getClass().getName())) {
- fail("incorrect instance: " + factory.getClass() +
- " expected: " + customSocketFactory.getClass().getName());
- }
- } else {
- if (!(factory instanceof DefaultSSLSocketFactory)) {
- fail("incorrect instance " + factory.getClass());
- }
- if (factory.getDefaultCipherSuites().length != 0) {
- fail("incorrect result: DefaultSSLSocketFactory.getDefaultCipherSuites()");
- }
- if (factory.getSupportedCipherSuites().length != 0) {
- fail("incorrect result: DefaultSSLSocketFactory.getDefaultCipherSuites()");
- }
- try {
- factory.createSocket("localhost", 2021);
- fail("No expected SocketException");
- } catch (SocketException e) {
- } catch (IOException e) {
- fail(e.toString());
- }
- }
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateMessageTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateMessageTest.java
deleted file mode 100644
index c852b22..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateMessageTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertificateMessage</code> constructor and methods
- */
-public class CertificateMessageTest extends TestCase {
-
- private static String base64certEncoding = "-----BEGIN CERTIFICATE-----\n"
- + "MIIC+jCCAragAwIBAgICAiswDAYHKoZIzjgEAwEBADAdMRswGQYDVQQKExJDZXJ0a"
- + "WZpY2F0ZSBJc3N1ZXIwIhgPMTk3MDAxMTIxMzQ2NDBaGA8xOTcwMDEyNDAzMzMyMF"
- + "owHzEdMBsGA1UEChMUU3ViamVjdCBPcmdhbml6YXRpb24wGTAMBgcqhkjOOAQDAQE"
- + "AAwkAAQIDBAUGBwiBAgCqggIAVaOCAhQwggIQMA8GA1UdDwEB/wQFAwMBqoAwEgYD"
- + "VR0TAQH/BAgwBgEB/wIBBTAUBgNVHSABAf8ECjAIMAYGBFUdIAAwZwYDVR0RAQH/B"
- + "F0wW4EMcmZjQDgyMi5OYW1lggdkTlNOYW1lpBcxFTATBgNVBAoTDE9yZ2FuaXphdG"
- + "lvboYaaHR0cDovL3VuaWZvcm0uUmVzb3VyY2UuSWSHBP///wCIByoDolyDsgMwDAY"
- + "DVR0eAQH/BAIwADAMBgNVHSQBAf8EAjAAMIGZBgNVHSUBAf8EgY4wgYsGBFUdJQAG"
- + "CCsGAQUFBwMBBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMDBggrBgEFBQcDB"
- + "AYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEFBQcDBwYIKwYBBQUHAwgGCCsGAQUFBw"
- + "MJBggrBgEFBQgCAgYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GA1UdNgEB/wQDAgE"
- + "BMA4GBCpNhgkBAf8EAwEBATBkBgNVHRIEXTBbgQxyZmNAODIyLk5hbWWCB2ROU05h"
- + "bWWkFzEVMBMGA1UEChMMT3JnYW5pemF0aW9uhhpodHRwOi8vdW5pZm9ybS5SZXNvd"
- + "XJjZS5JZIcE////AIgHKgOiXIOyAzAJBgNVHR8EAjAAMAoGA1UdIwQDAQEBMAoGA1"
- + "UdDgQDAQEBMAoGA1UdIQQDAQEBMAwGByqGSM44BAMBAQADMAAwLQIUAL4QvoazNWP"
- + "7jrj84/GZlhm09DsCFQCBKGKCGbrP64VtUt4JPmLjW1VxQA==\n"
- + "-----END CERTIFICATE-----\n";
-
- /*
- * Test for CertificateMessage(null) and
- * CertificateMessage(HandshakeIODataStream, int)
- */
- public void testCertificateMessage1() throws Exception {
-
- CertificateMessage message = new CertificateMessage(null);
- assertEquals("incorrect type", Handshake.CERTIFICATE, message.getType());
- assertEquals("incorrect message", 3, message.length());
- assertEquals("incorrect message", 0, message.certs.length);
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(), encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
-
- CertificateMessage message_2 = new CertificateMessage(in, message.length());
- assertEquals("incorrect message_2", 3, message_2.length());
- assertEquals("incorrect message_2", 0, message_2.certs.length);
- }
-
- /*
- * Test for void CertificateMessage(X509Certificate[]),
- * CertificateMessage(HandshakeIODataStream, int)
- */
- public void testCertificateMessage2() throws Exception {
- CertificateFactory certFactory = CertificateFactory.getInstance("X509");
-
- ByteArrayInputStream bais = new ByteArrayInputStream(base64certEncoding
- .getBytes("UTF-8"));
- X509Certificate cert = (X509Certificate) certFactory.generateCertificate(bais);
- CertificateMessage message = new CertificateMessage(
- new X509Certificate[] { cert });
- assertEquals("incorrect type", Handshake.CERTIFICATE, message.getType());
-
- assertTrue("incorrect cert encoding", Arrays.equals(message.certs[0]
- .getEncoded(), cert.getEncoded()));
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(), encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- CertificateMessage message_2 = new CertificateMessage(in, message.length());
- assertEquals("Incorrect message decoding", message.certs.length, message_2.certs.length);
- assertTrue("incorrect cert encoding", Arrays.equals(message.certs[0]
- .getEncoded(), message_2.certs[0].getEncoded()));
-
- in.append(encoded);
- try {
- message_2 = new CertificateMessage(in, message.length() - 1);
- fail("Small length: No expected AlertException");
- } catch (AlertException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- message_2 = new CertificateMessage(in, message.length() + 3);
- fail("Extra bytes: No expected AlertException ");
- } catch (AlertException e) {
- }
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateRequestTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateRequestTest.java
deleted file mode 100644
index 2b3c6e3..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateRequestTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.Arrays;
-
-import javax.security.auth.x500.X500Principal;
-
-import junit.framework.TestCase;
-
-/**
- * Test for <code>CertificateRequest</code> constructors and methods
- */
-public class CertificateRequestTest extends TestCase {
-
- private static String base64certEncoding = "-----BEGIN CERTIFICATE-----\n"
- + "MIIC+jCCAragAwIBAgICAiswDAYHKoZIzjgEAwEBADAdMRswGQYDVQQKExJDZXJ0a"
- + "WZpY2F0ZSBJc3N1ZXIwIhgPMTk3MDAxMTIxMzQ2NDBaGA8xOTcwMDEyNDAzMzMyMF"
- + "owHzEdMBsGA1UEChMUU3ViamVjdCBPcmdhbml6YXRpb24wGTAMBgcqhkjOOAQDAQE"
- + "AAwkAAQIDBAUGBwiBAgCqggIAVaOCAhQwggIQMA8GA1UdDwEB/wQFAwMBqoAwEgYD"
- + "VR0TAQH/BAgwBgEB/wIBBTAUBgNVHSABAf8ECjAIMAYGBFUdIAAwZwYDVR0RAQH/B"
- + "F0wW4EMcmZjQDgyMi5OYW1lggdkTlNOYW1lpBcxFTATBgNVBAoTDE9yZ2FuaXphdG"
- + "lvboYaaHR0cDovL3VuaWZvcm0uUmVzb3VyY2UuSWSHBP///wCIByoDolyDsgMwDAY"
- + "DVR0eAQH/BAIwADAMBgNVHSQBAf8EAjAAMIGZBgNVHSUBAf8EgY4wgYsGBFUdJQAG"
- + "CCsGAQUFBwMBBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMDBggrBgEFBQcDB"
- + "AYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEFBQcDBwYIKwYBBQUHAwgGCCsGAQUFBw"
- + "MJBggrBgEFBQgCAgYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GA1UdNgEB/wQDAgE"
- + "BMA4GBCpNhgkBAf8EAwEBATBkBgNVHRIEXTBbgQxyZmNAODIyLk5hbWWCB2ROU05h"
- + "bWWkFzEVMBMGA1UEChMMT3JnYW5pemF0aW9uhhpodHRwOi8vdW5pZm9ybS5SZXNvd"
- + "XJjZS5JZIcE////AIgHKgOiXIOyAzAJBgNVHR8EAjAAMAoGA1UdIwQDAQEBMAoGA1"
- + "UdDgQDAQEBMAoGA1UdIQQDAQEBMAwGByqGSM44BAMBAQADMAAwLQIUAL4QvoazNWP"
- + "7jrj84/GZlhm09DsCFQCBKGKCGbrP64VtUt4JPmLjW1VxQA==\n"
- + "-----END CERTIFICATE-----\n";
-
- public void testCertificateRequest() throws Exception {
-
- CertificateFactory certFactory = CertificateFactory.getInstance("X509");
- ByteArrayInputStream bais = new ByteArrayInputStream(base64certEncoding
- .getBytes("UTF-8"));
- X509Certificate cert = (X509Certificate) certFactory.generateCertificate(bais);
- X509Certificate[] accepted = { cert };
- X500Principal[] certificate_authorities = { cert.getIssuerX500Principal() };
-
- byte[] certificate_types = new byte[] { CertificateRequest.RSA_SIGN,
- CertificateRequest.RSA_FIXED_DH };
- CertificateRequest message = new CertificateRequest(certificate_types,
- accepted);
- assertEquals("incorrect type", Handshake.CERTIFICATE_REQUEST, message
- .getType());
- assertTrue("incorrect CertificateRequest", Arrays.equals(
- message.certificate_types, certificate_types));
- assertTrue("incorrect CertificateRequest", Arrays.equals(
- message.certificate_authorities, certificate_authorities));
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(), encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- CertificateRequest message_2 = new CertificateRequest(in, message.length());
- assertTrue("incorrect message decoding",
- Arrays.equals(message.certificate_types, message_2.certificate_types));
- assertTrue("incorrect message decoding",
- Arrays.equals(message.certificate_authorities, message_2.certificate_authorities));
-
- in.append(encoded);
- try {
- message_2 = new CertificateRequest(in, message.length() - 1);
- fail("Small length: No expected AlertException");
- } catch (AlertException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- message_2 = new CertificateRequest(in, message.length() + 3);
- fail("Extra bytes: No expected AlertException ");
- } catch (AlertException e) {
- }
- }
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateVerifyTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateVerifyTest.java
deleted file mode 100644
index 34d1807..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateVerifyTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertificateVerify</code> constructor and methods
- */
-public class CertificateVerifyTest extends TestCase {
-
- public void testCertificateVerify() throws Exception {
- byte[] anonHash = new byte[0];
- byte[] RSAHash = new byte[] {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
- 1, 2, 3, 4, 5, 6 };
- byte[] DSAHash = new byte[] {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
- byte[][] signatures = new byte[][] { RSAHash, DSAHash };
- try {
- new CertificateVerify(anonHash);
- fail("Anonymous: No expected AlertException");
- } catch (AlertException e) {
- }
- try {
- HandshakeIODataStream in = new HandshakeIODataStream();
- new CertificateVerify(in, 0);
- fail("Anonymous: No expected AlertException");
- } catch (AlertException e) {
- }
- for (int i = 0; i < signatures.length; i++) {
- CertificateVerify message = new CertificateVerify(signatures[i]);
- assertEquals("incorrect type", Handshake.CERTIFICATE_VERIFY,
- message.getType());
- assertTrue("incorrect CertificateVerify",
- Arrays.equals(message.signedHash, signatures[i]));
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(),
- encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- CertificateVerify message_2 = new CertificateVerify(in, message.length());
- assertTrue("incorrect message decoding",
- Arrays.equals(message.signedHash, message_2.signedHash));
-
- in.append(encoded);
- try {
- message_2 = new CertificateVerify(in, message.length() - 1);
- fail("Small length: No expected AlertException");
- } catch (AlertException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- message_2 = new CertificateVerify(in, message.length() + 3);
- fail("Extra bytes: No expected AlertException ");
- } catch (AlertException e) {
- }
- }
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CipherSuiteTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CipherSuiteTest.java
deleted file mode 100644
index 1bea358..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CipherSuiteTest.java
+++ /dev/null
@@ -1,554 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CipherSuite</code> constructor and methods
- */
-public class CipherSuiteTest extends TestCase {
-
- public void testEquals() {
- CipherSuite c1 = new CipherSuite("CipherSuite1", false, 0, "", "",
- new byte[] { 10, 10 });
- CipherSuite c2 = new CipherSuite("CipherSuite2", false, 0, "", "",
- new byte[] { 10, 10 });
- CipherSuite c3 = new CipherSuite("CipherSuite3", false, 0, "", "",
- new byte[] { 10, 11 });
- CipherSuite c4 = new CipherSuite("CipherSuite4", false, 0, "", "",
- new byte[] { 11, 10 });
- if (!c1.equals(c2) || c1.equals(c3) || c4.equals(c1) || c4.equals(c3)) {
- fail("testEquals failed");
- }
- }
-
- public void testToString() {
- CipherSuite c1 = new CipherSuite("CipherSuite1", false, 0, "", "",
- new byte[] { 10, 10 });
- assertEquals("testToString failed", "CipherSuite1: 10 10",
- c1.toString());
- }
-
- public void testGetByName() {
- CipherSuite[] suites = CipherSuite.getSupported();
- for (int i = 0; i < suites.length; i++) {
- assertEquals("incorrect cipher suite returned", suites[i],
- CipherSuite.getByName(suites[i].getName()));
- }
- assertNull("non null cipher suite returned for name: SomeName",
- CipherSuite.getByName("SomeName"));
- }
-
- /*
- * Class under test for CipherSuite getByCode(byte, byte)
- */
- public void testGetByCodebytebyte() {
- CipherSuite[] suites = CipherSuite.getSupported();
- for (int i = 0; i < suites.length; i++) {
- byte[] code = suites[i].toBytes();
- assertEquals("incorrect cipher suite returned", suites[i],
- CipherSuite.getByCode(code[0], code[1]));
- }
- assertEquals("incorrect cipher suite returned for code: 10 10",
- new CipherSuite("UNKNOUN_10_10", false, 0, "", "", new byte[] {
- 10, 10 }), CipherSuite.getByCode((byte) 10, (byte) 10));
- }
-
- /*
- * Class under test for CipherSuite getByCode(byte, byte, byte)
- */
- public void testGetByCodebytebytebyte() {
- CipherSuite[] suites = CipherSuite.getSupported();
- for (int i = 0; i < suites.length; i++) {
- byte[] code = suites[i].toBytes();
- assertEquals("incorrect cipher suite returned", suites[i],
- CipherSuite.getByCode((byte) 0, (byte) 0, code[1]));
- }
- assertEquals("incorrect cipher suite returned for code: 10 10 10",
- new CipherSuite("UNKNOUN_10_10_10", false, 0, "", "",
- new byte[] { 10, 10, 10 }),
- CipherSuite.getByCode((byte) 10, (byte) 10, (byte) 10));
- }
-
- public void testIsAnonymous() {
- CipherSuite c1 = new CipherSuite("CipherSuite1", false,
- CipherSuite.KeyExchange_DH_anon, "", "", new byte[] { 10, 10 });
- CipherSuite c2 = new CipherSuite("CipherSuite2", false,
- CipherSuite.KeyExchange_DH_anon_EXPORT, "", "", new byte[] { 9,
- 10 });
- CipherSuite c3 = new CipherSuite("CipherSuite3", false,
- CipherSuite.KeyExchange_DH_DSS, "", "", new byte[] { 10, 11 });
- CipherSuite c4 = new CipherSuite("CipherSuite4", false,
- CipherSuite.KeyExchange_DH_RSA, "", "", new byte[] { 11, 10 });
- assertTrue(c1.isAnonymous());
- assertTrue(c1.isAnonymous());
- assertFalse(c3.isAnonymous());
- assertFalse(c4.isAnonymous());
- }
-
- public void testGetSupported() {
- CipherSuite[] suites = CipherSuite.getSupported();
- for (int i = 0; i < suites.length; i++) {
- assertTrue(suites[i].supported);
- }
- }
-
- public void testGetSupportedCipherSuiteNames() {
- CipherSuite[] suites = CipherSuite.getSupported();
- String[] names = CipherSuite.getSupportedCipherSuiteNames();
- for (int i = 0; i < suites.length; i++) {
- assertEquals(suites[i].getName(), names[i]);
- }
- }
-
- public void testGetBulkEncryptionAlgorithm() {
- assertNull(CipherSuite.TLS_NULL_WITH_NULL_NULL
- .getBulkEncryptionAlgorithm());
- assertNull(CipherSuite.TLS_RSA_WITH_NULL_MD5
- .getBulkEncryptionAlgorithm());
- assertNull(CipherSuite.TLS_RSA_WITH_NULL_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("RC4",
- CipherSuite.TLS_RSA_EXPORT_WITH_RC4_40_MD5
- .getBulkEncryptionAlgorithm());
- assertEquals("RC4",
- CipherSuite.TLS_RSA_WITH_RC4_128_MD5
- .getBulkEncryptionAlgorithm());
- assertEquals("RC4",
- CipherSuite.TLS_RSA_WITH_RC4_128_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("RC2/CBC/NoPadding",
- CipherSuite.TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5
- .getBulkEncryptionAlgorithm());
- assertEquals("IDEA/CBC/NoPadding",
- CipherSuite.TLS_RSA_WITH_IDEA_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DES/CBC/NoPadding",
- CipherSuite.TLS_RSA_EXPORT_WITH_DES40_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DES/CBC/NoPadding",
- CipherSuite.TLS_RSA_WITH_DES_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DESede/CBC/NoPadding",
- CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DES/CBC/NoPadding",
- CipherSuite.TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DES/CBC/NoPadding",
- CipherSuite.TLS_DH_DSS_WITH_DES_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DESede/CBC/NoPadding",
- CipherSuite.TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DES/CBC/NoPadding",
- CipherSuite.TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DES/CBC/NoPadding",
- CipherSuite.TLS_DH_RSA_WITH_DES_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DESede/CBC/NoPadding",
- CipherSuite.TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DES/CBC/NoPadding",
- CipherSuite.TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DES/CBC/NoPadding",
- CipherSuite.TLS_DHE_DSS_WITH_DES_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DESede/CBC/NoPadding",
- CipherSuite.TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DES/CBC/NoPadding",
- CipherSuite.TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DES/CBC/NoPadding",
- CipherSuite.TLS_DHE_RSA_WITH_DES_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DESede/CBC/NoPadding",
- CipherSuite.TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("RC4",
- CipherSuite.TLS_DH_anon_EXPORT_WITH_RC4_40_MD5
- .getBulkEncryptionAlgorithm());
- assertEquals("RC4",
- CipherSuite.TLS_DH_anon_WITH_RC4_128_MD5
- .getBulkEncryptionAlgorithm());
- assertEquals("DES/CBC/NoPadding",
- CipherSuite.TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DES/CBC/NoPadding",
- CipherSuite.TLS_DH_anon_WITH_DES_CBC_SHA
- .getBulkEncryptionAlgorithm());
- assertEquals("DESede/CBC/NoPadding",
- CipherSuite.TLS_DH_anon_WITH_3DES_EDE_CBC_SHA
- .getBulkEncryptionAlgorithm());
- }
-
- public void testGetBlockSize() {
- assertEquals(0,
- CipherSuite.TLS_NULL_WITH_NULL_NULL
- .getBlockSize());
- assertEquals(0,
- CipherSuite.TLS_RSA_WITH_NULL_MD5
- .getBlockSize());
- assertEquals(0,
- CipherSuite.TLS_RSA_WITH_NULL_SHA
- .getBlockSize());
- assertEquals(0,
- CipherSuite.TLS_RSA_EXPORT_WITH_RC4_40_MD5
- .getBlockSize());
- assertEquals(0,
- CipherSuite.TLS_RSA_WITH_RC4_128_MD5
- .getBlockSize());
- assertEquals(0,
- CipherSuite.TLS_RSA_WITH_RC4_128_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_RSA_WITH_IDEA_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_RSA_EXPORT_WITH_DES40_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_RSA_WITH_DES_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DH_DSS_WITH_DES_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DH_RSA_WITH_DES_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DHE_DSS_WITH_DES_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DHE_RSA_WITH_DES_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
- .getBlockSize());
- assertEquals(0,
- CipherSuite.TLS_DH_anon_EXPORT_WITH_RC4_40_MD5
- .getBlockSize());
- assertEquals(0,
- CipherSuite.TLS_DH_anon_WITH_RC4_128_MD5
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DH_anon_WITH_DES_CBC_SHA
- .getBlockSize());
- assertEquals(8,
- CipherSuite.TLS_DH_anon_WITH_3DES_EDE_CBC_SHA
- .getBlockSize());
- }
-
- public void testGetHmacName() {
- assertNull(CipherSuite.TLS_NULL_WITH_NULL_NULL
- .getHmacName());
- assertEquals("HmacMD5",
- CipherSuite.TLS_RSA_WITH_NULL_MD5
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_RSA_WITH_NULL_SHA
- .getHmacName());
- assertEquals("HmacMD5",
- CipherSuite.TLS_RSA_EXPORT_WITH_RC4_40_MD5
- .getHmacName());
- assertEquals("HmacMD5",
- CipherSuite.TLS_RSA_WITH_RC4_128_MD5
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_RSA_WITH_RC4_128_SHA
- .getHmacName());
- assertEquals("HmacMD5",
- CipherSuite.TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_RSA_WITH_IDEA_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_RSA_EXPORT_WITH_DES40_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_RSA_WITH_DES_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DH_DSS_WITH_DES_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DH_RSA_WITH_DES_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DHE_DSS_WITH_DES_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DHE_RSA_WITH_DES_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
- .getHmacName());
- assertEquals("HmacMD5",
- CipherSuite.TLS_DH_anon_EXPORT_WITH_RC4_40_MD5
- .getHmacName());
- assertEquals("HmacMD5",
- CipherSuite.TLS_DH_anon_WITH_RC4_128_MD5
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DH_anon_WITH_DES_CBC_SHA
- .getHmacName());
- assertEquals("HmacSHA1",
- CipherSuite.TLS_DH_anon_WITH_3DES_EDE_CBC_SHA
- .getHmacName());
- }
-
- public void testGetHashName() {
- assertNull(CipherSuite.TLS_NULL_WITH_NULL_NULL
- .getHashName());
- assertEquals("MD5",
- CipherSuite.TLS_RSA_WITH_NULL_MD5
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_RSA_WITH_NULL_SHA
- .getHashName());
- assertEquals("MD5",
- CipherSuite.TLS_RSA_EXPORT_WITH_RC4_40_MD5
- .getHashName());
- assertEquals("MD5",
- CipherSuite.TLS_RSA_WITH_RC4_128_MD5
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_RSA_WITH_RC4_128_SHA
- .getHashName());
- assertEquals("MD5",
- CipherSuite.TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_RSA_WITH_IDEA_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_RSA_EXPORT_WITH_DES40_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_RSA_WITH_DES_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DH_DSS_WITH_DES_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DH_RSA_WITH_DES_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DHE_DSS_WITH_DES_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DHE_RSA_WITH_DES_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
- .getHashName());
- assertEquals("MD5",
- CipherSuite.TLS_DH_anon_EXPORT_WITH_RC4_40_MD5
- .getHashName());
- assertEquals("MD5",
- CipherSuite.TLS_DH_anon_WITH_RC4_128_MD5
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DH_anon_WITH_DES_CBC_SHA
- .getHashName());
- assertEquals("SHA-1",
- CipherSuite.TLS_DH_anon_WITH_3DES_EDE_CBC_SHA
- .getHashName());
- }
-
- public void testGetMACLength() {
- assertEquals(0,
- CipherSuite.TLS_NULL_WITH_NULL_NULL.getMACLength());
- assertEquals(16, CipherSuite.TLS_RSA_WITH_NULL_MD5.getMACLength());
- assertEquals(20, CipherSuite.TLS_RSA_WITH_NULL_SHA.getMACLength());
- assertEquals(16, CipherSuite.TLS_RSA_EXPORT_WITH_RC4_40_MD5.getMACLength());
- assertEquals(16, CipherSuite.TLS_RSA_WITH_RC4_128_MD5.getMACLength());
- assertEquals(20, CipherSuite.TLS_RSA_WITH_RC4_128_SHA.getMACLength());
- assertEquals(16, CipherSuite.TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5.getMACLength());
- assertEquals(20, CipherSuite.TLS_RSA_WITH_IDEA_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_RSA_EXPORT_WITH_DES40_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_RSA_WITH_DES_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DH_DSS_WITH_DES_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DH_RSA_WITH_DES_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DHE_DSS_WITH_DES_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DHE_RSA_WITH_DES_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA.getMACLength());
- assertEquals(16, CipherSuite.TLS_DH_anon_EXPORT_WITH_RC4_40_MD5.getMACLength());
- assertEquals(16, CipherSuite.TLS_DH_anon_WITH_RC4_128_MD5.getMACLength());
- assertEquals(20, CipherSuite.TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DH_anon_WITH_DES_CBC_SHA.getMACLength());
- assertEquals(20, CipherSuite.TLS_DH_anon_WITH_3DES_EDE_CBC_SHA.getMACLength());
- }
-
- public void testIsExportable() {
- assertTrue(CipherSuite.TLS_NULL_WITH_NULL_NULL
- .isExportable());
- assertTrue(CipherSuite.TLS_RSA_WITH_NULL_MD5
- .isExportable());
- assertTrue(CipherSuite.TLS_RSA_WITH_NULL_SHA
- .isExportable());
- assertTrue(CipherSuite.TLS_RSA_EXPORT_WITH_RC4_40_MD5
- .isExportable());
- assertFalse(CipherSuite.TLS_RSA_WITH_RC4_128_MD5
- .isExportable());
- assertFalse(CipherSuite.TLS_RSA_WITH_RC4_128_SHA
- .isExportable());
- assertTrue(CipherSuite.TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5
- .isExportable());
- assertFalse(CipherSuite.TLS_RSA_WITH_IDEA_CBC_SHA
- .isExportable());
- assertTrue(CipherSuite.TLS_RSA_EXPORT_WITH_DES40_CBC_SHA
- .isExportable());
- assertFalse(CipherSuite.TLS_RSA_WITH_DES_CBC_SHA
- .isExportable());
- assertFalse(CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA
- .isExportable());
- assertTrue(CipherSuite.TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA
- .isExportable());
- assertFalse(CipherSuite.TLS_DH_DSS_WITH_DES_CBC_SHA
- .isExportable());
- assertFalse(CipherSuite.TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA
- .isExportable());
- assertTrue(CipherSuite.TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA
- .isExportable());
- assertFalse(CipherSuite.TLS_DH_RSA_WITH_DES_CBC_SHA
- .isExportable());
- assertFalse(CipherSuite.TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA
- .isExportable());
- assertTrue(CipherSuite.TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
- .isExportable());
- assertFalse(CipherSuite.TLS_DHE_DSS_WITH_DES_CBC_SHA
- .isExportable());
- assertFalse(CipherSuite.TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA
- .isExportable());
- assertTrue(CipherSuite.TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA
- .isExportable());
- assertFalse(CipherSuite.TLS_DHE_RSA_WITH_DES_CBC_SHA
- .isExportable());
- assertFalse(CipherSuite.TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
- .isExportable());
- assertTrue(CipherSuite.TLS_DH_anon_EXPORT_WITH_RC4_40_MD5
- .isExportable());
- assertFalse(CipherSuite.TLS_DH_anon_WITH_RC4_128_MD5
- .isExportable());
- assertTrue(CipherSuite.TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA
- .isExportable());
- assertFalse(CipherSuite.TLS_DH_anon_WITH_DES_CBC_SHA
- .isExportable());
- assertFalse(CipherSuite.TLS_DH_anon_WITH_3DES_EDE_CBC_SHA
- .isExportable());
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientHelloTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientHelloTest.java
deleted file mode 100644
index 08d0bde..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientHelloTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.IOException;
-import java.security.SecureRandom;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ClientHello</code> constructor and methods
- */
-public class ClientHelloTest extends TestCase {
-
-
- /*
- * Test for ClientHello(SecureRandom, byte[], byte[], CipherSuite[]),
- * ClientHello(HandshakeIODataStream, int), getType(), getRandom(), and
- * send();
- */
- public void testClientHello() throws Exception {
- byte[] ses_id = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
- byte[] version = new byte[] { 3, 1 };
- CipherSuite[] cipher_suite = new CipherSuite[] {
- CipherSuite.TLS_RSA_WITH_RC4_128_MD5 };
- ClientHello message = new ClientHello(new SecureRandom(), version,
- ses_id, cipher_suite);
- assertEquals("incorrect type", Handshake.CLIENT_HELLO, message.getType());
- assertEquals("incorrect length", 51, message.length());
- assertEquals("incorrect random", 32, message.getRandom().length);
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(), encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- ClientHello message_2 = new ClientHello(in, message.length());
-
- assertTrue("Incorrect message decoding",
- Arrays.equals(message.client_version, message_2.client_version));
- assertTrue("Incorrect message decoding",
- Arrays.equals(message.getRandom(), message_2.getRandom()));
-
- in.append(encoded);
- try {
- message_2 = new ClientHello(in, message.length() - 1);
- fail("Small length: No expected AlertException");
- } catch (AlertException e) {
- }
-
- in.append(encoded);
- try {
- message_2 = new ClientHello(in, message.length() + 1);
- fail("Big length: No expected IO exception");
- } catch (IOException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- new ClientHello(in, message.length() + 3); // extra bytes must be
- // ignored
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientKeyExchangeTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientKeyExchangeTest.java
deleted file mode 100644
index 1d835da..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientKeyExchangeTest.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ClientKeyExchange</code> constructor and methods
- */
-public class ClientKeyExchangeTest extends TestCase {
-
- /*
- * Test for void ClientKeyExchange(byte[], boolean)
- */
- public void testClientKeyExchangebyteArrayboolean() throws Exception {
- byte[] encrypted_pre_master_secret = new byte[] {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
- boolean[] isTLS = new boolean[] { true, false };
-
- for (int i = 0; i < isTLS.length; i++) {
- ClientKeyExchange message = new ClientKeyExchange(
- encrypted_pre_master_secret, isTLS[i]);
- assertEquals("incorrect type", Handshake.CLIENT_KEY_EXCHANGE,
- message.getType());
-
- assertTrue("incorrect ClientKeyExchange", Arrays.equals(
- message.exchange_keys, encrypted_pre_master_secret));
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length ", message.length(),
- encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- ClientKeyExchange message_2 = new ClientKeyExchange(in, message
- .length(), isTLS[i], true);
-
- assertTrue("Incorrect message decoding", Arrays.equals(
- message.exchange_keys, message_2.exchange_keys));
- assertEquals("Incorrect message decoding", message.length(),
- message_2.length());
-
- in.append(encoded);
- try {
- message_2 = new ClientKeyExchange(in, message.length() - 1,
- isTLS[i], true);
- if (isTLS[i]) {
- fail("Small length: No expected AlertException");
- }
- } catch (AlertException e) {
- if (!isTLS[i]) {
- fail(e.toString());
- }
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- message_2 = new ClientKeyExchange(in, message.length() + 3,
- isTLS[i], true);
- if (isTLS[i]) {
- fail("Extra bytes: No expected AlertException");
- }
- } catch (AlertException e) {
- if (!isTLS[i]) {
- fail(e.toString());
- }
- }
- }
- }
-
- /*
- * Test for void ClientKeyExchange(BigInteger)
- */
- public void testClientKeyExchangeBigInteger() throws Exception {
- BigInteger dh_Yc = new BigInteger("1234567890");
- boolean[] isTLS = new boolean[] { true, false };
-
- for (int i = 0; i < isTLS.length; i++) {
- ClientKeyExchange message = new ClientKeyExchange(dh_Yc);
- assertEquals("incorrect type", Handshake.CLIENT_KEY_EXCHANGE,
- message.getType());
- assertEquals("incorrect ClientKeyExchange", dh_Yc, new BigInteger(
- message.exchange_keys));
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(),
- encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- ClientKeyExchange message_2 = new ClientKeyExchange(in, message
- .length(), isTLS[i], false);
-
- assertEquals("Incorrect message decoding", message.length(),
- message_2.length());
- assertTrue("Incorrect message decoding", Arrays.equals(
- message.exchange_keys, message_2.exchange_keys));
-
- in.append(encoded);
- try {
- message_2 = new ClientKeyExchange(in, message.length() - 1,
- isTLS[i], false);
- fail("Small length: No expected AlertException");
- } catch (AlertException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- message_2 = new ClientKeyExchange(in, message.length() + 3,
- isTLS[i], false);
- fail("Extra bytes: No expected AlertException");
- } catch (AlertException e) {
- }
- }
- }
-
- /*
- * Test for void ClientKeyExchange()
- */
- public void testClientKeyExchange() throws Exception {
-
- ClientKeyExchange message = new ClientKeyExchange();
- assertEquals("incorrect type", Handshake.CLIENT_KEY_EXCHANGE, message
- .getType());
- assertEquals("incorrect ClientKeyExchange", 0,
- message.exchange_keys.length);
- assertEquals("incorrect ClientKeyExchange", 0, message.length());
- assertTrue("incorrect ClientKeyExchange", message.isEmpty());
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect ClientKeyExchange", 0, message.length());
- assertEquals("incorrect out data length", message.length(),
- encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- ClientKeyExchange message_2 = new ClientKeyExchange(in, message
- .length(), true, false);
-
- assertEquals("Incorrect message decoding", 0,
- message_2.exchange_keys.length);
- assertEquals("Incorrect message decoding", 0, message_2.length());
- assertTrue("Incorrect message decoding", message_2.isEmpty());
-
- in.append(encoded);
- try {
- message_2 = new ClientKeyExchange(in, message.length() - 1, true,
- false);
- fail("Small length: No expected IOException");
- } catch (IOException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- message_2 = new ClientKeyExchange(in, message.length() + 3, true,
- false);
- fail("Extra bytes: No expected IOException");
- } catch (IOException e) {
- }
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/DelegatedTaskTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/DelegatedTaskTest.java
deleted file mode 100644
index a8803ae..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/DelegatedTaskTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.security.KeyManagementException;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>DelegatedTask</code> constructor and methods
- */
-public class DelegatedTaskTest extends TestCase {
-
- public void testDelegatedTask() throws Exception {
- HandshakeProtocol protocol = new ClientHandshakeImpl(new SSLEngineImpl(
- new SSLParameters(null, null, null,
- new SSLSessionContextImpl(),
- new SSLSessionContextImpl())));
-
- DelegatedTask task = new DelegatedTask(null, protocol, null);
- task.run();
- assertTrue(protocol.delegatedTaskErr instanceof NullPointerException);
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/DigitalSignatureTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/DigitalSignatureTest.java
deleted file mode 100644
index ded3dac..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/DigitalSignatureTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.security.KeyStore;
-import java.security.MessageDigest;
-import java.security.PrivateKey;
-import java.security.cert.Certificate;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>DigitalSignature</code> constructor and methods
- */
-public class DigitalSignatureTest extends TestCase {
-
- private PrivateKey key;
- private Certificate cert;
-
- @Override
- public void setUp() throws Exception {
-
- char[] pwd = JSSETestData.KS_PASSWORD;
- KeyStore ks = JSSETestData.getKeyStore();
- KeyStore.PrivateKeyEntry entry = (KeyStore.PrivateKeyEntry) ks
- .getEntry("ssl_test_store",
- new KeyStore.PasswordProtection(pwd));
- key = entry.getPrivateKey();
- cert = entry.getCertificate();
- }
-
- public void testDigitalSignature_1() throws Exception {
-
- MessageDigest md5 = null;
- MessageDigest sha = null;
-
- md5 = MessageDigest.getInstance("MD5");
- sha = MessageDigest.getInstance("SHA-1");
-
- DigitalSignature ds_sign = new DigitalSignature(
- CipherSuite.KeyExchange_RSA_EXPORT);
- DigitalSignature ds_verify = new DigitalSignature(
- CipherSuite.KeyExchange_RSA_EXPORT);
- ds_sign.init(key);
- // use pivateKeyEncoding as signed data
- byte[] pivateKeyEncoding = key.getEncoded();
- ds_sign.update(pivateKeyEncoding);
- byte[] hash = ds_sign.sign();
-
- // verify
- byte[] md5_hash = new byte[16];
- byte[] sha_hash = new byte[20];
- sha.update(pivateKeyEncoding);
- md5.update(pivateKeyEncoding);
-
- sha.digest(sha_hash, 0, sha_hash.length);
- md5.digest(md5_hash, 0, md5_hash.length);
-
- ds_verify.init(cert);
- ds_verify.setMD5(md5_hash);
- ds_verify.setSHA(sha_hash);
-
- assertTrue(ds_verify.verifySignature(hash));
- }
-
- public void testDigitalSignature_2() throws Exception {
-
- DigitalSignature ds_sign = new DigitalSignature(
- CipherSuite.KeyExchange_RSA_EXPORT);
- DigitalSignature ds_verify = new DigitalSignature(
- CipherSuite.KeyExchange_RSA_EXPORT);
- ds_sign.init(key);
-
- byte[] md5_hash = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16 };
- byte[] sha_hash = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, 20 };
- ds_sign.setMD5(md5_hash);
- ds_sign.setSHA(sha_hash);
- byte[] hash = ds_sign.sign();
-
- // verify
- ds_verify.init(cert);
- ds_verify.setMD5(md5_hash);
- ds_verify.setSHA(sha_hash);
- assertTrue(ds_verify.verifySignature(hash));
- }
-
-} \ No newline at end of file
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/HandshakeProtocolTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/HandshakeProtocolTest.java
deleted file mode 100644
index 8d0ee7c..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/HandshakeProtocolTest.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.security.KeyManagementException;
-import java.security.KeyPairGenerator;
-import java.security.PublicKey;
-import java.security.SecureRandom;
-
-import javax.net.ssl.SSLEngineResult;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>HandshakeProtocol</code> constructor and methods
- */
-public class HandshakeProtocolTest extends TestCase {
-
- public void testGetStatus() throws Exception {
- HandshakeProtocol protocol = new ClientHandshakeImpl(new SSLEngineImpl(
- new SSLParameters(null, null, null,
- new SSLSessionContextImpl(),
- new SSLSessionContextImpl())));
-
- assertEquals(protocol.getStatus(),
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING);
-
- protocol.status = HandshakeProtocol.NEED_UNWRAP;
- assertEquals(protocol.getStatus(),
- SSLEngineResult.HandshakeStatus.NEED_UNWRAP);
-
- protocol.status = HandshakeProtocol.FINISHED;
- assertEquals(protocol.getStatus(),
- SSLEngineResult.HandshakeStatus.FINISHED);
- assertEquals(protocol.status, HandshakeProtocol.NOT_HANDSHAKING);
-
- protocol.delegatedTaskErr = new Exception();
- assertEquals(protocol.getStatus(),
- SSLEngineResult.HandshakeStatus.NEED_WRAP);
- protocol.delegatedTaskErr = null;
-
- protocol.delegatedTasks.add(new DelegatedTask(null, null, null));
- assertEquals(protocol.getStatus(),
- SSLEngineResult.HandshakeStatus.NEED_TASK);
- protocol.delegatedTasks.clear();
-
- protocol.io_stream.write(new byte[] { 1, 2, 3 });
- assertEquals(protocol.getStatus(),
- SSLEngineResult.HandshakeStatus.NEED_WRAP);
- }
-
- public void testSendChangeCipherSpec() throws Exception {
- HandshakeProtocol protocol = new ServerHandshakeImpl(new SSLEngineImpl(
- new SSLParameters(null, null, null,
- new SSLSessionContextImpl(),
- new SSLSessionContextImpl())));
-
- protocol.sendChangeCipherSpec();
- assertEquals(protocol.getStatus(),
- SSLEngineResult.HandshakeStatus.NEED_WRAP);
- }
-
- public void testWrap() throws Exception {
- HandshakeProtocol protocol = new ClientHandshakeImpl(new SSLEngineImpl(
- new SSLParameters(null, null, null,
- new SSLSessionContextImpl(),
- new SSLSessionContextImpl())));
-
- assertNull(protocol.wrap());
-
- protocol.delegatedTaskErr = new Exception();
- try {
- protocol.wrap();
- fail("No expected AlertException");
- } catch (AlertException e) {
- assertEquals(e.getDescriptionCode(),
- AlertProtocol.HANDSHAKE_FAILURE);
- assertNull(protocol.delegatedTaskErr);
- }
- }
-
- public void testcomputerVerifyDataTLS() throws Exception {
- HandshakeProtocol hs_protocol = new ClientHandshakeImpl(
- new SSLEngineImpl(new SSLParameters(null, null, null,
- new SSLSessionContextImpl(),
- new SSLSessionContextImpl())));
-
- SecureRandom sr = new SecureRandom();
- SSLSessionImpl ses = new SSLSessionImpl(sr);
- hs_protocol.session = ses;
- hs_protocol.session.protocol = ProtocolVersion.TLSv1;
- assertSame(hs_protocol.getSession(), ses);
-
- hs_protocol.clientHello = new ClientHello(
- sr,
- hs_protocol.session.protocol.version,
- hs_protocol.session.id,
- new CipherSuite[] { CipherSuite.TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA });
- hs_protocol.serverHello = new ServerHello(sr,
- hs_protocol.session.protocol.version, hs_protocol.session.id,
- CipherSuite.TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA, (byte) 0);
-
- hs_protocol.preMasterSecret = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
- hs_protocol.computerMasterSecret();
- assertNull(hs_protocol.preMasterSecret);
- assertEquals(48, hs_protocol.session.master_secret.length);
-
- hs_protocol.send(hs_protocol.clientHello);
- hs_protocol.send(hs_protocol.serverHello);
-
- hs_protocol.computerReferenceVerifyDataTLS("test");
-
- byte[] data = new byte[12];
- hs_protocol.computerVerifyDataTLS("test", data);
-
- hs_protocol.verifyFinished(data);
-
- try {
- hs_protocol.verifyFinished(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9,
- 0, 1, 2 });
- fail("No expected AlertException");
- } catch (AlertException e) {
- }
- }
-
- public void testComputerReferenceVerifyDataSSLv3() throws Exception {
- HandshakeProtocol hs_protocol = new ClientHandshakeImpl(
- new SSLEngineImpl(new SSLParameters(null, null, null,
- new SSLSessionContextImpl(),
- new SSLSessionContextImpl())));
-
- SecureRandom sr = new SecureRandom();
- SSLSessionImpl ses = new SSLSessionImpl(sr);
- hs_protocol.session = ses;
- hs_protocol.session.protocol = ProtocolVersion.SSLv3;
- assertSame(hs_protocol.getSession(), ses);
-
- hs_protocol.clientHello = new ClientHello(
- sr,
- hs_protocol.session.protocol.version,
- hs_protocol.session.id,
- new CipherSuite[] { CipherSuite.TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA });
- hs_protocol.serverHello = new ServerHello(sr,
- hs_protocol.session.protocol.version, hs_protocol.session.id,
- CipherSuite.TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA, (byte) 0);
-
- hs_protocol.preMasterSecret = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
- hs_protocol.computerMasterSecret();
- assertNull(hs_protocol.preMasterSecret);
- assertEquals(48, hs_protocol.session.master_secret.length);
-
- hs_protocol.send(hs_protocol.clientHello);
- hs_protocol.send(hs_protocol.serverHello);
-
- hs_protocol.computerReferenceVerifyDataSSLv3(SSLv3Constants.client);
-
- byte[] data = new byte[36];
- hs_protocol.computerVerifyDataSSLv3(SSLv3Constants.client, data);
-
- hs_protocol.verifyFinished(data);
-
- try {
- hs_protocol.verifyFinished(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9,
- 0, 1, 2 });
- fail("No expected AlertException");
- } catch (AlertException e) {
- }
- }
-
- public void testUnexpectedMessage() throws Exception {
- HandshakeProtocol protocol = new ClientHandshakeImpl(new SSLEngineImpl(
- new SSLParameters(null, null, null,
- new SSLSessionContextImpl(),
- new SSLSessionContextImpl())));
- try {
- protocol.unexpectedMessage();
- fail("No expected AlertException");
- } catch (AlertException e) {
- assertEquals(e.getDescriptionCode(),
- AlertProtocol.UNEXPECTED_MESSAGE);
- }
- }
-
- public void testGetTask() throws Exception {
- HandshakeProtocol protocol = new ClientHandshakeImpl(new SSLEngineImpl(
- new SSLParameters(null, null, null,
- new SSLSessionContextImpl(),
- new SSLSessionContextImpl())));
-
- DelegatedTask task = new DelegatedTask(null, null, null);
- protocol.delegatedTasks.add(task);
- assertSame(protocol.getTask(), task);
- assertNull(protocol.getTask());
- }
-
- public void testGetRSAKeyLength() throws Exception {
- KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
- kpg.initialize(512);
- PublicKey key = kpg.genKeyPair().getPublic();
-
- assertEquals(512, HandshakeProtocol.getRSAKeyLength(key));
-
- }
-
-} \ No newline at end of file
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/KeyManagerImplTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/KeyManagerImplTest.java
deleted file mode 100644
index b908ade..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/KeyManagerImplTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.net.Socket;
-import java.security.KeyStore;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyManagerImpl</code> constructor and methods
- */
-public class KeyManagerImplTest extends TestCase {
-
- public void testKeyManagerImpl1() throws Exception {
- KeyStore ks = null;
- ks = KeyStore.getInstance("BKS");
- ks.load(null, null);
-
- KeyManagerImpl km = new KeyManagerImpl(ks, new char[0]);
- String[] keyType = { "RSA", "DSA" };
- String al = km.chooseClientAlias(keyType, null, new Socket());
- assertNull(al);
-
- al = km.chooseEngineClientAlias(keyType, null, new SSLEngineImpl(null));
- assertNull(al);
-
- al = km.chooseEngineServerAlias("RSA", null, new SSLEngineImpl(null));
- assertNull(al);
-
- al = km.chooseServerAlias("RSA", null, new Socket());
- assertNull(al);
-
- assertNull(km.getClientAliases("RSA", null));
-
- assertNull(km.getServerAliases("RSA", null));
-
- assertNull(km.getCertificateChain("alias"));
- assertNull(km.getPrivateKey("alias"));
- }
-
- public void testKeyManagerImpl2() throws Exception {
-
- KeyStore ks = JSSETestData.getKeyStore();
- char[] pwd = JSSETestData.KS_PASSWORD;
-
- KeyManagerImpl km = new KeyManagerImpl(ks, pwd);
- String[] keyType = { "RSA", "DSA" };
- String al = km.chooseClientAlias(keyType, null, new Socket());
- assertEquals("ssl_test_store", al);
-
- al = km.chooseEngineClientAlias(keyType, null, new SSLEngineImpl(null));
- assertEquals("ssl_test_store", al);
-
- al = km.chooseEngineServerAlias("RSA", null, new SSLEngineImpl(null));
- assertEquals("ssl_test_store", al);
-
- al = km.chooseServerAlias("RSA", null, new Socket());
- assertEquals("ssl_test_store", al);
-
- assertTrue(km.getCertificateChain("ssl_test_store") != null);
- assertTrue(km.getPrivateKey("ssl_test_store") != null);
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLEngineImplTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLEngineImplTest.java
deleted file mode 100644
index c366d96..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLEngineImplTest.java
+++ /dev/null
@@ -1,1388 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLEngineResult;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLSession;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * SSLEngine implementation test.
- */
-public class SSLEngineImplTest extends TestCase {
-
- /**
- * The cipher suites used for functionality testing.
- */
- private static final String[] cipher_suites = {
- "RSA_WITH_RC4_128_MD5",
- "RSA_WITH_DES_CBC_SHA",
- "DH_anon_EXPORT_WITH_DES40_CBC_SHA"
- };
-
- /**
- * Test logging switch.
- */
- private static boolean doLog = false;
-
- /**
- * Sets up the test case.
- */
- @Override
- public void setUp() throws Exception {
- if (doLog) {
- System.out.println("");
- System.out.println("========================");
- System.out.println("====== Running the test: " + getName());
- System.out.println("========================");
- }
- }
-
- /**
- * Tests the interaction between the engines.
- */
- public void testSelfInteraction() throws Exception {
- String[] protocols = { "SSLv3", "TLSv1" };
- for (int i = 0; i < cipher_suites.length; i++) {
- for (int j = 0; j < 2; j++) {
- if (doLog) {
- System.out.println("\n===== Interact over suite: "
- + cipher_suites[i]);
- }
- SSLEngine client = getEngine();
- SSLEngine server = getEngine();
- initEngines(client, server);
-
- doHandshake(client, server);
- doDataExchange(client, server);
- doClose(client, server);
- }
- }
- }
-
- /**
- * Tests the session negotiation process.
- */
- public void testHandshake() throws Exception {
- SSLEngine client = getEngine();
- SSLEngine server = getEngine();
-
- initEngines(client, server);
-
- // checks the impossibility of initial handshake
- // with the server not allowed to session creation
- doNoRenegotiationTest(client, server, true);
-
- client = getEngine();
- server = getEngine();
- initEngines(client, server);
-
- client.setUseClientMode(true);
- server.setUseClientMode(false);
-
- // do initial handshake
- doHandshake(client, server);
-
- // client initiates rehandshake
- client.beginHandshake();
- doHandshakeImpl(client, server);
-
- // server initiates rehandshake
- server.beginHandshake();
- doHandshakeImpl(client, server);
-
- // client initiates rehandshake while server invalidates
- // used session
- server.getSession().invalidate();
- client.beginHandshake();
- doHandshakeImpl(client, server);
-
- // server initiates rehandshake while client invalidates
- // used session
- client.getSession().invalidate();
- server.beginHandshake();
- doHandshakeImpl(client, server);
-
- client.getSession().invalidate();
- server.getSession().invalidate();
- doHandshake(client, server);
-
- doNoRenegotiationTest(client, server, false);
-
- doNoRenegotiationTest(server, client, false);
-
- doClose(client, server);
- }
-
- /**
- * setNeedClientAuth(boolean need) method testing.
- * getNeedClientAuth() method testing.
- */
- public void testSetGetNeedClientAuth() throws Exception {
- SSLEngine engine = getEngine();
-
- engine.setWantClientAuth(true);
- engine.setNeedClientAuth(false);
- assertFalse("Result differs from expected",
- engine.getNeedClientAuth());
- assertFalse("Socket did not reset its want client auth state",
- engine.getWantClientAuth());
- engine.setWantClientAuth(true);
- engine.setNeedClientAuth(true);
- assertTrue("Result differs from expected",
- engine.getNeedClientAuth());
- assertFalse("Socket did not reset its want client auth state",
- engine.getWantClientAuth());
- }
-
- /**
- * setWantClientAuth(boolean want) method testing.
- * getWantClientAuth() method testing.
- */
- public void testSetGetWantClientAuth() throws Exception {
- SSLEngine engine = getEngine();
-
- engine.setNeedClientAuth(true);
- engine.setWantClientAuth(false);
- assertFalse("Result differs from expected",
- engine.getWantClientAuth());
- assertFalse("Socket did not reset its want client auth state",
- engine.getNeedClientAuth());
- engine.setNeedClientAuth(true);
- engine.setWantClientAuth(true);
- assertTrue("Result differs from expected",
- engine.getWantClientAuth());
- assertFalse("Socket did not reset its want client auth state",
- engine.getNeedClientAuth());
- }
-
- /**
- * getSupportedCipherSuites() method testing.
- */
- public void testGetSupportedCipherSuites() throws Exception {
- SSLEngine engine = getEngine();
- String[] supported = engine.getSupportedCipherSuites();
- assertNotNull(supported);
- supported[0] = "NOT_SUPPORTED_CIPHER_SUITE";
- supported = engine.getEnabledCipherSuites();
- for (int i = 0; i < supported.length; i++) {
- if ("NOT_SUPPORTED_CIPHER_SUITE".equals(supported[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- /**
- * getEnabledCipherSuites() method testing.
- */
- public void testGetEnabledCipherSuites() throws Exception {
- SSLEngine engine = getEngine();
- String[] enabled = engine.getEnabledCipherSuites();
- assertNotNull(enabled);
- String[] supported = engine.getSupportedCipherSuites();
- for (int i = 0; i < enabled.length; i++) {
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (enabled[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Enabled suite does not belong to the set "
- + "of supported cipher suites: " + enabled[i]);
- }
- }
- engine.setEnabledCipherSuites(supported);
- for (int i = 0; i < supported.length; i++) {
- enabled = new String[supported.length - i];
- System.arraycopy(supported, 0,
- enabled, 0, supported.length - i);
- engine.setEnabledCipherSuites(enabled);
- String[] result = engine.getEnabledCipherSuites();
- if (result.length != enabled.length) {
- fail("Returned result differs from expected.");
- }
- for (int k = 0; k < result.length; k++) {
- found:
- {
- for (int n = 0; n < enabled.length; n++) {
- if (result[k].equals(enabled[n])) {
- break found;
- }
- }
- if (result.length != enabled.length) {
- fail("Returned result does not correspond "
- + "to expected.");
- }
- }
- }
- }
- }
-
- /**
- * setEnabledCipherSuites(String[] suites) method testing.
- */
- public void testSetEnabledCipherSuites() throws Exception {
- SSLEngine engine = getEngine();
- String[] enabled = engine.getEnabledCipherSuites();
- assertNotNull(enabled);
- String[] supported = engine.getSupportedCipherSuites();
- for (int i = 0; i < enabled.length; i++) {
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (enabled[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Enabled suite does not belong to the set "
- + "of supported cipher suites: " + enabled[i]);
- }
- }
- engine.setEnabledCipherSuites(supported);
- engine.setEnabledCipherSuites(enabled);
- engine.setEnabledCipherSuites(supported);
- String[] more_than_supported = new String[supported.length + 1];
- for (int i = 0; i < supported.length + 1; i++) {
- more_than_supported[i]
- = "NOT_SUPPORTED_CIPHER_SUITE";
- System.arraycopy(supported, 0,
- more_than_supported, 0, i);
- System.arraycopy(supported, i,
- more_than_supported, i + 1, supported.length - i);
- try {
- engine.setEnabledCipherSuites(more_than_supported);
- fail("Expected IllegalArgumentException was not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- enabled = engine.getEnabledCipherSuites();
- enabled[0] = "NOT_SUPPORTED_CIPHER_SUITE";
- enabled = engine.getEnabledCipherSuites();
- for (int i = 0; i < enabled.length; i++) {
- if ("NOT_SUPPORTED_CIPHER_SUITE".equals(enabled[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- /**
- * getSupportedProtocols() method testing.
- */
- public void testGetSupportedProtocols() throws Exception {
- SSLEngine engine = getEngine();
- String[] supported = engine.getSupportedProtocols();
- assertNotNull(supported);
- assertFalse(supported.length == 0);
- supported[0] = "NOT_SUPPORTED_PROTOCOL";
- supported = engine.getSupportedProtocols();
- for (int i = 0; i < supported.length; i++) {
- if ("NOT_SUPPORTED_PROTOCOL".equals(supported[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- /**
- * getEnabledProtocols() method testing.
- */
- public void testGetEnabledProtocols() throws Exception {
- SSLEngine engine = getEngine();
- String[] enabled = engine.getEnabledProtocols();
- assertNotNull(enabled);
- String[] supported = engine.getSupportedProtocols();
- for (int i = 0; i < enabled.length; i++) {
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (enabled[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Enabled protocol does not belong to the set "
- + "of supported protocols: " + enabled[i]);
- }
- }
- engine.setEnabledProtocols(supported);
- for (int i = 0; i < supported.length; i++) {
- enabled = new String[supported.length - i];
- System.arraycopy(supported, i,
- enabled, 0, supported.length - i);
- engine.setEnabledProtocols(enabled);
- String[] result = engine.getEnabledProtocols();
- if (result.length != enabled.length) {
- fail("Returned result differs from expected.");
- }
- for (int k = 0; k < result.length; k++) {
- found:
- {
- for (int n = 0; n < enabled.length; n++) {
- if (result[k].equals(enabled[n])) {
- break found;
- }
- }
- if (result.length != enabled.length) {
- fail("Returned result does not correspond "
- + "to expected.");
- }
- }
- }
- }
- }
-
- /**
- * setUseClientMode(boolean mode) method testing.
- * getUseClientMode() method testing.
- */
- public void testSetGetUseClientMode() throws Exception {
- SSLEngine engine = getEngine();
-
- engine.setUseClientMode(false);
- assertFalse("Result differs from expected",
- engine.getUseClientMode());
- engine.setUseClientMode(true);
- assertTrue("Result differs from expected",
- engine.getUseClientMode());
-
- engine.beginHandshake();
- try {
- engine.setUseClientMode(false);
- fail("Expected IllegalArgumentException was not thrown");
- } catch (IllegalArgumentException e) {
- }
-
- engine.wrap(ByteBuffer.allocate(0), ByteBuffer.allocate(
- engine.getSession().getPacketBufferSize()));
- try {
- engine.setUseClientMode(false);
- fail("Expected IllegalArgumentException was not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * setEnableSessionCreation(boolean flag) method testing.
- * getEnableSessionCreation() method testing.
- */
- public void testSetGetEnableSessionCreation() throws Exception {
- SSLEngine engine = getEngine();
-
- engine.setEnableSessionCreation(false);
- assertFalse("Result differs from expected",
- engine.getEnableSessionCreation());
- engine.setEnableSessionCreation(true);
- assertTrue("Result differs from expected",
- engine.getEnableSessionCreation());
- }
-
- /**
- * getSession() method testing.
- */
- public void testGetSession() throws Exception {
- SSLEngine engine = getEngine();
-
- SSLSession session = engine.getSession();
- if ((session == null)
- || (!session.getCipherSuite()
- .endsWith("_NULL_WITH_NULL_NULL"))) {
- fail("Returned session is null "
- + "or not TLS_NULL_WITH_NULL_NULL");
- }
- }
-
- /**
- * beginHandshake() method testing
- */
- public void testBeginHandshake() throws Exception {
- SSLEngine engine = getEngine();
- assertEquals("Incorrect initial handshake status",
- engine.getHandshakeStatus(),
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING);
- try {
- engine.beginHandshake();
- fail("Expected IllegalStateException was not thrown");
- } catch (IllegalStateException e) {
- }
-
- engine = getEngine();
- engine.setUseClientMode(false);
- engine.beginHandshake();
- assertEquals("Incorrect initial handshake status",
- engine.getHandshakeStatus(),
- SSLEngineResult.HandshakeStatus.NEED_UNWRAP);
-
- engine = getEngine();
- engine.setUseClientMode(true);
- engine.beginHandshake();
- assertEquals("Incorrect initial handshake status",
- engine.getHandshakeStatus(),
- SSLEngineResult.HandshakeStatus.NEED_WRAP);
- }
-
- /**
- * closeOutbound() method testing.
- */
- public void testCloseOutbound() throws Exception {
- SSLEngine engine = getEngine();
- assertFalse(engine.isOutboundDone());
- engine.closeOutbound();
- SSLEngineResult result = engine.wrap(ByteBuffer.allocate(0),
- ByteBuffer.allocate(20000));
- assertEquals("Incorrect status", result.getStatus(),
- SSLEngineResult.Status.CLOSED);
- assertEquals("Incorrect status", result.getHandshakeStatus(),
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING);
- try {
- // should throw SSLException "engine already closed"
- engine.beginHandshake();
- fail("Expected exception was not thrown.");
- } catch (SSLException e) {
- }
- assertTrue(engine.isOutboundDone());
- }
-
- /**
- * closeInbound() method testing.
- */
- public void testCloseInbound() throws Exception {
- SSLEngine engine = getEngine();
- assertFalse(engine.isInboundDone());
- engine.closeInbound();
- SSLEngineResult result = engine.wrap(ByteBuffer.allocate(0),
- ByteBuffer.allocate(20000));
- assertEquals("Incorrect status", result.getStatus(),
- SSLEngineResult.Status.CLOSED);
- assertEquals("Incorrect status", result.getHandshakeStatus(),
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING);
- try {
- // should throw SSLException "engine already closed"
- engine.beginHandshake();
- fail("Expected exception was not thrown.");
- } catch (SSLException e) {
- }
- assertTrue(engine.isInboundDone());
- }
-
- /**
- * closeInbound() method testing.
- * Tests error processing in the case of unexpected closeInbound.
- */
- public void testCloseInbound2() throws Exception {
- SSLEngine client = getEngine();
- SSLEngine server = getEngine();
- initEngines(client, server);
-
- int packetBufferSize =
- client.getSession().getPacketBufferSize();
- int applicationBufferSize =
- server.getSession().getApplicationBufferSize();
-
- ByteBuffer buffer = ByteBuffer.allocate(packetBufferSize);
- ByteBuffer app_data_buffer = ByteBuffer.allocate(applicationBufferSize);
-
- client.setUseClientMode(true);
- server.setUseClientMode(false);
-
- doHandshake(client, server);
-
- if (doLog) {
- System.out.println("\nError processing test:");
- }
- try {
- // should cause SSLException, prepare fatal alert "internal error",
- // and set HandshakeStatus to NEED_WRAP
- // (to send alert to another side)
- server.closeInbound();
- fail("Expected exception was not thrown.");
- } catch (Exception e) {
- if (doLog) {
- System.out.println("Server threw exception: "
- + e.getMessage());
- }
- // e.printStackTrace();
- // should do nothing
- server.closeInbound();
- assertEquals("Unexpected status:",
- SSLEngineResult.HandshakeStatus.NEED_WRAP,
- server.getHandshakeStatus());
-
- if (doLog) {
- System.out.println("Wrapping of the alert message");
- }
- SSLEngineResult result = null;
- print(result = server.wrap(ByteBuffer.allocate(0), buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.CLOSED,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- result.getHandshakeStatus());
- assertEquals(
- "The length of the consumed data differs from expected",
- 0, result.bytesConsumed());
- assertTrue(
- "The length of the produced data differs from expected",
- result.bytesProduced() > 0);
- // tune buffer to be read
- buffer.flip();
- try {
- // should rethrow the SSLException "internal error"
- print(client.unwrap(buffer, app_data_buffer));
- fail("Expected exception was not thrown.");
- } catch (Exception ex) {
- if (doLog) {
- System.out.println("Client rethrew received alert: "
- + ex.getMessage());
- }
- // NOT_HANDSHAKING..
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- client.getHandshakeStatus());
- client.closeOutbound();
- // NEED_WRAP.. should it be so? it contradicts to the TLS spec:
- // "Upon transmission or receipt of an fatal alert message, both
- // parties immediately close the connection. Servers and clients
- // are required to forget any session-identifiers, keys, and
- // secrets associated with a failed connection."
- // So in this case we expect NOT_HANDSHAKING
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- client.getHandshakeStatus());
- assertTrue("Outbound should be closed.",
- client.isOutboundDone());
- assertTrue("Inbound should be closed.",
- client.isInboundDone());
- }
- }
- }
-
- /**
- * closeInbound() method testing.
- * Tests error processing
- */
- public void testErrorProcessing() throws Exception {
- SSLEngine client = getEngine();
- SSLEngine server = getEngine();
- initEngines(client, server);
-
- int packetBufferSize =
- client.getSession().getPacketBufferSize();
- int applicationBufferSize =
- server.getSession().getApplicationBufferSize();
-
- ByteBuffer buffer = ByteBuffer.allocate(packetBufferSize);
- ByteBuffer app_data_buffer = ByteBuffer.allocate(applicationBufferSize);
-
- client.setUseClientMode(true);
- server.setUseClientMode(false);
-
- doHandshake(client, server);
-
- if (doLog) {
- System.out.println("\nError processing test:");
- }
- try {
- print(server.unwrap(ByteBuffer.allocate(40), app_data_buffer));
- fail("Expected exception was not thrown.");
- } catch (Exception e) {
- if (doLog) {
- System.out.println("\nServer threw exception: "
- + e.getMessage());
- }
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NEED_WRAP,
- server.getHandshakeStatus());
-
- SSLEngineResult result = null;
- assertFalse("Outbound should not be closed.",
- server.isOutboundDone());
- assertTrue("Inbound should be closed.",
- server.isInboundDone());
-
- if (doLog) {
- System.out.println(
- "\nServer tries to unwrap the data after error");
- }
- print(result =
- server.unwrap(ByteBuffer.allocate(40), app_data_buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.CLOSED,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NEED_WRAP,
- result.getHandshakeStatus());
- assertEquals(
- "The length of the consumed data differs from expected",
- 0, result.bytesConsumed());
- assertEquals(
- "The length of the produced data differs from expected",
- 0, result.bytesProduced());
-
- if (doLog) {
- System.out.println("\nServer wraps the fatal alert");
- }
- print(result = server.wrap(ByteBuffer.allocate(0), buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.CLOSED,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- result.getHandshakeStatus());
- assertEquals(
- "The length of the consumed data differs from expected",
- 0, result.bytesConsumed());
- assertTrue(
- "The length of the produced data differs from expected",
- result.bytesProduced() > 0);
-
- assertTrue("Outbound should be closed.",
- server.isOutboundDone());
- assertTrue("Inbound should be closed.",
- server.isInboundDone());
-
- buffer.flip();
- try {
- if (doLog) {
- System.out.println("\nClient unwraps the fatal alert");
- }
- print(client.unwrap(buffer, app_data_buffer));
- fail("Expected exception was not thrown.");
- } catch (Exception ex) {
- if (doLog) {
- System.out.println("\nClient rethrew the exception: "
- + ex.getMessage());
- }
- // NOT_HANDSHAKING..
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- client.getHandshakeStatus());
- client.closeOutbound();
- // NEED_WRAP.. should it be so? it contradicts to the TLS spec:
- // "Upon transmission or receipt of an fatal alert message, both
- // parties immediately close the connection. Servers and clients
- // are required to forget any session-identifiers, keys, and
- // secrets associated with a failed connection."
- // So in this case we expect NOT_HANDSHAKING
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- client.getHandshakeStatus());
- assertTrue("Outbound should be closed.",
- client.isOutboundDone());
- assertTrue("Inbound should be closed.",
- client.isInboundDone());
- }
- }
- }
-
-
- // --------------------------------------------------------------------
- // ------------------------ Staff methods -----------------------------
- // --------------------------------------------------------------------
-
- /*
- * Performs the handshake over the specified engines
- */
- private void doHandshake(SSLEngine client,
- SSLEngine server) throws Exception {
- if (doLog) {
- System.out.println("\n--- doHandshake:");
- System.out.println("Server: " + server.getSession().getClass());
- System.out.println("Client: " + client.getSession().getClass());
- }
-
- client.beginHandshake();
- server.beginHandshake();
-
- doHandshakeImpl(client, server);
- }
-
- /*
- * Performs the handshake over the specified engines.
- * Note that method passes app data between the engines during
- * the handshake process.
- */
- private void doHandshakeImpl(SSLEngine client,
- SSLEngine server) throws Exception {
- if (doLog) {
- System.out.println("\n--- doHandshakeImpl:");
- System.out.println("Client's hsh status: "
- + client.getHandshakeStatus());
- System.out.println("Client's session: " + client.getSession());
- System.out.println("Server's hsh status: "
- + server.getHandshakeStatus());
- System.out.println("Server's session: " + server.getSession());
- }
-
- int packetBufferSize =
- client.getSession().getPacketBufferSize();
- int applicationBufferSize =
- server.getSession().getApplicationBufferSize();
-
- // buffer will contain handshake messages
- ByteBuffer clients_buffer = ByteBuffer.allocate(packetBufferSize + 1000);
- ByteBuffer servers_buffer = ByteBuffer.allocate(packetBufferSize + 1000);
- // buffers will contain application data messages
- ByteBuffer app_data = ByteBuffer.allocate(packetBufferSize);
- ByteBuffer app_data_plain = ByteBuffer.allocate(applicationBufferSize);
-
- SSLEngine[] engines = new SSLEngine[] { client, server };
- ByteBuffer[] buffers =
- new ByteBuffer[] { clients_buffer, servers_buffer };
-
- // choose which peer will start handshake negotiation
- // (initial handshake is initiated by client, but rehandshake
- // can be initiated by any peer)
- int step = (client.getHandshakeStatus()
- != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) ? 0 : 1;
-
- SSLEngine current_engine = engines[step];
- ByteBuffer buffer;
- SSLEngineResult result = null;
- SSLEngineResult.HandshakeStatus status;
-
- while ((client.getHandshakeStatus()
- != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING)
- || (server.getHandshakeStatus()
- != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING)) {
- if (doLog) {
- System.out.print("\n"
- + ((current_engine == client) ? "CLIENT " : "SERVER "));
- }
- status = current_engine.getHandshakeStatus();
- if (status == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) {
- // so another peer produced
- // the handshaking data which has to be unwrapped
- if (doLog) {
- System.out.print("(NOT_HANDSHAKING) ");
- }
- status = SSLEngineResult.HandshakeStatus.NEED_UNWRAP;
- }
- if (status == SSLEngineResult.HandshakeStatus.NEED_WRAP) {
- if (doLog) {
- System.out.println("NEED_WRAP");
- }
- // will wrap handshake data into its special buffer
- buffer = buffers[step];
- if (buffer.remaining() == 0) {
- // handshake data was fully read by another peer,
- // so we need clear the buffer before reusing it
- buffer.clear();
- }
- // wrap the next handshake message
- print(result = current_engine.wrap(app_data, buffer));
- // if there are no any messages to send, switch the engine
- if (current_engine.getHandshakeStatus()
- != SSLEngineResult.HandshakeStatus.NEED_WRAP) {
- // switch the current engine
- step ^= 1;
- current_engine = engines[step];
- // and prepare the buffer for reading
- buffer.flip();
- }
- } else if (status == SSLEngineResult.HandshakeStatus.NEED_UNWRAP) {
- if (doLog) {
- System.out.println("NEED_UNWRAP");
- }
-
- // If there are no unread handshake messages produced by the
- // current engine, try to wrap the application data and unwrap
- // it by another engine. It will test app data flow during
- // the rehandshake.
- if (!buffers[step].hasRemaining()) {
- if (doLog) {
- System.out.println(
- "\nTry to WRAP the application data");
- }
- print(result = current_engine.wrap(
- ByteBuffer.wrap(new byte[] { 0 }), app_data));
- // The output in app_data will be produced only if it
- // is rehandshaking stage
- // (i.e. initial handshake has been done)
- if (result.bytesProduced() > 0) {
- // if the app data message has been produced,
- // unwrap it by another peer
- if (doLog) {
- System.out.print("\n" + ((current_engine != client)
- ? "CLIENT " : "SERVER "));
- System.out.println(
- "UNWRAPs app data sent during handshake");
- }
- app_data.flip();
- print(result = engines[(step + 1) % 2].unwrap(
- app_data, app_data_plain));
- app_data.clear();
- app_data_plain.clear();
- }
- }
-
- buffer = buffers[step ^ 1];
-
- // check if there is handshake data to be unwrapped
- if (buffer.remaining() == 0) {
- if (doLog) {
- System.out.println(
- "There is no handshake data to be unwrapped.");
- }
- // switch the current engine
- step ^= 1;
- current_engine = engines[step];
- if ((current_engine.getHandshakeStatus()
- == SSLEngineResult.HandshakeStatus.NEED_UNWRAP)
- && (buffers[step ^ 1].remaining() == 0)) {
- System.out.println(
- "Both engines are in NEED_UNWRAP state");
- fail("Both engines are in NEED_UNWRAP state");
- }
- continue;
- }
-
- print(result = current_engine.unwrap(buffer, app_data));
- if (current_engine.getHandshakeStatus()
- == SSLEngineResult.HandshakeStatus.NEED_TASK) {
- if (doLog) {
- System.out.println("NEED_TASK");
- }
- current_engine.getDelegatedTask().run();
- if (doLog) {
- System.out.println("status after the task: "
- + current_engine.getHandshakeStatus());
- }
- }
- } else {
- fail("Unexpected HandshakeStatus: " + status);
- }
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.OK,
- result.getStatus());
- }
- }
-
- /*
- * Performs the session renegotiation process when one
- * of the peers is not allowed to create the session.
- */
- private void doNoRenegotiationTest(SSLEngine allowed,
- SSLEngine not_allowed, boolean is_initial) throws Exception {
- if (doLog) {
- System.out.println(
- "\n--- doNoRenegotiationTest: is_initial: " + is_initial);
- }
-
- not_allowed.setEnableSessionCreation(false);
- not_allowed.getSession().invalidate();
-
- int packetBufferSize =
- allowed.getSession().getPacketBufferSize();
- int applicationBufferSize =
- not_allowed.getSession().getApplicationBufferSize();
-
- // buffer will contain handshake messages
- ByteBuffer buffer = ByteBuffer.allocate(packetBufferSize + 1000);
- // buffers will contain application data messages
- ByteBuffer app_data = ByteBuffer.allocate(packetBufferSize);
- ByteBuffer app_data_plain = ByteBuffer.allocate(applicationBufferSize);
-
- SSLEngineResult result = null;
-
- allowed.beginHandshake();
- //not_allowed.beginHandshake();
-
- if (doLog) {
- System.out.println(
- "\nAllowed peer wraps the initial session negotiation message");
- }
- // wrap the initial session negotiation message
- while (allowed.getHandshakeStatus().equals(
- SSLEngineResult.HandshakeStatus.NEED_WRAP)) {
- print(result = allowed.wrap(app_data_plain, buffer));
- assertTrue("Engine did not produce any data",
- result.bytesProduced() > 0);
- }
- // prepare the buffer for reading
- buffer.flip();
- if (doLog) {
- System.out.println("\nNot allowed unwraps the message");
- }
- try {
- // unwrap the message. expecting whether SSLException or NEED_WRAP
- print(result = not_allowed.unwrap(buffer, app_data_plain));
- } catch (SSLException e) {
- if (is_initial) {
- return; // ok, exception was thrown
- } else {
- fail("Unexpected SSLException was thrown " + e);
- }
- }
- // if it is not an initial handshake phase it is posible
- // SSLException to be thrown.
- try {
- while (!not_allowed.getHandshakeStatus().equals(
- SSLEngineResult.HandshakeStatus.NEED_WRAP)) {
- assertTrue("Engine did not consume any data",
- result.bytesConsumed() > 0);
- if (not_allowed.getHandshakeStatus().equals(
- SSLEngineResult.HandshakeStatus.NEED_TASK)) {
- not_allowed.getDelegatedTask().run();
- if (doLog) {
- System.out.println("Status after the task: "
- + not_allowed.getHandshakeStatus());
- }
- continue;
- } else if (not_allowed.getHandshakeStatus().equals(
- SSLEngineResult.HandshakeStatus.NEED_UNWRAP)) {
- print(result = not_allowed.unwrap(buffer, app_data_plain));
- } else {
- fail("Unexpected status of operation: "
- + not_allowed.getHandshakeStatus());
- }
- }
- // prepare for writting
- buffer.clear();
- if (doLog) {
- System.out.println(
- "\nWrapping the message. Expecting no_renegotiation alert");
- }
- // wrapping the message. expecting no_renegotiation alert
- print(result = not_allowed.wrap(app_data_plain, buffer));
- } catch (SSLException e) {
- if (!is_initial) {
- fail("Unexpected SSLException was thrown." + e.getMessage());
- }
- if (doLog) {
- System.out.println("Throwed exception during the unwrapping "
- + "of handshake initiation message:");
- e.printStackTrace();
- System.out.println("Handshake Status: "
- + not_allowed.getHandshakeStatus());
- }
- if (not_allowed.getHandshakeStatus().equals(
- SSLEngineResult.HandshakeStatus.NEED_WRAP)) {
- // needs to wrap fatal alert message
- if (doLog) {
- System.out.println(
- "\nnot_allowed wraps fatal alert message");
- }
- // prepare for writting
- buffer.clear();
- print(result = not_allowed.wrap(app_data_plain, buffer));
- }
- }
- // check whether alert message has been sent
- assertTrue("Engine did not produce any data",
- result.bytesProduced() > 0);
- // check whether not_allowed engine stoped handshake operation
- assertEquals("Unexpected status of operation: not_allowed "
- + "to session creation peer did not stop its handshake process",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- not_allowed.getHandshakeStatus());
- // prepare for reading
- buffer.flip();
- try {
- print(result = allowed.unwrap(buffer, app_data_plain));
- assertTrue("Engine did not consume any data",
- result.bytesConsumed() > 0);
- assertEquals("Responce from the peer not allowed to create "
- + "the session did not cause the stopping of "
- + "the session negotiation process",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- result.getHandshakeStatus());
- } catch (SSLException e) {
- if (!is_initial) {
- fail("Unexpected SSLException was thrown." + e.getMessage());
- }
- if (doLog) {
- System.out.println("Throwed exception during the unwrapping "
- + "of responce from allowed peer:");
- e.printStackTrace();
- System.out.println("Handshake Status: "
- + not_allowed.getHandshakeStatus());
- }
- }
- }
-
- /*
- * Tests the data exchange process between two engines
- */
- private void doDataExchange(SSLEngine client,
- SSLEngine server) throws Exception {
- if (doLog) {
- System.out.println("\n--- doDataExchange:");
- }
- ByteBuffer co = ByteBuffer.allocate(
- client.getSession().getPacketBufferSize());
- ByteBuffer si = ByteBuffer.allocate(
- server.getSession().getPacketBufferSize());
- SSLEngineResult result;
-
- String data_2b_sent = "data to be sent";
- ByteBuffer data = ByteBuffer.wrap(data_2b_sent.getBytes());
-
- if (doLog) {
- System.out.println("\nTry to wrap the data into small buffer");
- }
- print(result = client.wrap(data, ByteBuffer.allocate(35)));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.BUFFER_OVERFLOW,
- result.getStatus());
-
- if (doLog) {
- System.out.println("\nWrapping the data of length "
- + data.remaining());
- }
- print(result = client.wrap(data, co));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.OK,
- result.getStatus());
-
- // tune the buffer to read from it
- co.limit(co.position());
- co.rewind();
-
- if (doLog) {
- System.out.println("\nTry to unwrap the data into small buffer");
- }
- print(result = server.unwrap(co, ByteBuffer.allocate(0)));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.BUFFER_OVERFLOW,
- result.getStatus());
- if (doLog) {
- System.out.println("\nUnwrapping the data into buffer");
- }
- print(result = server.unwrap(co, si));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.OK,
- result.getStatus());
- assertEquals(
- "The length of the received data differs from expected",
- "data to be sent".length(), result.bytesProduced());
-
- // take the data from the buffer
- byte[] resulting_data = new byte[result.bytesProduced()];
- si.rewind();
- si.get(resulting_data);
- si.clear();
- assertTrue(Arrays.equals(data_2b_sent.getBytes(), resulting_data));
-
- co.clear();
- for (int i = 1; i < 10; i++) {
- byte[] buff = new byte[i];
- data = ByteBuffer.wrap(buff);
- if (doLog) {
- System.out.println("\nWrap the data");
- }
- print(result = client.wrap(data, co));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.OK,
- result.getStatus());
- if (doLog) {
- System.out.println("\nUnwrap the data");
- }
- co.rewind();
- print(result = server.unwrap(co, si));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.OK,
- result.getStatus());
- assertEquals(
- "The length of the received data differs from expected",
- i, result.bytesProduced());
- resulting_data = new byte[i];
- si.rewind();
- si.get(resulting_data);
- si.clear();
- assertTrue(Arrays.equals(buff, resulting_data));
- co.clear();
- si.clear();
- }
- }
-
- /*
- * Performs the closure process over the two communicationg engines.
- * The handshake process should be performed before the call of this
- * method.
- */
- private void doClose(SSLEngine client, SSLEngine server) throws Exception {
- if (doLog) {
- System.out.println("\n--- doClose: ");
- }
- ByteBuffer buffer = ByteBuffer.allocate(
- // +100 because we put the data into the buffer multiple times
- server.getSession().getPacketBufferSize() + 100);
- ByteBuffer app_data_buffer = ByteBuffer.allocate(
- client.getSession().getApplicationBufferSize());
- SSLEngineResult result;
- // first: send 0 just for fun
- if (doLog) {
- System.out.println("\nServer sends pending outboud data:");
- }
- print(result = server.wrap(ByteBuffer.wrap(new byte[] { 0 }), buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.OK,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- result.getHandshakeStatus());
- // second: initiate a close
- if (doLog) {
- System.out.println("\nServer initiates a closure:");
- }
- server.closeOutbound();
- // should do nothing:
- server.closeOutbound();
-
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NEED_WRAP,
- server.getHandshakeStatus());
-
- // will cause SSLException because closure alert was not received yet:
- // server.closeInbound();
-
- // wrap closure alert (previosly sent 0 should not be lost)
- print(result = server.wrap(ByteBuffer.allocate(0), buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.CLOSED,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NEED_UNWRAP,
- result.getHandshakeStatus());
-
- if (doLog) {
- System.out.println("\nServer sends pending outboud data again:");
- }
- // will do nothing because closure alert has been sent
- // and outbound has been closed
- print(result = server.wrap(ByteBuffer.wrap(new byte[] { 0 }), buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.CLOSED,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NEED_UNWRAP,
- result.getHandshakeStatus());
- assertEquals(
- "The length of the consumed data differs from expected",
- 0, result.bytesConsumed());
- assertEquals(
- "The length of the produced data differs from expected",
- 0, result.bytesProduced());
-
- // prepare the buffer for reading
- buffer.flip();
-
- if (doLog) {
- System.out.println(
- "\nClient receives pending servers' outbound data");
- }
- print(result = client.unwrap(buffer, app_data_buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.OK,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- result.getHandshakeStatus());
- assertEquals(
- "The length of the produced data differs from expected",
- 1, result.bytesProduced());
-
- app_data_buffer.clear();
-
- if (doLog) {
- System.out.println("\nClient receives close notify");
- }
- print(result = client.unwrap(buffer, app_data_buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.CLOSED,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NEED_WRAP,
- result.getHandshakeStatus());
- assertTrue(
- "The length of the consumed data differs from expected",
- result.bytesConsumed() > 0);
- assertEquals(
- "The length of the received data differs from expected",
- 0, result.bytesProduced());
-
- // prepare the buffer for writing
- app_data_buffer.clear();
-
- // it's needless, but should work (don't cause exceptions):
- client.closeInbound();
- client.closeOutbound();
-
- if (doLog) {
- System.out.println("\nClient tries to read data again");
- }
- // CLOSED, 0 consumed, 0 produced
- print(result = client.unwrap(buffer, app_data_buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.CLOSED,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NEED_WRAP,
- result.getHandshakeStatus());
- assertEquals(
- "The length of the consumed data differs from expected",
- 0, result.bytesConsumed());
- assertEquals(
- "The length of the received data differs from expected",
- 0, result.bytesProduced());
-
- // prepare the buffer for writing
- buffer.clear();
-
- if (doLog) {
- System.out.println("\nClient sends responding close notify");
- }
- print(result = client.wrap(ByteBuffer.wrap(new byte[] { 0 }), buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.CLOSED,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- result.getHandshakeStatus());
- assertEquals(
- "The length of the consumed data differs from expected",
- 0, result.bytesConsumed());
- assertTrue(
- "The length of the produced data differs from expected",
- result.bytesProduced() > 0);
- if (doLog) {
- System.out.println(
- "\nClient tries to send data after closure alert");
- }
- // this data will not be sent (should do nothing - 0 cons, 0 prod)
- print(result = client.wrap(ByteBuffer.wrap(new byte[] { 0 }), buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.CLOSED,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- result.getHandshakeStatus());
- assertEquals(
- "The length of the consumed data differs from expected",
- 0, result.bytesConsumed());
- assertEquals(
- "The length of the produced data differs from expected",
- 0, result.bytesProduced());
-
- // prepare the buffers for reading
- app_data_buffer.clear();
- buffer.flip();
-
- if (doLog) {
- System.out.println("\nServer receives close notify");
- }
- print(result = server.unwrap(buffer, app_data_buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.CLOSED,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- result.getHandshakeStatus());
- assertTrue(
- "The length of the consumed data differs from expected",
- result.bytesConsumed() > 0);
- assertEquals(
- "The length of the produced data differs from expected",
- 0, result.bytesProduced());
-
- if (doLog) {
- System.out.println("\nServer tries to read after closure");
- }
- // will be ignored
- print(result = server.unwrap(buffer, app_data_buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.CLOSED,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- result.getHandshakeStatus());
- assertEquals(
- "The length of the consumed data differs from expected",
- 0, result.bytesConsumed());
- assertEquals(
- "The length of the produced data differs from expected",
- 0, result.bytesProduced());
-
- // it's needless, but should work:
- client.closeInbound();
- // will be ignored
-
- if (doLog) {
- System.out.println("\nServer tries to write after closure");
- }
- buffer.clear();
- print(result = server.wrap(ByteBuffer.allocate(0), buffer));
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.Status.CLOSED,
- result.getStatus());
- assertEquals("Unexpected status of operation:",
- SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
- result.getHandshakeStatus());
- assertEquals(
- "The length of the consumed data differs from expected",
- 0, result.bytesConsumed());
- assertEquals(
- "The length of the produced data differs from expected",
- 0, result.bytesProduced());
- }
-
- private static void print(SSLEngineResult result) {
- if (doLog) {
- System.out.println("result:\n" + result);
- }
- }
-
- /**
- * Returns the engine to be tested.
- */
- private SSLEngine getEngine() throws Exception {
- return JSSETestData.getContext().createSSLEngine("localhost", 2345);
- }
-
- /**
- * Initializes the engines.
- */
- private void initEngines(SSLEngine client, SSLEngine server) {
- String prefix = "TLS_";
-
- client.setEnabledProtocols(new String[] { "TLSv1" });
- server.setEnabledProtocols(new String[] { "TLSv1" });
- client.setEnabledCipherSuites(
- new String[] { prefix + cipher_suites[0] });
- server.setEnabledCipherSuites(
- new String[] { prefix + cipher_suites[0] });
-
- client.setUseClientMode(true);
- server.setUseClientMode(false);
- }
-
- public static Test suite() {
- return new TestSuite(SSLEngineImplTest.class);
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLServerSocketImplTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLServerSocketImplTest.java
deleted file mode 100644
index 2c6ac16..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLServerSocketImplTest.java
+++ /dev/null
@@ -1,682 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.IOException;
-import java.net.Socket;
-import java.net.InetSocketAddress;
-import javax.net.ssl.SSLServerSocket;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * SSLServerSocketImplTest test
- */
-public class SSLServerSocketImplTest extends TestCase {
-
- private static boolean doLog = false;
-
- /**
- * Sets up the test case.
- */
- @Override
- public void setUp() {
- if (doLog) {
- System.out.println("");
- System.out.println("========================");
- System.out.println("====== Running the test: " + getName());
- }
- }
-
- private SSLServerSocket createSSLServerSocket() throws Exception {
- return new SSLServerSocketImpl(JSSETestData.getSSLParameters());
- }
-
- /**
- * SSLServerSocketImpl(SSLParameters sslParameters) method testing.
- */
- public void testSSLServerSocketImpl1() throws Exception {
- Client client = null;
- SSLServerSocket ssocket = null;
- try {
- ssocket = new SSLServerSocketImpl(JSSETestData.getSSLParameters());
- ssocket.bind(null);
- ssocket.setUseClientMode(true);
-
- final SSLServerSocket s = ssocket;
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- s.accept().close();
- } catch (Exception e) {
- }
- }
- };
-
- thread.start();
-
- client = new Client(ssocket.getLocalPort());
- client.start();
-
- int timeout = 10; // wait no more than 5 seconds for handshake
- while (!client.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- try {
- client.close();
- } catch (IOException ex) {
- }
- try {
- ssocket.close();
- } catch (IOException ex) {
- }
- fail("Handshake was not started");
- }
- }
- } finally {
- if (client != null) {
- try {
- client.close();
- } catch (IOException ex) {
- }
- }
- if (ssocket != null) {
- try {
- ssocket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * SSLServerSocketImpl(int port, SSLParameters sslParameters) method
- * testing.
- */
- public void testSSLServerSocketImpl2() throws Exception {
- Client client = null;
- SSLServerSocket ssocket = null;
- try {
- ssocket = new SSLServerSocketImpl(0,
- JSSETestData.getSSLParameters());
- ssocket.setUseClientMode(true);
-
- final SSLServerSocket s = ssocket;
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- s.accept().close();
- } catch (Exception e) {
- }
- }
- };
-
- thread.start();
-
- client = new Client(ssocket.getLocalPort());
- client.start();
-
- int timeout = 10; // wait no more than 5 seconds for handshake
- while (!client.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- try {
- client.close();
- } catch (IOException ex) {
- }
- try {
- ssocket.close();
- } catch (IOException ex) {
- }
- fail("Handshake was not started");
- }
- }
- } finally {
- if (client != null) {
- try {
- client.close();
- } catch (IOException ex) {
- }
- }
- if (ssocket != null) {
- try {
- ssocket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * SSLServerSocketImpl(int port, int backlog,
- * SSLParameters sslParameters) method testing.
- */
- public void testSSLServerSocketImpl3() throws Exception {
- Client client = null;
- SSLServerSocket ssocket = null;
- try {
- ssocket = new SSLServerSocketImpl(0, 1,
- JSSETestData.getSSLParameters());
- ssocket.setUseClientMode(true);
-
- final SSLServerSocket s = ssocket;
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- s.accept().close();
- } catch (Exception e) {
- }
- }
- };
-
- thread.start();
-
- client = new Client(ssocket.getLocalPort());
- client.start();
-
- int timeout = 10; // wait no more than 5 seconds for handshake
- while (!client.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- try {
- client.close();
- } catch (IOException ex) {
- }
- try {
- ssocket.close();
- } catch (IOException ex) {
- }
- fail("Handshake was not started");
- }
- }
- } finally {
- if (client != null) {
- try {
- client.close();
- } catch (IOException ex) {
- }
- }
- if (ssocket != null) {
- try {
- ssocket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * SSLServerSocketImpl(int port, int backlog, InetAddress iAddress,
- * SSLParameters sslParameters) method testing.
- */
- public void testSSLServerSocketImpl4() throws Exception {
- Client client = null;
- SSLServerSocket ssocket = null;
- try {
- ssocket = new SSLServerSocketImpl(0, 1, null,
- JSSETestData.getSSLParameters());
- ssocket.setUseClientMode(true);
-
- final SSLServerSocket s = ssocket;
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- s.accept().close();
- } catch (Exception e) {
- }
- }
- };
-
- thread.start();
-
- client = new Client(ssocket.getLocalPort());
- client.start();
-
- int timeout = 10; // wait no more than 5 seconds for handshake
- while (!client.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- try {
- client.close();
- } catch (IOException ex) {
- }
- try {
- ssocket.close();
- } catch (IOException ex) {
- }
- fail("Handshake was not started");
- }
- }
- } finally {
- if (client != null) {
- try {
- client.close();
- } catch (IOException ex) {
- }
- }
- if (ssocket != null) {
- try {
- ssocket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * getSupportedCipherSuites() method testing.
- */
- public void testGetSupportedCipherSuites() throws Exception {
- SSLServerSocket ssocket = createSSLServerSocket();
- String[] supported = ssocket.getSupportedCipherSuites();
- assertNotNull(supported);
- supported[0] = "NOT_SUPPORTED_CIPHER_SUITE";
- supported = ssocket.getEnabledCipherSuites();
- for (int i = 0; i < supported.length; i++) {
- if ("NOT_SUPPORTED_CIPHER_SUITE".equals(supported[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- /**
- * getEnabledCipherSuites() method testing.
- */
- public void testGetEnabledCipherSuites() throws Exception {
- SSLServerSocket ssocket = createSSLServerSocket();
- String[] enabled = ssocket.getEnabledCipherSuites();
- assertNotNull(enabled);
- String[] supported = ssocket.getSupportedCipherSuites();
- for (int i = 0; i < enabled.length; i++) {
- //System.out.println("Checking of "+enabled[i]);
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (enabled[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Enabled suite does not belong to the set "
- + "of supported cipher suites: " + enabled[i]);
- }
- }
- ssocket.setEnabledCipherSuites(supported);
- for (int i = 0; i < supported.length; i++) {
- enabled = new String[supported.length - i];
- System.arraycopy(supported, 0,
- enabled, 0, supported.length - i);
- ssocket.setEnabledCipherSuites(enabled);
- String[] result = ssocket.getEnabledCipherSuites();
- if (result.length != enabled.length) {
- fail("Returned result does not correspond to expected.");
- }
- for (int k = 0; k < result.length; k++) {
- found:
- {
- for (int n = 0; n < enabled.length; n++) {
- if (result[k].equals(enabled[n])) {
- break found;
- }
- }
- if (result.length != enabled.length) {
- fail("Returned result does not correspond "
- + "to expected.");
- }
- }
- }
- }
- }
-
- /**
- * setEnabledCipherSuites(String[] suites) method testing.
- */
- public void testSetEnabledCipherSuites() throws Exception {
- SSLServerSocket ssocket = createSSLServerSocket();
- String[] enabled = ssocket.getEnabledCipherSuites();
- assertNotNull(enabled);
- String[] supported = ssocket.getSupportedCipherSuites();
- for (int i = 0; i < enabled.length; i++) {
- //System.out.println("Checking of "+enabled[i]);
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (enabled[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Enabled suite does not belong to the set "
- + "of supported cipher suites: " + enabled[i]);
- }
- }
- ssocket.setEnabledCipherSuites(supported);
- ssocket.setEnabledCipherSuites(enabled);
- ssocket.setEnabledCipherSuites(supported);
- String[] more_than_supported = new String[supported.length + 1];
- for (int i = 0; i < supported.length + 1; i++) {
- more_than_supported[i]
- = "NOT_SUPPORTED_CIPHER_SUITE";
- System.arraycopy(supported, 0,
- more_than_supported, 0, i);
- System.arraycopy(supported, i,
- more_than_supported, i + 1, supported.length - i);
- try {
- ssocket.setEnabledCipherSuites(more_than_supported);
- fail("Expected IllegalArgumentException was not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- enabled = ssocket.getEnabledCipherSuites();
- enabled[0] = "NOT_SUPPORTED_CIPHER_SUITE";
- enabled = ssocket.getEnabledCipherSuites();
- for (int i = 0; i < enabled.length; i++) {
- if ("NOT_SUPPORTED_CIPHER_SUITE".equals(enabled[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- /**
- * getSupportedProtocols() method testing.
- */
- public void testGetSupportedProtocols() throws Exception {
- SSLServerSocket ssocket = createSSLServerSocket();
- String[] supported = ssocket.getSupportedProtocols();
- assertNotNull(supported);
- assertFalse(supported.length == 0);
- supported[0] = "NOT_SUPPORTED_PROTOCOL";
- supported = ssocket.getSupportedProtocols();
- for (int i = 0; i < supported.length; i++) {
- if ("NOT_SUPPORTED_PROTOCOL".equals(supported[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- /**
- * getEnabledProtocols() method testing.
- */
- public void testGetEnabledProtocols() throws Exception {
- SSLServerSocket ssocket = createSSLServerSocket();
- String[] enabled = ssocket.getEnabledProtocols();
- assertNotNull(enabled);
- String[] supported = ssocket.getSupportedProtocols();
- for (int i = 0; i < enabled.length; i++) {
- //System.out.println("Checking of "+enabled[i]);
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (enabled[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Enabled protocol does not belong to the set "
- + "of supported protocols: " + enabled[i]);
- }
- }
- ssocket.setEnabledProtocols(supported);
- for (int i = 0; i < supported.length; i++) {
- enabled = new String[supported.length - i];
- System.arraycopy(supported, i,
- enabled, 0, supported.length - i);
- //System.out.println("");
- //for (int k=0; k<supported.length - i; k++) {
- // System.out.println("---- "+enabled[k]);
- //}
- ssocket.setEnabledProtocols(enabled);
- String[] result = ssocket.getEnabledProtocols();
- if (result.length != enabled.length) {
- fail("Returned result does not correspond to expected.");
- }
- for (int k = 0; k < result.length; k++) {
- found:
- {
- for (int n = 0; n < enabled.length; n++) {
- if (result[k].equals(enabled[n])) {
- break found;
- }
- }
- if (result.length != enabled.length) {
- fail("Returned result does not correspond "
- + "to expected.");
- }
- }
- }
- }
- }
-
- /**
- * setEnabledProtocols(String[] protocols) method testing.
- */
- public void testSetEnabledProtocols() throws Exception {
- SSLServerSocket ssocket = createSSLServerSocket();
- String[] enabled = ssocket.getEnabledProtocols();
- assertNotNull(enabled);
- String[] supported = ssocket.getSupportedProtocols();
- for (int i = 0; i < enabled.length; i++) {
- //System.out.println("Checking of "+enabled[i]);
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (enabled[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Enabled suite does not belong to the set "
- + "of supported cipher suites: " + enabled[i]);
- }
- }
- ssocket.setEnabledProtocols(supported);
- ssocket.setEnabledProtocols(enabled);
- ssocket.setEnabledProtocols(supported);
- String[] more_than_supported = new String[supported.length + 1];
- for (int i = 0; i < supported.length + 1; i++) {
- more_than_supported[i]
- = "NOT_SUPPORTED_PROTOCOL";
- System.arraycopy(supported, 0,
- more_than_supported, 0, i);
- System.arraycopy(supported, i,
- more_than_supported, i + 1, supported.length - i);
- try {
- ssocket.setEnabledProtocols(more_than_supported);
- fail("Expected IllegalArgumentException was not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- enabled = ssocket.getEnabledProtocols();
- enabled[0] = "NOT_SUPPORTED_PROTOCOL";
- enabled = ssocket.getEnabledProtocols();
- for (int i = 0; i < enabled.length; i++) {
- if ("NOT_SUPPORTED_PROTOCOL".equals(enabled[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- /**
- * setUseClientMode(boolean mode) method testing.
- * getUseClientMode() method testing.
- */
- public void testSetGetUseClientMode() throws Exception {
- SSLServerSocket ssocket = createSSLServerSocket();
-
- ssocket.setUseClientMode(false);
- assertFalse("Result does not correspond to expected",
- ssocket.getUseClientMode());
- ssocket.setUseClientMode(true);
- assertTrue("Result does not correspond to expected",
- ssocket.getUseClientMode());
- }
-
- /**
- * setNeedClientAuth(boolean need) method testing.
- * getNeedClientAuth() method testing.
- */
- public void testSetGetNeedClientAuth() throws Exception {
- SSLServerSocket ssocket = createSSLServerSocket();
-
- ssocket.setWantClientAuth(true);
- ssocket.setNeedClientAuth(false);
- assertFalse("Result does not correspond to expected",
- ssocket.getNeedClientAuth());
- assertFalse("Socket did not reset its want client auth state",
- ssocket.getWantClientAuth());
- ssocket.setWantClientAuth(true);
- ssocket.setNeedClientAuth(true);
- assertTrue("Result does not correspond to expected",
- ssocket.getNeedClientAuth());
- assertFalse("Socket did not reset its want client auth state",
- ssocket.getWantClientAuth());
- }
-
- /**
- * setWantClientAuth(boolean want) method testing.
- * getWantClientAuth() method testing.
- */
- public void testSetGetWantClientAuth() throws Exception {
- SSLServerSocket ssocket = createSSLServerSocket();
-
- ssocket.setNeedClientAuth(true);
- ssocket.setWantClientAuth(false);
- assertFalse("Result does not correspond to expected",
- ssocket.getWantClientAuth());
- assertFalse("Socket did not reset its want client auth state",
- ssocket.getNeedClientAuth());
- ssocket.setNeedClientAuth(true);
- ssocket.setWantClientAuth(true);
- assertTrue("Result does not correspond to expected",
- ssocket.getWantClientAuth());
- assertFalse("Socket did not reset its want client auth state",
- ssocket.getNeedClientAuth());
- }
-
- /**
- * setEnableSessionCreation(boolean flag) method testing.
- * getEnableSessionCreation() method testing.
- */
- public void testSetGetEnableSessionCreation() throws Exception {
- SSLServerSocket ssocket = createSSLServerSocket();
-
- ssocket.setEnableSessionCreation(false);
- assertFalse("Result does not correspond to expected",
- ssocket.getEnableSessionCreation());
- ssocket.setEnableSessionCreation(true);
- assertTrue("Result does not correspond to expected",
- ssocket.getEnableSessionCreation());
- }
-
- /**
- * toString() method testing.
- */
- public void testToString() throws Exception {
- SSLServerSocket ssocket = createSSLServerSocket();
- assertNotNull("String representation is null", ssocket.toString());
- }
-
- private static class Client extends Thread {
-
- private boolean closed;
- private boolean handshake_started = false;
- private Socket client = null;
- private int port;
-
- public Client(int port) throws IOException {
- super();
- this.port = port;
- client = new Socket();
- client.setSoTimeout(10000);
- }
-
- public int getPort() {
- return client.getLocalPort();
- }
-
- @Override
- public void run() {
- while (!closed) {
- try {
- if (doLog) {
- System.out.print(".");
- }
- if (!handshake_started) {
- client.connect(
- new InetSocketAddress("localhost", port));
- client.getInputStream().read();
- handshake_started = true;
- }
- Thread.sleep(1000);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- if (client != null) {
- try {
- client.close();
- } catch (IOException e) {
- }
- }
- //System.out.println("===== client has been stopped");
- }
-
- public boolean handshakeStarted() {
- return handshake_started;
- }
-
- public void close() throws IOException {
- closed = true;
- client.close();
- }
-
- }
-
- ;
-
- public static Test suite() {
- return new TestSuite(SSLServerSocketImplTest.class);
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSessionContextImplTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSessionContextImplTest.java
deleted file mode 100644
index 269fb39..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSessionContextImplTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.util.Enumeration;
-import java.security.SecureRandom;
-
-import javax.net.ssl.SSLSession;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>SSLSessionContextImp</code> constructor and methods
- */
-public class SSLSessionContextImplTest extends TestCase {
-
- public void testSSLSessionContextImpl() {
- SecureRandom sr = new SecureRandom();
- SSLSessionImpl ses1 = new SSLSessionImpl(
- CipherSuite.TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA, sr);
- SSLSessionImpl ses2 = new SSLSessionImpl(
- CipherSuite.TLS_DH_anon_WITH_3DES_EDE_CBC_SHA, sr);
- SSLSessionImpl ses3 = new SSLSessionImpl(
- CipherSuite.TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5, sr);
-
- SSLSessionContextImpl context = new SSLSessionContextImpl();
- context.putSession(ses1);
- context.putSession(ses2);
- context.putSession(ses3);
-
- for (Enumeration en = context.getIds(); en.hasMoreElements(); ) {
- byte[] id = (byte[]) en.nextElement();
- assertTrue(context.getSession(id) != null);
- }
-
- SSLSession ses = context.getSession(ses1.getId());
- assertSame(ses1, ses);
-
- ses = context.getSession(ses3.getId());
- assertSame(ses3, ses);
- }
-
- public void testGetSessionCacheSize() {
- SSLSessionContextImpl context = new SSLSessionContextImpl();
- assertEquals(0, context.getSessionCacheSize());
-
- context.setSessionCacheSize(100);
- assertEquals(100, context.getSessionCacheSize());
-
- try {
- context.setSessionCacheSize(-1);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testGetSessionTimeout() {
- SSLSessionContextImpl context = new SSLSessionContextImpl();
- assertEquals(0, context.getSessionTimeout());
-
- context.setSessionTimeout(1000);
- assertEquals(1000, context.getSessionTimeout());
-
- try {
- context.setSessionTimeout(-1);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
-} \ No newline at end of file
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSessionImplTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSessionImplTest.java
deleted file mode 100644
index 61c669c..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSessionImplTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.security.SecureRandom;
-import java.util.Arrays;
-
-import javax.net.ssl.SSLPeerUnverifiedException;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>SSLSessionContextImp</code> constructor and methods
- */
-public class SSLSessionImplTest extends TestCase {
-
- /*
- * Class under test for void SSLSessionImpl(CipherSuite, SecureRandom)
- */
- public void testSSLSessionImplCipherSuiteSecureRandom() {
- SSLSessionImpl session = new SSLSessionImpl(null, null);
- assertEquals(session.getCipherSuite(),
- CipherSuite.TLS_NULL_WITH_NULL_NULL.getName());
-
- session = new SSLSessionImpl(CipherSuite.TLS_RSA_WITH_NULL_MD5,
- new SecureRandom());
- session.protocol = ProtocolVersion.TLSv1;
- assertEquals("Incorrect protocol", "TLSv1", session.getProtocol());
- assertEquals("Incorrect cipher suite", session.getCipherSuite(),
- CipherSuite.TLS_RSA_WITH_NULL_MD5.getName());
- assertEquals("Incorrect id", 32, session.getId().length);
- assertTrue("Incorrect isValid", session.isValid());
- assertTrue("Incorrect isServer", session.isServer);
- long time = session.getCreationTime();
- assertTrue("Incorrect CreationTime", time <= System.currentTimeMillis());
- assertEquals("Incorrect LastAccessedTime", time, session.getLastAccessedTime());
- assertNull("Incorrect LocalCertificates", session.getLocalCertificates());
- assertNull("Incorrect LocalPrincipal", session.getLocalPrincipal());
- assertNull(session.getPeerHost());
- assertEquals(-1, session.getPeerPort());
- assertNull(session.getSessionContext());
-
- try {
- session.getPeerCertificateChain();
- fail("getPeerCertificateChain: No expected SSLPeerUnverifiedException");
- } catch (SSLPeerUnverifiedException e) {
- }
-
- try {
- session.getPeerCertificates();
- fail("getPeerCertificates: No expected SSLPeerUnverifiedException");
- } catch (SSLPeerUnverifiedException e) {
- }
-
- try {
- session.getPeerPrincipal();
- fail("getPeerPrincipal: No expected SSLPeerUnverifiedException");
- } catch (SSLPeerUnverifiedException e) {
- }
- }
-
- public void testGetApplicationBufferSize() {
- assertEquals(SSLSessionImpl.NULL_SESSION.getApplicationBufferSize(),
- SSLRecordProtocol.MAX_DATA_LENGTH);
- }
-
- public void testGetPacketBufferSize() {
- assertEquals(SSLSessionImpl.NULL_SESSION.getPacketBufferSize(),
- SSLRecordProtocol.MAX_SSL_PACKET_SIZE);
- }
-
- public void testInvalidate() {
- SSLSessionImpl session = new SSLSessionImpl(
- CipherSuite.TLS_RSA_WITH_NULL_MD5, new SecureRandom());
- session.invalidate();
- assertFalse("Incorrect isValid", session.isValid());
-
- }
-
- public void testSetPeer() {
- SSLSessionImpl session = new SSLSessionImpl(null);
- session.setPeer("someHost", 8080);
- assertEquals("someHost", session.getPeerHost());
- assertEquals(8080, session.getPeerPort());
- }
-
-
- public void testGetValue() {
- SSLSessionImpl session = new SSLSessionImpl(null);
-
- assertEquals(0, session.getValueNames().length);
-
- try {
- session.getValue(null);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- assertNull(session.getValue("abc"));
-
- try {
- session.removeValue(null);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- session.removeValue("abc");
-
- try {
- session.putValue(null, "1");
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- session.putValue("abc", null);
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
-
- Object o = new Object();
- session.putValue("abc", o);
- assertSame(session.getValue("abc"), o);
- assertEquals("abc", session.getValueNames()[0]);
-
- session.removeValue("abc");
- assertNull(session.getValue("abc"));
- }
-
- public void testClone() {
- SSLSessionImpl session1 = new SSLSessionImpl(
- CipherSuite.TLS_RSA_WITH_NULL_MD5, new SecureRandom());
- SSLSessionImpl session2 = (SSLSessionImpl) session1.clone();
- assertTrue(Arrays.equals(session1.getId(), session2.getId()));
- }
-
-} \ No newline at end of file
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFactoriesTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFactoriesTest.java
deleted file mode 100644
index 354a3f9..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFactoriesTest.java
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.util.Arrays;
-import javax.net.ssl.SSLServerSocket;
-import javax.net.ssl.SSLServerSocketFactory;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.SSLSocketFactory;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * SSLSocketImplTest
- */
-public class SSLSocketFactoriesTest extends TestCase {
-
- // turn on/off the debug logging
- private boolean doLog = false;
-
- /**
- * Sets up the test case.
- */
- @Override
- public void setUp() throws Exception {
- super.setUp();
- if (doLog) {
- System.out.println("========================");
- System.out.println("====== Running the test: " + getName());
- System.out.println("========================");
- }
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Tests default initialized factories.
- */
- public void testDefaultInitialized() throws Exception {
-
- SSLServerSocketFactory ssfactory =
- (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
- SSLSocketFactory sfactory =
- (SSLSocketFactory) SSLSocketFactory.getDefault();
-
- assertNotNull(ssfactory.getDefaultCipherSuites());
- assertNotNull(ssfactory.getSupportedCipherSuites());
- assertNotNull(ssfactory.createServerSocket());
-
- assertNotNull(sfactory.getDefaultCipherSuites());
- assertNotNull(sfactory.getSupportedCipherSuites());
- assertNotNull(sfactory.createSocket());
- }
-
- public void testSocketCreation() throws Throwable {
- SSLSocketFactory socketFactory
- = new SSLSocketFactoryImpl(JSSETestData.getSSLParameters());
- SSLServerSocketFactory serverSocketFactory
- = new SSLServerSocketFactoryImpl(JSSETestData.getSSLParameters());
-
- String[] enabled = { "TLS_RSA_WITH_RC4_128_MD5" };
- for (int i = 0; i < 4; i++) {
- SSLServerSocket ssocket;
- switch (i) {
- case 0:
- if (doLog) {
- System.out.println(
- "*** ServerSocketFactory.createServerSocket()");
- }
- ssocket = (SSLServerSocket)
- serverSocketFactory.createServerSocket();
- ssocket.bind(null);
- break;
- case 1:
- if (doLog) {
- System.out.println(
- "*** ServerSocketFactory.createServerSocket(int)");
- }
- ssocket = (SSLServerSocket)
- serverSocketFactory.createServerSocket(0);
- break;
- case 2:
- if (doLog) {
- System.out.println(
- "*** ServerSocketFactory.createServerSocket(int,int)");
- }
- ssocket = (SSLServerSocket)
- serverSocketFactory.createServerSocket(0, 6);
- break;
- default:
- if (doLog) {
- System.out.println("*** ServerSocketFactory."
- + "createServerSocket(int,int,InetAddress)");
- }
- ssocket = (SSLServerSocket)
- serverSocketFactory.createServerSocket(0, 6, null);
- break;
- }
- ssocket.setUseClientMode(false);
- ssocket.setEnabledCipherSuites(enabled);
- for (int j = 0; j < 6; j++) {
- SSLSocket csocket;
- switch (j) {
- case 0:
- if (doLog) {
- System.out.println(
- "=== SocketFactory.createSocket()");
- }
- csocket = (SSLSocket) socketFactory.createSocket();
- csocket.connect(
- new InetSocketAddress("localhost",
- ssocket.getLocalPort()));
- break;
- case 1:
- if (doLog) {
- System.out.println(
- "=== SocketFactory.createSocket(String,int)");
- }
- csocket = (SSLSocket)
- socketFactory.createSocket("localhost",
- ssocket.getLocalPort());
- break;
- case 2:
- if (doLog) {
- System.out.println("=== SocketFactory.createSocket("
- + "String,int,InetAddress,int)");
- }
- csocket = (SSLSocket)
- socketFactory.createSocket("localhost",
- ssocket.getLocalPort(),
- InetAddress.getByName("localhost"), 0);
- break;
- case 3:
- if (doLog) {
- System.out.println("=== SocketFactory.createSocket("
- + "InetAddress,int)");
- }
- csocket = (SSLSocket) socketFactory.createSocket(
- InetAddress.getByName("localhost"),
- ssocket.getLocalPort());
- break;
- case 4:
- if (doLog) {
- System.out.println("=== SocketFactory.createSocket("
- + "InetAddress,int,InetAddress,int)");
- }
- csocket = (SSLSocket) socketFactory.createSocket(
- InetAddress.getByName("localhost"),
- ssocket.getLocalPort(),
- InetAddress.getByName("localhost"),
- 0);
- break;
- default:
- if (doLog) {
- System.out.println(
- "=== SSLSocketFactory.createSocket("
- + "socket,String,int,boolean)");
- }
- Socket socket = new Socket(
- InetAddress.getByName("localhost"),
- ssocket.getLocalPort());
- csocket = (SSLSocket) socketFactory.createSocket(
- socket, "localhost", ssocket.getLocalPort(),
- true);
- break;
-
- }
- csocket.setUseClientMode(true);
- csocket.setEnabledCipherSuites(enabled);
- doTest(ssocket, csocket);
- }
- }
- }
-
- /**
- * SSLSocketFactory.getSupportedCipherSuites() method testing.
- */
- public void testGetSupportedCipherSuites1() throws Exception {
- SSLSocketFactory socketFactory
- = new SSLSocketFactoryImpl(JSSETestData.getSSLParameters());
- String[] supported = socketFactory.getSupportedCipherSuites();
- assertNotNull(supported);
- supported[0] = "NOT_SUPPORTED_CIPHER_SUITE";
- supported = socketFactory.getSupportedCipherSuites();
- for (int i = 0; i < supported.length; i++) {
- if ("NOT_SUPPORTED_CIPHER_SUITE".equals(supported[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- /**
- * SSLServerSocketFactory.getSupportedCipherSuites() method testing.
- */
- public void testGetSupportedCipherSuites2() throws Exception {
- SSLServerSocketFactory serverSocketFactory
- = new SSLServerSocketFactoryImpl(JSSETestData.getSSLParameters());
- String[] supported = serverSocketFactory.getSupportedCipherSuites();
- assertNotNull(supported);
- supported[0] = "NOT_SUPPORTED_CIPHER_SUITE";
- supported = serverSocketFactory.getSupportedCipherSuites();
- for (int i = 0; i < supported.length; i++) {
- if ("NOT_SUPPORTED_CIPHER_SUITE".equals(supported[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- /**
- * SSLSocketFactory.getDefaultCipherSuites() method testing.
- */
- public void testGetDefaultCipherSuites1() throws Exception {
- SSLSocketFactory socketFactory
- = new SSLSocketFactoryImpl(JSSETestData.getSSLParameters());
- String[] supported = socketFactory.getSupportedCipherSuites();
- String[] defaultcs = socketFactory.getDefaultCipherSuites();
- assertNotNull(supported);
- assertNotNull(defaultcs);
- for (int i = 0; i < defaultcs.length; i++) {
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (defaultcs[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Default suite does not belong to the set "
- + "of supported cipher suites: " + defaultcs[i]);
- }
- }
- }
-
- /**
- * SSLServerSocketFactory.getDefaultCipherSuites() method testing.
- */
- public void testGetDefaultCipherSuites2() throws Exception {
- SSLServerSocketFactory serverSocketFactory
- = new SSLServerSocketFactoryImpl(JSSETestData.getSSLParameters());
- String[] supported = serverSocketFactory.getSupportedCipherSuites();
- String[] defaultcs = serverSocketFactory.getDefaultCipherSuites();
- assertNotNull(supported);
- assertNotNull(defaultcs);
- for (int i = 0; i < defaultcs.length; i++) {
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (defaultcs[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Default suite does not belong to the set "
- + "of supported cipher suites: " + defaultcs[i]);
- }
- }
- }
-
- /**
- * Performs SSL connection between the sockets
- *
- * @return
- */
- public void doTest(SSLServerSocket ssocket, SSLSocket csocket)
- throws Throwable {
- final String server_message = "Hello from SSL Server Socket!";
- final String client_message = "Hello from SSL Socket!";
- Thread server = null;
- Thread client = null;
- final Throwable[] throwed = new Throwable[1];
- try {
- final SSLServerSocket ss = ssocket;
- final SSLSocket s = csocket;
- server = new Thread() {
- @Override
- public void run() {
- InputStream is = null;
- OutputStream os = null;
- SSLSocket s = null;
- try {
- s = (SSLSocket) ss.accept();
- if (doLog) {
- System.out.println("Socket accepted: " + s);
- }
- is = s.getInputStream();
- os = s.getOutputStream();
- // send the message to the client
- os.write(server_message.getBytes());
- // read the response
- byte[] buff = new byte[client_message.length()];
- int len = is.read(buff);
- if (doLog) {
- System.out.println("Received message of length "
- + len + ": '" + new String(buff, 0, len) + "'");
- }
- assertTrue("Read message does not equal to expected",
- Arrays.equals(client_message.getBytes(), buff));
- os.write(-1);
- assertEquals("Read data differs from expected",
- 255, is.read());
- if (doLog) {
- System.out.println("Server is closed: "
- + s.isClosed());
- }
- assertEquals("Returned value should be -1",
- // initiate an exchange of closure alerts
- -1, is.read());
- if (doLog) {
- System.out.println("Server is closed: "
- + s.isClosed());
- }
- assertEquals("Returned value should be -1",
- // initiate an exchange of closure alerts
- -1, is.read());
- } catch (Throwable e) {
- synchronized (throwed) {
- if (doLog) {
- e.printStackTrace();
- }
- if (throwed[0] == null) {
- throwed[0] = e;
- }
- }
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } catch (IOException ex) {
- }
- try {
- if (os != null) {
- os.close();
- }
- } catch (IOException ex) {
- }
- try {
- if (s != null) {
- s.close();
- }
- } catch (IOException ex) {
- }
- }
- }
- };
-
- client = new Thread() {
- @Override
- public void run() {
- InputStream is = null;
- OutputStream os = null;
- try {
- assertTrue("Client was not connected", s.isConnected());
- if (doLog) {
- System.out.println("Client connected");
- }
- is = s.getInputStream();
- os = s.getOutputStream();
- s.startHandshake();
- if (doLog) {
- System.out.println("Client: HS was done");
- }
- // read the message from the server
- byte[] buff = new byte[server_message.length()];
- int len = is.read(buff);
- if (doLog) {
- System.out.println("Received message of length "
- + len + ": '" + new String(buff, 0, len) + "'");
- }
- assertTrue("Read message does not equal to expected",
- Arrays.equals(server_message.getBytes(), buff));
- // send the response
- buff = (" " + client_message + " ").getBytes();
- os.write(buff, 1, buff.length - 2);
- assertEquals("Read data differs from expected",
- 255, is.read());
- os.write(-1);
- if (doLog) {
- System.out.println("Client is closed: "
- + s.isClosed());
- }
- s.close();
- if (doLog) {
- System.out.println("Client is closed: "
- + s.isClosed());
- }
- } catch (Throwable e) {
- synchronized (throwed) {
- if (doLog) {
- e.printStackTrace();
- }
- if (throwed[0] == null) {
- throwed[0] = e;
- }
- }
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } catch (IOException ex) {
- }
- try {
- if (os != null) {
- os.close();
- }
- } catch (IOException ex) {
- }
- try {
- if (s != null) {
- s.close();
- }
- } catch (IOException ex) {
- }
- }
- }
- };
-
- server.start();
- client.start();
-
- while (server.isAlive() || client.isAlive()) {
- if (throwed[0] != null) {
- throw throwed[0];
- }
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- }
- } finally {
- if (server != null) {
- server.stop();
- }
- if (client != null) {
- client.stop();
- }
- }
- if (throwed[0] != null) {
- throw throwed[0];
- }
- }
-
- public static Test suite() {
- return new TestSuite(SSLSocketFactoriesTest.class);
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFunctionalTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFunctionalTest.java
deleted file mode 100644
index 5accd5c..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFunctionalTest.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-import javax.net.ssl.HandshakeCompletedEvent;
-import javax.net.ssl.HandshakeCompletedListener;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLServerSocket;
-import javax.net.ssl.SSLSocket;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * SSLSocketImplTest
- */
-public class SSLSocketFunctionalTest extends TestCase {
-
- /**
- * The cipher suites used for functionality testing.
- */
- private String[] cipher_suites = {
- "RSA_WITH_RC4_128_MD5",
- "RSA_WITH_DES_CBC_SHA",
- "DH_anon_EXPORT_WITH_DES40_CBC_SHA"
- };
-
- // turn on/off the debug logging
- private boolean doLog = false;
-
- /**
- * Sets up the test case.
- */
- @Override
- public void setUp() throws Exception {
- if (doLog) {
- System.out.println("========================");
- System.out.println("====== Running the test: " + getName());
- System.out.println("========================");
- }
- }
-
- public void testContextInitialized2() throws Throwable {
- doTestSelfInteraction(JSSETestData.getContext());
- }
-
- public void doTestInteraction(SSLContext context, SSLContext ctx_other)
- throws Throwable {
- SSLContext ctx1, ctx2;
-
- ctx1 = context;
- ctx2 = ctx_other;
-
- int k = 1;
-
- SSLServerSocket ssocket = (SSLServerSocket) ctx1
- .getServerSocketFactory().createServerSocket(0);
- ssocket.setUseClientMode(false);
- ssocket.setEnabledCipherSuites(
- ((k & 1) > 0)
- ? new String[] { "TLS_" + cipher_suites[0] }
- : new String[] { "SSL_" + cipher_suites[0] });
-
- SSLSocket csocket = (SSLSocket) ctx2
- .getSocketFactory().createSocket("localhost",
- ssocket.getLocalPort());
- csocket.setEnabledProtocols(new String[] { "TLSv1" });
- csocket.setUseClientMode(true);
- csocket.setEnabledCipherSuites(
- (((k & 2) >> 1) > 0)
- ? new String[] { "TLS_" + cipher_suites[0] }
- : new String[] { "SSL_" + cipher_suites[0] });
- doTest(ssocket, csocket);
- }
-
- public void _doTestInteraction(SSLContext context, SSLContext ctx_other)
- throws Throwable {
- for (int i = 0; i < cipher_suites.length; i++) {
- if (doLog) {
- System.out.println("======== Checking the work on cipher: "
- + cipher_suites[i]);
- }
- SSLContext ctx1, ctx2;
- // k: 00, 01, 10, 11;
- // where 1 means implementation under the test,
- // 0 - another implementation to interract with
- for (int k = 0; k < 4; k++) {
- if (doLog) {
- System.out.println("======== " + (k & 1) + " " + ((k & 2) >> 1));
- }
- ctx1 = ((k & 1) > 0) ? context : ctx_other;
- ctx2 = (((k & 2) >> 1) > 0) ? context : ctx_other;
-
- SSLServerSocket ssocket = (SSLServerSocket) ctx1
- .getServerSocketFactory().createServerSocket(0);
- ssocket.setUseClientMode(false);
- ssocket.setEnabledCipherSuites(
- ((k & 1) > 0)
- ? new String[] { "TLS_" + cipher_suites[i] }
- : new String[] { "SSL_" + cipher_suites[i] });
-
- SSLSocket csocket = (SSLSocket) ctx2
- .getSocketFactory().createSocket("localhost",
- ssocket.getLocalPort());
- csocket.setEnabledProtocols(new String[] { "TLSv1" });
- csocket.setUseClientMode(true);
- csocket.setEnabledCipherSuites(
- (((k & 2) >> 1) > 0)
- ? new String[] { "TLS_" + cipher_suites[i] }
- : new String[] { "SSL_" + cipher_suites[i] });
- doTest(ssocket, csocket);
- }
- }
- }
-
- /**
- * Tests the interaction with other implementation.
- */
- public void doTestSelfInteraction(SSLContext context)
- throws Throwable {
- String[] protocols = { "SSLv3", "TLSv1" };
- for (int i = 0; i < cipher_suites.length; i++) {
- for (int j = 0; j < 2; j++) {
- if (doLog) {
- System.out.println("======= " + cipher_suites[i]);
- }
- SSLServerSocket ssocket = (SSLServerSocket) context
- .getServerSocketFactory().createServerSocket(0);
- ssocket.setUseClientMode(false);
- ssocket.setEnabledProtocols(new String[] { protocols[j] });
- ssocket.setEnabledCipherSuites(
- new String[] { "TLS_" + cipher_suites[i] });
-
- SSLSocket csocket = (SSLSocket) context
- .getSocketFactory().createSocket("localhost",
- ssocket.getLocalPort());
- csocket.setEnabledProtocols(new String[] { protocols[j] });
- csocket.setUseClientMode(true);
- csocket.setEnabledCipherSuites(
- new String[] { "TLS_" + cipher_suites[i] });
-
- doTest(ssocket, csocket);
- }
- }
- }
-
- private static class HandshakeListener
- implements HandshakeCompletedListener {
- boolean compleated = false;
-
- public void handshakeCompleted(HandshakeCompletedEvent event) {
- compleated = true;
- }
- }
-
- /**
- * Performs SSL connection between the sockets
- *
- * @return
- */
- public void doTest(SSLServerSocket ssocket, SSLSocket csocket)
- throws Throwable {
- final String server_message = "Hello from SSL Server Socket!";
- final String client_message = "Hello from SSL Socket!";
- Thread server = null;
- Thread client = null;
- final Throwable[] throwed = new Throwable[1];
- try {
- final SSLServerSocket ss = ssocket;
- final SSLSocket s = csocket;
- server = new Thread() {
- @Override
- public void run() {
- InputStream is = null;
- OutputStream os = null;
- SSLSocket s = null;
- try {
- s = (SSLSocket) ss.accept();
- if (doLog) {
- System.out.println("Socket accepted: " + s);
- }
- is = s.getInputStream();
- os = s.getOutputStream();
- // send the message to the client
- os.write(server_message.getBytes());
- // read the response
- byte[] buff = new byte[client_message.length()];
- int len = is.read(buff);
- if (doLog) {
- System.out.println("Received message of length "
- + len + ": '" + new String(buff, 0, len) + "'");
- }
- assertTrue("Read message does not equal to expected",
- Arrays.equals(client_message.getBytes(), buff));
- os.write(-1);
- assertEquals("Read data differs from expected",
- 255, is.read());
- if (doLog) {
- System.out.println("Server is closed: "
- + s.isClosed());
- }
- assertEquals("Returned value should be -1",
- // initiate an exchange of closure alerts
- -1, is.read());
- if (doLog) {
- System.out.println("Server is closed: "
- + s.isClosed());
- }
- assertEquals("Returned value should be -1",
- // initiate an exchange of closure alerts
- -1, is.read());
- } catch (Throwable e) {
- synchronized (throwed) {
- if (doLog) {
- e.printStackTrace();
- }
- if (throwed[0] == null) {
- throwed[0] = e;
- }
- }
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } catch (IOException ex) {
- }
- try {
- if (os != null) {
- os.close();
- }
- } catch (IOException ex) {
- }
- try {
- if (s != null) {
- s.close();
- }
- } catch (IOException ex) {
- }
- }
- }
- };
-
- client = new Thread() {
- @Override
- public void run() {
- InputStream is = null;
- OutputStream os = null;
- try {
- assertTrue("Client was not connected", s.isConnected());
- if (doLog) {
- System.out.println("Client connected");
- }
- is = s.getInputStream();
- os = s.getOutputStream();
- s.startHandshake();
- if (doLog) {
- System.out.println("Client: HS was done");
- }
- // read the message from the server
- byte[] buff = new byte[server_message.length()];
- int len = is.read(buff);
- if (doLog) {
- System.out.println("Received message of length "
- + len + ": '" + new String(buff, 0, len) + "'");
- }
- assertTrue("Read message does not equal to expected",
- Arrays.equals(server_message.getBytes(), buff));
- // send the response
- buff = (" " + client_message + " ").getBytes();
- os.write(buff, 1, buff.length - 2);
- assertEquals("Read data differs from expected",
- 255, is.read());
- os.write(-1);
- if (doLog) {
- System.out.println("\n======== Closing ========");
- }
- if (doLog) {
- System.out.println("Client is closed: "
- + s.isClosed());
- }
- s.close();
- if (doLog) {
- System.out.println("Client is closed: "
- + s.isClosed());
- }
- } catch (Throwable e) {
- synchronized (throwed) {
- if (doLog) {
- e.printStackTrace();
- }
- if (throwed[0] == null) {
- throwed[0] = e;
- }
- }
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } catch (IOException ex) {
- }
- try {
- if (os != null) {
- os.close();
- }
- } catch (IOException ex) {
- }
- try {
- if (s != null) {
- s.close();
- }
- } catch (IOException ex) {
- }
- }
- }
- };
-
- server.start();
- client.start();
-
- while (server.isAlive() || client.isAlive()) {
- if (throwed[0] != null) {
- throw throwed[0];
- }
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- }
- } finally {
- if (server != null) {
- server.stop();
- }
- if (client != null) {
- client.stop();
- }
- }
- if (throwed[0] != null) {
- throw throwed[0];
- }
- }
-
- public static Test suite() {
- return new TestSuite(SSLSocketFunctionalTest.class);
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketImplTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketImplTest.java
deleted file mode 100644
index 3ea8619..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketImplTest.java
+++ /dev/null
@@ -1,1234 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import javax.net.ssl.HandshakeCompletedEvent;
-import javax.net.ssl.HandshakeCompletedListener;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSocket;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * SSLSocketImplTest test
- */
-public class SSLSocketImplTest extends TestCase {
-
- // turn on/off the debug logging
- private static boolean doLog = false;
-
- /**
- * Sets up the test case.
- */
- @Override
- public void setUp() throws Exception {
- if (doLog) {
- System.out.println("");
- System.out.println("========================");
- System.out.println("====== Running the test: " + getName());
- }
- }
-
- private SSLSocket createSSLSocket() throws Exception {
- return new SSLSocketImpl(JSSETestData.getSSLParameters());
- }
-
- private SSLSocket createSSLSocket(int port) throws Exception {
- return new SSLSocketImpl("localhost", port,
- JSSETestData.getSSLParameters());
- }
-
- /**
- * SSLSocketImpl(SSLParameters sslParameters) method testing.
- */
- public void testSSLSocketImpl1() throws Exception {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
-
- socket = new SSLSocketImpl(JSSETestData.getSSLParameters());
- socket.connect(
- new InetSocketAddress("localhost", server.getPort()));
- ((SSLSocketImpl) socket).init();
- socket.setUseClientMode(true);
-
- server.start();
- final SSLSocket s = socket;
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- s.startHandshake();
- } catch (Exception e) {
- }
- }
- };
-
- thread.start();
-
- int timeout = 10; // wait no more than 10*500 ms for handshake
- while (!server.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- try {
- socket.close();
- } catch (IOException ex) {
- }
- fail("Handshake was not started");
- }
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * SSLSocketImpl(String host, int port, SSLParameters sslParameters) method
- * testing.
- */
- public void testSSLSocketImpl2() throws Exception {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
-
- socket = new SSLSocketImpl("localhost",
- server.getPort(), JSSETestData.getSSLParameters());
- socket.setUseClientMode(true);
-
- server.start();
- final SSLSocket s = socket;
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- s.startHandshake();
- } catch (Exception e) {
- }
- }
- };
-
- thread.start();
-
- int timeout = 10; // wait no more than 5 seconds for handshake
- while (!server.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- try {
- socket.close();
- } catch (IOException ex) {
- }
- fail("Handshake was not started");
- }
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * SSLSocketImpl(String host, int port, InetAddress localHost, int
- * localPort, SSLParameters sslParameters) method testing.
- */
- public void testSSLSocketImpl3() throws Exception {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
-
- socket = new SSLSocketImpl(
- "localhost",
- server.getPort(),
- InetAddress.getByName("localhost"),
- 0, JSSETestData.getSSLParameters());
- socket.setUseClientMode(true);
-
- server.start();
- final SSLSocket s = socket;
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- s.startHandshake();
- } catch (Exception e) {
- }
- }
- };
-
- thread.start();
-
- int timeout = 10; // wait no more than 5 seconds for handshake
- while (!server.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- try {
- socket.close();
- } catch (IOException ex) {
- }
- fail("Handshake was not started");
- }
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * SSLSocketImpl(InetAddress host, int port, SSLParameters sslParameters)
- * method testing.
- */
- public void testSSLSocketImpl4() throws Exception {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
-
- socket = new SSLSocketImpl(
- InetAddress.getByName("localhost"),
- server.getPort(),
- JSSETestData.getSSLParameters());
- socket.setUseClientMode(true);
-
- server.start();
- final SSLSocket s = socket;
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- s.startHandshake();
- } catch (Exception e) {
- }
- }
- };
-
- thread.start();
-
- int timeout = 10; // wait no more than 5 seconds for handshake
- while (!server.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- try {
- socket.close();
- } catch (IOException ex) {
- }
- fail("Handshake was not started");
- }
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * SSLSocketImpl(InetAddress address, int port, InetAddress localAddress,
- * int localPort, SSLParameters sslParameters) method testing.
- */
- public void testSSLSocketImpl5() throws Exception {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
-
- socket = new SSLSocketImpl(
- InetAddress.getByName("localhost"),
- server.getPort(),
- InetAddress.getByName("localhost"),
- 0, JSSETestData.getSSLParameters());
- socket.setUseClientMode(true);
-
- server.start();
- final SSLSocket s = socket;
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- s.startHandshake();
- } catch (Exception e) {
- }
- }
- };
-
- thread.start();
-
- int timeout = 10; // wait no more than 5 seconds for handshake
- while (!server.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- try {
- socket.close();
- } catch (IOException ex) {
- }
- fail("Handshake was not started");
- }
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * getSupportedCipherSuites() method testing.
- */
- public void testGetSupportedCipherSuites() throws Exception {
- SSLSocket socket = createSSLSocket();
- String[] supported = socket.getSupportedCipherSuites();
- assertNotNull(supported);
- supported[0] = "NOT_SUPPORTED_CIPHER_SUITE";
- supported = socket.getEnabledCipherSuites();
- for (int i = 0; i < supported.length; i++) {
- if ("NOT_SUPPORTED_CIPHER_SUITE".equals(supported[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- /**
- * getEnabledCipherSuites() method testing.
- */
- public void testGetEnabledCipherSuites() throws Exception {
- SSLSocket socket = createSSLSocket();
- String[] enabled = socket.getEnabledCipherSuites();
- assertNotNull(enabled);
- String[] supported = socket.getSupportedCipherSuites();
- for (int i = 0; i < enabled.length; i++) {
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (enabled[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Enabled suite does not belong to the set "
- + "of supported cipher suites: " + enabled[i]);
- }
- }
- socket.setEnabledCipherSuites(supported);
- for (int i = 0; i < supported.length; i++) {
- enabled = new String[supported.length - i];
- System.arraycopy(supported, 0,
- enabled, 0, supported.length - i);
- socket.setEnabledCipherSuites(enabled);
- String[] result = socket.getEnabledCipherSuites();
- if (result.length != enabled.length) {
- fail("Returned result does not correspond to expected.");
- }
- for (int k = 0; k < result.length; k++) {
- found:
- {
- for (int n = 0; n < enabled.length; n++) {
- if (result[k].equals(enabled[n])) {
- break found;
- }
- }
- if (result.length != enabled.length) {
- fail("Returned result does not correspond "
- + "to expected.");
- }
- }
- }
- }
- }
-
- /**
- * setEnabledCipherSuites(String[] suites) method testing.
- */
- public void testSetEnabledCipherSuites() throws Exception {
- SSLSocket socket = createSSLSocket();
- String[] enabled = socket.getEnabledCipherSuites();
- assertNotNull(enabled);
- String[] supported = socket.getSupportedCipherSuites();
- for (int i = 0; i < enabled.length; i++) {
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (enabled[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Enabled suite does not belong to the set "
- + "of supported cipher suites: " + enabled[i]);
- }
- }
- socket.setEnabledCipherSuites(supported);
- socket.setEnabledCipherSuites(enabled);
- socket.setEnabledCipherSuites(supported);
- String[] more_than_supported = new String[supported.length + 1];
- for (int i = 0; i < supported.length + 1; i++) {
- more_than_supported[i]
- = "NOT_SUPPORTED_CIPHER_SUITE";
- System.arraycopy(supported, 0,
- more_than_supported, 0, i);
- System.arraycopy(supported, i,
- more_than_supported, i + 1, supported.length - i);
- try {
- socket.setEnabledCipherSuites(more_than_supported);
- fail("Expected IllegalArgumentException was not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- enabled = socket.getEnabledCipherSuites();
- enabled[0] = "NOT_SUPPORTED_CIPHER_SUITE";
- enabled = socket.getEnabledCipherSuites();
- for (int i = 0; i < enabled.length; i++) {
- if ("NOT_SUPPORTED_CIPHER_SUITE".equals(enabled[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- /**
- * getSupportedProtocols() method testing.
- */
- public void testGetSupportedProtocols() throws Exception {
- SSLSocket socket = createSSLSocket();
- String[] supported = socket.getSupportedProtocols();
- assertNotNull(supported);
- assertFalse(supported.length == 0);
- supported[0] = "NOT_SUPPORTED_PROTOCOL";
- supported = socket.getSupportedProtocols();
- for (int i = 0; i < supported.length; i++) {
- if ("NOT_SUPPORTED_PROTOCOL".equals(supported[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- /**
- * getEnabledProtocols() method testing.
- */
- public void testGetEnabledProtocols() throws Exception {
- SSLSocket socket = createSSLSocket();
- String[] enabled = socket.getEnabledProtocols();
- assertNotNull(enabled);
- String[] supported = socket.getSupportedProtocols();
- for (int i = 0; i < enabled.length; i++) {
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (enabled[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Enabled protocol does not belong to the set "
- + "of supported protocols: " + enabled[i]);
- }
- }
- socket.setEnabledProtocols(supported);
- for (int i = 0; i < supported.length; i++) {
- enabled = new String[supported.length - i];
- System.arraycopy(supported, i,
- enabled, 0, supported.length - i);
- socket.setEnabledProtocols(enabled);
- String[] result = socket.getEnabledProtocols();
- if (result.length != enabled.length) {
- fail("Returned result does not correspond to expected.");
- }
- for (int k = 0; k < result.length; k++) {
- found:
- {
- for (int n = 0; n < enabled.length; n++) {
- if (result[k].equals(enabled[n])) {
- break found;
- }
- }
- if (result.length != enabled.length) {
- fail("Returned result does not correspond "
- + "to expected.");
- }
- }
- }
- }
- }
-
- /**
- * setEnabledProtocols(String[] protocols) method testing.
- */
- public void testSetEnabledProtocols() throws Exception {
- SSLSocket socket = createSSLSocket();
- String[] enabled = socket.getEnabledProtocols();
- assertNotNull(enabled);
- String[] supported = socket.getSupportedProtocols();
- for (int i = 0; i < enabled.length; i++) {
- //System.out.println("Checking of "+enabled[i]);
- found:
- {
- for (int j = 0; j < supported.length; j++) {
- if (enabled[i].equals(supported[j])) {
- break found;
- }
- }
- fail("Enabled suite does not belong to the set "
- + "of supported cipher suites: " + enabled[i]);
- }
- }
- socket.setEnabledProtocols(supported);
- socket.setEnabledProtocols(enabled);
- socket.setEnabledProtocols(supported);
- String[] more_than_supported = new String[supported.length + 1];
- for (int i = 0; i < supported.length + 1; i++) {
- more_than_supported[i]
- = "NOT_SUPPORTED_PROTOCOL";
- System.arraycopy(supported, 0,
- more_than_supported, 0, i);
- System.arraycopy(supported, i,
- more_than_supported, i + 1, supported.length - i);
- try {
- socket.setEnabledProtocols(more_than_supported);
- fail("Expected IllegalArgumentException was not thrown");
- } catch (IllegalArgumentException e) {
- }
- }
- enabled = socket.getEnabledProtocols();
- enabled[0] = "NOT_SUPPORTED_PROTOCOL";
- enabled = socket.getEnabledProtocols();
- for (int i = 0; i < enabled.length; i++) {
- if ("NOT_SUPPORTED_PROTOCOL".equals(enabled[i])) {
- fail("Modification of the returned result "
- + "causes the modification of the internal state");
- }
- }
- }
-
- private static class Server extends Thread {
-
- private final ServerSocket server;
- private boolean closed;
- private boolean handshake_started = false;
- private Socket endpoint = null;
-
- public Server() throws IOException {
- super();
- server = new ServerSocket(0);
- server.setSoTimeout(1000);
- }
-
- public int getPort() {
- return server.getLocalPort();
- }
-
- @Override
- public void run() {
- while (!closed) {
- try {
- if (doLog) {
- System.out.print(".");
- }
- if (!handshake_started) {
- endpoint = server.accept();
- endpoint.getInputStream().read();
- handshake_started = true;
- }
- Thread.sleep(1000);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- if (endpoint != null) {
- try {
- endpoint.close();
- } catch (IOException e) {
- }
- }
- }
-
- public boolean handshakeStarted() {
- return handshake_started;
- }
-
- public void close() throws IOException {
- closed = true;
- server.close();
- }
-
- }
-
- ;
-
- /**
- * setUseClientMode(boolean mode) method testing.
- * getUseClientMode() method testing.
- */
- public void testSetGetUseClientMode() throws Exception {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
-
- socket = createSSLSocket(server.getPort());
-
- socket.setUseClientMode(false);
- assertFalse("Result does not correspond to expected",
- socket.getUseClientMode());
- socket.setUseClientMode(true);
- assertTrue("Result does not correspond to expected",
- socket.getUseClientMode());
-
- server.start();
- final SSLSocket s = socket;
- new Thread() {
- @Override
- public void run() {
- try {
- s.startHandshake();
- } catch (IOException e) {
- //e.printStackTrace();
- }
- }
- }.start();
-
- while (!server.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- }
-
- try {
- socket.setUseClientMode(false);
- server.close();
- socket.close();
- fail("Expected IllegalArgumentException was not thrown");
- } catch (IllegalArgumentException e) {
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * setNeedClientAuth(boolean need) method testing.
- * getNeedClientAuth() method testing.
- */
- public void testSetGetNeedClientAuth() throws Exception {
- SSLSocket socket = createSSLSocket();
-
- socket.setWantClientAuth(true);
- socket.setNeedClientAuth(false);
- assertFalse("Result does not correspond to expected",
- socket.getNeedClientAuth());
- assertFalse("Socket did not reset its want client auth state",
- socket.getWantClientAuth());
- socket.setWantClientAuth(true);
- socket.setNeedClientAuth(true);
- assertTrue("Result does not correspond to expected",
- socket.getNeedClientAuth());
- assertFalse("Socket did not reset its want client auth state",
- socket.getWantClientAuth());
- }
-
- /**
- * setWantClientAuth(boolean want) method testing.
- * getWantClientAuth() method testing.
- */
- public void testSetGetWantClientAuth() throws Exception {
- SSLSocket socket = createSSLSocket();
-
- socket.setNeedClientAuth(true);
- socket.setWantClientAuth(false);
- assertFalse("Result does not correspond to expected",
- socket.getWantClientAuth());
- assertFalse("Socket did not reset its want client auth state",
- socket.getNeedClientAuth());
- socket.setNeedClientAuth(true);
- socket.setWantClientAuth(true);
- assertTrue("Result does not correspond to expected",
- socket.getWantClientAuth());
- assertFalse("Socket did not reset its want client auth state",
- socket.getNeedClientAuth());
- }
-
- /**
- * setEnableSessionCreation(boolean flag) method testing.
- * getEnableSessionCreation() method testing.
- */
- public void testSetGetEnableSessionCreation() throws Exception {
- SSLSocket socket = createSSLSocket();
-
- socket.setEnableSessionCreation(false);
- assertFalse("Result does not correspond to expected",
- socket.getEnableSessionCreation());
- socket.setEnableSessionCreation(true);
- assertTrue("Result does not correspond to expected",
- socket.getEnableSessionCreation());
- }
-
- /**
- * getSession() method testing.
- */
- public void testGetSession() throws Exception {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
-
- socket = createSSLSocket(server.getPort());
- socket.setUseClientMode(true);
-
- server.start();
- final SSLSocket s = socket;
- final SSLSession[] session = new SSLSession[1];
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- session[0] = s.getSession();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- };
-
- thread.start();
-
- int timeout = 10; // wait no more than 5 seconds for handshake
- while (!server.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- try {
- socket.close();
- } catch (IOException ex) {
- }
- fail("getSession method did not start a handshake");
- }
- }
-
- server.close(); // makes error during the handshake
- thread.join();
- if ((session[0] == null) ||
- (!session[0].getCipherSuite()
- .endsWith("_NULL_WITH_NULL_NULL"))) {
- fail("Returned session is null "
- + "or not TLS_NULL_WITH_NULL_NULL");
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * addHandshakeCompletedListener( HandshakeCompletedListener listener)
- * method testing.
- * removeHandshakeCompletedListener( HandshakeCompletedListener listener)
- * method testing.
- */
- public void testAddRemoveHandshakeCompletedListener() throws Exception {
- HandshakeCompletedListener listener =
- new HandshakeCompletedListener() {
- public void handshakeCompleted(
- HandshakeCompletedEvent event) {
- }
- };
- SSLSocket socket = createSSLSocket();
- socket.addHandshakeCompletedListener(listener);
- try {
- socket.addHandshakeCompletedListener(null);
- fail("Expected IllegalArgumentException was not thrown.");
- } catch (IllegalArgumentException e) {
- }
- try {
- socket.removeHandshakeCompletedListener(null);
- fail("Expected IllegalArgumentException was not thrown.");
- } catch (IllegalArgumentException e) {
- }
- try {
- socket.removeHandshakeCompletedListener(
- new HandshakeCompletedListener() {
- public void handshakeCompleted(
- HandshakeCompletedEvent event) {
- }
- });
- fail("Expected IllegalArgumentException was not thrown.");
- } catch (IllegalArgumentException e) {
- }
- try {
- socket.removeHandshakeCompletedListener(listener);
- } catch (IllegalArgumentException e) {
- fail("Unxpected IllegalArgumentException was thrown.");
- }
- }
-
- /**
- * startHandshake() method testing.
- */
- public void testStartHandshake() throws Exception {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
-
- socket = createSSLSocket(server.getPort());
- socket.setUseClientMode(true);
-
- server.start();
- final SSLSocket s = socket;
- final Exception[] exception = new Exception[1];
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- s.startHandshake();
- } catch (Exception e) {
- exception[0] = e;
- }
- }
- };
-
- thread.start();
-
- int timeout = 10; // wait no more than 5 seconds for handshake
- while (!server.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- fail("Handshake was not started");
- }
- }
-
- server.close(); // makes error during the handshake
- thread.join();
- if (exception[0] == null) {
- fail("Expected IOException was not thrown");
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * getInputStream() method testing.
- */
- public void testGetInputStream() throws Exception {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
-
- socket = createSSLSocket(server.getPort());
- socket.setUseClientMode(true);
-
- server.start();
- final SSLSocket s = socket;
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- s.getInputStream().read(); // should start handshake
- } catch (Exception e) {
- }
- }
- };
-
- thread.start();
-
- int timeout = 10; // wait no more than 5 seconds for handshake
- while (!server.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- try {
- socket.close();
- } catch (IOException ex) {
- }
- fail("Handshake was not started");
- }
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * getOutputStream() method testing.
- */
- public void testGetOutputStream() throws Exception {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
-
- socket = createSSLSocket(server.getPort());
- socket.setUseClientMode(true);
-
- server.start();
- final SSLSocket s = socket;
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- s.getOutputStream().write(0); // should start handshake
- } catch (Exception e) {
- }
- }
- };
-
- thread.start();
-
- int timeout = 10; // wait no more than 5 seconds for handshake
- while (!server.handshakeStarted()) {
- // wait for handshake start
- try {
- Thread.sleep(500);
- } catch (Exception e) {
- }
- timeout--;
- if (timeout < 0) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- try {
- socket.close();
- } catch (IOException ex) {
- }
- fail("Handshake was not started");
- }
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * sendUrgentData(int data) method testing.
- */
- public void testSendUrgentData() {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
- socket = createSSLSocket(server.getPort());
-
- socket.sendUrgentData(0);
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- if (doLog) {
- System.out.println("Trowed exception: " + e.getMessage());
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * setOOBInline(boolean on) method testing.
- */
- public void testSetOOBInline() {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
- socket = createSSLSocket(server.getPort());
-
- socket.setOOBInline(true);
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- if (doLog) {
- System.out.println("Trowed exception: " + e.getMessage());
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * shutdownOutput() method testing.
- */
- public void testShutdownOutput() {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
- socket = createSSLSocket(server.getPort());
-
- socket.shutdownOutput();
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- if (doLog) {
- System.out.println("Trowed exception: " + e.getMessage());
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * shutdownInput() method testing.
- */
- public void testShutdownInput() {
- Server server = null;
- SSLSocket socket = null;
- try {
- server = new Server();
- socket = createSSLSocket(server.getPort());
-
- socket.shutdownInput();
- fail("Expected exception was not thrown");
- } catch (Exception e) {
- if (doLog) {
- System.out.println("Trowed exception: " + e.getMessage());
- }
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException ex) {
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- }
- }
- }
- }
-
- /**
- * toString() method testing.
- */
- public void testToString() throws Exception {
- SSLSocket socket = createSSLSocket();
- assertNotNull("String representation is null", socket.toString());
- }
-
- public static Test suite() {
- return new TestSuite(SSLSocketImplTest.class);
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLStreamedInputTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLStreamedInputTest.java
deleted file mode 100644
index d9e14a8..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLStreamedInputTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.ByteArrayInputStream;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * SSLStreamedInputTest test
- */
-public class SSLStreamedInputTest extends TestCase {
-
- /**
- * SSLStreamedInput(InputStream in) method testing.
- */
- public void testSSLStreamedInput() throws Exception {
- byte[] data = { 1, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 5 };
- ByteArrayInputStream bis = new ByteArrayInputStream(data);
- SSLStreamedInput sslsi = new SSLStreamedInput(bis);
- assertEquals(bis.available(), sslsi.available());
- assertEquals(1, sslsi.read());
- assertEquals(1, sslsi.readUint32());
- sslsi.skip(3);
- assertEquals(5, sslsi.readUint64());
- try {
- sslsi.read();
- fail("Expected EndOfSourceException was not thrown");
- } catch (EndOfSourceException e) {
- }
- }
-
- public static Test suite() {
- return new TestSuite(SSLStreamedInputTest.class);
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHandshakeImplTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHandshakeImplTest.java
deleted file mode 100644
index 5b3c215..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHandshakeImplTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.security.KeyStore;
-import java.security.SecureRandom;
-
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.TrustManagerFactory;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ServerHandshakeImpl</code> constructor and methods
- */
-public class ServerHandshakeImplTest extends TestCase {
- // to store initialization Exception
- private static Exception initException;
-
-
- private SSLParameters sslParameters;
- private ServerHandshakeImpl server;
-
- @Override
- public void setUp() throws Exception {
- char[] pwd = JSSETestData.KS_PASSWORD;
- KeyStore ks = JSSETestData.getKeyStore();
-
- KeyManagerFactory kmf = KeyManagerFactory.getInstance("X509");
- kmf.init(ks, pwd);
-
- TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
- tmf.init(ks);
-
- sslParameters = new SSLParameters(kmf.getKeyManagers(), tmf
- .getTrustManagers(), new SecureRandom(),
- new SSLSessionContextImpl(), new SSLSessionContextImpl());
-
- server = new ServerHandshakeImpl(new SSLEngineImpl(sslParameters));
-
- SSLEngineAppData appData = new SSLEngineAppData();
- AlertProtocol alertProtocol = new AlertProtocol();
- SSLBufferedInput recProtIS = new SSLBufferedInput();
- SSLRecordProtocol recordProtocol = new SSLRecordProtocol(server,
- alertProtocol, recProtIS, appData);
- }
-
- public void testUnwrap() {
- byte[] ses_id = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
- byte[] version = new byte[] { 3, 1 };
- CipherSuite[] cipher_suite = new CipherSuite[] {
- CipherSuite.TLS_RSA_WITH_RC4_128_MD5 };
- ClientHello message = new ClientHello(new SecureRandom(), version,
- ses_id, cipher_suite);
- HandshakeIODataStream out = new HandshakeIODataStream();
- out.writeUint8(message.getType());
- out.writeUint24(message.length());
- message.send(out);
- byte[] encodedClientHello = out.getData(1000);
-
- // ----------------------------------------
- // unwrap client hello (full handshake)
- // precondition: session hash does not contains requested session
- server.unwrap(encodedClientHello);
- server.getTask().run(); // process client hello in delegated task
- server.wrap(); // modelling of server respond sending
-
- assertFalse(server.isResuming);
-
- // unwrap unexpected second client hello
- try {
- server.unwrap(encodedClientHello);
- fail("No expected AlertException");
- } catch (AlertException e) {
- }
-
- // unexpected ChangeCipherSpec
- try {
- server.receiveChangeCipherSpec();
- fail("No expected AlertException");
- } catch (AlertException e) {
- }
-
- // ----------------------------------------
- // unwrap client hello (abbreviated handshake)
- // precondition: session hash contains requested session
- clearServerData();
- SSLSessionImpl session = new SSLSessionImpl(
- CipherSuite.TLS_RSA_WITH_RC4_128_MD5, new SecureRandom());
- session.id = ses_id;
- // put session to hash
- server.parameters.getServerSessionContext().putSession(session);
-
- server.unwrap(encodedClientHello);
- server.getTask().run(); // process client hello in delegated task
- server.wrap(); // modelling of server respond sending
-
- assertTrue(server.isResuming);
-
- server.makeFinished(); // complete handshake
-
- // expected ChangeCipherSpec
- server.receiveChangeCipherSpec();
- }
-
- public void testServerHandshakeImpl() {
- assertEquals(server.status, HandshakeProtocol.NEED_UNWRAP);
- assertTrue(server.nonBlocking);
- assertSame(server.parameters.getKeyManager(), sslParameters
- .getKeyManager());
- assertSame(server.parameters.getTrustManager(), sslParameters
- .getTrustManager());
- assertNotNull(server.engineOwner);
- assertNull(server.socketOwner);
- }
-
- private void clearServerData() {
- server.clearMessages();
- server.io_stream = new HandshakeIODataStream();
- server.status = HandshakeProtocol.NEED_UNWRAP;
- }
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHelloTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHelloTest.java
deleted file mode 100644
index 88de18e..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHelloTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.IOException;
-import java.security.SecureRandom;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ServerHello</code> constructor and methods
- */
-public class ServerHelloTest extends TestCase {
-
- public void testServerHello() throws Exception {
- byte[] session_id = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
- CipherSuite cipher_suite = CipherSuite.TLS_DH_DSS_WITH_DES_CBC_SHA;
- byte[] server_version = new byte[] { 3, 1 };
- ServerHello message = new ServerHello(new SecureRandom(),
- server_version, session_id, cipher_suite, (byte) 0);
- assertEquals("incorrect type", Handshake.SERVER_HELLO, message
- .getType());
-
- assertTrue("incorrect CertificateRequest", Arrays.equals(
- message.server_version, server_version));
- assertTrue("incorrect CertificateRequest", Arrays.equals(
- message.session_id, session_id));
- assertEquals("incorrect CertificateRequest", cipher_suite,
- message.cipher_suite);
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(),
- encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- ServerHello message_2 = new ServerHello(in, message.length());
-
- assertTrue("incorrect message decoding", Arrays.equals(
- message.server_version, message_2.server_version));
- assertTrue("incorrect message decoding", Arrays.equals(
- message.session_id, message_2.session_id));
- assertTrue("incorrect message decoding", Arrays.equals(message.random,
- message_2.random));
- assertEquals("incorrect message decoding", message.cipher_suite,
- message_2.cipher_suite);
-
- in.append(encoded);
- try {
- new ServerHello(in, message.length() - 1);
- fail("Small length: No expected AlertException");
- } catch (AlertException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- new ServerHello(in, message.length() + 3);
- fail("Extra bytes: No expected AlertException ");
- } catch (AlertException e) {
- }
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerKeyExchangeTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerKeyExchangeTest.java
deleted file mode 100644
index e5628a7..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerKeyExchangeTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ServerKeyExchange</code> constructor and methods
- */
-public class ServerKeyExchangeTest extends TestCase {
-
- public void testServerKeyExchange_RSA_EXPORT() throws Exception {
- BigInteger rsa_mod = new BigInteger(
- "0620872145533812525365347773040950432706816921321053881493952289532007782427182339053847578435298266865073748931755945944874247298083566202475988854994079");
- BigInteger rsa_exp = new BigInteger("65537");
-
- byte[] hash = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6 };
- ServerKeyExchange message = new ServerKeyExchange(rsa_mod, rsa_exp,
- null, hash);
- assertEquals("incorrect type", Handshake.SERVER_KEY_EXCHANGE, message
- .getType());
-
- assertTrue("incorrect ServerKeyExchange", Arrays.equals(message.hash,
- hash));
- assertEquals("incorrect ServerKeyExchange", rsa_mod, message.par1);
- assertEquals("incorrect ServerKeyExchange", rsa_exp, message.par2);
- assertNull("incorrect ServerKeyExchange", message.par3);
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(),
- encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- ServerKeyExchange message_2 = new ServerKeyExchange(in, message
- .length(), CipherSuite.KeyExchange_RSA_EXPORT);
-
- assertTrue("incorrect message decoding", Arrays.equals(message.hash,
- message_2.hash));
- assertEquals("incorrect message decoding", message.par1, message_2.par1);
- assertEquals("incorrect message decoding", message.par2, message_2.par2);
- assertNull("incorrect message decoding", message_2.par3);
- assertEquals("incorrect message decoding", message.getRSAPublicKey(),
- message_2.getRSAPublicKey());
-
- in.append(encoded);
- try {
- new ServerKeyExchange(in, message.length() - 1,
- CipherSuite.KeyExchange_RSA_EXPORT);
- fail("Small length: No expected AlertException");
- } catch (AlertException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- new ServerKeyExchange(in, message.length() + 3,
- CipherSuite.KeyExchange_RSA_EXPORT);
- fail("Extra bytes: No expected AlertException ");
- } catch (AlertException e) {
- }
- }
-
- public void testServerKeyExchange_DHE_DSS() throws Exception {
- BigInteger dh_p = new BigInteger("1234567890");
- BigInteger dh_g = new BigInteger("987654321");
- BigInteger dh_Ys = new BigInteger("123123123");
- byte[] hash = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 0 };
- ServerKeyExchange message = new ServerKeyExchange(dh_p, dh_g, dh_Ys,
- hash);
- assertEquals("incorrect type", Handshake.SERVER_KEY_EXCHANGE, message
- .getType());
-
- assertTrue("incorrect ServerKeyExchange", Arrays.equals(message.hash,
- hash));
- assertEquals("incorrect ServerKeyExchange", dh_p, message.par1);
- assertEquals("incorrect ServerKeyExchange", dh_g, message.par2);
- assertEquals("incorrect ServerKeyExchange", dh_Ys, message.par3);
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(),
- encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- ServerKeyExchange message_2 = new ServerKeyExchange(in, message
- .length(), CipherSuite.KeyExchange_DHE_DSS);
-
- assertTrue("incorrect message decoding", Arrays.equals(message.hash,
- message_2.hash));
- assertEquals("incorrect message decoding", message.par1, message_2.par1);
- assertEquals("incorrect message decoding", message.par2, message_2.par2);
- assertEquals("incorrect message decoding", message.par3, message_2.par3);
-
- in.append(encoded);
- try {
- new ServerKeyExchange(in, message.length() - 1,
- CipherSuite.KeyExchange_DHE_DSS);
- fail("Small length: No expected AlertException");
- } catch (AlertException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- new ServerKeyExchange(in, message.length() + 3,
- CipherSuite.KeyExchange_DHE_DSS);
- fail("Extra bytes: No expected AlertException ");
- } catch (AlertException e) {
- }
- }
-
- public void testServerKeyExchange_DH_anon() throws Exception {
- BigInteger dh_p = new BigInteger("1234567890");
- BigInteger dh_g = new BigInteger("987654321");
- BigInteger dh_Ys = new BigInteger("123123123");
- ServerKeyExchange message = new ServerKeyExchange(dh_p, dh_g, dh_Ys,
- null);
- assertEquals("incorrect type", Handshake.SERVER_KEY_EXCHANGE, message
- .getType());
-
- assertNull("incorrect ServerKeyExchange", message.hash);
- assertEquals("incorrect ServerKeyExchange", dh_p, message.par1);
- assertEquals("incorrect ServerKeyExchange", dh_g, message.par2);
- assertEquals("incorrect ServerKeyExchange", dh_Ys, message.par3);
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(),
- encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- ServerKeyExchange message_2 = new ServerKeyExchange(in, message
- .length(), CipherSuite.KeyExchange_DH_anon);
-
- assertNull("incorrect message decoding", message_2.hash);
- assertEquals("incorrect message decoding", message.par1, message_2.par1);
- assertEquals("incorrect message decoding", message.par2, message_2.par2);
- assertEquals("incorrect message decoding", message.par3, message_2.par3);
-
- in.append(encoded);
- try {
- new ServerKeyExchange(in, message.length() - 1,
- CipherSuite.KeyExchange_DH_anon);
- fail("Small length: No expected AlertException");
- } catch (AlertException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- new ServerKeyExchange(in, message.length() + 3,
- CipherSuite.KeyExchange_DH_anon);
- fail("Extra bytes: No expected AlertException ");
- } catch (AlertException e) {
- }
- }
-
-}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/TrustManagerImplTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/TrustManagerImplTest.java
deleted file mode 100644
index 372d969..0000000
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/TrustManagerImplTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.security.KeyStore;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>TrustManagerImpl</code> constructor and methods
- */
-public class TrustManagerImplTest extends TestCase {
-
- // Cert. encoding.was generated by using of classes
- // from org.apache.harmony.security.asn1 package and encoded
- // by org.apache.harmony.misc.Base64 class.
- // Source:
- // org.apache.harmony.security.tests.support.provider.cert.CertFactoryTestData
- private static String base64certEncoding =
- "-----BEGIN CERTIFICATE-----\n" +
- "MIIC+jCCAragAwIBAgICAiswDAYHKoZIzjgEAwEBADAdMRswGQYDVQQKExJDZXJ0a" +
- "WZpY2F0ZSBJc3N1ZXIwIhgPMTk3MDAxMTIxMzQ2NDBaGA8xOTcwMDEyNDAzMzMyMF" +
- "owHzEdMBsGA1UEChMUU3ViamVjdCBPcmdhbml6YXRpb24wGTAMBgcqhkjOOAQDAQE" +
- "AAwkAAQIDBAUGBwiBAgCqggIAVaOCAhQwggIQMA8GA1UdDwEB/wQFAwMBqoAwEgYD" +
- "VR0TAQH/BAgwBgEB/wIBBTAUBgNVHSABAf8ECjAIMAYGBFUdIAAwZwYDVR0RAQH/B" +
- "F0wW4EMcmZjQDgyMi5OYW1lggdkTlNOYW1lpBcxFTATBgNVBAoTDE9yZ2FuaXphdG" +
- "lvboYaaHR0cDovL3VuaWZvcm0uUmVzb3VyY2UuSWSHBP///wCIByoDolyDsgMwDAY" +
- "DVR0eAQH/BAIwADAMBgNVHSQBAf8EAjAAMIGZBgNVHSUBAf8EgY4wgYsGBFUdJQAG" +
- "CCsGAQUFBwMBBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMDBggrBgEFBQcDB" +
- "AYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEFBQcDBwYIKwYBBQUHAwgGCCsGAQUFBw" +
- "MJBggrBgEFBQgCAgYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GA1UdNgEB/wQDAgE" +
- "BMA4GBCpNhgkBAf8EAwEBATBkBgNVHRIEXTBbgQxyZmNAODIyLk5hbWWCB2ROU05h" +
- "bWWkFzEVMBMGA1UEChMMT3JnYW5pemF0aW9uhhpodHRwOi8vdW5pZm9ybS5SZXNvd" +
- "XJjZS5JZIcE////AIgHKgOiXIOyAzAJBgNVHR8EAjAAMAoGA1UdIwQDAQEBMAoGA1" +
- "UdDgQDAQEBMAoGA1UdIQQDAQEBMAwGByqGSM44BAMBAQADMAAwLQIUAL4QvoazNWP" +
- "7jrj84/GZlhm09DsCFQCBKGKCGbrP64VtUt4JPmLjW1VxQA==\n" +
- "-----END CERTIFICATE-----\n";
-
- private X509Certificate[] untrustedChain;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- CertificateFactory certFactory = CertificateFactory.getInstance("X509");
- ByteArrayInputStream bais = new ByteArrayInputStream(base64certEncoding
- .getBytes("UTF-8"));
- X509Certificate cert = (X509Certificate) certFactory
- .generateCertificate(bais);
- untrustedChain = new X509Certificate[] { cert };
- }
-
- public void testTrustManagerImpl_1() throws Exception {
- KeyStore ks = KeyStore.getInstance("BKS");
- ks.load(null, null);
-
- TrustManagerImpl tm = new TrustManagerImpl(ks);
- assertEquals(0, tm.getAcceptedIssuers().length);
- checkTrustManager(tm);
- }
-
- public void testTrustManagerImpl_2() throws Exception {
- KeyStore ks = JSSETestData.getKeyStore();
-
- TrustManagerImpl tm = new TrustManagerImpl(ks);
- assertEquals(1, tm.getAcceptedIssuers().length);
- checkTrustManager(tm);
- }
-
- private void checkTrustManager(TrustManagerImpl tm) throws Exception {
- try {
- tm.checkClientTrusted(null, "RSA");
- fail("No expected IllegalArgumentException ");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- tm.checkClientTrusted(new X509Certificate[0], "RSA");
- fail("No expected IllegalArgumentException ");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- tm.checkClientTrusted(untrustedChain, "RSA");
- fail("No expected CertificateException ");
- } catch (CertificateException e) {
- }
-
- try {
- tm.checkServerTrusted(null, "RSA");
- fail("No expected IllegalArgumentException ");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- tm.checkServerTrusted(new X509Certificate[0], "RSA");
- fail("No expected IllegalArgumentException ");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- tm.checkServerTrusted(untrustedChain, "RSA");
- fail("No expected CertificateException ");
- } catch (CertificateException e) {
- }
- }
-} \ No newline at end of file
diff --git a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/DigitalSignatureTest.java b/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/DigitalSignatureTest.java
deleted file mode 100644
index 819843b..0000000
--- a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/DigitalSignatureTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.provider.jsse;
-
-import java.security.InvalidKeyException;
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.security.spec.X509EncodedKeySpec;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.luni.util.Base64;
-import org.apache.harmony.xnet.provider.jsse.DigitalSignature;
-
-/**
- * Tests for <code>DigitalSignature</code>class
- */
-public class DigitalSignatureTest extends TestCase {
-
- public void test_Sign() throws Exception {
-
- // Regression for HARMONY-2029
- // data arrays were taken from HARMONY-2125
-
- byte[] b64PublicKeySpec = ("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk7q/qebK6/tSLydRUCAvwcqRlS95aau5"
- + "xj2fFpLRYYG0avuO0qXn14HNmoC8kztk66Q+4oZS9SkQYwr24x+9ide0s9xfjQ5ohDpY6P+mtD6k"
- + "0piKwYmLXtqi7BTgpgoDXtYi6VJYzvBxLhe050vi1lUNe2iCl/jsU4IcBCcOjV4CwbTDRhq6PzT7"
- + "70uWtMhAV28E/jcszlyxHYZ5qK0wp8BoBdcNQf3tihBuQkrsv57z94tbEJxg5JeMOl1aWVtw6LLR"
- + "K2GQBaDrwvy7R4FA2oOc/JS9PsiT0ieKO1dhPGmqJDaVMlZMFeUY41hTzU3BAmcjYBWQI2oNqHRv"
- + "ya9tUQIDAQAB").getBytes("UTF-8");
-
- byte[] b64PrivateKeySpec = ("MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCTur+p5srr+1IvJ1FQIC/BypGV"
- + "L3lpq7nGPZ8WktFhgbRq+47SpefXgc2agLyTO2TrpD7ihlL1KRBjCvbjH72J17Sz3F+NDmiEOljo"
- + "/6a0PqTSmIrBiYte2qLsFOCmCgNe1iLpUljO8HEuF7TnS+LWVQ17aIKX+OxTghwEJw6NXgLBtMNG"
- + "Gro/NPvvS5a0yEBXbwT+NyzOXLEdhnmorTCnwGgF1w1B/e2KEG5CSuy/nvP3i1sQnGDkl4w6XVpZ"
- + "W3DostErYZAFoOvC/LtHgUDag5z8lL0+yJPSJ4o7V2E8aaokNpUyVkwV5RjjWFPNTcECZyNgFZAj"
- + "ag2odG/Jr21RAgMBAAECggEAJevfPUbQOilGXHJUTiQk/jL4kfogyX5absfsqYfAla4M2RWAARSz"
- + "Yb+hPpLjVUv+yPpdZhqi+umymin7XCwOpG6ppS3hnTzgmWi83/qYGVanSqP7olijXRL0lXN6g0S4"
- + "vsRrK8eGooBYHUPanTD+ppQopNAcDdTJHVqdxHceJi1gum4c3yZmoe510TjlqpOezAO6B0N1dfJf"
- + "KEIQjMdlWgKRq2WNzPDFO8Luhyg40PoTcoWZRhKWV5xPBmq4ew4epxuZpNnuVIzxs9gpjuK55xFg"
- + "ukXyyhmjsfJzdRs/9kToJdGU3prxf716fk+7OgzgdfWTXK0/uVBE9JIUPBxuAQKBgQDvT+jtTLYN"
- + "781CujruJUGIn5HHAsqzs1PuKhXS3Nb/+UPkdz0SK3BqReDWIF7db5bxcDDsbfe+OP90DGhd5O6w"
- + "QbuWA7PdyUJiz2tZ2gBZwvfKYJ/N45KYrFv+f2YmIqhS8lOCV9OoU1/snn8kHRa/UlFfWc8sXSub"
- + "frWjPAT+4QKBgQCeB/KHW5nv0vjifx3afxo6ZPfD4QOtDRkG9mduzJFkFE5pFFuaLVMHuXph+RFL"
- + "/vxcukEZOdBBy0/srXN5PV/1kwrhXcRh5YUq8UHF4ExYctCnSn0NbMPazVHY5HSCVwWdNrMk3jIb"
- + "vNBnTMXtoi7XpSDHM3nk4mF41KZc8nRscQKBgQCQyMXhm8GhWO3UaxtwLTYi1He78aJ1ag9jTi75"
- + "7gZdw48h0EowjftrMG/A3MDIM9UcqYXP5RA4E//pVABonjMSjBJTxlWx3yu84ETQjaYcqGqGFENa"
- + "q05r9AuMQ8OnWtx/ooCHoV86vYaRf6roTHkQs1rr10gSTSQu5VA7O/rBwQKBgElAUdEgSqh52FfU"
- + "qFfhVpz+tEIdiQCr84/go20ecb48E2RtxVAf9j68YNgNBVF+rielRguVWs1EmpWQiNgH9PT15bM1"
- + "LZRbOXEAR4abQ4g0IDeLNZAFfHttdKTesIrCH54R/tP2Eq/8w3U+hvhxltjqd9keKUBJFvlVSJAI"
- + "6qJhAoGBAJU8ET4NHv4/AS3SiTcg65TE4ktrTsVZixNYVORE32bFZCZClWLI2aUattiIk8UqvG74"
- + "wugnxUGk8tJMcw1J/gh+UlnGrX7HqiWTCzEyepOiDQV3NkOQ+9z9WeQNNUtQyIFZZB4wQHaH21BB"
- + "a1kmrzyqihpAVWrpBOJCipel8S0X").getBytes("UTF-8");
-
- // Create public/private keys and certificate
- KeyFactory keyFactory = KeyFactory.getInstance("RSA");
- PrivateKey privateKey = keyFactory
- .generatePrivate(new PKCS8EncodedKeySpec(Base64
- .decode(b64PrivateKeySpec)));
- final PublicKey publicKey = keyFactory
- .generatePublic(new X509EncodedKeySpec(Base64
- .decode(b64PublicKeySpec)));
-
- @SuppressWarnings("serial")
- Certificate cert = new Certificate("myType") {
-
- @Override
- public PublicKey getPublicKey() {
- return publicKey;
- }
-
- @Override
- public byte[] getEncoded() {
- return null;
- }
-
- @Override
- public String toString() {
- return null;
- }
-
- @Override
- public void verify(PublicKey key) throws CertificateException,
- NoSuchAlgorithmException, InvalidKeyException,
- NoSuchProviderException, SignatureException {
- }
-
- @Override
- public void verify(PublicKey key, String sigProvider)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException {
- }
- };
-
- // Sign first: init DigitalSignature with md5 and sha1
- // CipherSuite.KeyExchange_RSA_EXPORT == 2
- DigitalSignature dsig = new DigitalSignature(2);
-
- dsig.init(privateKey);
-
- byte[] md5 = new byte[] {
- 0x00, // <=== this is a problem byte (see HARMONY-2125)
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
- 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
-
- byte[] sha1 = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
- 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
- 0x11, 0x12, 0x13 };
-
- dsig.setMD5(md5);
- dsig.setSHA(sha1);
-
- byte[] enc = dsig.sign();
-
- // Now let's verify
- dsig.init(cert);
- assertTrue(dsig.verifySignature(enc));
- }
-}
diff --git a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/FinishedTest.java b/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/FinishedTest.java
deleted file mode 100644
index f700eb2..0000000
--- a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/FinishedTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.provider.jsse;
-
-import java.util.Arrays;
-
-import org.apache.harmony.xnet.provider.jsse.AlertException;
-import org.apache.harmony.xnet.provider.jsse.Finished;
-import org.apache.harmony.xnet.provider.jsse.Handshake;
-import org.apache.harmony.xnet.provider.jsse.HandshakeIODataStream;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>Finished</code> constructor and methods
- */
-public class FinishedTest extends TestCase {
-
- public void testFinished() throws Exception {
- byte[] bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2 };
- Finished message = new Finished(bytes);
- assertEquals("incorrect type", Handshake.FINISHED, message.getType());
- assertTrue("incorrect CertificateVerify", Arrays.equals(message
- .getData(), bytes));
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(),
- encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- Finished message_2 = new Finished(in, message.length());
- assertTrue("incorrect message decoding", Arrays.equals(message
- .getData(), message_2.getData()));
-
- in.append(encoded);
- try {
- message_2 = new Finished(in, message.length() - 1);
- fail("Small length: No expected AlertException");
- } catch (AlertException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- message_2 = new Finished(in, message.length() + 3);
- fail("Extra bytes: No expected AlertException ");
- } catch (AlertException e) {
- }
- }
-
-}
diff --git a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/HelloRequestTest.java b/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/HelloRequestTest.java
deleted file mode 100644
index 72c7601..0000000
--- a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/HelloRequestTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.provider.jsse;
-
-import org.apache.harmony.xnet.provider.jsse.AlertException;
-import org.apache.harmony.xnet.provider.jsse.Handshake;
-import org.apache.harmony.xnet.provider.jsse.HandshakeIODataStream;
-import org.apache.harmony.xnet.provider.jsse.HelloRequest;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>HelloRequest</code> constructor and methods
- */
-public class HelloRequestTest extends TestCase {
-
- public void testHelloRequest() throws Exception {
- HelloRequest message = new HelloRequest();
- assertEquals("incorrect type", Handshake.HELLO_REQUEST, message
- .getType());
- assertEquals("incorrect HelloRequest", 0, message.length());
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(),
- encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- HelloRequest message_2 = new HelloRequest(in, message.length());
- assertEquals("incorrect message decoding", 0, message_2.length());
-
- in.append(encoded);
- try {
- new HelloRequest(in, message.length() - 1);
- fail("Small length: No expected AlertException");
- } catch (AlertException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- new HelloRequest(in, message.length() + 3);
- fail("Extra bytes: No expected AlertException ");
- } catch (AlertException e) {
- }
- }
-
-}
diff --git a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/KeyManagerFactoryImplTest.java b/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/KeyManagerFactoryImplTest.java
deleted file mode 100644
index 184f60d..0000000
--- a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/KeyManagerFactoryImplTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.provider.jsse;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-
-import javax.net.ssl.KeyManager;
-
-import org.apache.harmony.xnet.provider.jsse.KeyManagerFactoryImpl;
-import org.apache.harmony.xnet.provider.jsse.KeyManagerImpl;
-import org.apache.harmony.xnet.provider.jsse.TrustManagerImpl;
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>KeyManagerFactoryImpl</code> constructor and methods
- */
-public class KeyManagerFactoryImplTest extends TestCase {
-
- /*
- * Class under test for void engineInit(KeyStore, char[])
- */
- public void testEngineInitKeyStorecharArray() throws Exception {
- KeyManagerFactoryImpl kmf = new KeyManagerFactoryImpl();
- kmf.engineInit(null, null);
-
- String def_keystore = System.getProperty("javax.net.ssl.keyStore");
- try {
- System.setProperty("javax.net.ssl.keyStore", "abc");
- kmf.engineInit(null, null);
- fail("No expected KeyStoreException");
- } catch (KeyStoreException e) {
- } finally {
- if (def_keystore == null) {
- System.clearProperty("javax.net.ssl.keyStore");
- } else {
- System.setProperty("javax.net.ssl.keyStore", def_keystore);
- }
- }
-
- }
-
- /*
- * Class under test for void engineInit(ManagerFactoryParameters)
- */
- public void testEngineInitManagerFactoryParameters() {
- KeyManagerFactoryImpl kmf = new KeyManagerFactoryImpl();
- try {
- kmf.engineInit(null);
- fail("No expected InvalidAlgorithmParameterException");
- } catch (InvalidAlgorithmParameterException e) {
- // expected
- }
- }
-
- public void testEngineGetKeyManagers() throws Exception {
- KeyManagerFactoryImpl kmf = new KeyManagerFactoryImpl();
- try {
- kmf.engineGetKeyManagers();
- fail("No expected IllegalStateException");
- } catch (IllegalStateException e) {
- // expected
- }
- KeyStore ks;
- ks = KeyStore.getInstance("BKS");
- ks.load(null, null);
- kmf.engineInit(ks, null);
-
- KeyManager[] kma = kmf.engineGetKeyManagers();
- assertEquals("Incorrect array length", 1, kma.length);
- assertTrue("Incorrect KeyManager type",
- kma[0] instanceof KeyManagerImpl);
- }
-
-} \ No newline at end of file
diff --git a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ProtocolVersionTest.java b/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ProtocolVersionTest.java
deleted file mode 100644
index aea78cd..0000000
--- a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ProtocolVersionTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.provider.jsse;
-
-import org.apache.harmony.xnet.provider.jsse.ProtocolVersion;
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ProtocolVersion</code> constructor and methods
- */
-public class ProtocolVersionTest extends TestCase {
-
- public void testEquals() {
- assertEquals(ProtocolVersion.getByVersion(new byte[] { 3, 0 }),
- ProtocolVersion.getByName("SSLv3"));
- assertEquals(ProtocolVersion.getByVersion(new byte[] { 3, 1 }),
- ProtocolVersion.getByName("TLSv1"));
- assertFalse(ProtocolVersion.getByVersion(new byte[] { 3, 0 }).equals(
- ProtocolVersion.getByName("TLSv1")));
-
- }
-
- /*
- * Class under test for boolean isSupported(byte[])
- */
- public void testIsSupportedbyteArray() {
- assertTrue(ProtocolVersion.isSupported(new byte[] { 3, 0 }));
- assertTrue(ProtocolVersion.isSupported(new byte[] { 3, 1 }));
- assertFalse(ProtocolVersion.isSupported(new byte[] { 3, 2 }));
- }
-
- public void testGetByVersion() {
- assertNull(ProtocolVersion.getByVersion(new byte[] { 2, 1 }));
- assertEquals("SSLv3",
- ProtocolVersion.getByVersion(new byte[] { 3, 0 }).name);
- assertEquals("TLSv1",
- ProtocolVersion.getByVersion(new byte[] { 3, 1 }).name);
- }
-
- /*
- * Class under test for boolean isSupported(String)
- */
- public void testIsSupportedString() {
- assertTrue(ProtocolVersion.isSupported("SSLv3"));
- assertTrue(ProtocolVersion.isSupported("SSL"));
- assertTrue(ProtocolVersion.isSupported("TLSv1"));
- assertTrue(ProtocolVersion.isSupported("TLS"));
- assertFalse(ProtocolVersion.isSupported("SSLv4"));
- }
-
- public void testGetByName() {
- assertNull(ProtocolVersion.getByName("SSLv2"));
- assertEquals("SSLv3", ProtocolVersion.getByName("SSLv3").name);
- assertEquals("TLSv1", ProtocolVersion.getByName("TLSv1").name);
- }
-
- public void testGetLatestVersion() {
- ProtocolVersion ver = ProtocolVersion.getLatestVersion(new String[] {
- "SSLv2", "TLSv1", "SSLv3" });
- assertEquals("Incorrect protocol version", "TLSv1", ver.name);
-
- ver = ProtocolVersion.getLatestVersion(new String[] { "SSLv3",
- "unknown", "SSLv2" });
- assertEquals("Incorrect protocol version", "SSLv3", ver.name);
- }
-
-} \ No newline at end of file
diff --git a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ServerHelloDoneTest.java b/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ServerHelloDoneTest.java
deleted file mode 100644
index f7a27c0..0000000
--- a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ServerHelloDoneTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.provider.jsse;
-
-import java.io.IOException;
-
-import org.apache.harmony.xnet.provider.jsse.AlertException;
-import org.apache.harmony.xnet.provider.jsse.Handshake;
-import org.apache.harmony.xnet.provider.jsse.HandshakeIODataStream;
-import org.apache.harmony.xnet.provider.jsse.ServerHelloDone;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>ServerHelloDone</code> constructor and methods
- */
-public class ServerHelloDoneTest extends TestCase {
-
- /*
- * Class under test for void ServerHelloDone()
- */
- public void testServerHelloDone() throws Exception {
-
- ServerHelloDone message = new ServerHelloDone();
- assertEquals("incorrect type", Handshake.SERVER_HELLO_DONE, message
- .getType());
- assertEquals("incorrect ServerHelloDone", 0, message.length());
-
- HandshakeIODataStream out = new HandshakeIODataStream();
- message.send(out);
- byte[] encoded = out.getData(1000);
- assertEquals("incorrect out data length", message.length(),
- encoded.length);
-
- HandshakeIODataStream in = new HandshakeIODataStream();
- in.append(encoded);
- ServerHelloDone message_2 = new ServerHelloDone(in, message.length());
- assertEquals("incorrect message decoding", 0, message_2.length());
-
- in.append(encoded);
- try {
- new ServerHelloDone(in, message.length() - 1);
- fail("Small length: No expected AlertException");
- } catch (AlertException e) {
- }
-
- in.append(encoded);
- in.append(new byte[] { 1, 2, 3 });
- try {
- new ServerHelloDone(in, message.length() + 3);
- fail("Extra bytes: No expected AlertException ");
- } catch (AlertException e) {
- }
- }
-
-}
diff --git a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/TrustManagerFactoryImplTest.java b/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/TrustManagerFactoryImplTest.java
deleted file mode 100644
index d7e1b2a..0000000
--- a/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/TrustManagerFactoryImplTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.provider.jsse;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-
-import javax.net.ssl.ManagerFactoryParameters;
-import javax.net.ssl.TrustManager;
-
-import org.apache.harmony.xnet.provider.jsse.TrustManagerFactoryImpl;
-import org.apache.harmony.xnet.provider.jsse.TrustManagerImpl;
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>TrustManagerFactoryImpl</code> constructor and methods
- */
-public class TrustManagerFactoryImplTest extends TestCase {
-
- /*
- * Class under test for void engineInit(KeyStore)
- */
- public void testEngineInitKeyStore() throws Exception {
- TrustManagerFactoryImpl tmf = new TrustManagerFactoryImpl();
- tmf.engineInit((KeyStore) null);
-
- String def_keystore = System.getProperty("javax.net.ssl.trustStore");
- System.setProperty("javax.net.ssl.trustStore", "abc");
- try {
- tmf.engineInit((KeyStore) null);
- fail("No expected KeyStoreException");
- } catch (KeyStoreException e) {
- } finally {
- if (def_keystore == null) {
- System.clearProperty("javax.net.ssl.trustStore");
- } else {
- System.setProperty("javax.net.ssl.trustStore", def_keystore);
- }
- }
- }
-
- /*
- * Class under test for void engineInit(ManagerFactoryParameters)
- */
- public void testEngineInitManagerFactoryParameters() {
- TrustManagerFactoryImpl tmf = new TrustManagerFactoryImpl();
-
- try {
- tmf.engineInit((ManagerFactoryParameters) null);
- fail("No expected InvalidAlgorithmParameterException");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- public void testEngineGetTrustManagers() throws Exception {
- TrustManagerFactoryImpl tmf = new TrustManagerFactoryImpl();
- try {
- tmf.engineGetTrustManagers();
- fail("No expected IllegalStateException");
- } catch (IllegalStateException e) {
- // expected
- }
- KeyStore ks;
- ks = KeyStore.getInstance("BKS");
- ks.load(null, null);
- tmf.engineInit(ks);
-
- TrustManager[] tma = tmf.engineGetTrustManagers();
- assertEquals("Incorrect array length", 1, tma.length);
- assertTrue("Incorrect KeyManager type",
- tma[0] instanceof TrustManagerImpl);
- }
-
-} \ No newline at end of file
diff --git a/x-net/src/test/java/javax/net/ssl/KeyManagerFactorySpiTests.java b/x-net/src/test/java/javax/net/ssl/KeyManagerFactorySpiTests.java
deleted file mode 100644
index e37c2d4..0000000
--- a/x-net/src/test/java/javax/net/ssl/KeyManagerFactorySpiTests.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package javax.net.ssl;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.UnrecoverableKeyException;
-
-import javax.net.ssl.KeyManagerFactorySpi;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>KeyManagerFactorySpi</code> class constructors and methods.
- */
-
-public class KeyManagerFactorySpiTests extends TestCase {
-
- /**
- * Constructor for KeyManegerFactorySpiTests.
- *
- * @param arg0
- */
- public KeyManagerFactorySpiTests(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>KeyManagerFactorySpi</code> constructor
- * Assertion: constructs KeyManagerFactorySpi
- */
- public void testKeyManagerFactorySpi01()
- throws Exception {
- KeyManagerFactorySpi kmfSpi = new MyKeyManagerFactorySpi();
- assertNull(kmfSpi.engineGetKeyManagers());
- KeyStore kStore = null;
- ManagerFactoryParameters mfp = null;
-
- char[] pass = { 'a', 'b', 'c' };
-
- try {
- kmfSpi.engineInit(kStore, null);
- fail("KeyStoreException must be thrown");
- } catch (KeyStoreException e) {
- }
- try {
- kmfSpi.engineInit(kStore, pass);
- fail("UnrecoverableKeyException must be thrown");
- } catch (UnrecoverableKeyException e) {
- }
- try {
- kmfSpi.engineInit(mfp);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- assertNull("getKeyManagers() should return null object",
- kmfSpi.engineGetKeyManagers());
-
- try {
- kStore = KeyStore.getInstance(KeyStore.getDefaultType());
- kStore.load(null, null);
- } catch (KeyStoreException e) {
- fail("default keystore type is not supported");
- return;
- }
- kmfSpi.engineInit(kStore, pass);
-
- mfp = new MyKeyManagerFactorySpi.Parameters(kStore, null);
- try {
- kmfSpi.engineInit(mfp);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- mfp = new MyKeyManagerFactorySpi.Parameters(kStore, pass);
- kmfSpi.engineInit(mfp);
- }
-}
-
diff --git a/x-net/src/test/java/javax/net/ssl/MyKeyManagerFactorySpi.java b/x-net/src/test/java/javax/net/ssl/MyKeyManagerFactorySpi.java
deleted file mode 100644
index 69e6ef5..0000000
--- a/x-net/src/test/java/javax/net/ssl/MyKeyManagerFactorySpi.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package javax.net.ssl;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-
-/**
- * Class for verification KeyManagerFactorySpi and KeyManagerFactory
- * functionality
- */
-
-public class MyKeyManagerFactorySpi extends KeyManagerFactorySpi {
-
- @Override
- protected void engineInit(KeyStore ks, char[] password)
- throws KeyStoreException, NoSuchAlgorithmException,
- UnrecoverableKeyException {
- if (password == null) {
- throw new KeyStoreException("Incorrect password");
- }
- if (ks == null) {
- throw new UnrecoverableKeyException("Incorrect keystore");
- }
- }
-
- @Override
- protected void engineInit(ManagerFactoryParameters spec)
- throws InvalidAlgorithmParameterException {
- if (spec == null) {
- throw new InvalidAlgorithmParameterException("Incorrect parameter");
- }
- if (spec instanceof Parameters) {
- try {
- engineInit(((Parameters) spec).getKeyStore(),
- ((Parameters) spec).getPassword());
- } catch (Exception e) {
- throw new InvalidAlgorithmParameterException(e.toString());
- }
- } else {
- throw new InvalidAlgorithmParameterException("Invalid parameter");
- }
- }
-
- @Override
- protected KeyManager[] engineGetKeyManagers() {
- return null;
- }
-
- public static class Parameters implements ManagerFactoryParameters {
- private KeyStore keyStore;
- private char[] passWD;
-
- public Parameters(KeyStore ks, char[] pass) {
- this.keyStore = ks;
- this.passWD = pass;
- }
-
- public KeyStore getKeyStore() {
- return keyStore;
- }
-
- public char[] getPassword() {
- return passWD;
- }
- }
-}
diff --git a/x-net/src/test/java/javax/net/ssl/MySSLContextSpi.java b/x-net/src/test/java/javax/net/ssl/MySSLContextSpi.java
deleted file mode 100644
index a148ea3..0000000
--- a/x-net/src/test/java/javax/net/ssl/MySSLContextSpi.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package javax.net.ssl;
-
-import java.nio.ByteBuffer;
-import java.security.KeyManagementException;
-import java.security.SecureRandom;
-
-/**
- * Additional class for verification of SSLContextSpi and SSLContext
- * functionality
- */
-
-public class MySSLContextSpi extends SSLContextSpi {
- private boolean init = false;
-
- @Override
- protected void engineInit(KeyManager[] km, TrustManager[] tm,
- SecureRandom sr) throws KeyManagementException {
- if (sr == null) {
- throw new KeyManagementException(
- "secureRandom is null");
- }
- init = true;
- }
-
- @Override
- protected SSLSocketFactory engineGetSocketFactory() {
- if (!init) {
- throw new RuntimeException("Not initialiazed");
- }
- return null;
- }
-
- @Override
- protected SSLServerSocketFactory engineGetServerSocketFactory() {
- if (!init) {
- throw new RuntimeException("Not initialiazed");
- }
- return null;
- }
-
- @Override
- protected SSLSessionContext engineGetServerSessionContext() {
- if (!init) {
- throw new RuntimeException("Not initialiazed");
- }
- return null;
- }
-
- @Override
- protected SSLSessionContext engineGetClientSessionContext() {
- if (!init) {
- throw new RuntimeException("Not initialiazed");
- }
- return null;
- }
-
- /*
- * FIXME: add these methods
- */
- @Override
- protected SSLEngine engineCreateSSLEngine(String host, int port) {
- if (!init) {
- throw new RuntimeException("Not initialiazed");
- }
- return new tmpSSLEngine(host, port);
- }
-
- @Override
- protected SSLEngine engineCreateSSLEngine() {
- if (!init) {
- throw new RuntimeException("Not initialiazed");
- }
- return new tmpSSLEngine();
- }
-
- public class tmpSSLEngine extends SSLEngine {
- String tmpHost;
- int tmpPort;
-
- public tmpSSLEngine() {
- tmpHost = null;
- tmpPort = 0;
- }
-
- public tmpSSLEngine(String host, int port) {
- tmpHost = host;
- tmpPort = port;
- }
-
- @Override
- public String getPeerHost() {
- return tmpHost;
- }
-
- @Override
- public int getPeerPort() {
- return tmpPort;
- }
-
- @Override
- public void beginHandshake() throws SSLException {
- }
-
- @Override
- public void closeInbound() throws SSLException {
- }
-
- @Override
- public void closeOutbound() {
- }
-
- @Override
- public Runnable getDelegatedTask() {
- return null;
- }
-
- @Override
- public String[] getEnabledCipherSuites() {
- return null;
- }
-
- @Override
- public String[] getEnabledProtocols() {
- return null;
- }
-
- @Override
- public boolean getEnableSessionCreation() {
- return true;
- }
-
- @Override
- public SSLEngineResult.HandshakeStatus getHandshakeStatus() {
- return null;
- }
-
- @Override
- public boolean getNeedClientAuth() {
- return true;
- }
-
- @Override
- public SSLSession getSession() {
- return null;
- }
-
- @Override
- public String[] getSupportedCipherSuites() {
- return null;
- }
-
- @Override
- public String[] getSupportedProtocols() {
- return null;
- }
-
- @Override
- public boolean getUseClientMode() {
- return true;
- }
-
- @Override
- public boolean getWantClientAuth() {
- return true;
- }
-
- @Override
- public boolean isInboundDone() {
- return true;
- }
-
- @Override
- public boolean isOutboundDone() {
- return true;
- }
-
- @Override
- public void setEnabledCipherSuites(String[] suites) {
- }
-
- @Override
- public void setEnabledProtocols(String[] protocols) {
- }
-
- @Override
- public void setEnableSessionCreation(boolean flag) {
- }
-
- @Override
- public void setNeedClientAuth(boolean need) {
- }
-
- @Override
- public void setUseClientMode(boolean mode) {
- }
-
- @Override
- public void setWantClientAuth(boolean want) {
- }
-
- @Override
- public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts,
- int offset, int length) throws SSLException {
- return null;
- }
-
- @Override
- public SSLEngineResult wrap(ByteBuffer[] srcs, int offset,
- int length, ByteBuffer dst) throws SSLException {
- return null;
- }
-
- @Override
- public SSLParameters getSSLParameters() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setSSLParameters(SSLParameters sslP) {
- // TODO Auto-generated method stub
-
- }
- }
-} \ No newline at end of file
diff --git a/x-net/src/test/java/javax/net/ssl/MyTrustManagerFactorySpi.java b/x-net/src/test/java/javax/net/ssl/MyTrustManagerFactorySpi.java
deleted file mode 100644
index 82976ca..0000000
--- a/x-net/src/test/java/javax/net/ssl/MyTrustManagerFactorySpi.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package javax.net.ssl;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-
-/**
- * Class for vertifying TrustManagerFactorySpi and TrustManagerFactory
- * functionality
- */
-
-public class MyTrustManagerFactorySpi extends TrustManagerFactorySpi {
- @Override
- protected void engineInit(KeyStore ks) throws KeyStoreException {
- if (ks == null) {
- throw new KeyStoreException("Not supported operation for null KeyStore");
- }
- }
-
- @Override
- protected void engineInit(ManagerFactoryParameters spec)
- throws InvalidAlgorithmParameterException {
- if (spec == null) {
- throw new InvalidAlgorithmParameterException("Null parameter");
- }
- if (spec instanceof Parameters) {
- try {
- engineInit(((Parameters) spec).getKeyStore());
- } catch (KeyStoreException e) {
- throw new RuntimeException(e);
- }
- } else {
- throw new InvalidAlgorithmParameterException("Invalid parameter");
- }
- }
-
- @Override
- protected TrustManager[] engineGetTrustManagers() {
- return null;
- }
-
-
- public static class Parameters implements ManagerFactoryParameters {
- private KeyStore keyStore;
-
- public Parameters(KeyStore ks) {
- this.keyStore = ks;
- }
-
- public KeyStore getKeyStore() {
- return keyStore;
- }
- }
-} \ No newline at end of file
diff --git a/x-net/src/test/java/javax/net/ssl/SSLContextSpiTests.java b/x-net/src/test/java/javax/net/ssl/SSLContextSpiTests.java
deleted file mode 100644
index bd35f40..0000000
--- a/x-net/src/test/java/javax/net/ssl/SSLContextSpiTests.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package javax.net.ssl;
-
-import java.security.KeyManagementException;
-import java.security.SecureRandom;
-
-import javax.net.ssl.SSLContextSpi;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>SSLContextSpi</code> class constructors and methods.
- */
-
-public class SSLContextSpiTests extends TestCase {
- /**
- * Constructor for SSLContextSpiTests.
- *
- * @param arg0
- */
- public SSLContextSpiTests(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>SSLContextSpi</code> constructor
- * Assertion: constructs SSLContextSpi
- */
- public void testSSLContextSpi01() throws KeyManagementException {
- SSLContextSpi sslConSpi = new MySSLContextSpi();
- try {
- sslConSpi.engineGetSocketFactory();
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertEquals("Incorrect message", "Not initialiazed", e.getMessage());
- }
- try {
- sslConSpi.engineGetServerSocketFactory();
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertEquals("Incorrect message", "Not initialiazed", e.getMessage());
- }
- try {
- sslConSpi.engineGetServerSessionContext();
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertEquals("Incorrect message", "Not initialiazed", e.getMessage());
- }
- try {
- sslConSpi.engineGetClientSessionContext();
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertEquals("Incorrect message", "Not initialiazed", e.getMessage());
- }
- try {
- sslConSpi.engineCreateSSLEngine();
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertEquals("Incorrect message", "Not initialiazed", e.getMessage());
- }
- try {
- sslConSpi.engineCreateSSLEngine("host", 1);
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertEquals("Incorrect message", "Not initialiazed", e.getMessage());
- }
- sslConSpi.engineInit(null, null, new SecureRandom());
- assertNull("Not null result", sslConSpi.engineGetSocketFactory());
- assertNull("Not null result", sslConSpi.engineGetServerSocketFactory());
- assertNotNull("Null result", sslConSpi.engineCreateSSLEngine());
- assertNotNull("Null result", sslConSpi.engineCreateSSLEngine("host", 1));
- assertNull("Not null result", sslConSpi.engineGetServerSessionContext());
- assertNull("Not null result", sslConSpi.engineGetClientSessionContext());
- }
-}
diff --git a/x-net/src/test/java/javax/net/ssl/TrustManagerFactorySpiTests.java b/x-net/src/test/java/javax/net/ssl/TrustManagerFactorySpiTests.java
deleted file mode 100644
index b000360..0000000
--- a/x-net/src/test/java/javax/net/ssl/TrustManagerFactorySpiTests.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package javax.net.ssl;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-
-import javax.net.ssl.TrustManagerFactorySpi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>TrustManagerFactorySpi</code> class constructors and
- * methods.
- */
-
-public class TrustManagerFactorySpiTests extends TestCase {
- /**
- * Constructor for TrustManegerFactorySpiTests.
- *
- * @param arg0
- */
- public TrustManagerFactorySpiTests(String arg0) {
- super(arg0);
- }
-
- /**
- * Test for <code>TrustManagerFactorySpi</code> constructor
- * Assertion: constructs TrustManagerFactorySpi
- */
- public void testTrustManagerFactorySpi01() throws Exception {
- TrustManagerFactorySpi kmfSpi = new MyTrustManagerFactorySpi();
- assertNull("Not null results", kmfSpi.engineGetTrustManagers());
- KeyStore kStore = null;
- ManagerFactoryParameters mfp = null;
-
- try {
- kmfSpi.engineInit(kStore);
- fail("KeyStoreException must be thrown");
- } catch (KeyStoreException e) {
- }
- try {
- kmfSpi.engineInit(mfp);
- fail("InvalidAlgorithmParameterException must be thrown");
- } catch (InvalidAlgorithmParameterException e) {
- }
- assertNull("getTrustManagers() should return null object",
- kmfSpi.engineGetTrustManagers());
-
- try {
- kStore = KeyStore.getInstance(KeyStore.getDefaultType());
- kStore.load(null, null);
- } catch (KeyStoreException e) {
- fail("default keystore is not supported");
- return;
- }
- kmfSpi.engineInit(kStore);
- mfp = new MyTrustManagerFactorySpi.Parameters(null);
- try {
- kmfSpi.engineInit(mfp);
- fail("RuntimeException must be thrown");
- } catch (RuntimeException e) {
- assertTrue("Incorrect exception", e.getCause() instanceof KeyStoreException);
- }
- mfp = new MyTrustManagerFactorySpi.Parameters(kStore);
- kmfSpi.engineInit(mfp);
- }
-}
diff --git a/x-net/src/test/resources/key_store.bks b/x-net/src/test/resources/key_store.bks
deleted file mode 100644
index 9aa43d8..0000000
--- a/x-net/src/test/resources/key_store.bks
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/HandshakeCompletedEventTest.golden.0.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/HandshakeCompletedEventTest.golden.0.ser
deleted file mode 100644
index 0fbaeb5..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/HandshakeCompletedEventTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.0.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.0.ser
deleted file mode 100644
index c39b410..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.1.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.1.ser
deleted file mode 100644
index 62deb7c..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.2.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.2.ser
deleted file mode 100644
index f9725b3..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.3.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.3.ser
deleted file mode 100644
index 69e827e..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.4.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.4.ser
deleted file mode 100644
index d1ab999..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLExceptionTest.golden.4.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.golden.0.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.golden.0.ser
deleted file mode 100644
index 8fa974d..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.golden.1.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.golden.1.ser
deleted file mode 100644
index 8504f4f..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.golden.2.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.golden.2.ser
deleted file mode 100644
index e509d62..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.golden.0.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.golden.0.ser
deleted file mode 100644
index c050e29..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.golden.1.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.golden.1.ser
deleted file mode 100644
index 71cffde..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.golden.2.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.golden.2.ser
deleted file mode 100644
index 44796c0..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.golden.0.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.golden.0.ser
deleted file mode 100644
index 19876f2..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.golden.1.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.golden.1.ser
deleted file mode 100644
index 3110c6b..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.golden.2.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.golden.2.ser
deleted file mode 100644
index aa7f703..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.golden.0.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.golden.0.ser
deleted file mode 100644
index cb74cad..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.golden.1.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.golden.1.ser
deleted file mode 100644
index c1e6a4f..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.golden.2.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.golden.2.ser
deleted file mode 100644
index 6c29b66..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLSessionBindingEventTest.golden.0.ser b/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLSessionBindingEventTest.golden.0.ser
deleted file mode 100644
index 5ce9eca..0000000
--- a/x-net/src/test/resources/serialization/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLSessionBindingEventTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/x-net/src/test/support/common/java/org/apache/harmony/xnet/provider/jsse/JSSETestData.java b/x-net/src/test/support/common/java/org/apache/harmony/xnet/provider/jsse/JSSETestData.java
deleted file mode 100644
index 1ddb8fe..0000000
--- a/x-net/src/test/support/common/java/org/apache/harmony/xnet/provider/jsse/JSSETestData.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.provider.jsse;
-
-import java.io.InputStream;
-import java.security.KeyStore;
-import java.security.SecureRandom;
-
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManagerFactory;
-
-import tests.support.resource.Support_Resources;
-
-/**
- * JSSETestData
- */
-public class JSSETestData {
-
- private static Exception initException;
-
- // the password to the store
- public static final char[] KS_PASSWORD = "password".toCharArray();
-
- private static SSLContext context;
- private static KeyStore keyStore;
- private static SSLParameters sslParameters;
-
- static {
- try {
- String ksDefaultType = KeyStore.getDefaultType();
- InputStream is = Support_Resources.getResourceStream(
- "key_store." + ksDefaultType.toLowerCase());
-
- keyStore = KeyStore.getInstance(ksDefaultType);
- keyStore.load(is, KS_PASSWORD);
-
- KeyManagerFactory kmf = KeyManagerFactory.getInstance("X509");
- kmf.init(keyStore, KS_PASSWORD);
-
- TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
- tmf.init(keyStore);
-
- sslParameters = new SSLParameters(kmf.getKeyManagers(), tmf
- .getTrustManagers(), new SecureRandom(),
- new SSLSessionContextImpl(), new SSLSessionContextImpl());
-
- context = SSLContext.getInstance("TLSv1");
- context.init(kmf.getKeyManagers(),
- tmf.getTrustManagers(), new SecureRandom());
- } catch (Exception e) {
- e.printStackTrace();
- initException = e;
- }
- }
-
- public static SSLContext getContext() throws Exception {
- if (initException != null) {
- throw initException;
- }
- return context;
- }
-
- public static SSLParameters getSSLParameters() throws Exception {
- if (initException != null) {
- throw initException;
- }
- return sslParameters;
- }
-
- public static KeyStore getKeyStore() throws Exception {
- if (initException != null) {
- throw initException;
- }
- return keyStore;
- }
-}
diff --git a/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MyKeyManagerFactorySpi.java b/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MyKeyManagerFactorySpi.java
deleted file mode 100644
index 1ee3004..0000000
--- a/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MyKeyManagerFactorySpi.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.support;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.KeyManagerFactorySpi;
-import javax.net.ssl.ManagerFactoryParameters;
-
-/**
- * Class for verification KeyManagerFactorySpi and KeyManagerFactory
- * functionality
- */
-
-public class MyKeyManagerFactorySpi extends KeyManagerFactorySpi {
-
- @Override
- protected void engineInit(KeyStore ks, char[] password)
- throws KeyStoreException, NoSuchAlgorithmException,
- UnrecoverableKeyException {
- if (password == null) {
- throw new KeyStoreException("Incorrect password");
- }
- if (ks == null) {
- throw new UnrecoverableKeyException("Incorrect keystore");
- }
- }
-
- @Override
- protected void engineInit(ManagerFactoryParameters spec)
- throws InvalidAlgorithmParameterException {
- if (spec == null) {
- throw new InvalidAlgorithmParameterException("Incorrect parameter");
- }
- if (spec instanceof Parameters) {
- try {
- engineInit(((Parameters) spec).getKeyStore(),
- ((Parameters) spec).getPassword());
- } catch (Exception e) {
- throw new InvalidAlgorithmParameterException(e.toString());
- }
- } else {
- throw new InvalidAlgorithmParameterException("Invalid parameter");
- }
- }
-
- @Override
- protected KeyManager[] engineGetKeyManagers() {
- return null;
- }
-
- public static class Parameters implements ManagerFactoryParameters {
- private KeyStore keyStore;
- private char[] passWD;
-
- public Parameters(KeyStore ks, char[] pass) {
- this.keyStore = ks;
- this.passWD = pass;
- }
-
- public KeyStore getKeyStore() {
- return keyStore;
- }
-
- public char[] getPassword() {
- return passWD;
- }
- }
-}
diff --git a/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MySSLContextSpi.java b/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MySSLContextSpi.java
deleted file mode 100644
index b18409d..0000000
--- a/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MySSLContextSpi.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.support;
-
-import java.nio.ByteBuffer;
-import java.security.KeyManagementException;
-import java.security.SecureRandom;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.SSLContextSpi;
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLEngineResult;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLParameters;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSessionContext;
-import javax.net.ssl.SSLServerSocketFactory;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-
-/**
- * Additional class for verification of SSLContextSpi and SSLContext
- * functionality
- */
-
-public class MySSLContextSpi extends SSLContextSpi {
- private boolean init = false;
-
- @Override
- protected void engineInit(KeyManager[] km, TrustManager[] tm,
- SecureRandom sr) throws KeyManagementException {
- if (sr == null) {
- throw new KeyManagementException(
- "secureRandom is null");
- }
- init = true;
- }
-
- @Override
- protected SSLSocketFactory engineGetSocketFactory() {
- if (!init) {
- throw new RuntimeException("Not initialiazed");
- }
- ;
- return null;
- }
-
- @Override
- protected SSLServerSocketFactory engineGetServerSocketFactory() {
- if (!init) {
- throw new RuntimeException("Not initialiazed");
- }
- return null;
- }
-
- @Override
- protected SSLSessionContext engineGetServerSessionContext() {
- if (!init) {
- throw new RuntimeException("Not initialiazed");
- }
- return null;
- }
-
- @Override
- protected SSLSessionContext engineGetClientSessionContext() {
- if (!init) {
- throw new RuntimeException("Not initialiazed");
- }
- return null;
- }
-
- /*
- * FIXME: add these methods
- */
- @Override
- protected SSLEngine engineCreateSSLEngine(String host, int port) {
- if (!init) {
- throw new RuntimeException("Not initialiazed");
- }
- return new tmpSSLEngine(host, port);
- }
-
- @Override
- protected SSLEngine engineCreateSSLEngine() {
- if (!init) {
- throw new RuntimeException("Not initialiazed");
- }
- return new tmpSSLEngine();
- }
-
- public class tmpSSLEngine extends SSLEngine {
- String tmpHost;
- int tmpPort;
-
- public tmpSSLEngine() {
- tmpHost = null;
- tmpPort = 0;
- }
-
- public tmpSSLEngine(String host, int port) {
- tmpHost = host;
- tmpPort = port;
- }
-
- @Override
- public String getPeerHost() {
- return tmpHost;
- }
-
- @Override
- public int getPeerPort() {
- return tmpPort;
- }
-
- @Override
- public void beginHandshake() throws SSLException {
- }
-
- @Override
- public void closeInbound() throws SSLException {
- }
-
- @Override
- public void closeOutbound() {
- }
-
- @Override
- public Runnable getDelegatedTask() {
- return null;
- }
-
- @Override
- public String[] getEnabledCipherSuites() {
- return null;
- }
-
- @Override
- public String[] getEnabledProtocols() {
- return null;
- }
-
- @Override
- public boolean getEnableSessionCreation() {
- return true;
- }
-
- @Override
- public SSLEngineResult.HandshakeStatus getHandshakeStatus() {
- return null;
- }
-
- ;
-
- @Override
- public boolean getNeedClientAuth() {
- return true;
- }
-
- @Override
- public SSLSession getSession() {
- return null;
- }
-
- @Override
- public String[] getSupportedCipherSuites() {
- return null;
- }
-
- @Override
- public String[] getSupportedProtocols() {
- return null;
- }
-
- @Override
- public boolean getUseClientMode() {
- return true;
- }
-
- @Override
- public boolean getWantClientAuth() {
- return true;
- }
-
- @Override
- public boolean isInboundDone() {
- return true;
- }
-
- @Override
- public boolean isOutboundDone() {
- return true;
- }
-
- @Override
- public void setEnabledCipherSuites(String[] suites) {
- }
-
- @Override
- public void setEnabledProtocols(String[] protocols) {
- }
-
- @Override
- public void setEnableSessionCreation(boolean flag) {
- }
-
- @Override
- public void setNeedClientAuth(boolean need) {
- }
-
- @Override
- public void setUseClientMode(boolean mode) {
- }
-
- @Override
- public void setWantClientAuth(boolean want) {
- }
-
- @Override
- public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts,
- int offset, int length) throws SSLException {
- return null;
- }
-
- @Override
- public SSLEngineResult wrap(ByteBuffer[] srcs, int offset,
- int length, ByteBuffer dst) throws SSLException {
- return null;
- }
-
- @Override
- public SSLParameters getSSLParameters() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setSSLParameters(SSLParameters sslP) {
- // TODO Auto-generated method stub
-
- }
- }
-
- @Override
- protected SSLParameters engineGetDefaultSSLParameters() {
- return new SSLParameters(new String[] { "Default_SSL_Parameters_For_Test1" },
- new String[] { "TLSv1" });
- }
-
- @Override
- protected SSLParameters engineGetSupportedSSLParameters() {
- return new SSLParameters(new String[] { "Default_SSL_Parameters_For_Test1",
- "Default_SSL_Parameters_For_Test2" }, new String[] { "TLSv1", "SSLv3" });
- }
-} \ No newline at end of file
diff --git a/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MyTrustManagerFactorySpi.java b/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MyTrustManagerFactorySpi.java
deleted file mode 100644
index 6e6de33..0000000
--- a/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MyTrustManagerFactorySpi.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.xnet.tests.support;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-
-import javax.net.ssl.ManagerFactoryParameters;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactorySpi;
-
-/**
- * Class for vertifying TrustManagerFactorySpi and TrustManagerFactory
- * functionality
- */
-
-public class MyTrustManagerFactorySpi extends TrustManagerFactorySpi {
- @Override
- protected void engineInit(KeyStore ks) throws KeyStoreException {
- if (ks == null) {
- throw new KeyStoreException("Not supported operation for null KeyStore");
- }
- }
-
- @Override
- protected void engineInit(ManagerFactoryParameters spec)
- throws InvalidAlgorithmParameterException {
- if (spec == null) {
- throw new InvalidAlgorithmParameterException("Null parameter");
- }
- if (spec instanceof Parameters) {
- try {
- engineInit(((Parameters) spec).getKeyStore());
- } catch (KeyStoreException e) {
- throw new RuntimeException(e);
- }
- } else {
- throw new InvalidAlgorithmParameterException("Invalid parameter");
- }
- }
-
- @Override
- protected TrustManager[] engineGetTrustManagers() {
- return null;
- }
-
-
- public static class Parameters implements ManagerFactoryParameters {
- private KeyStore keyStore;
-
- public Parameters(KeyStore ks) {
- this.keyStore = ks;
- }
-
- public KeyStore getKeyStore() {
- return keyStore;
- }
- }
-} \ No newline at end of file
diff --git a/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/SpiEngUtils.java b/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/SpiEngUtils.java
deleted file mode 100644
index d1d434c..0000000
--- a/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/SpiEngUtils.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Vera Y. Petrashkova
- */
-
-package org.apache.harmony.xnet.tests.support;
-
-import java.security.Provider;
-import java.security.Security;
-
-/**
- * Additional class for verification spi-engine classes
- */
-
-public class SpiEngUtils {
-
- public static final String[] invalidValues = {
- "",
- "BadAlgorithm",
- "Long message Long message Long message Long message Long message Long message Long message Long message Long message Long message Long message Long message Long message" };
-
- /**
- * Verification: is algorithm supported or not
- *
- * @param algorithm
- * @param service
- * @return
- */
- public static Provider isSupport(String algorithm, String service) {
- try {
- Provider[] provs = Security.getProviders(service.concat(".")
- .concat(algorithm));
- if (provs == null) {
- return null;
- }
- return (provs.length == 0 ? null : provs[0]);
- } catch (Exception e) {
- return null;
- }
- }
-
- public class MyProvider extends Provider {
-
- private static final long serialVersionUID = 1L;
-
- public MyProvider(String name, String info, String key, String clName) {
- super(name, 1.0, info);
- put(key, clName);
- }
-
- }
-
-} \ No newline at end of file