home *** CD-ROM | disk | FTP | other *** search
- package java.security;
-
- public abstract class Signature {
- private static boolean debug;
- private String algorithm;
- protected static final int UNINITIALIZED = 0;
- protected static final int SIGN = 2;
- protected static final int VERIFY = 3;
- protected int state = 0;
-
- protected Signature(String var1) {
- this.algorithm = var1;
- }
-
- public static Signature getInstance(String var0) throws NoSuchAlgorithmException {
- try {
- return (Signature)Security.getImpl(var0, "Signature", (String)null);
- } catch (NoSuchProviderException var1) {
- throw new InternalError("please send a bug report via " + System.getProperty("java.vendor.url.bug"));
- }
- }
-
- public static Signature getInstance(String var0, String var1) throws NoSuchAlgorithmException, NoSuchProviderException {
- return (Signature)Security.getImpl(var0, "Signature", var1);
- }
-
- public final void initVerify(PublicKey var1) throws InvalidKeyException {
- this.engineInitVerify(var1);
- this.state = 3;
- }
-
- public final void initSign(PrivateKey var1) throws InvalidKeyException {
- this.engineInitSign(var1);
- this.state = 2;
- }
-
- public final byte[] sign() throws SignatureException {
- if (this.state == 2) {
- return this.engineSign();
- } else {
- throw new SignatureException("object not initialized for signing.");
- }
- }
-
- public final boolean verify(byte[] var1) throws SignatureException {
- if (this.state == 3) {
- return this.engineVerify(var1);
- } else {
- throw new SignatureException("object not initialized for verification.");
- }
- }
-
- public final void update(byte var1) throws SignatureException {
- if (this.state != 3 && this.state != 2) {
- throw new SignatureException("object not initialized for signature or verification.");
- } else {
- this.engineUpdate(var1);
- }
- }
-
- public final void update(byte[] var1) throws SignatureException {
- this.update(var1, 0, var1.length);
- }
-
- public final void update(byte[] var1, int var2, int var3) throws SignatureException {
- if (this.state != 2 && this.state != 3) {
- throw new SignatureException("object not initialized for signature or verification.");
- } else {
- this.engineUpdate(var1, var2, var3);
- }
- }
-
- public final String getAlgorithm() {
- return this.algorithm;
- }
-
- public String toString() {
- String var1 = "";
- switch (this.state) {
- case 0:
- var1 = "<not initialized>";
- case 1:
- default:
- break;
- case 2:
- var1 = "<initialized for signing>";
- break;
- case 3:
- var1 = "<initialized for verifying>";
- }
-
- return "Signature object: " + this.getAlgorithm() + var1;
- }
-
- public final void setParameter(String var1, Object var2) throws InvalidParameterException {
- this.engineSetParameter(var1, var2);
- }
-
- public final Object getParameter(String var1) throws InvalidParameterException {
- return this.engineGetParameter(var1);
- }
-
- protected abstract void engineInitVerify(PublicKey var1) throws InvalidKeyException;
-
- protected abstract void engineInitSign(PrivateKey var1) throws InvalidKeyException;
-
- protected abstract void engineUpdate(byte var1) throws SignatureException;
-
- protected abstract void engineUpdate(byte[] var1, int var2, int var3) throws SignatureException;
-
- protected abstract byte[] engineSign() throws SignatureException;
-
- protected abstract boolean engineVerify(byte[] var1) throws SignatureException;
-
- protected abstract void engineSetParameter(String var1, Object var2) throws InvalidParameterException;
-
- protected abstract Object engineGetParameter(String var1) throws InvalidParameterException;
-
- public Object clone() throws CloneNotSupportedException {
- if (this instanceof Cloneable) {
- return super.clone();
- } else {
- throw new CloneNotSupportedException();
- }
- }
-
- private static void debug(String var0) {
- if (debug) {
- System.err.println(var0);
- }
-
- }
-
- private static void debug(Exception var0) {
- if (debug) {
- ((Throwable)var0).printStackTrace();
- }
-
- }
- }
-