Home | History | Annotate | Download | only in support
      1 package org.apache.harmony.xnet.tests.support;
      2 
      3 import java.security.InvalidAlgorithmParameterException;
      4 import java.security.KeyStore;
      5 import java.security.KeyStoreException;
      6 import java.security.NoSuchAlgorithmException;
      7 import java.security.UnrecoverableKeyException;
      8 
      9 import javax.net.ssl.KeyManager;
     10 import javax.net.ssl.ManagerFactoryParameters;
     11 
     12 public class KeyManagerFactorySpiImpl extends MyKeyManagerFactorySpi {
     13 
     14     private boolean isInitialized = false;
     15 
     16     public void engineInit(KeyStore ks, char[] password)
     17             throws KeyStoreException, NoSuchAlgorithmException,
     18             UnrecoverableKeyException {
     19 
     20         if (ks == null && password == null) {
     21             throw new NoSuchAlgorithmException();
     22         }
     23 
     24         if (ks == null) {
     25             throw new KeyStoreException();
     26         }
     27 
     28         if (password == null) {
     29             throw new UnrecoverableKeyException();
     30         }
     31 
     32         isInitialized = true;
     33     }
     34 
     35     public void engineInit(ManagerFactoryParameters spec)
     36             throws InvalidAlgorithmParameterException {
     37         if (spec == null) {
     38             throw new InvalidAlgorithmParameterException("Incorrect parameter");
     39         }
     40         isInitialized = true;
     41     }
     42 
     43     public KeyManager[] engineGetKeyManagers() {
     44         if(!isInitialized)
     45             throw new IllegalStateException("KeyManagerFactoryImpl is not initialized");
     46         else
     47             return null;
     48     }
     49 }
     50