MySignature2.java revision 561ee011997c6c2f1befbfaa9d5f0a99771c1d63
1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17/**
18* @author Boris V. Kuznetsov
19*/
20
21package org.apache.harmony.security.tests.support;
22
23import java.security.InvalidKeyException;
24import java.security.InvalidParameterException;
25import java.security.PrivateKey;
26import java.security.PublicKey;
27import java.security.SignatureException;
28import java.security.SignatureSpi;
29
30/**
31 * Tests implementation of Signature
32 *
33 */
34public class MySignature2 extends SignatureSpi {
35
36	public static boolean runEngineInitVerify = false;
37	public static boolean runEngineInitSign = false;
38	public static boolean runEngineUpdate1 = false;
39	public static boolean runEngineUpdate2 = false;
40	public static boolean runEngineSign = false;
41	public static boolean runEngineVerify = false;
42	public static boolean runEngineSetParameter = false;
43	public static boolean runEngineGetParameter = false;
44
45	protected void engineInitVerify(PublicKey publicKey)
46			throws InvalidKeyException {
47		runEngineInitVerify = true;
48	}
49
50	protected void engineInitSign(PrivateKey privateKey)
51			throws InvalidKeyException {
52		runEngineInitSign = true;
53	}
54
55	protected void engineUpdate(byte b) throws SignatureException {
56		runEngineUpdate1 = true;
57	}
58
59	protected void engineUpdate(byte[] b, int off, int len)
60			throws SignatureException {
61		runEngineUpdate2 = true;
62	}
63
64	protected byte[] engineSign() throws SignatureException {
65		runEngineSign = true;
66		return null;
67	}
68
69	protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
70		runEngineVerify = true;
71		return false;
72	}
73
74	protected void engineSetParameter(String param, Object value)
75			throws InvalidParameterException {
76		runEngineSetParameter = true;
77	}
78
79	protected Object engineGetParameter(String param)
80			throws InvalidParameterException {
81		runEngineGetParameter = true;
82		return null;
83	}
84}
85