本文整理匯總了Java中org.apache.harmony.security.tests.support.cert.MyCertificate類的典型用法代碼示例。如果您正苦於以下問題:Java MyCertificate類的具體用法?Java MyCertificate怎麽用?Java MyCertificate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MyCertificate類屬於org.apache.harmony.security.tests.support.cert包,在下文中一共展示了MyCertificate類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testPrivateKeyEntry01
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* Test for <code>PrivateKeyEntry(PrivateKey privateKey, Certificate[] chain)</code>
* constructor
* Assertion: throws NullPointerException when privateKey is null
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "",
method = "PrivateKeyEntry",
args = {java.security.PrivateKey.class, java.security.cert.Certificate[].class}
)
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) {
}
}
示例2: testCertificateFactory16
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* Test for <code>generateCertPath(List certificates)</code> method
* Assertion: throws CertificateException when certificates contains
* incorrect Certificate
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Verifies CertificateException. Valid parameters checking missed.",
method = "generateCertPath",
args = {java.util.List.class}
)
public void testCertificateFactory16() {
if (!X509Support) {
fail(NotSupportMsg);
return;
}
CertificateFactory[] certFs = initCertFs();
assertNotNull("CertificateFactory objects were not created", certFs);
MyCertificate ms = createMC();
List<Certificate> list = new Vector<Certificate>();
list.add(ms);
for (int i = 0; i < certFs.length; i++) {
try {
certFs[i].generateCertPath(list);
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
}
}
示例3: testCollectionCertStoreParametersCollection03
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* Test #3 for <code>CollectionCertStoreParameters(Collection)</code>
* constructor<br>
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "",
method = "CollectionCertStoreParameters",
args = {java.util.Collection.class}
)
public final void testCollectionCertStoreParametersCollection03() {
Vector<Certificate> certificates = new Vector<Certificate>();
// 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()));
}
示例4: testClone01
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* Test #1 for <code>clone()</code> method<br>
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "",
method = "clone",
args = {}
)
public final void testClone01() {
Vector<Certificate> certificates = new Vector<Certificate>();
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);
}
示例5: testClone02
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* Test #2 for <code>clone()</code> method<br>
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "",
method = "clone",
args = {}
)
public final void testClone02() {
Vector<Certificate> certificates = new Vector<Certificate>();
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());
}
示例6: testCertificate
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* Test for <code>Certificate(String type)</code> method<br>
*/
@TestTargetNew(
level = TestLevel.SUFFICIENT,
notes = "",
method = "Certificate",
args = {java.lang.String.class}
)
@AndroidOnly("Gets security providers with specific signature algorithm: " +
"Security.getProviders(\"Signature.sha1WithRSAEncryption\")")
public final void testCertificate() {
try {
Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
assertTrue(Arrays.equals(testEncoding, c1.getEncoded()));
assertEquals("TEST", c1.getPublicKey().getAlgorithm());
assertTrue(Arrays.equals(
new byte[] { (byte) 1, (byte) 2, (byte) 3 }, c1
.getPublicKey().getEncoded()));
assertEquals("TEST_FORMAT", c1.getPublicKey().getFormat());
assertEquals("TEST_TYPE", c1.getType());
} catch (CertificateEncodingException e) {
fail("Unexpected CertificateEncodingException " + e.getMessage());
}
}
示例7: testHashCode
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* Test for <code>hashCode()</code> method<br>
* Assertion: returns hash of the <code>Certificate</code> instance
* @throws CertificateEncodingException
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "",
method = "hashCode",
args = {}
)
@AndroidOnly("Gets security providers with specific signature algorithm: " +
"Security.getProviders(\"Signature.sha1WithRSAEncryption\")")
public final void testHashCode() throws CertificateEncodingException {
Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
Certificate c2 = new MyCertificate("TEST_TYPE", testEncoding);
assertTrue(c1.hashCode() == c2.hashCode());
assertFalse(c1.hashCode() == new MyCertificate("TEST_TYPE", cert
.getEncoded()).hashCode());
assertFalse(c1.hashCode() == cert.hashCode());
}
示例8: testHashCodeEqualsObject
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* Test for <code>hashCode()</code> method<br>
* Assertion: hash code of equal objects should be the same
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "",
method = "hashCode",
args = {}
)
@AndroidOnly("Gets security providers with specific signature algorithm: " +
"Security.getProviders(\"Signature.sha1WithRSAEncryption\")")
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));
assertFalse(cert.equals(c1));
}
示例9: testVerifyPublicKey
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* This test just calls <code>verify(PublicKey)</code> method<br>
*
* @throws InvalidKeyException
* @throws CertificateException
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
* @throws SignatureException
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Verifies only null as a parameter.",
method = "verify",
args = {java.security.PublicKey.class}
)
@AndroidOnly("Gets security providers with specific signature algorithm: " +
"Security.getProviders(\"Signature.sha1WithRSAEncryption\")")
public final void testVerifyPublicKey()
throws InvalidKeyException,
CertificateException,
NoSuchAlgorithmException,
NoSuchProviderException,
SignatureException {
Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
c1.verify(null);
}
示例10: testVerifyPublicKeyString
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* This test just calls <code>verify(PublicKey,String)</code> method<br>
*
* @throws InvalidKeyException
* @throws CertificateException
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
* @throws SignatureException
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Verifies only null as parameters.",
method = "verify",
args = {java.security.PublicKey.class, java.lang.String.class}
)
@AndroidOnly("Gets security providers with specific signature algorithm: " +
"Security.getProviders(\"Signature.sha1WithRSAEncryption\")")
public final void testVerifyPublicKeyString()
throws InvalidKeyException,
CertificateException,
NoSuchAlgorithmException,
NoSuchProviderException,
SignatureException {
Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
c1.verify(null, null);
}
示例11: testWriteReplace
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* This test just calls <code>writeReplace()</code> method<br>
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Doesn't verify ObjectStreamException.",
method = "writeReplace",
args = {}
)
@AndroidOnly("Gets security providers with specific signature algorithm: " +
"Security.getProviders(\"Signature.sha1WithRSAEncryption\")")
public final void testWriteReplace() {
MyCertificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
try {
Object obj = c1.writeReplace();
assertTrue(obj.toString().contains(
"java.security.cert.Certificate$CertificateRep"));
} catch (ObjectStreamException e) {
fail("Unexpected ObjectStreamException " + e.getMessage());
}
}
示例12: testWriteReplace2
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* This test just calls <code>writeReplace()</code> method<br>
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "",
method = "writeReplace",
args = {}
)
@AndroidOnly("Gets security providers with specific signature algorithm: " +
"Security.getProviders(\"Signature.sha1WithRSAEncryption\")")
public final void testWriteReplace2() {
MyCertificate c1 = new MyFailingCertificate("TEST_TYPE", testEncoding);
try {
Object obj = c1.writeReplace();
} catch (ObjectStreamException e) {
//ok
}
}
示例13: testCertificateFactory16
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* 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) {
}
}
}
示例14: testCollectionCertStoreParametersCollection03
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
/**
* 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()));
}
示例15: createParams
import org.apache.harmony.security.tests.support.cert.MyCertificate; //導入依賴的package包/類
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()));
}