Signerpublic abstract class Signer extends Identity {@link Signer} represents an identity (individual or corporation) that owns a
private key and the corresponding public key. |
Fields Summary |
---|
private static final long | serialVersionUID | private PrivateKey | privateKey |
Constructors Summary |
---|
protected Signer()Constructs a new instance of {@code Signer}.
super();
| public Signer(String name)Constructs a new instance of {@code Signer} with the given name.
super(name);
| public Signer(String name, IdentityScope scope)Constructs a new instance of {@code Signer} with the given name in the
given scope.
super(name, scope);
|
Methods Summary |
---|
public java.security.PrivateKey | getPrivateKey()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.
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkSecurityAccess("getSignerPrivateKey"); //$NON-NLS-1$
}
return privateKey;
| public final void | setKeyPair(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.
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.String | toString()Returns a string containing a concise, human-readable description of this
{@code Signer} including its name and its scope if present.
String s = "[Signer]" + getName(); //$NON-NLS-1$
if (getScope() != null) {
s = s + '[" + getScope().toString() + ']";
}
return s;
|
|