/** * Wrap an existing initialised {@link KeyStore} with an unmodifiable wrapper. * * Note: References are held to the underlying {@link KeyStore} can still be modified and changes will still be visible in * the representation returned here. * * @param toWrap the {@link KeyStore} to wrap. * @return the unmodifiable wrapper around the {@link KeyStore} * @throws NoSuchAlgorithmException * @throws CertificateException * @throws IOException * @throws IllegalArgumentException if the {@link KeyStore} being wrapped is {@code null} */ public static KeyStore unmodifiableKeyStore(final KeyStore toWrap) throws NoSuchAlgorithmException, CertificateException, IOException { Assert.checkNotNullParam("toWrap", toWrap); KeyStore keyStore = new UnmodifiableKeyStore(new UnmodifiableKeyStoreSpi(toWrap), toWrap.getProvider(), toWrap.getType()); keyStore.load(null, null); return keyStore; } }
@Override public void start(StartContext startContext) throws StartException { try { KeyStore keyStore = keyStoreInjector.getValue(); AliasFilter filter = AliasFilter.fromString(aliasFilter); KeyStore unmodifiable = UnmodifiableKeyStore.unmodifiableKeyStore(keyStore); KeyStore modifiable = keyStore; ROOT_LOGGER.tracef( "starting: aliasFilter = %s filter = %s unmodifiable = %s modifiable = %s", aliasFilter, filter, unmodifiable, modifiable); filteringKeyStore = FilteringKeyStore.filteringKeyStore(unmodifiable, filter); if (modifiableFilteringKeyStore == null) { modifiableFilteringKeyStore = FilteringKeyStore.filteringKeyStore(modifiable, filter); } } catch (Exception e) { throw new StartException(e); } }
KeyStore intermediate = aliasFilter != null ? FilteringKeyStore.filteringKeyStore(keyStore, AliasFilter.fromString(aliasFilter)) : keyStore; this.trackingKeyStore = ModifyTrackingKeyStore.modifyTrackingKeyStore(intermediate); this.unmodifiableKeyStore = UnmodifiableKeyStore.unmodifiableKeyStore(intermediate); } catch (Exception e) { throw ROOT_LOGGER.unableToStartService(e);
/** * Wrap an existing initialised {@link KeyStore} with an unmodifiable wrapper. * * Note: References are held to the underlying {@link KeyStore} can still be modified and changes will still be visible in * the representation returned here. * * @param toWrap the {@link KeyStore} to wrap. * @return the unmodifiable wrapper around the {@link KeyStore} * @throws NoSuchAlgorithmException * @throws CertificateException * @throws IOException * @throws IllegalArgumentException if the {@link KeyStore} being wrapped is {@code null} */ public static KeyStore unmodifiableKeyStore(final KeyStore toWrap) throws NoSuchAlgorithmException, CertificateException, IOException { Assert.checkNotNullParam("toWrap", toWrap); KeyStore keyStore = new UnmodifiableKeyStore(new UnmodifiableKeyStoreSpi(toWrap), toWrap.getProvider(), toWrap.getType()); keyStore.load(null, null); return keyStore; } }
@Override public void start(StartContext startContext) throws StartException { try { LdapKeyStore.Builder builder = LdapKeyStore.builder() .setDirContextSupplier(dirContextSupplierInjector.getValue()) .setSearchPath(searchPath); if (filterAlias != null) builder.setFilterAlias(filterAlias); if (filterCertificate != null) builder.setFilterCertificate(filterCertificate); if (filterIterate != null) builder.setFilterIterate(filterIterate); if (createPath != null) builder.setCreatePath(createPath); if (createRdn != null) builder.setCreateRdn(createRdn); if (createAttributes != null) builder.setCreateAttributes(createAttributes); if (aliasAttribute != null) builder.setAliasAttribute(aliasAttribute); if (certificateAttribute != null) builder.setCertificateAttribute(certificateAttribute); if (certificateType != null) builder.setCertificateType(certificateType); if (certificateChainAttribute != null) builder.setCertificateChainAttribute(certificateChainAttribute); if (certificateChainEncoding != null) builder.setCertificateChainEncoding(certificateChainEncoding); if (keyAttribute != null) builder.setKeyAttribute(keyAttribute); if (keyType != null) builder.setKeyType(keyType); KeyStore keyStore = builder.build(); keyStore.load(null); // initialize this.modifiableKeyStore = keyStore; this.unmodifiableKeyStore = UnmodifiableKeyStore.unmodifiableKeyStore(keyStore); } catch (GeneralSecurityException | IOException e) { throw ROOT_LOGGER.unableToStartService(e); } }
/** * Wrap an existing initialised {@link KeyStore} with an unmodifiable wrapper. * * Note: References are held to the underlying {@link KeyStore} can still be modified and changes will still be visible in * the representation returned here. * * @param toWrap the {@link KeyStore} to wrap. * @return the unmodifiable wrapper around the {@link KeyStore} * @throws NoSuchAlgorithmException * @throws CertificateException * @throws IOException * @throws IllegalArgumentException if the {@link KeyStore} being wrapped is {@code null} */ public static KeyStore unmodifiableKeyStore(final KeyStore toWrap) throws NoSuchAlgorithmException, CertificateException, IOException { Assert.checkNotNullParam("toWrap", toWrap); KeyStore keyStore = new UnmodifiableKeyStore(new UnmodifiableKeyStoreSpi(toWrap), toWrap.getProvider(), toWrap.getType()); keyStore.load(null, null); return keyStore; } }
/** * Wrap an existing initialised {@link KeyStore} with an unmodifiable wrapper. * * Note: References are held to the underlying {@link KeyStore} can still be modified and changes will still be visible in * the representation returned here. * * @param toWrap the {@link KeyStore} to wrap. * @return the unmodifiable wrapper around the {@link KeyStore} * @throws NoSuchAlgorithmException * @throws CertificateException * @throws IOException * @throws IllegalArgumentException if the {@link KeyStore} being wrapped is {@code null} */ public static KeyStore unmodifiableKeyStore(final KeyStore toWrap) throws NoSuchAlgorithmException, CertificateException, IOException { Assert.checkNotNullParam("toWrap", toWrap); KeyStore keyStore = new UnmodifiableKeyStore(new UnmodifiableKeyStoreSpi(toWrap), toWrap.getProvider(), toWrap.getType()); keyStore.load(null, null); return keyStore; } }