Class PkiCredentialFactory
java.lang.Object
se.swedenconnect.security.credential.factory.PkiCredentialFactory
Factory class for creating
PkiCredential instances. It can either be used statically, or instantiated with a
resource loader and loaders for credentials or keystores (or a credential bundles object).- Author:
- Martin Lindström
-
Constructor Summary
ConstructorsConstructorDescriptionPkiCredentialFactory(Function<String, PkiCredential> credentialProvider, Function<String, KeyStore> keyStoreProvider, ConfigurationResourceLoader resourceLoader, boolean useCache) Constructor assigning theCredentialBundles, credential and keystore providers.PkiCredentialFactory(CredentialBundles credentialBundles, ConfigurationResourceLoader resourceLoader, boolean useCache) Constructor assigning theCredentialBundlesandConfigurationResourceLoader. -
Method Summary
Modifier and TypeMethodDescriptioncreateCredential(PemCredentialConfiguration configuration) Creates aPkiCredentialbased on aPemCredentialConfiguration.static PkiCredentialcreateCredential(PemCredentialConfiguration configuration, ConfigurationResourceLoader resourceLoader) Creates aPkiCredentialbased on aPemCredentialConfiguration.createCredential(PkiCredentialConfiguration configuration) Creates aPkiCredentialbased on the suppliedPkiCredentialConfiguration.static PkiCredentialcreateCredential(PkiCredentialConfiguration configuration, ConfigurationResourceLoader resourceLoader, Function<String, PkiCredential> credentialProvider, Function<String, KeyStore> keyStoreProvider, Function<String, KeyStoreReloader> keyStoreReloaderProvider) Creates aPkiCredentialbased on the suppliedPkiCredentialConfiguration.createCredential(StoreCredentialConfiguration configuration) Creates aPkiCredentialbased on aStoreCredentialConfiguration.static PkiCredentialcreateCredential(StoreCredentialConfiguration configuration, ConfigurationResourceLoader resourceLoader, Function<String, KeyStore> keyStoreProvider, Function<String, KeyStoreReloader> keyStoreReloaderProvider) Creates aPkiCredentialbased on aStoreCredentialConfiguration.createCredentialCollection(PkiCredentialCollectionConfiguration configuration) Creates aPkiCredentialCollectionbased on the suppliedPkiCredentialCollectionConfiguration.static PkiCredentialCollectioncreateCredentialCollection(PkiCredentialCollectionConfiguration configuration, ConfigurationResourceLoader resourceLoader, Function<String, PkiCredential> credentialProvider, Function<String, KeyStore> keyStoreProvider, Function<String, KeyStoreReloader> keyStoreReloaderProvider) Creates aPkiCredentialCollectionbased on the suppliedPkiCredentialCollectionConfiguration.
-
Constructor Details
-
PkiCredentialFactory
public PkiCredentialFactory(@Nullable Function<String, PkiCredential> credentialProvider, @Nullable Function<String, KeyStore> keyStoreProvider, @Nullable ConfigurationResourceLoader resourceLoader, boolean useCache) Constructor assigning theCredentialBundles, credential and keystore providers.- Parameters:
credentialProvider- for loading credentialskeyStoreProvider- for loading keystoresresourceLoader- for loading resourcesuseCache- whether caches will be used
-
PkiCredentialFactory
public PkiCredentialFactory(@Nullable CredentialBundles credentialBundles, @Nullable ConfigurationResourceLoader resourceLoader, boolean useCache) Constructor assigning theCredentialBundlesandConfigurationResourceLoader.- Parameters:
credentialBundles- the credentials bundles to useresourceLoader- for loading resourcesuseCache- whether caches will be used
-
-
Method Details
-
createCredential
@Nonnull public static PkiCredential createCredential(@Nonnull PkiCredentialConfiguration configuration, @Nullable ConfigurationResourceLoader resourceLoader, @Nullable Function<String, PkiCredential> credentialProvider, @Nullable Function<String, throws IllegalArgumentException, IOException, NoSuchCredentialException, NoSuchKeyStoreException, CertificateException, KeyException, KeyStoreException, NoSuchProviderExceptionKeyStore> keyStoreProvider, @Nullable Function<String, KeyStoreReloader> keyStoreReloaderProvider) Creates aPkiCredentialbased on the suppliedPkiCredentialConfiguration.- Parameters:
configuration- the configurationresourceLoader- loader for readning files, ifnull, aDefaultConfigurationResourceLoaderwill be usedcredentialProvider- if the supplied configuration object contains a credential bundle reference, this provider must be suppliedkeyStoreProvider- if the supplied configuration object contains a key store reference, this provider must be suppliedkeyStoreReloaderProvider- if store references are used, and those key stores are "reloadable", a function that resolves references to aKeyStoreReloadermay be supplied. If not, credentials will not be reloadable- Returns:
- a
PkiCredential - Throws:
IllegalArgumentException- for invalid configuration settingsIOException- if a referenced file can not be readNoSuchCredentialException- if a bundle is used in the supplied configuration, and it does not existNoSuchKeyStoreException- if a reference to a key store can not be foundCertificateException- for certificate decoding errorsKeyException- for key decoding errorsKeyStoreException- for errors unlocking the key storeNoSuchProviderException- if a referenced provider does not exist
-
createCredential
@Nonnull public PkiCredential createCredential(@Nonnull PkiCredentialConfiguration configuration) throws IllegalArgumentException, IOException, NoSuchCredentialException, NoSuchKeyStoreException, CertificateException, KeyException, KeyStoreException, NoSuchProviderException Creates aPkiCredentialbased on the suppliedPkiCredentialConfiguration.- Parameters:
configuration- the configuration- Returns:
- a
PkiCredential - Throws:
IllegalArgumentException- for invalid configuration settingsIOException- if a referenced file can not be readNoSuchCredentialException- if a bundle is used in the supplied configuration, and it does not existNoSuchKeyStoreException- if a reference to a key store can not be foundCertificateException- for certificate decoding errorsKeyException- for key decoding errorsKeyStoreException- for errors unlocking the key storeNoSuchProviderException- if a referenced provider does not exist
-
createCredential
@Nonnull public static PkiCredential createCredential(@Nonnull PemCredentialConfiguration configuration, @Nullable ConfigurationResourceLoader resourceLoader) throws IllegalArgumentException, IOException, CertificateException, KeyException Creates aPkiCredentialbased on aPemCredentialConfiguration.- Parameters:
configuration- the configurationresourceLoader- loader for readning files, ifnull, aDefaultConfigurationResourceLoaderwill be used- Returns:
- a
PkiCredential - Throws:
IllegalArgumentException- for invalid configuration settingsIOException- if a referenced file can not be readCertificateException- for certificate decoding errorsKeyException- for key decoding errors
-
createCredential
@Nonnull public PkiCredential createCredential(@Nonnull PemCredentialConfiguration configuration) throws IllegalArgumentException, IOException, CertificateException, KeyException Creates aPkiCredentialbased on aPemCredentialConfiguration.- Parameters:
configuration- the configuration- Returns:
- a
PkiCredential - Throws:
IllegalArgumentException- for invalid configuration settingsIOException- if a referenced file can not be readCertificateException- for certificate decoding errorsKeyException- for key decoding errors
-
createCredential
@Nonnull public static PkiCredential createCredential(@Nonnull StoreCredentialConfiguration configuration, @Nullable ConfigurationResourceLoader resourceLoader, @Nullable Function<String, KeyStore> keyStoreProvider, @Nullable Function<String, throws IllegalArgumentException, IOException, NoSuchKeyStoreException, KeyStoreException, NoSuchProviderException, CertificateExceptionKeyStoreReloader> keyStoreReloaderProvider) Creates aPkiCredentialbased on aStoreCredentialConfiguration.- Parameters:
configuration- the configurationresourceLoader- loader for readning files, ifnull, aDefaultConfigurationResourceLoaderwill be usedkeyStoreProvider- if store references are used, a function that resolves references to key stores must be suppliedkeyStoreReloaderProvider- if store references are used, and those key stores are "reloadable", a function that resolves references to aKeyStoreReloadermay be supplied. If not, it will be assumed that the key store may be reloaded using the key password (which then must be the same as the store password)- Returns:
- a
PkiCredential - Throws:
IllegalArgumentException- for invalid configuration settingsIOException- if a referenced file can not be readNoSuchKeyStoreException- if a reference to a key store can not be foundKeyStoreException- for errors unlocking the key storeNoSuchProviderException- if a referenced provider does not existCertificateException- for certificate decoding errors
-
createCredential
@Nonnull public PkiCredential createCredential(@Nonnull StoreCredentialConfiguration configuration) throws IllegalArgumentException, IOException, NoSuchKeyStoreException, KeyStoreException, NoSuchProviderException, CertificateException Creates aPkiCredentialbased on aStoreCredentialConfiguration.- Parameters:
configuration- the configuration- Returns:
- a
PkiCredential - Throws:
IllegalArgumentException- for invalid configuration settingsIOException- if a referenced file can not be readNoSuchKeyStoreException- if a reference to a key store can not be foundKeyStoreException- for errors unlocking the key storeNoSuchProviderException- if a referenced provider does not existCertificateException- for certificate decoding errors
-
createCredentialCollection
@Nonnull public static PkiCredentialCollection createCredentialCollection(@Nonnull PkiCredentialCollectionConfiguration configuration, @Nullable ConfigurationResourceLoader resourceLoader, @Nullable Function<String, PkiCredential> credentialProvider, @Nullable Function<String, throws IllegalArgumentException, IOException, NoSuchCredentialException, NoSuchKeyStoreException, CertificateException, KeyException, KeyStoreException, NoSuchProviderExceptionKeyStore> keyStoreProvider, @Nullable Function<String, KeyStoreReloader> keyStoreReloaderProvider) Creates aPkiCredentialCollectionbased on the suppliedPkiCredentialCollectionConfiguration.- Parameters:
configuration- the configurationresourceLoader- loader for readning files, ifnull, aDefaultConfigurationResourceLoaderwill be usedcredentialProvider- if the supplied configuration object contains a credential bundle reference, this provider must be suppliedkeyStoreProvider- if the supplied configuration object contains a key store reference, this provider must be suppliedkeyStoreReloaderProvider- if store references are used, and those key stores are "reloadable", a function that resolves references to aKeyStoreReloadermay be supplied. If not, credentials will not be reloadable- Returns:
- a
PkiCredentialCollection - Throws:
IllegalArgumentException- for invalid configuration settingsIOException- if a referenced file can not be readNoSuchCredentialException- if a bundle is used in the supplied configuration, and it does not existNoSuchKeyStoreException- if a reference to a key store can not be foundCertificateException- for certificate decoding errorsKeyException- for key decoding errorsKeyStoreException- for errors unlocking the key storeNoSuchProviderException- if a referenced provider does not exist
-
createCredentialCollection
@Nonnull public PkiCredentialCollection createCredentialCollection(@Nonnull PkiCredentialCollectionConfiguration configuration) throws IllegalArgumentException, IOException, NoSuchCredentialException, NoSuchKeyStoreException, CertificateException, KeyException, KeyStoreException, NoSuchProviderException Creates aPkiCredentialCollectionbased on the suppliedPkiCredentialCollectionConfiguration.- Parameters:
configuration- the configuration- Returns:
- a
PkiCredentialCollection - Throws:
IllegalArgumentException- for invalid configuration settingsIOException- if a referenced file can not be readNoSuchCredentialException- if a bundle is used in the supplied configuration, and it does not existNoSuchKeyStoreException- if a reference to a key store can not be foundCertificateException- for certificate decoding errorsKeyException- for key decoding errorsKeyStoreException- for errors unlocking the key storeNoSuchProviderException- if a referenced provider does not exist
-