FileDocCategorySizeDatePackage
CertPath.javaAPI DocAndroid 1.5 API8563Wed May 06 22:41:06 BST 2009java.security.cert

CertPath

public abstract class CertPath extends Object implements Serializable
An immutable certificate path that can be validated. All certificates in the path are of the same type (i.e., X509).

A {@code CertPath} can be represented as a byte array in at least one supported encoding scheme (i.e. PkiPath or PKCS7) when serialized.

When a {@code List} of the certificates is obtained it must be immutable.

A {@code CertPath} must be thread-safe without requiring coordinated access.

see
Certificate
since
Android 1.0

Fields Summary
private static final long
serialVersionUID
private final String
type
Constructors Summary
protected CertPath(String type)
Creates a new {@code CertPath} instance for the specified certificate type.

param
type the certificate type.
since
Android 1.0


                                        
       
        this.type = type;
    
Methods Summary
public booleanequals(java.lang.Object other)
Returns {@code true} if {@code Certificate}s in the list are the same type and the lists are equal (and by implication the certificates contained within are the same).

param
other {@code CertPath} to be compared for equality.
return
{@code true} if the object are equal, {@code false} otherwise.
since
Android 1.0

        if (this == other) {
            return true;
        }
        if (other instanceof CertPath) {
            CertPath o = (CertPath)other;
            if (getType().equals(o.getType())) {
                if (getCertificates().equals(o.getCertificates())) {
                    return true;
                }
            }
        }
        return false;
    
public abstract java.util.ListgetCertificates()
Returns an immutable List of the {@code Certificate}s contained in the {@code CertPath}.

return
a list of {@code Certificate}s in the {@code CertPath}.
since
Android 1.0

public abstract byte[]getEncoded()
Returns an encoding of the {@code CertPath} using the default encoding.

return
default encoding of the {@code CertPath}.
throws
CertificateEncodingException if the encoding fails.
since
Android 1.0

public abstract byte[]getEncoded(java.lang.String encoding)
Returns an encoding of the {@code CertPath} using the specified encoding.

param
encoding encoding that should be generated.
return
default encoding of the {@code CertPath}.
throws
CertificateEncodingException if the encoding fails.
since
Android 1.0

public abstract java.util.IteratorgetEncodings()
Returns an {@code Iterator} over the supported encodings for a representation of the certificate path.

return
{@code Iterator} over supported encodings (as {@code String}s).
since
Android 1.0

public java.lang.StringgetType()
Returns the type of {@code Certificate} in this instance.

return
the certificate type.
since
Android 1.0

        return type;
    
public inthashCode()
Overrides {@code Object.hashCode()}. The function is defined as follows:
{@code hashCode = 31 * path.getType().hashCode() + path.getCertificates().hashCode();}

return
the hash code for this instance.
since
Android 1.0

        int hash = getType().hashCode();
        hash = hash*31 + getCertificates().hashCode();
        return hash;
    
public java.lang.StringtoString()
Returns a {@code String} representation of this {@code CertPath} instance.

return
a string representation of this instance.
since
Android 1.0

        StringBuffer sb = new StringBuffer(getType());
        sb.append(" Cert Path, len="); //$NON-NLS-1$
        sb.append(getCertificates().size());
        sb.append(": [\n"); //$NON-NLS-1$
        int n=1;
        // BEGIN android-changed
        for (Iterator<? extends Certificate> i=getCertificates().iterator();
                      i.hasNext(); n++) {
            sb.append("---------------certificate "); //$NON-NLS-1$
            sb.append(n);
            sb.append("---------------\n"); //$NON-NLS-1$
            sb.append(((Certificate)i.next()).toString());
        }
        // END android-changed
        sb.append("\n]"); //$NON-NLS-1$
        return sb.toString();
    
protected java.lang.ObjectwriteReplace()
Returns an alternate object to be serialized.

return
an alternate object to be serialized.
throws
ObjectStreamException if the creation of the alternate object fails.
since
Android 1.0

        try {
            return new CertPathRep(getType(), getEncoded());
        } catch (CertificateEncodingException e) {
            throw new NotSerializableException (
                    Messages.getString("security.66", e)); //$NON-NLS-1$
        }