You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/06/01 10:15:44 UTC

svn commit: r410788 [11/13] - in /incubator/harmony/enhanced/classlib/trunk/modules: auth/make/common/ auth/src/test/java/common/javax/security/auth/ auth/src/test/java/common/javax/security/auth/callback/serialization/ auth/src/test/java/common/javax/...

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/IdentityStub.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/IdentityStub.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/IdentityStub.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/IdentityStub.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,76 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Aleksei Y. Semenov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.Identity;
+import java.security.IdentityScope;
+import java.security.KeyManagementException;
+import java.security.PublicKey;
+
+/**
+ * Stub for abstract class Identity
+ * 
+ */
+
+public class IdentityStub extends Identity {
+
+    /**
+     *  Default constructor
+     */
+    public IdentityStub() {
+        super();        
+    }
+
+    /**
+     * TODO Put ctor description here
+     * 
+     * @param name
+     */
+    public IdentityStub(String name) {
+        super(name);        
+    }
+
+    /**
+     * TODO Put ctor description here
+     * 
+     * @param name
+     * @param scope
+     * @throws KeyManagementException
+     */
+    public IdentityStub(String name, IdentityScope scope)
+            throws KeyManagementException {
+        super(name, scope);
+    }
+
+    /**
+     * Auxilary constructor 
+     * @param name
+     * @param key
+     * @throws KeyManagementException
+     */
+    
+    public IdentityStub(String name, PublicKey key) throws KeyManagementException{
+        this(name);
+        setPublicKey(key);
+    }
+    
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MDGoldenData.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MDGoldenData.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MDGoldenData.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MDGoldenData.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,200 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+* @author Vladimir N. Molotkov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.util.HashMap;
+
+/**
+ * Golden data for Message Digest related tests.<br>
+ * Incapsulates the following data:<br>
+ * - reference message<br>
+ * - reference message digests calculated using
+ *   BEA JRockit j2sdk1.4.2_04 (http://www.bea.com)
+ *   for various MD algorithms: 
+ *   SHA-1, SHA-256, SHA-384, SHA-512, MD-5.
+ * Standart algorithm names are defined in 
+ * "JavaTM Cryptography Architecture API Specification & Reference"
+ *   
+ */
+public class MDGoldenData {
+    // The length of test message
+    private static final int MY_MESSAGE_LEN = 1024;
+    // Test message for digest computations
+    private static final byte[] myMessage = new byte[MY_MESSAGE_LEN];
+    // Reference digests for various algorithms calculated
+    // for <code>myMessage</code>
+    private static final HashMap goldenData = new HashMap();
+    
+    static {
+        // fill myMessage
+        for (int i=0; i<myMessage.length; i++) {
+            myMessage[i] = (byte)i;
+        }
+        // fill goldenData
+        // digest updated with myMessage bytes
+        goldenData.put("SHA-1", new byte[] {
+                (byte)0x5b, (byte)0x00, (byte)0x66, (byte)0x9c,
+                (byte)0x48, (byte)0x0d, (byte)0x5c, (byte)0xff,
+                (byte)0xbd, (byte)0xfa, (byte)0x8b, (byte)0xdb,
+                (byte)0xa9, (byte)0x95, (byte)0x61, (byte)0x16,
+                (byte)0x0f, (byte)0x2d, (byte)0x1b, (byte)0x77
+        });
+        // digest without updates at all;
+        // use MD algorithm name + "_NU" if not updated MD value is needed
+        goldenData.put("SHA-1_NU", new byte[] {
+                (byte)0xda, (byte)0x39, (byte)0xa3, (byte)0xee,
+                (byte)0x5e, (byte)0x6b, (byte)0x4b, (byte)0x0d,
+                (byte)0x32, (byte)0x55, (byte)0xbf, (byte)0xef,
+                (byte)0x95, (byte)0x60, (byte)0x18, (byte)0x90,
+                (byte)0xaf, (byte)0xd8, (byte)0x07, (byte)0x09
+        });
+
+        goldenData.put("SHA", goldenData.get("SHA-1"));
+        goldenData.put("SHA_NU", goldenData.get("SHA-1_NU"));
+
+        goldenData.put("SHA1", goldenData.get("SHA-1"));
+        goldenData.put("SHA1_NU", goldenData.get("SHA-1_NU"));
+
+        goldenData.put("SHA-256", new byte[] {
+                (byte)0x78, (byte)0x5b, (byte)0x07, (byte)0x51,
+                (byte)0xfc, (byte)0x2c, (byte)0x53, (byte)0xdc,
+                (byte)0x14, (byte)0xa4, (byte)0xce, (byte)0x3d,
+                (byte)0x80, (byte)0x0e, (byte)0x69, (byte)0xef,
+                (byte)0x9c, (byte)0xe1, (byte)0x00, (byte)0x9e,
+                (byte)0xb3, (byte)0x27, (byte)0xcc, (byte)0xf4,
+                (byte)0x58, (byte)0xaf, (byte)0xe0, (byte)0x9c,
+                (byte)0x24, (byte)0x2c, (byte)0x26, (byte)0xc9
+        });
+        goldenData.put("SHA-256_NU", new byte[] {
+                (byte)0xe3, (byte)0xb0, (byte)0xc4, (byte)0x42,
+                (byte)0x98, (byte)0xfc, (byte)0x1c, (byte)0x14,
+                (byte)0x9a, (byte)0xfb, (byte)0xf4, (byte)0xc8,
+                (byte)0x99, (byte)0x6f, (byte)0xb9, (byte)0x24,
+                (byte)0x27, (byte)0xae, (byte)0x41, (byte)0xe4,
+                (byte)0x64, (byte)0x9b, (byte)0x93, (byte)0x4c,
+                (byte)0xa4, (byte)0x95, (byte)0x99, (byte)0x1b,
+                (byte)0x78, (byte)0x52, (byte)0xb8, (byte)0x55
+        });
+        goldenData.put("SHA-384", new byte[] {
+                (byte)0x55, (byte)0xfd, (byte)0x17, (byte)0xee,
+                (byte)0xb1, (byte)0x61, (byte)0x1f, (byte)0x91,
+                (byte)0x93, (byte)0xf6, (byte)0xac, (byte)0x60,
+                (byte)0x02, (byte)0x38, (byte)0xce, (byte)0x63,
+                (byte)0xaa, (byte)0x29, (byte)0x8c, (byte)0x2e,
+                (byte)0x33, (byte)0x2f, (byte)0x04, (byte)0x2b,
+                (byte)0x80, (byte)0xc8, (byte)0xf6, (byte)0x91,
+                (byte)0xf8, (byte)0x00, (byte)0xe4, (byte)0xc7,
+                (byte)0x50, (byte)0x5a, (byte)0xf2, (byte)0x0c,
+                (byte)0x1a, (byte)0x86, (byte)0xa3, (byte)0x1f,
+                (byte)0x08, (byte)0x50, (byte)0x45, (byte)0x87,
+                (byte)0x39, (byte)0x5f, (byte)0x08, (byte)0x1f
+        });
+        goldenData.put("SHA-384_NU", new byte[] {
+                (byte)0x38, (byte)0xb0, (byte)0x60, (byte)0xa7,
+                (byte)0x51, (byte)0xac, (byte)0x96, (byte)0x38,
+                (byte)0x4c, (byte)0xd9, (byte)0x32, (byte)0x7e,
+                (byte)0xb1, (byte)0xb1, (byte)0xe3, (byte)0x6a,
+                (byte)0x21, (byte)0xfd, (byte)0xb7, (byte)0x11,
+                (byte)0x14, (byte)0xbe, (byte)0x07, (byte)0x43,
+                (byte)0x4c, (byte)0x0c, (byte)0xc7, (byte)0xbf,
+                (byte)0x63, (byte)0xf6, (byte)0xe1, (byte)0xda,
+                (byte)0x27, (byte)0x4e, (byte)0xde, (byte)0xbf,
+                (byte)0xe7, (byte)0x6f, (byte)0x65, (byte)0xfb,
+                (byte)0xd5, (byte)0x1a, (byte)0xd2, (byte)0xf1,
+                (byte)0x48, (byte)0x98, (byte)0xb9, (byte)0x5b
+        });
+        goldenData.put("SHA-512", new byte[] {
+                (byte)0x37, (byte)0xf6, (byte)0x52, (byte)0xbe,
+                (byte)0x86, (byte)0x7f, (byte)0x28, (byte)0xed,
+                (byte)0x03, (byte)0x32, (byte)0x69, (byte)0xcb,
+                (byte)0xba, (byte)0x20, (byte)0x1a, (byte)0xf2,
+                (byte)0x11, (byte)0x2c, (byte)0x2b, (byte)0x3f,
+                (byte)0xd3, (byte)0x34, (byte)0xa8, (byte)0x9f,
+                (byte)0xd2, (byte)0xf7, (byte)0x57, (byte)0x93,
+                (byte)0x8d, (byte)0xde, (byte)0xe8, (byte)0x15,
+                (byte)0x78, (byte)0x7c, (byte)0xc6, (byte)0x1d,
+                (byte)0x6e, (byte)0x24, (byte)0xa8, (byte)0xa3,
+                (byte)0x33, (byte)0x40, (byte)0xd0, (byte)0xf7,
+                (byte)0xe8, (byte)0x6f, (byte)0xfc, (byte)0x05,
+                (byte)0x88, (byte)0x16, (byte)0xb8, (byte)0x85,
+                (byte)0x30, (byte)0x76, (byte)0x6b, (byte)0xa6,
+                (byte)0xe2, (byte)0x31, (byte)0x62, (byte)0x0a,
+                (byte)0x13, (byte)0x0b, (byte)0x56, (byte)0x6c
+        });
+        goldenData.put("SHA-512_NU", new byte[] {
+                (byte)0xcf, (byte)0x83, (byte)0xe1, (byte)0x35,
+                (byte)0x7e, (byte)0xef, (byte)0xb8, (byte)0xbd,
+                (byte)0xf1, (byte)0x54, (byte)0x28, (byte)0x50,
+                (byte)0xd6, (byte)0x6d, (byte)0x80, (byte)0x07,
+                (byte)0xd6, (byte)0x20, (byte)0xe4, (byte)0x05,
+                (byte)0x0b, (byte)0x57, (byte)0x15, (byte)0xdc,
+                (byte)0x83, (byte)0xf4, (byte)0xa9, (byte)0x21,
+                (byte)0xd3, (byte)0x6c, (byte)0xe9, (byte)0xce,
+                (byte)0x47, (byte)0xd0, (byte)0xd1, (byte)0x3c,
+                (byte)0x5d, (byte)0x85, (byte)0xf2, (byte)0xb0,
+                (byte)0xff, (byte)0x83, (byte)0x18, (byte)0xd2,
+                (byte)0x87, (byte)0x7e, (byte)0xec, (byte)0x2f,
+                (byte)0x63, (byte)0xb9, (byte)0x31, (byte)0xbd,
+                (byte)0x47, (byte)0x41, (byte)0x7a, (byte)0x81,
+                (byte)0xa5, (byte)0x38, (byte)0x32, (byte)0x7a,
+                (byte)0xf9, (byte)0x27, (byte)0xda, (byte)0x3e
+        });
+        goldenData.put("MD5", new byte[] {
+                (byte)0xb2, (byte)0xea, (byte)0x9f, (byte)0x7f,
+                (byte)0xce, (byte)0xa8, (byte)0x31, (byte)0xa4,
+                (byte)0xa6, (byte)0x3b, (byte)0x21, (byte)0x3f,
+                (byte)0x41, (byte)0xa8, (byte)0x85, (byte)0x5b
+        });
+        goldenData.put("MD5_NU", new byte[] {
+                (byte)0xd4, (byte)0x1d, (byte)0x8c, (byte)0xd9,
+                (byte)0x8f, (byte)0x00, (byte)0xb2, (byte)0x04,
+                (byte)0xe9, (byte)0x80, (byte)0x09, (byte)0x98,
+                (byte)0xec, (byte)0xf8, (byte)0x42, (byte)0x7e
+        });
+    }
+
+    // No need to instantiate
+    private MDGoldenData() {
+    }
+
+    /**
+     * Returns reference message
+     *
+     * @return reference message
+     */
+    public static byte[] getMessage() {
+        return myMessage.clone();
+    }
+
+    /**
+     * Returns digest golden data
+     *
+     * @param key
+     *  MD algorithm name or MD algorithm name + "_NU" if
+     *  not updated MD value requested  
+     * @return
+     *  reference digest for specified MD algorithm name
+     */
+    public static byte[] getDigest(String key) {
+        return ((byte[])goldenData.get(key)).clone();
+    }
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyAlgorithmParameterGeneratorSpi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyAlgorithmParameterGeneratorSpi.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyAlgorithmParameterGeneratorSpi.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyAlgorithmParameterGeneratorSpi.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,54 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.AlgorithmParameterGeneratorSpi;
+import java.security.AlgorithmParameters;
+import java.security.SecureRandom;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * Additional class for verification AlgorithmParameterGeneratorSpi and
+ * AlgorithmParameterGenerator classes
+ * 
+ */
+
+public class MyAlgorithmParameterGeneratorSpi 
+        extends AlgorithmParameterGeneratorSpi {
+    
+    protected void engineInit(int keysize, SecureRandom random) {
+        if (keysize < 0) {
+            throw new IllegalArgumentException("keysize < 0");
+        }
+    }
+
+    protected void engineInit(AlgorithmParameterSpec genParamSpec,
+            SecureRandom random) {
+        if (random == null) {
+            throw new IllegalArgumentException("random is null");
+        }
+    }
+    
+    protected AlgorithmParameters engineGenerateParameters() {
+        return null;
+    }
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyAlgorithmParameters.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyAlgorithmParameters.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyAlgorithmParameters.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyAlgorithmParameters.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,76 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+* @author Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.io.IOException;
+import java.security.AlgorithmParametersSpi;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
+
+/**
+ * Tests implementation of AlgorithmParameters
+ * 
+ */
+public class MyAlgorithmParameters extends AlgorithmParametersSpi {
+
+	public static boolean runEngineInit1 = false;
+	public static boolean runEngineInit2 = false;
+	public static boolean runEngineInit3 = false;
+	public static boolean runEngineGetParameterSpec = false;
+	public static boolean runEngineGetEncoded1 = false;
+	public static boolean runEngineGetEncoded2 = false;	
+	public static boolean runEngineToString = false;
+	
+	protected void engineInit(AlgorithmParameterSpec paramSpec)
+			throws InvalidParameterSpecException {
+		runEngineInit1 = true;
+	}
+
+	protected void engineInit(byte[] params) throws IOException {
+		runEngineInit2 = true;
+	}
+
+	protected void engineInit(byte[] params, String format) throws IOException {
+		runEngineInit3 = true;
+	}
+
+	protected AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec)
+			throws InvalidParameterSpecException {
+		runEngineGetParameterSpec = true;
+		return null;
+	}
+
+	protected byte[] engineGetEncoded() throws IOException {
+		runEngineGetEncoded1 = true;
+		return null;
+	}
+
+	protected byte[] engineGetEncoded(String format) throws IOException {
+		runEngineGetEncoded2 = true;
+		return null;
+	}
+
+	protected String engineToString() {
+		runEngineToString = true;
+		return "AlgorithmParameters";
+	}
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator1.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator1.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator1.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator1.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,145 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidParameterException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SecureRandom;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * Additional class extends KeyPairGenerator
+ * 
+ */
+
+public class MyKeyPairGenerator1 extends KeyPairGenerator {
+    public int keySize;
+
+    public SecureRandom secureRandom;
+
+    public AlgorithmParameterSpec paramSpec;
+
+    public MyKeyPairGenerator1() {
+        super("MyKeyPairGenerator1");
+    }
+
+    public MyKeyPairGenerator1(String pp) {
+        super(pp);
+    }
+
+    public String getAlgorithm() {
+        return "MyKeyPairGenerator1";
+    }
+
+    public static final String getResAlgorithm() {
+        return "MyKeyPairGenerator1";
+    }
+
+    public void initialize(int keysize, SecureRandom random) {
+        if ((keysize < 0) || ((keysize % 100) != 0)) {
+            throw new InvalidParameterException("Incorrect keysize parameter");
+        }
+        if (random == null) {
+            throw new InvalidParameterException("Incorrect random");
+        }
+        keySize = keysize;
+        secureRandom = random;
+    }
+
+    public KeyPair generateKeyPair() {
+        try {
+            return new KeyPair(new PubKey(), new PrivKey());
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    public void initialize(AlgorithmParameterSpec param, SecureRandom random)
+            throws InvalidAlgorithmParameterException {
+        if (random == null) {
+            throw new InvalidParameterException("Incorrect random");
+        }
+        if (param == null) {
+            throw new InvalidAlgorithmParameterException("Incorrect param");
+        }
+        paramSpec = param;
+        secureRandom = random;
+    }
+
+    public class PubKey implements PublicKey {
+        private String algorithm;
+
+        private String format;
+
+        private byte[] encoded;
+
+        public PubKey() {
+            this.algorithm = "MyKeyPairGenerator1";
+            this.format = "test1";
+            this.encoded = new byte[10];
+        }
+
+        public String getAlgorithm() {
+            return algorithm;
+        }
+
+        public String getFormat() {
+            return format;
+        }
+
+        public byte[] getEncoded() {
+            return encoded;
+        }
+    }
+
+    public class PrivKey implements PrivateKey {
+        private String algorithm;
+
+        private String format;
+
+        private byte[] encoded;
+
+        public PrivKey() {
+            this.algorithm = "MyKeyPairGenerator1";
+            this.format = "test1";
+            this.encoded = new byte[10];
+        }
+
+        public String getAlgorithm() {
+            return algorithm;
+        }
+
+        public String getFormat() {
+            return format;
+        }
+
+        public byte[] getEncoded() {
+            return encoded;
+        }
+    }
+
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator2.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator2.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator2.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator2.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,67 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.InvalidParameterException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.SecureRandom;
+
+/**
+ *  Additional class extends KeyPairGenerator
+ * 
+ */
+
+public class MyKeyPairGenerator2 extends KeyPairGenerator {
+    int keySize;
+
+    SecureRandom secureRandom;
+
+    public MyKeyPairGenerator2() {
+        super("MyKeyPairGenerator2");
+    }
+
+    public String getAlgorithm() {
+        return "MyKeyPairGenerator2";
+    }
+
+    public static final String getResAlgorithm() {
+        return "MyKeyPairGenerator2";
+    }
+
+    public MyKeyPairGenerator2(String pp) {
+        super(pp);
+    }
+
+    public void initialize(int keysize, SecureRandom random) {
+        if (keysize < 64) {
+            throw new InvalidParameterException("Incorrect keysize parameter");
+        }
+        keySize = keysize;
+        secureRandom = random;
+    }
+
+    public KeyPair generateKeyPair() {
+        return null;
+    }
+}
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator3.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator3.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator3.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator3.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,50 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+
+/**
+ * Additional class extends KeyPairGenerator
+ * 
+ */
+
+public class MyKeyPairGenerator3 extends KeyPairGenerator {
+    public MyKeyPairGenerator3() {
+        super("KPGen_3");
+    }
+
+    public MyKeyPairGenerator3(String s) {
+        super(s);
+    }
+
+    public KeyPair generateKeyPair() {
+        PublicKey pubK = (new MyKeyPairGenerator1()).new PubKey();
+        PrivateKey priK = (new MyKeyPairGenerator1()).new PrivKey();
+        return new KeyPair(pubK, priK);
+    }
+
+}
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGeneratorSpi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGeneratorSpi.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGeneratorSpi.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyPairGeneratorSpi.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,59 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidParameterException;
+import java.security.KeyPair;
+import java.security.KeyPairGeneratorSpi;
+import java.security.SecureRandom;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * Additional class for verification of KeyPairGeneratorSpi and KeyPairGenerator
+ * 
+ */
+
+public class MyKeyPairGeneratorSpi extends KeyPairGeneratorSpi {
+
+    public void initialize(int keysize, SecureRandom random) {
+        if (keysize < 100) {
+            throw new InvalidParameterException(
+                    "Invalid keysize: less than 100");
+        }
+        if (random == null) {
+            throw new IllegalArgumentException("Invalid random");
+        }
+    }
+
+    public KeyPair generateKeyPair() {
+        return null;
+    }
+
+    public void initialize(AlgorithmParameterSpec params, SecureRandom random)
+            throws InvalidAlgorithmParameterException {
+        if (random == null) {
+            throw new UnsupportedOperationException(
+                    "Not supported for null random");
+        }
+    }
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyStoreSpi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyStoreSpi.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyStoreSpi.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyKeyStoreSpi.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,124 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.Key;
+import java.security.KeyStoreException;
+import java.security.KeyStoreSpi;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.Date;
+import java.util.Enumeration;
+
+/**
+ * Additional class for KeyStoreSpi and KeyStore verification
+ * 
+ */
+
+public class MyKeyStoreSpi extends KeyStoreSpi {
+
+    public Key engineGetKey(String alias, char[] password)
+            throws NoSuchAlgorithmException, UnrecoverableKeyException {
+        return null;
+    }
+
+    public Certificate[] engineGetCertificateChain(String alias) {
+        return null;
+    }
+
+    public Certificate engineGetCertificate(String alias) {
+        return null;
+    }
+
+    public Date engineGetCreationDate(String alias) {
+        return new Date(0);
+    }
+
+    public void engineSetKeyEntry(String alias, Key key, char[] password,
+            Certificate[] chain) throws KeyStoreException {
+        throw new KeyStoreException(
+                "engineSetKeyEntry is not supported in myKeyStoreSpi");
+    }
+
+    public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain)
+            throws KeyStoreException {
+        throw new KeyStoreException(
+                "engineSetKeyEntry is not supported in myKeyStoreSpi");
+    }
+
+    public void engineSetCertificateEntry(String alias, Certificate cert)
+            throws KeyStoreException {
+        throw new KeyStoreException(
+                "engineSetCertificateEntry is not supported in myKeyStoreSpi");
+    }
+
+    public void engineDeleteEntry(String alias) throws KeyStoreException {
+        throw new KeyStoreException(
+                "engineDeleteEntry is not supported in myKeyStoreSpi");
+    }
+
+    public Enumeration engineAliases() {
+        return null;
+    }
+
+    public boolean engineContainsAlias(String alias) {
+        return false;
+    }
+
+    public int engineSize() {
+        return 0;
+    }
+
+    public boolean engineIsKeyEntry(String alias) {
+        return false;
+    }
+
+    public boolean engineIsCertificateEntry(String alias) {
+        return false;
+    }
+
+    public String engineGetCertificateAlias(Certificate cert) {
+        return "";
+    }
+
+    public void engineStore(OutputStream stream, char[] password)
+            throws IOException, NoSuchAlgorithmException, CertificateException {
+        if (!(stream instanceof ByteArrayOutputStream)) {
+            throw new IOException("Incorrect stream");
+        }
+        if (((ByteArrayOutputStream) stream).size() == 0) {
+            throw new IOException("Incorrect stream size ");
+
+        }
+
+    }
+
+    public void engineLoad(InputStream stream, char[] password)
+            throws IOException, NoSuchAlgorithmException, CertificateException {
+    }
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyLoadStoreParams.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyLoadStoreParams.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyLoadStoreParams.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyLoadStoreParams.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,46 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.KeyStore;
+
+/**
+ * Additional class extends KeyStore.LoadStoreParameter
+ * 
+ */
+
+public class MyLoadStoreParams implements 
+        KeyStore.LoadStoreParameter {
+    
+    KeyStore.ProtectionParameter protPar;
+
+    public MyLoadStoreParams(KeyStore.ProtectionParameter p) {
+        if (p == null) {
+            throw new NullPointerException("null parameter");
+        }
+        this.protPar = p;
+    }
+
+    public KeyStore.ProtectionParameter getProtectionParameter() {
+        return protPar;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,78 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.MessageDigest;
+
+/**
+ * Tests implementation of MessageDigest
+ * 
+ */
+public class MyMessageDigest1 extends MessageDigest {
+
+	public boolean runEngineReset = false;
+	public boolean runEngineDigest = false;
+	public boolean runEngineUpdate1 = false;
+	public boolean runEngineUpdate2 = false;	
+	
+	public MyMessageDigest1() {
+		super(null);
+	}
+	
+	/**
+	 * 
+	 * @param algorithm
+	 */
+	public MyMessageDigest1(String algorithm) {
+		super(algorithm);
+	}
+	
+	/**
+	 * 
+	 */
+	public void engineReset() {
+		runEngineReset = true;
+	}
+
+	/**
+	 * 
+	 */
+	public byte[] engineDigest() {
+		runEngineDigest = true;
+		return null;
+	}
+
+	/**
+	 * 
+	 */
+	public void engineUpdate(byte arg0) {
+		runEngineUpdate1 = true;
+	}
+
+	/**
+	 * 
+	 */
+	public void engineUpdate(byte[] arg0, int arg1, int arg2) {
+		runEngineUpdate2 = true;
+	}
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,72 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.MessageDigestSpi;
+
+/**
+ * Tests implementation of MessageDigest
+ * 
+ */
+public class MyMessageDigest2 extends MessageDigestSpi {
+
+	public static boolean runEngineReset = false;
+	public static boolean runEngineDigest = false;
+	public static boolean runEngineUpdate1 = false;
+	public static boolean runEngineUpdate2 = false;			
+
+	/**
+	 * 
+	 */
+	public void engineReset() {
+		runEngineReset = true;
+	}
+
+	/**
+	 * 
+	 */
+	public byte[] engineDigest() {
+		runEngineDigest = true;
+		return null;
+	}
+
+	/**
+	 * 
+	 */
+	public void engineUpdate(byte arg0) {
+		runEngineUpdate1 = true;
+	}
+
+	/**
+	 * 
+	 */
+	public void engineUpdate(byte[] arg0, int arg1, int arg2) {
+		runEngineUpdate2 = true;
+	}
+
+	/**
+	 * The implementation is not cloneable
+	 */
+	public Object clone() throws CloneNotSupportedException {
+		throw new CloneNotSupportedException();
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature1.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature1.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature1.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature1.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,104 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+* @author Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.InvalidKeyException;
+import java.security.InvalidParameterException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.Signature;
+import java.security.SignatureException;
+
+/**
+ * Tests implementation of Signature
+ * 
+ */
+public class MySignature1 extends Signature {
+
+	public boolean runEngineInitVerify = false;
+	public boolean runEngineInitSign = false;
+	public boolean runEngineUpdate1 = false;
+	public boolean runEngineUpdate2 = false;	
+	public boolean runEngineSign = false;
+	public boolean runEngineVerify = false;
+	public boolean runEngineSetParameter = false;	
+	public boolean runEngineGetParameter = false;
+	
+	/**
+	 * 
+	 *
+	 */
+	public MySignature1() {
+		super(null);
+	}
+	
+	/**
+	 * 
+	 * @param algorithm
+	 */
+	public MySignature1(String algorithm) {
+		super(algorithm);
+	}
+	
+	protected void engineInitVerify(PublicKey publicKey)
+			throws InvalidKeyException {
+		runEngineInitVerify = true;
+	}
+
+	protected void engineInitSign(PrivateKey privateKey)
+			throws InvalidKeyException {
+		runEngineInitSign = true;
+	}
+
+	protected void engineUpdate(byte b) throws SignatureException {
+		runEngineUpdate1 = true;
+	}
+
+	protected void engineUpdate(byte[] b, int off, int len)
+			throws SignatureException {
+		runEngineUpdate2 = true;
+	}
+
+	protected byte[] engineSign() throws SignatureException {
+		runEngineSign = true;
+		return null;
+	}
+
+	protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
+		runEngineVerify = true;
+		return false;
+	}
+
+	protected void engineSetParameter(String param, Object value)
+			throws InvalidParameterException {
+		runEngineSetParameter = true;
+	}
+
+	protected Object engineGetParameter(String param)
+			throws InvalidParameterException {
+		runEngineGetParameter = true;
+		return null;
+	}
+	
+	public int getState() {
+		return state;
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature2.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature2.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature2.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MySignature2.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,84 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+* @author Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.InvalidKeyException;
+import java.security.InvalidParameterException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.SignatureSpi;
+
+/**
+ * Tests implementation of Signature
+ * 
+ */
+public class MySignature2 extends SignatureSpi {
+
+	public static boolean runEngineInitVerify = false;
+	public static boolean runEngineInitSign = false;
+	public static boolean runEngineUpdate1 = false;
+	public static boolean runEngineUpdate2 = false;	
+	public static boolean runEngineSign = false;
+	public static boolean runEngineVerify = false;
+	public static boolean runEngineSetParameter = false;	
+	public static boolean runEngineGetParameter = false;
+	
+	protected void engineInitVerify(PublicKey publicKey)
+			throws InvalidKeyException {
+		runEngineInitVerify = true;
+	}
+
+	protected void engineInitSign(PrivateKey privateKey)
+			throws InvalidKeyException {
+		runEngineInitSign = true;
+	}
+
+	protected void engineUpdate(byte b) throws SignatureException {
+		runEngineUpdate1 = true;
+	}
+
+	protected void engineUpdate(byte[] b, int off, int len)
+			throws SignatureException {
+		runEngineUpdate2 = true;
+	}
+
+	protected byte[] engineSign() throws SignatureException {
+		runEngineSign = true;
+		return null;
+	}
+
+	protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
+		runEngineVerify = true;
+		return false;
+	}
+
+	protected void engineSetParameter(String param, Object value)
+			throws InvalidParameterException {
+		runEngineSetParameter = true;
+	}
+
+	protected Object engineGetParameter(String param)
+			throws InvalidParameterException {
+		runEngineGetParameter = true;
+		return null;
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PrivateKeyStub.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PrivateKeyStub.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PrivateKeyStub.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PrivateKeyStub.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,74 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Aleksei Y. Semenov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.PrivateKey;
+
+/**
+ * Stub for interface PrivateKey tests
+ */
+
+public class PrivateKeyStub implements PrivateKey {
+
+    String algorithm = null;
+    String format = null;
+    byte [] encoded = null;
+    
+    
+    /**
+     * Constructor
+     * 
+     * @param algorithm
+     * @param format
+     * @param encoded
+     */
+    public PrivateKeyStub(String algorithm, String format, byte[] encoded) {
+        this.algorithm = algorithm;
+        this.format = format;
+        this.encoded = encoded;
+    }
+
+    /**
+     * Returns algorithm
+     * @see java.security.Key#getAlgorithm()
+     */
+    public String getAlgorithm() {
+        return algorithm;
+    }
+
+    /**
+     * Returns format
+     * @see java.security.Key#getFormat()
+     */
+    public String getFormat() {
+        return format;
+    }
+
+    /**
+     * Returns encoded form
+     * @see java.security.Key#getEncoded()
+     */
+    public byte[] getEncoded() {
+        return encoded;
+    }
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PublicKeyStub.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PublicKeyStub.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PublicKeyStub.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/PublicKeyStub.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,70 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Aleksei Y. Semenov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+
+import java.security.PublicKey;
+
+
+/**
+ * Stub implements interface PublicKey
+ * 
+ */
+
+public class PublicKeyStub implements PublicKey {
+
+    String algorithm = null;
+    String format = null;
+    byte [] encoded = null;
+    
+    /**
+     *  constructor 
+     */
+    public PublicKeyStub(String algorithm, String format, byte[] encoded) {
+        this.algorithm = algorithm;
+        this.format = format;
+        this.encoded = encoded;
+    }
+
+    /**
+     * returns algorithm
+     */
+    public String getAlgorithm() {
+        return algorithm;
+    }
+
+    /**
+     * returns format
+     * @see java.security.Key#getFormat()
+     */
+    public String getFormat() {
+        return format;
+    }
+
+    /** 
+     * returns encoded
+     * @see java.security.Key#getEncoded()
+     */
+    public byte[] getEncoded() {
+        return encoded;
+    }
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SecurityChecker.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SecurityChecker.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SecurityChecker.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SecurityChecker.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,57 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Alexey V. Varlamov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.Permission;
+
+/**
+ * Custom security manager
+ */
+
+public class SecurityChecker extends SecurityManager {
+
+    public boolean enableAccess;
+
+    public Permission checkTarget;
+
+    public boolean checkAsserted;
+
+    public SecurityChecker(Permission target, boolean enable) {
+        checkAsserted = false;
+        checkTarget = target;
+        enableAccess = enable;
+    }
+
+    public void checkPermission(Permission p) {
+        if (checkTarget.equals(p)) {
+            checkAsserted = true;
+            if (!enableAccess) {
+                throw new SecurityException();
+            }
+        }
+    }
+    
+    public SecurityChecker reset() {
+        checkAsserted = false;
+        return this;
+    }
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SerializationTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SerializationTest.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SerializationTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SerializationTest.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,308 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Alexey V. Varlamov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+/**
+ * Framework for serialization testing. Subclasses only need to override
+ * getData() method and, optionally, assertDeserialized() method. The first one
+ * returns array of objects to be de/serialized in tests, and the second
+ * compares reference and deserialized objects (needed only if tested objects do
+ * not provide specific method equals()). <br>
+ * There are two modes of test run: <b>reference generation mode </b> and
+ * <b>testing mode </b>. The actual mode is selected via
+ * <b>&quot;test.mode&quot; </b> system property. The <b>testing mode </b> is
+ * the default mode. <br>
+ * To turn on the <b>reference generation mode </b>, the test.mode property
+ * should be set to value &quot;serial.reference&quot;. In this mode, no testing
+ * is performed but golden files are produced, which contain reference
+ * serialized objects. This mode should be run on a pure 
+ * Implementation classes, which are targeted for compartibility. <br>
+ * The location of golden files (in both modes) is controlled via
+ * <b>&quot;RESOURCE_DIR&quot; </b> system property.
+ * 
+ */
+public abstract class SerializationTest extends TestCase {
+
+    /**
+     * Property name for the testing mode.
+     */
+    public static final String MODE_KEY = "test.mode";
+
+
+    /**
+     * Testing mode.
+     */
+    public static String mode = System.getProperty(MODE_KEY);
+
+    /**
+     * Reference files generation mode switch.
+     */
+    public static final String SERIAL_REFERENCE_MODE = "serial.reference";
+
+    /**
+     * Key to a system property defining root location of golden files.
+     */
+    public static final String GOLDEN_PATH = "RESOURCE_DIR";
+
+    private static String outputPath = System.getProperty(GOLDEN_PATH,
+                                                          "test/common/unit");
+
+    /**
+     * Parameterized c-tor inherited from superclass.
+     */
+    public SerializationTest(String name) {
+        super(name);
+    }
+
+    /**
+     * Default c-tor inherited from superclass.
+     */
+    public SerializationTest() {
+        super();
+    }
+
+    /**
+     * Depending on testing mode, produces golden files or performs testing.
+     */
+    public void runBare() throws Throwable {
+
+        if (mode != null && mode.equals(SERIAL_REFERENCE_MODE)) {
+            produceGoldenFiles();
+        } else {
+            super.runBare();
+        }
+    }
+
+    /**
+     * Returns zero value to exclude serialization tests from performance runs.
+     */
+    public long getRepeatCount() {
+        return 0;
+    }
+
+    /**
+     * This is the main working method of this framework. Subclasses must
+     * override it to provide actual objects for testing.
+     * 
+     * @return array of objects to be de/serialized in tests.
+     */
+    protected abstract Object[] getData();
+
+    /**
+     * Compares deserialized and reference objects. This default implementation
+     * just asserts equality of the two objects. Should be overriden if a class
+     * under test does not provide specific equals() method and it's instances
+     * should to be compared manually.
+     */
+    protected void assertDeserialized(Object reference, Object test) {
+        assertEquals(reference, test);
+    }
+
+    /**
+     * Tests that data objects can be serialized and deserialized without
+     * exceptions, and that deserialization really produces deeply cloned
+     * objects.
+     */
+    public void testSelf() throws Throwable {
+
+        SerializableAssert comparator = defineComparator();
+
+        Object[] data = getData();
+        for (int i = 0; i < data.length; i++) {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            putObjectToStream(data[i], bos);
+            ByteArrayInputStream bis = new ByteArrayInputStream(bos
+                .toByteArray());
+
+            comparator.assertDeserialized((Serializable) data[i],
+                    (Serializable) getObjectFromStream(bis));
+        }
+    }
+
+    /**
+     * Tests that data objects can be deserialized from golden files, to verify
+     * compartibility with Reference Implementation.
+     */
+    public void testGolden() throws Throwable {
+        
+        SerializableAssert comparator = defineComparator();
+        
+        Object[] data = getData();
+        for (int i = 0; i < data.length; i++) {
+            comparator.assertDeserialized((Serializable) data[i],
+                    (Serializable) getObjectFromStream(new FileInputStream(
+                            getDataFile(i))));
+        }
+    }
+
+    /**
+     * Returns golden file for an object being tested.
+     * 
+     * @param index array index of tested data (as returned by
+     *        {@link #getData() getData()})
+     * @return corresponding golden file
+     */
+    protected File getDataFile(int index) {
+        String name = this.getClass().getName();
+        int dot = name.lastIndexOf(".");
+        String path = name.substring(0, dot).replace('.', File.separatorChar);
+        if (outputPath != null && outputPath.length() != 0) {
+            path = outputPath + File.separator + path;
+        }
+
+        return new File(path, name.substring(dot + 1) + "." + index + ".dat");
+    }
+
+    /**
+     * Working method for files generation mode. Serializes test objects
+     * returned by {@link #getData() getData()}to golden files, each object to
+     * a separate file.
+     * 
+     * @throws IOException
+     */
+    protected void produceGoldenFiles() throws IOException {
+        Object[] data = getData();
+        for (int i = 0; i < data.length; i++) {
+            File gf = getDataFile(i);
+            gf.getParentFile().mkdirs();
+            gf.createNewFile();
+            putObjectToStream(data[i], new FileOutputStream(gf));
+        }
+    }
+
+    /**
+     * Serializes specified object to an output stream.
+     */
+    protected void putObjectToStream(Object obj, OutputStream os)
+        throws IOException {
+        ObjectOutputStream oos = new ObjectOutputStream(os);
+        oos.writeObject(obj);
+        oos.flush();
+        oos.close();
+    }
+
+    /**
+     * Deserializes single object from an input stream.
+     */
+    protected Object getObjectFromStream(InputStream is) throws IOException,
+        ClassNotFoundException {
+        ObjectInputStream ois = new ObjectInputStream(is);
+        Object result = ois.readObject();
+        ois.close();
+        return result;
+    }
+    
+    /**
+     * Interface to compare (de)serialized objects
+     */
+    public interface SerializableAssert {
+        void assertDeserialized(Serializable reference, Serializable test);
+    }
+
+    // default comparator for a class that has equals(Object) method
+    private final static SerializableAssert DEFAULT_COMPARATOR = new SerializableAssert() {
+        public void assertDeserialized(Serializable reference, Serializable test) {
+            TestCase.assertEquals(reference, test);
+        }
+    };
+
+    // for comparing java.lang.Throwable objects
+    private final static SerializableAssert THROWABLE_COMPARATOR = new SerializableAssert() {
+        public void assertDeserialized(Serializable reference, Serializable test) {
+
+            Throwable refThr = (Throwable) reference;
+            Throwable tstThr = (Throwable) test;
+
+            // verify class
+            TestCase.assertEquals(refThr.getClass(), tstThr.getClass());
+
+            // verify message
+            TestCase.assertEquals(refThr.getMessage(), tstThr.getMessage());
+
+            // verify cause
+            if (refThr.getCause() == null) {
+                TestCase.assertNull(tstThr.getCause());
+            } else {
+                TestCase.assertNotNull(tstThr.getCause());
+
+                refThr = refThr.getCause();
+                tstThr = tstThr.getCause();
+
+                TestCase.assertEquals(refThr.getClass(), tstThr.getClass());
+                TestCase.assertEquals(refThr.getMessage(), tstThr.getMessage());
+            }
+        }
+    };
+
+    private SerializableAssert defineComparator() throws Exception {
+
+        if (this instanceof SerializableAssert) {
+            return (SerializableAssert) this;
+        }
+
+        Object s[] = getData();
+        if (s == null || s.length == 0) {
+            // nothing to compare - OK with default comparator
+            return DEFAULT_COMPARATOR;
+
+        }
+
+        Method m = s[0].getClass().getMethod("equals", Object.class);
+
+        if (m.getDeclaringClass() != Object.class) {
+            // one of classes overrides Object.equals(Object) method
+            // use default comparator
+            return DEFAULT_COMPARATOR;
+        }
+
+        // TODO use generics to detect comparator
+        // instead of 'instanceof' for the first element
+        if(s[0] instanceof java.lang.Throwable){
+            return THROWABLE_COMPARATOR;
+        }
+
+        // TODO - throw new RuntimeException() if failed to detect comparator
+        // return stub comparator for a while
+        final SerializationTest thisTest = this;
+        return new SerializableAssert() {
+            public void assertDeserialized(Serializable reference,
+                    Serializable test) {
+                thisTest.assertDeserialized(reference, test);
+            }
+        };
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SignerStub.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SignerStub.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SignerStub.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SignerStub.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,63 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Aleksei Y. Semenov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.security.IdentityScope;
+import java.security.KeyManagementException;
+import java.security.Signer;
+
+/**
+ * Stub for abstract class Signer, necessary for testing purposes
+ * 
+ */
+
+public class SignerStub extends Signer {
+
+    /**
+     * Default constructor 
+     */
+    public SignerStub() {
+        super();
+    }
+
+    /**
+     * Constructor, sets given name
+     * 
+     * @param name
+     */
+    public SignerStub(String name) {
+        super(name);
+    }
+
+    /**
+     * Constructor, sets given name and scope
+     * 
+     * @param name
+     * @param scope
+     * @throws KeyManagementException
+     */
+    public SignerStub(String name, IdentityScope scope)
+            throws KeyManagementException {
+        super(name, scope);
+    }
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SpiEngUtils.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SpiEngUtils.java?rev=410788&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SpiEngUtils.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SpiEngUtils.java Thu Jun  1 01:15:17 2006
@@ -0,0 +1,84 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.support;
+
+import java.io.File;
+import java.security.Security;
+import java.security.Provider;
+import java.util.StringTokenizer;
+
+/**
+ * Additional class for verification spi-engine classes
+ * 
+ */
+
+public class SpiEngUtils {
+
+    public static final String[] invalidValues = {
+            "",
+            "BadAlgorithm",
+            "Long message Long message Long message Long message Long message Long message Long message Long message Long message Long message Long message Long message Long message" };
+
+    /**
+     * Verification: is algorithm supported or not
+     * 
+     * @param algorithm
+     * @param service
+     * @return
+     */
+    public static Provider isSupport(String algorithm, String service) {
+        try {
+            Provider[] provs = Security.getProviders(service.concat(".")
+                    .concat(algorithm));
+            if (provs == null) {
+                return null;
+            }
+            return (provs.length == 0 ? null : provs[0]);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public static String getFileName(String dir, String name) {
+        String res = dir;
+        if (res.charAt(res.length() - 1) == '/') {
+            res = res.substring(0, res.length() - 1);
+        }
+        char[] mm = { File.separatorChar };
+        String sp = String.copyValueOf(mm);
+        StringTokenizer st = new StringTokenizer(name, "/");
+        while (st.hasMoreElements()) {
+            res = res.concat(sp).concat((String) st.nextElement());
+        }
+        return res;
+    }
+
+    public class MyProvider extends Provider {
+
+        public MyProvider(String name, String info, String key, String clName) {
+            super(name, 1.0, info);
+            put(key, clName);
+        }
+
+    }
+
+}
\ No newline at end of file