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* @version $Revision$
20*/
21
22package org.apache.harmony.security.tests.support;
23
24import java.security.InvalidKeyException;
25import java.security.InvalidParameterException;
26import java.security.PrivateKey;
27import java.security.PublicKey;
28import java.security.SignatureException;
29import java.security.SignatureSpi;
30
31/**
32 * Tests implementation of Signature
33 *
34 */
35public class MySignature2 extends SignatureSpi {
36
37    public static boolean runEngineInitVerify = false;
38    public static boolean runEngineInitSign = false;
39    public static boolean runEngineUpdate1 = false;
40    public static boolean runEngineUpdate2 = false;
41    public static boolean runEngineSign = false;
42    public static boolean runEngineVerify = false;
43    public static boolean runEngineSetParameter = false;
44    public static boolean runEngineGetParameter = false;
45
46    protected void engineInitVerify(PublicKey publicKey)
47            throws InvalidKeyException {
48        runEngineInitVerify = true;
49    }
50
51    protected void engineInitSign(PrivateKey privateKey)
52            throws InvalidKeyException {
53        runEngineInitSign = true;
54    }
55
56    protected void engineUpdate(byte b) throws SignatureException {
57        runEngineUpdate1 = true;
58    }
59
60    protected void engineUpdate(byte[] b, int off, int len)
61            throws SignatureException {
62        runEngineUpdate2 = true;
63    }
64
65    protected byte[] engineSign() throws SignatureException {
66        runEngineSign = true;
67        return null;
68    }
69
70    protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
71        runEngineVerify = true;
72        return false;
73    }
74
75    protected void engineSetParameter(String param, Object value)
76            throws InvalidParameterException {
77        runEngineSetParameter = true;
78    }
79
80    protected Object engineGetParameter(String param)
81            throws InvalidParameterException {
82        runEngineGetParameter = true;
83        return null;
84    }
85}
86