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
18package tests.support;
19
20import java.security.AccessController;
21import java.security.PrivilegedAction;
22import java.security.Provider;
23
24/**
25 * This class implements a dummy provider.
26 */
27public class Support_ProviderRSA extends Provider {
28    private static final long serialVersionUID = 1L;
29
30    // Provider name
31	private static final String NAME = "ProviderRSA";
32
33	// Version of the services provided
34	private static final double VERSION = 1.0;
35
36	private static final String INFO = NAME
37			+ " DSA key, parameter generation and signing; SHA-1 digest";
38
39	/**
40	 * Constructs a new instance of the dummy provider.
41	 */
42	public Support_ProviderRSA() {
43		super(NAME, VERSION, INFO);
44		registerServices();
45	}
46
47	/**
48	 * Register the services the receiver provides.
49	 */
50	private void registerServices() {
51		AccessController.doPrivileged(new PrivilegedAction<Void>() {
52			public Void run() {
53				// Digest engine
54				put("MessageDigest.SHA",
55						"made.up.provider.name.MessageDigestSHA");
56				put("MessageDigest.MD5",
57						"made.up.provider.name.MessageDigestMD5");
58
59				// Secure Random
60				put("SecureRandom.SHA1PRNG",
61						"made.up.provider.name.SecureRandomImpl");
62
63				// Algorithm parameter generator
64				put("AlgorithmParameterGenerator.DSA",
65						"made.up.provider.name.AlgorithmParameterGeneratorDSA");
66
67				// Algorithm parameters
68				put("AlgorithmParameters.DSA",
69						"made.up.provider.name.AlgorithmParametersDSA");
70
71				// Key pair generator
72				put("KeyPairGenerator.DSA",
73						"made.up.provider.name.KeyPairGeneratorDSA");
74
75				// Key factory
76				put("KeyFactory.DSA",
77						"made.up.provider.name.KeyFactoryDSA");
78				put("KeyFactory.RSA",
79						"made.up.provider.name.KeyFactoryRSA");
80
81				// Signature algorithm
82				put("Signature.SHA1withDSA",
83						"made.up.provider.name.SignatureDSA");
84
85				// KeyStore
86				put("KeyStore.PKCS#12/Netscape",
87						"made.up.provider.name.KeyStore");
88
89				// Certificate
90				put("CertificateFactory.X509",
91						"made.up.provider.name.CertificateFactoryX509");
92				return null;
93			}
94		});
95	}
96}