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