java.security.KeyStore.LoadStoreParameter Java Examples

The following examples show how to use java.security.KeyStore.LoadStoreParameter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DistributedKeyStoreRegistry.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public KeyStore createDistributedKeyStore(String key, DistributedSignerProxy proxy) throws TechnicalConnectorException {
   try {
      KeyStore store = KeyStore.getInstance("DistributedKeyProvider");
      Validate.notNull(store);
      LoadStoreParameter param = new DistributedKeyLoadStoreParam(proxy);
      store.load(param);
      if (this.distributedKeyStores.containsKey(key)) {
         LOG.info("Key [" + key + "] already in cache.");
      }

      this.distributedKeyStores.put(key, store);
      return store;
   } catch (IOException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var5, new Object[]{var5.getMessage()});
   } catch (KeyStoreException var6) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var6, new Object[]{var6.getMessage()});
   } catch (NoSuchAlgorithmException var7) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var7, new Object[]{var7.getMessage()});
   } catch (CertificateException var8) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var8, new Object[]{var8.getMessage()});
   }
}
 
Example #2
Source File: DistributedKeyStoreRegistry.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public KeyStore createDistributedKeyStore(String key, DistributedSignerProxy proxy) throws TechnicalConnectorException {
   try {
      KeyStore store = KeyStore.getInstance("DistributedKeyProvider");
      Validate.notNull(store);
      LoadStoreParameter param = new DistributedKeyLoadStoreParam(proxy);
      store.load(param);
      if (this.distributedKeyStores.containsKey(key)) {
         LOG.info("Key [" + key + "] already in cache.");
      }

      this.distributedKeyStores.put(key, store);
      return store;
   } catch (IOException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var5, new Object[]{var5.getMessage()});
   } catch (KeyStoreException var6) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var6, new Object[]{var6.getMessage()});
   } catch (NoSuchAlgorithmException var7) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var7, new Object[]{var7.getMessage()});
   } catch (CertificateException var8) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var8, new Object[]{var8.getMessage()});
   }
}
 
Example #3
Source File: DistributedKeyStoreRegistry.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public KeyStore createDistributedKeyStore(String key, DistributedSignerProxy proxy) throws TechnicalConnectorException {
   try {
      KeyStore store = KeyStore.getInstance("DistributedKeyProvider");
      Validate.notNull(store);
      LoadStoreParameter param = new DistributedKeyLoadStoreParam(proxy);
      store.load(param);
      if (this.distributedKeyStores.containsKey(key)) {
         LOG.info("Key [" + key + "] already in cache.");
      }

      this.distributedKeyStores.put(key, store);
      return store;
   } catch (IOException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var5, new Object[]{var5.getMessage()});
   } catch (KeyStoreException var6) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var6, new Object[]{var6.getMessage()});
   } catch (NoSuchAlgorithmException var7) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var7, new Object[]{var7.getMessage()});
   } catch (CertificateException var8) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var8, new Object[]{var8.getMessage()});
   }
}
 
Example #4
Source File: DistributedKeyStoreRegistry.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public KeyStore createDistributedKeyStore(String key, DistributedSignerProxy proxy) throws TechnicalConnectorException {
   try {
      KeyStore store = KeyStore.getInstance("DistributedKeyProvider");
      Validate.notNull(store);
      LoadStoreParameter param = new DistributedKeyLoadStoreParam(proxy);
      store.load(param);
      if (this.distributedKeyStores.containsKey(key)) {
         LOG.info("Key [" + key + "] already in cache.");
      }

      this.distributedKeyStores.put(key, store);
      return store;
   } catch (IOException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var5, new Object[]{var5.getMessage()});
   } catch (KeyStoreException var6) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var6, new Object[]{var6.getMessage()});
   } catch (NoSuchAlgorithmException var7) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var7, new Object[]{var7.getMessage()});
   } catch (CertificateException var8) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var8, new Object[]{var8.getMessage()});
   }
}
 
Example #5
Source File: DistributedKeyStoreRegistry.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public KeyStore createDistributedKeyStore(String key, DistributedSignerProxy proxy) throws TechnicalConnectorException {
   try {
      KeyStore store = KeyStore.getInstance("DistributedKeyProvider");
      Validate.notNull(store);
      LoadStoreParameter param = new DistributedKeyLoadStoreParam(proxy);
      store.load(param);
      if (this.distributedKeyStores.containsKey(key)) {
         LOG.info("Key [" + key + "] already in cache.");
      }

      this.distributedKeyStores.put(key, store);
      return store;
   } catch (IOException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var5, new Object[]{var5.getMessage()});
   } catch (KeyStoreException var6) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var6, new Object[]{var6.getMessage()});
   } catch (NoSuchAlgorithmException var7) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var7, new Object[]{var7.getMessage()});
   } catch (CertificateException var8) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var8, new Object[]{var8.getMessage()});
   }
}
 
Example #6
Source File: TestKeyStoreSpi.java    From j2objc with Apache License 2.0 6 votes vote down vote up
@Override
public void engineLoad(LoadStoreParameter param) throws IOException,
        NoSuchAlgorithmException, CertificateException {
    if (param == null) {
        engineLoad(null, null);
        return;
    }

    ProtectionParameter pParam = param.getProtectionParameter();
    if (pParam == null) {
        throw new NoSuchAlgorithmException();
    }

    if (pParam instanceof PasswordProtection) {
        char[] password = ((PasswordProtection) pParam).getPassword();
        if (password == null) {
            throw new NoSuchAlgorithmException();
        } else {
            return;
        }
    }
    throw new CertificateException();
}
 
Example #7
Source File: TestKeyStoreSpi.java    From j2objc with Apache License 2.0 6 votes vote down vote up
@Override
public void engineStore(LoadStoreParameter param) throws IOException,
        NoSuchAlgorithmException, CertificateException {
    if (param == null) {
        throw new IOException();
    }

    ProtectionParameter pParam = param.getProtectionParameter();
    if (pParam instanceof PasswordProtection) {
        char[] password = ((PasswordProtection) pParam).getPassword();
        if (password == null) {
            throw new NoSuchAlgorithmException();
        } else if (password.length == 0) {
            throw new CertificateException();
        }
        return;
    }
    throw new UnsupportedOperationException();
}
 
Example #8
Source File: Jre8Compat.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public LoadStoreParameter getDomainLoadStoreParameter(URI uri) {
    try {
        return (LoadStoreParameter) domainLoadStoreParameterConstructor.newInstance(
                uri, Collections.EMPTY_MAP);
    } catch (InstantiationException | IllegalAccessException | IllegalArgumentException |
            InvocationTargetException e) {
        throw new UnsupportedOperationException(e);
    }
}
 
Example #9
Source File: JreCompat.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@SuppressWarnings("unused")
public LoadStoreParameter getDomainLoadStoreParameter(URI uri) {
    throw new UnsupportedOperationException(sm.getString("jreCompat.noDomainLoadStoreParameter"));
}
 
Example #10
Source File: DistributedKeyStore.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public void engineLoad(LoadStoreParameter param) throws IOException, NoSuchAlgorithmException, CertificateException {
   if (param instanceof DistributedKeyLoadStoreParam) {
      this.keyStoreParameter = (DistributedKeyLoadStoreParam)param;
   }

}
 
Example #11
Source File: DistributedKeyStore.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public void engineLoad(LoadStoreParameter param) throws IOException, NoSuchAlgorithmException, CertificateException {
   if (param instanceof DistributedKeyLoadStoreParam) {
      this.keyStoreParameter = (DistributedKeyLoadStoreParam)param;
   }

}
 
Example #12
Source File: DistributedKeyStore.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public void engineLoad(LoadStoreParameter param) throws IOException, NoSuchAlgorithmException, CertificateException {
   if (param instanceof DistributedKeyLoadStoreParam) {
      this.keyStoreParameter = (DistributedKeyLoadStoreParam)param;
   }

}
 
Example #13
Source File: DistributedKeyStore.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public void engineLoad(LoadStoreParameter param) throws IOException, NoSuchAlgorithmException, CertificateException {
   if (param instanceof DistributedKeyLoadStoreParam) {
      this.keyStoreParameter = (DistributedKeyLoadStoreParam)param;
   }

}
 
Example #14
Source File: DistributedKeyStore.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public void engineLoad(LoadStoreParameter param) throws IOException, NoSuchAlgorithmException, CertificateException {
   if (param instanceof DistributedKeyLoadStoreParam) {
      this.keyStoreParameter = (DistributedKeyLoadStoreParam)param;
   }

}
 
Example #15
Source File: PKCS12KeyStoreSpi.java    From RipplePower with Apache License 2.0 4 votes vote down vote up
public void engineStore(LoadStoreParameter param)
    throws IOException,
    NoSuchAlgorithmException, CertificateException
{
    if (param == null)
    {
        throw new IllegalArgumentException("'param' arg cannot be null");
    }

    if (!(param instanceof PKCS12StoreParameter || param instanceof JDKPKCS12StoreParameter))
    {
        throw new IllegalArgumentException(
            "No support for 'param' of type " + param.getClass().getName());
    }

    PKCS12StoreParameter bcParam;

    if (param instanceof PKCS12StoreParameter)
    {
        bcParam = (PKCS12StoreParameter)param;
    }
    else
    {
        bcParam = new PKCS12StoreParameter(((JDKPKCS12StoreParameter)param).getOutputStream(),
            param.getProtectionParameter(), ((JDKPKCS12StoreParameter)param).isUseDEREncoding());
    }

    char[] password;
    ProtectionParameter protParam = param.getProtectionParameter();
    if (protParam == null)
    {
        password = null;
    }
    else if (protParam instanceof KeyStore.PasswordProtection)
    {
        password = ((KeyStore.PasswordProtection)protParam).getPassword();
    }
    else
    {
        throw new IllegalArgumentException(
            "No support for protection parameter of type " + protParam.getClass().getName());
    }

    doStore(bcParam.getOutputStream(), password, bcParam.isForDEREncoding());
}
 
Example #16
Source File: PKCS12KeyStoreSpi.java    From ripple-lib-java with ISC License 4 votes vote down vote up
public void engineStore(LoadStoreParameter param)
    throws IOException,
    NoSuchAlgorithmException, CertificateException
{
    if (param == null)
    {
        throw new IllegalArgumentException("'param' arg cannot be null");
    }

    if (!(param instanceof PKCS12StoreParameter || param instanceof JDKPKCS12StoreParameter))
    {
        throw new IllegalArgumentException(
            "No support for 'param' of type " + param.getClass().getName());
    }

    PKCS12StoreParameter bcParam;

    if (param instanceof PKCS12StoreParameter)
    {
        bcParam = (PKCS12StoreParameter)param;
    }
    else
    {
        bcParam = new PKCS12StoreParameter(((JDKPKCS12StoreParameter)param).getOutputStream(),
            param.getProtectionParameter(), ((JDKPKCS12StoreParameter)param).isUseDEREncoding());
    }

    char[] password;
    ProtectionParameter protParam = param.getProtectionParameter();
    if (protParam == null)
    {
        password = null;
    }
    else if (protParam instanceof KeyStore.PasswordProtection)
    {
        password = ((KeyStore.PasswordProtection)protParam).getPassword();
    }
    else
    {
        throw new IllegalArgumentException(
            "No support for protection parameter of type " + protParam.getClass().getName());
    }

    doStore(bcParam.getOutputStream(), password, bcParam.isForDEREncoding());
}