本文整理匯總了Java中org.apache.harmony.security.tests.support.TestKeyPair類的典型用法代碼示例。如果您正苦於以下問題:Java TestKeyPair類的具體用法?Java TestKeyPair怎麽用?Java TestKeyPair使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TestKeyPair類屬於org.apache.harmony.security.tests.support包,在下文中一共展示了TestKeyPair類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testTrustAnchorStringPublicKeybyteArray01
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* 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
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "",
method = "TrustAnchor",
args = {java.lang.String.class, java.security.PublicKey.class, byte[].class}
)
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());
}
示例2: testTrustAnchorStringPublicKeybyteArray03
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* 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
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Verifies positive case.",
method = "TrustAnchor",
args = {java.lang.String.class, java.security.PublicKey.class, byte[].class}
)
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()));
}
示例3: testTrustAnchorX500PrincipalPublicKeybyteArray01
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* 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
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Verifies positive case.",
method = "TrustAnchor",
args = {javax.security.auth.x500.X500Principal.class, java.security.PublicKey.class, byte[].class}
)
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());
}
示例4: testTrustAnchorX500PrincipalPublicKeybyteArray02
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* 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
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Verifies null as a parameter.",
method = "TrustAnchor",
args = {javax.security.auth.x500.X500Principal.class, java.security.PublicKey.class, byte[].class}
)
public final void testTrustAnchorX500PrincipalPublicKeybyteArray02()
throws Exception {
PublicKey pk = new TestKeyPair(keyAlg).getPublic();
X500Principal x500p = new X500Principal(validCaNameRfc2253);
new TrustAnchor(x500p, pk, null);
}
示例5: testTrustAnchorX500PrincipalPublicKeybyteArray03
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* 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
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Verifies TrustAnchor with copied byte array.",
method = "TrustAnchor",
args = {javax.security.auth.x500.X500Principal.class, java.security.PublicKey.class, byte[].class}
)
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()));
}
示例6: testGetCAPublicKey01
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* Test #1 for <code>getCAPublicKey()</code> method<br>
*
* 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>
*
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getCAPublicKey",
args = {}
)
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());
}
示例7: testGetCAName01
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* Test #1 for <code>getCAName()</code> method<br>
*
* 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
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getCAName",
args = {}
)
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());
}
示例8: testGetTrustedCer02
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* Test #2 for <code>getCAName()</code> method<br>
*
* 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
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
method = "getTrustedCert",
args = {}
)
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());
X509Certificate cert = new TestCertUtils.TestX509Certificate(x500p, x500p);
TrustAnchor ta2 = new TrustAnchor(cert, null);
assertSame(cert, ta2.getTrustedCert());
}
示例9: testGetNameConstraints01
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* Test #1 for <code>getNameConstraints()</code> method<br>
*
* Assertion: Returns the name constraints parameter.<br>
* Test preconditions: valid parameters are passed to the constructors<br>
* Expected: the valid parameters must be returned by the method<br>
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Verifies positive case.",
method = "getNameConstraints",
args = {}
)
public final void testGetNameConstraints01() throws Exception {
PublicKey pk = new TestKeyPair(keyAlg).getPublic();
TrustAnchor ta1 = new TrustAnchor(validCaNameRfc2253, pk,
getFullEncoding());
assertTrue(Arrays.equals(getFullEncoding(), ta1.getNameConstraints()));
X500Principal x500p = new X500Principal(validCaNameRfc2253);
TrustAnchor ta2 = new TrustAnchor(x500p, pk, getEncodingNoMinMax());
assertTrue(Arrays.equals(getEncodingNoMinMax(), ta2
.getNameConstraints()));
CertificateFactory certFact = CertificateFactory.getInstance("X509");
X509Certificate pemCert = (X509Certificate) certFact
.generateCertificate(new ByteArrayInputStream(TestUtils
.getX509Certificate_v3()));
TrustAnchor ta3 = new TrustAnchor(pemCert, getEncodingPSOnly());
assertTrue(Arrays.equals(getEncodingPSOnly(), ta3.getNameConstraints()));
}
示例10: testGetNameConstraints02
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* Test #2 for <code>getNameConstraints()</code> method<br>
*
* Assertion: Returns the name constraints parameter.<br>
* Test preconditions: null parameters are passed to the constructors<br>
* Expected: the null parameters must be returned by the method<br>
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Verifies that getNameConstraints returns null.",
method = "getNameConstraints",
args = {}
)
public final void testGetNameConstraints02() throws Exception {
PublicKey pk = new TestKeyPair(keyAlg).getPublic();
TrustAnchor ta1 = new TrustAnchor(validCaNameRfc2253, pk, null);
assertNull(ta1.getNameConstraints());
X500Principal x500p = new X500Principal(validCaNameRfc2253);
TrustAnchor ta2 = new TrustAnchor(x500p, pk, null);
assertNull(ta2.getNameConstraints());
CertificateFactory certFact = CertificateFactory.getInstance("X509");
X509Certificate pemCert = (X509Certificate) certFact
.generateCertificate(new ByteArrayInputStream(TestUtils
.getX509Certificate_v3()));
TrustAnchor ta3 = new TrustAnchor(pemCert, null);
assertNull(ta3.getNameConstraints());
}
示例11: testToString
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* Test #1 for <code>toString()</code> method<br>
*
* Assertion: returns a formatted string describing the TrustAnchor<br>
* Test preconditions: valid parameters are passed to the constructors<br>
* Expected: not null string<br>
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "toString",
args = {}
)
public final void testToString() throws Exception {
PublicKey pk = new TestKeyPair(keyAlg).getPublic();
TrustAnchor ta1 = new TrustAnchor(validCaNameRfc2253, pk,
getFullEncoding());
assertNotNull(ta1.toString());
X500Principal x500p = new X500Principal(validCaNameRfc2253);
TrustAnchor ta2 = new TrustAnchor(x500p, pk, getEncodingNoMinMax());
assertNotNull(ta2.toString());
CertificateFactory certFact = CertificateFactory.getInstance("X509");
X509Certificate pemCert = (X509Certificate) certFact
.generateCertificate(new ByteArrayInputStream(TestUtils
.getX509Certificate_v3()));
TrustAnchor ta3 = new TrustAnchor(pemCert, getEncodingPSOnly());
assertNotNull(ta3.toString());
}
示例12: testGetCA01
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* Test #1 for <code>getCA()</code> method<br>
*
* 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
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getCA",
args = {}
)
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());
}
示例13: testTrustAnchorStringPublicKeybyteArray03
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* 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()));
}
示例14: testTrustAnchorX500PrincipalPublicKeybyteArray01
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* 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());
}
示例15: testTrustAnchorX500PrincipalPublicKeybyteArray03
import org.apache.harmony.security.tests.support.TestKeyPair; //導入依賴的package包/類
/**
* 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()));
}