/** * Load a key store from a resource. * * @param aKeyStoreType * Type of key store. May not be <code>null</code>. * @param sKeyStorePath * The path pointing to the key store. May not be <code>null</code>. * @param sKeyStorePassword * The key store password. May be <code>null</code> to indicate that no * password is required. * @return The Java key-store object. * @throws GeneralSecurityException * In case of a key store error * @throws IOException * In case key store loading fails * @throws IllegalArgumentException * If the key store path is invalid */ @Nonnull public static KeyStore loadKeyStoreDirect (@Nonnull final IKeyStoreType aKeyStoreType, @Nonnull final String sKeyStorePath, @Nullable final String sKeyStorePassword) throws GeneralSecurityException, IOException { return loadKeyStoreDirect (aKeyStoreType, sKeyStorePath, sKeyStorePassword == null ? null : sKeyStorePassword.toCharArray ()); }
void load (@Nonnull InputStream aIS, @Nonnull char [] aPassword) throws OpenAS2Exception;
/** * Load the specified secret key entry from the provided key store. * * @param aKeyStore * The key store to load the key from. May not be <code>null</code>. * @param sKeyStorePath * Key store path. For nice error messages only. May be * <code>null</code>. * @param sKeyStoreKeyAlias * The alias to be resolved in the key store. Must be non- * <code>null</code> to succeed. * @param aKeyStoreKeyPassword * The key password for the key store. Must be non-<code>null</code> to * succeed. * @return The key loading result. Never <code>null</code>. */ @Nonnull public static LoadedKey <KeyStore.SecretKeyEntry> loadSecretKey (@Nonnull final KeyStore aKeyStore, @Nonnull final String sKeyStorePath, @Nullable final String sKeyStoreKeyAlias, @Nullable final char [] aKeyStoreKeyPassword) { return _loadKey (aKeyStore, sKeyStorePath, sKeyStoreKeyAlias, aKeyStoreKeyPassword, KeyStore.SecretKeyEntry.class); }
final LoadedKeyStore aLKS = KeyStoreHelper.loadKeyStore (aKeyStoreType, sKeyStorePath, sKeyStorePassword); if (aLKS.isFailure ()) throw new IllegalStateException (aLKS.getErrorText (TextHelper.EN)); final LoadedKey <KeyStore.PrivateKeyEntry> aLK = KeyStoreHelper.loadPrivateKey (aLKS.getKeyStore (), sKeyStorePath, sKeyAlias,
final LoadedKeyStore aLoadedKeyStore = KeyStoreHelper.loadKeyStore (PDClientConfiguration.getKeyStoreType (), PDClientConfiguration.getKeyStorePath (), PDClientConfiguration.getKeyStorePassword ()); final LoadedKeyStore aLoadedTrustStore = KeyStoreHelper.loadKeyStore (PDClientConfiguration.getTrustStoreType (), PDClientConfiguration.getTrustStorePath (), PDClientConfiguration.getTrustStorePassword ());
ValueEnforcer.notNull (sAliasToCopy, "AliasToCopy"); final KeyStore aKeyStore = getSimiliarKeyStore (aBaseKeyStore);
final LoadedKeyStore aLoadedKeyStore = KeyStoreHelper.loadKeyStore (SMPServerConfiguration.getKeyStoreType (), SMPServerConfiguration.getKeyStorePath (), SMPServerConfiguration.getKeyStorePassword ()); final LoadedKey <KeyStore.PrivateKeyEntry> aLoadedKey = KeyStoreHelper.loadPrivateKey (m_aKeyStore, SMPServerConfiguration.getKeyStorePath (), SMPServerConfiguration.getKeyStoreKeyAlias (),
private void _loadCertificates () { // Reset every time _setCertValid (false); _loadError (null, null); m_aTrustStore = null; // Load the trust store final LoadedKeyStore aTrustStoreLoading = KeyStoreHelper.loadKeyStore (SMPServerConfiguration.getTrustStoreType (), SMPServerConfiguration.getTrustStorePath (), SMPServerConfiguration.getTrustStorePassword ()); if (aTrustStoreLoading.isFailure ()) { _loadError (aTrustStoreLoading.getError (), PeppolKeyStoreHelper.getLoadError (aTrustStoreLoading)); throw new InitializationException (s_sInitError); } m_aTrustStore = aTrustStoreLoading.getKeyStore (); LOGGER.info ("SMPTrustManager successfully initialized with truststore '" + SMPServerConfiguration.getTrustStorePath () + "'"); _setCertValid (true); }
final LoadedKeyStore aLoadedKeyStore = KeyStoreHelper.loadKeyStore (SMPServerConfiguration.getKeyStoreType (), SMPServerConfiguration.getKeyStorePath (), SMPServerConfiguration.getKeyStorePassword ()); final LoadedKey <KeyStore.PrivateKeyEntry> aLoadedKey = KeyStoreHelper.loadPrivateKey (m_aKeyStore, SMPServerConfiguration.getKeyStorePath (), SMPServerConfiguration.getKeyStoreKeyAlias (),
private void _loadCertificates () { // Reset every time _setCertValid (false); _loadError (null, null); m_aTrustStore = null; // Load the trust store final LoadedKeyStore aTrustStoreLoading = KeyStoreHelper.loadKeyStore (SMPServerConfiguration.getTrustStoreType (), SMPServerConfiguration.getTrustStorePath (), SMPServerConfiguration.getTrustStorePassword ()); if (aTrustStoreLoading.isFailure ()) { _loadError (aTrustStoreLoading.getError (), PeppolKeyStoreHelper.getLoadError (aTrustStoreLoading)); throw new InitializationException (s_sInitError); } m_aTrustStore = aTrustStoreLoading.getKeyStore (); LOGGER.info ("SMPTrustManager successfully initialized with truststore '" + SMPServerConfiguration.getTrustStorePath () + "'"); _setCertValid (true); }
aKeyStore = loadKeyStoreDirect (aKeyStoreType, sKeyStorePath, sKeyStorePassword);
final InputStream aIS = getResourceProvider ().getInputStream (sKeyStorePath); if (aIS == null) throw new IllegalArgumentException ("Failed to open key store '" + sKeyStorePath + "'");
/** * Load the specified private key entry from the provided key store. * * @param aKeyStore * The key store to load the key from. May not be <code>null</code>. * @param sKeyStorePath * Key store path. For nice error messages only. May be * <code>null</code>. * @param sKeyStoreKeyAlias * The alias to be resolved in the key store. Must be non- * <code>null</code> to succeed. * @param aKeyStoreKeyPassword * The key password for the key store. Must be non-<code>null</code> to * succeed. * @return The key loading result. Never <code>null</code>. */ @Nonnull public static LoadedKey <KeyStore.PrivateKeyEntry> loadPrivateKey (@Nonnull final KeyStore aKeyStore, @Nonnull final String sKeyStorePath, @Nullable final String sKeyStoreKeyAlias, @Nullable final char [] aKeyStoreKeyPassword) { return _loadKey (aKeyStore, sKeyStorePath, sKeyStoreKeyAlias, aKeyStoreKeyPassword, KeyStore.PrivateKeyEntry.class); }
final String sKeyStorePath = PDClientConfiguration.getKeyStorePath (); final LoadedKeyStore aKeyStoreLR = KeyStoreHelper.loadKeyStore (eKeyStoreType, sKeyStorePath, PDClientConfiguration.getKeyStorePassword ()); final LoadedKey <KeyStore.PrivateKeyEntry> aKeyLoading = KeyStoreHelper.loadPrivateKey (aKeyStore, sKeyStorePath, sKeyStoreAlias,
new HCDiv ().addChild ("A connection to the " + sDirectoryName + " server cannot be establised!")); final LoadedKeyStore aLoadedKeyStore = KeyStoreHelper.loadKeyStore (PDClientConfiguration.getKeyStoreType (), PDClientConfiguration.getKeyStorePath (), PDClientConfiguration.getKeyStorePassword ());
m_aKeyStore = KeyStoreHelper.loadKeyStoreDirect (m_eTruststoreType, m_sTruststorePath, m_sTrustStorePassword);
/** * Load the specified private key entry from the provided key store. * * @param aKeyStore * The key store to load the key from. May not be <code>null</code>. * @param sKeyStorePath * Key store path. For nice error messages only. May be * <code>null</code>. * @param sKeyStoreKeyAlias * The alias to be resolved in the key store. Must be non- * <code>null</code> to succeed. * @param aKeyStoreKeyPassword * The key password for the key store. Must be non-<code>null</code> to * succeed. * @return The key loading result. Never <code>null</code>. */ @Nonnull public static LoadedKey <KeyStore.TrustedCertificateEntry> loadTrustedCertificateKey (@Nonnull final KeyStore aKeyStore, @Nonnull final String sKeyStorePath, @Nullable final String sKeyStoreKeyAlias, @Nullable final char [] aKeyStoreKeyPassword) { return _loadKey (aKeyStore, sKeyStorePath, sKeyStoreKeyAlias, aKeyStoreKeyPassword, KeyStore.TrustedCertificateEntry.class); } }
final String sKeyStorePath = PDClientConfiguration.getKeyStorePath (); final LoadedKeyStore aKeyStoreLR = KeyStoreHelper.loadKeyStore (eKeyStoreType, sKeyStorePath, PDClientConfiguration.getKeyStorePassword ()); final LoadedKey <KeyStore.PrivateKeyEntry> aKeyLoading = KeyStoreHelper.loadPrivateKey (aKeyStore, sKeyStorePath, sKeyStoreAlias,
new HCDiv ().addChild ("A connection to the " + sDirectoryName + " server cannot be establised!")); final LoadedKeyStore aLoadedKeyStore = KeyStoreHelper.loadKeyStore (PDClientConfiguration.getKeyStoreType (), PDClientConfiguration.getKeyStorePath (), PDClientConfiguration.getKeyStorePassword ());
try final KeyStore aKS = KeyStoreHelper.loadKeyStoreDirect (aTS.getType (), aTS.getPath (), aTS.getPassword ()); aCert = (X509Certificate) aKS.getCertificate (aTS.getAlias ());