FileDocCategorySizeDatePackage
Signer.javaAPI DocAndroid 1.5 API5464Wed May 06 22:41:06 BST 2009java.security

Signer

public abstract class Signer extends Identity
{@link Signer} represents an identity (individual or corporation) that owns a private key and the corresponding public key.
deprecated
Replaced by behavior in {@link java.security.cert java.security.cert} package and {@link java.security.Principal Principal}
since
Android 1.0

Fields Summary
private static final long
serialVersionUID
private PrivateKey
privateKey
Constructors Summary
protected Signer()
Constructs a new instance of {@code Signer}.

since
Android 1.0


                    
      
        super();
    
public Signer(String name)
Constructs a new instance of {@code Signer} with the given name.

param
name the name of the signer.
since
Android 1.0

        super(name);
    
public Signer(String name, IdentityScope scope)
Constructs a new instance of {@code Signer} with the given name in the given scope.

param
name the name of the signer.
param
scope the scope of the signer.
throws
KeyManagementException if a signer with the specified name already exists in the provided scope.
since
Android 1.0

        super(name, scope);
    
Methods Summary
public java.security.PrivateKeygetPrivateKey()
Returns the private key of this {@code Signer}. If a {@code SecurityManager} is installed, code calling this method needs the {@code SecurityPermission} {@code "getSignerPrivateKey"} to be granted, otherwise a {@code SecurityException} will be thrown.

return
the private key of this {@code Signer}.
throws
SecurityException if a {@code SecurityManager} is installed and the caller does not have permission to invoke this method.
since
Android 1.0

        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkSecurityAccess("getSignerPrivateKey"); //$NON-NLS-1$
        }

        return privateKey;
    
public final voidsetKeyPair(java.security.KeyPair pair)
Associates the specified key pair with this {@code Signer}. If a {@code SecurityManager} is installed, code calling this method needs the {@code SecurityPermission} {@code getSignerPrivateKey} to be granted, otherwise a {@code SecurityException} will be thrown.

param
pair the key pair to associate with this {@code Signer}.
throws
InvalidParameterException if the key pair is invalid.
throws
KeyException if any other key related problem occurs.
throws
SecurityException if a {@code SecurityManager} is installed and the caller does not have permission to invoke this method.
since
Android 1.0

        
        if (pair == null) {
            throw new NullPointerException();
        }

        if ((pair.getPrivate() == null) || (pair.getPublic() == null)) {
            throw new InvalidParameterException();
        }
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkSecurityAccess("setSignerKeyPair"); //$NON-NLS-1$
        }
        final PublicKey pk = pair.getPublic();
        try {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                public Void run() throws KeyManagementException {
                    setPublicKey(pk);
                    return null;
                }
            });
        } catch (PrivilegedActionException e) {
            throw new KeyException(e.getException());
        }
        this.privateKey = pair.getPrivate();
    
public java.lang.StringtoString()
Returns a string containing a concise, human-readable description of this {@code Signer} including its name and its scope if present.

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

        String s = "[Signer]" + getName(); //$NON-NLS-1$
        if (getScope() != null) {
            s = s + '[" + getScope().toString() + ']";
        }
        return s;