FileDocCategorySizeDatePackage
TestCertUtils.javaAPI DocAndroid 1.5 API26758Wed May 06 22:41:06 BST 2009org.apache.harmony.security.tests.support

TestCertUtils

public final class TestCertUtils extends Object
The class contains various utility methods used during the java.security classes testing.

Fields Summary
private static Provider
provider
private static final String
providerName
public static final X500Principal
rootPrincipal
A Principal used to form rootCA's certificate
public static final X509Certificate
rootCA
Some fake rootCA's certificate.
Constructors Summary
private TestCertUtils()

        throw new Error("statics only");
    
Methods Summary
public static java.security.cert.CertPathgenCertPath(int howMany, int startID)
Generates and returns an instance of TestCertPath.
TestCertificate-s included in the CertPath will be uniq (will have different numbers passed to their ctor-s).
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

        Certificate[] certs = new Certificate[howMany];
        for (int i = 0; i < howMany; i++) {
            certs[i] = new TestCertificate(Integer.toString(startID + i));
        }
        return new TestCertPath(certs);
    
public static java.security.cert.CertificategetCert()
Returns new instance of test certificate each time the method is called.

return
test certificate

        return new TestCertificate();
    
public static java.security.cert.Certificate[]getCertChain()
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

        Certificate[] chain = { new TestCertificate(), new TestCertificate(),
                new TestCertificate() };
        return chain;
    
public static java.security.cert.CertPathgetCertPath()
Returns a test CertPath, which uses getCertChain() to obtain a list of certificates to store.

return
test cert path

        return new TestCertPath();
    
public static voidinstall_test_x509_factory()


        
        if (provider == null) {
            provider = new TestProvider(providerName, 0.01,
                    "Test provider for serialization testing");
            Security.insertProviderAt(provider, 1);
        }
    
public static voiduninstall_test_x509_factory()

        if (provider != null) {
            Security.removeProvider(providerName);
            provider = null;
        }