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