MySignature1.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.Signature; 28import java.security.SignatureException; 29 30/** 31 * Tests implementation of Signature 32 * 33 */ 34public class MySignature1 extends Signature { 35 36 public boolean runEngineInitVerify = false; 37 public boolean runEngineInitSign = false; 38 public boolean runEngineUpdate1 = false; 39 public boolean runEngineUpdate2 = false; 40 public boolean runEngineSign = false; 41 public boolean runEngineVerify = false; 42 public boolean runEngineSetParameter = false; 43 public boolean runEngineGetParameter = false; 44 45 /** 46 * 47 * 48 */ 49 public MySignature1() { 50 super(null); 51 } 52 53 /** 54 * 55 * @param algorithm 56 */ 57 public MySignature1(String algorithm) { 58 super(algorithm); 59 } 60 61 protected void engineInitVerify(PublicKey publicKey) 62 throws InvalidKeyException { 63 runEngineInitVerify = true; 64 } 65 66 protected void engineInitSign(PrivateKey privateKey) 67 throws InvalidKeyException { 68 runEngineInitSign = true; 69 } 70 71 protected void engineUpdate(byte b) throws SignatureException { 72 runEngineUpdate1 = true; 73 } 74 75 protected void engineUpdate(byte[] b, int off, int len) 76 throws SignatureException { 77 runEngineUpdate2 = true; 78 } 79 80 protected byte[] engineSign() throws SignatureException { 81 runEngineSign = true; 82 return null; 83 } 84 85 protected boolean engineVerify(byte[] sigBytes) throws SignatureException { 86 runEngineVerify = true; 87 return false; 88 } 89 90 protected void engineSetParameter(String param, Object value) 91 throws InvalidParameterException { 92 runEngineSetParameter = true; 93 } 94 95 protected Object engineGetParameter(String param) 96 throws InvalidParameterException { 97 runEngineGetParameter = true; 98 return null; 99 } 100 101 public int getState() { 102 return state; 103 } 104} 105