FileDocCategorySizeDatePackage
CodeSigner.javaAPI DocAndroid 1.5 API5338Wed May 06 22:41:04 BST 2009java.security

CodeSigner

public final class CodeSigner extends Object implements Serializable
{@code CodeSigner} represents a signer of code. Instances are immutable.
since
Android 1.0

Fields Summary
private static final long
serialVersionUID
private CertPath
signerCertPath
private Timestamp
timestamp
private transient int
hash
Constructors Summary
public CodeSigner(CertPath signerCertPath, Timestamp timestamp)
Constructs a new instance of {@code CodeSigner}.

param
signerCertPath the certificate path associated with this code signer.
param
timestamp the time stamp associated with this code signer, maybe {@code null}.
throws
NullPointerException if {@code signerCertPath} is {@code null}.
since
Android 1.0


                                                                                                
         
        if (signerCertPath == null) {
            throw new NullPointerException(Messages.getString("security.10")); //$NON-NLS-1$
        }
        this.signerCertPath = signerCertPath;
        this.timestamp = timestamp;
    
Methods Summary
public booleanequals(java.lang.Object obj)
Compares the specified object with this {@code CodeSigner} for equality. Returns {@code true} if the specified object is also an instance of {@code CodeSigner}, the two {@code CodeSigner} encapsulate the same certificate path and the same time stamp, if present in both.

param
obj object to be compared for equality with this {@code CodeSigner}.
return
{@code true} if the specified object is equal to this {@code CodeSigner}, otherwise {@code false}.
since
Android 1.0

        if (obj == this) {
            return true;
        }
        if (obj instanceof CodeSigner) {
            CodeSigner that = (CodeSigner) obj;
            if (!signerCertPath.equals(that.signerCertPath)) {
                return false;
            }
            return timestamp == null ? that.timestamp == null : timestamp
                    .equals(that.timestamp);
        }
        return false;
    
public java.security.cert.CertPathgetSignerCertPath()
Returns the certificate path associated with this {@code CodeSigner}.

return
the certificate path associated with this {@code CodeSigner}.
since
Android 1.0

        return signerCertPath;
    
public java.security.TimestampgetTimestamp()
Returns the time stamp associated with this {@code CodeSigner}.

return
the time stamp associated with this {@code CodeSigner}, maybe {@code null}.
since
Android 1.0

        return timestamp;
    
public inthashCode()
Returns the hash code value for this {@code CodeSigner}. Returns the same hash code for {@code CodeSigner}s that are equal to each other as required by the general contract of {@link Object#hashCode}.

return
the hash code value for this {@code CodeSigner}.
see
Object#equals(Object)
see
CodeSigner#equals(Object)
since
Android 1.0

        if (hash == 0) {
            hash = signerCertPath.hashCode()
                    ^ (timestamp == null ? 0 : timestamp.hashCode());
        }
        return hash;
    
public java.lang.StringtoString()
Returns a string containing a concise, human-readable description of the this {@code CodeSigner} including its first certificate and its time stamp, if present.

return
a printable representation for this {@code CodeSigner}.
since
Android 1.0

        // There is no any special reason for '256' here, it's taken abruptly
        // FIXME: 1.5 StringBuffer => StringBuilder
        StringBuffer buf = new StringBuffer(256);
        // The javadoc says nothing, and the others implementations behavior seems as 
        // dumping only the first certificate. Well, let's do the same.
        buf.append("CodeSigner [").append(signerCertPath.getCertificates().get(0)); //$NON-NLS-1$
        if( timestamp != null ) {
            buf.append("; ").append(timestamp); //$NON-NLS-1$
        }
        buf.append("]"); //$NON-NLS-1$
        return buf.toString();