public Object apply(final ExceptionSupplier<Object, E> supplier) throws E { return supplier.get(); } }
InputStream createStream() throws IOException { return resourceSupplier.get(); } }
@Override public CredentialSource get() { try { return this.supplier.get(); } catch (Exception e) { throw new IllegalArgumentException(e); } }
public KeyStore get() throws ConfigXMLParseException { try { KeyStore keyStore = delegateFactory.get(); try (InputStream fis = createStream()) { keyStore.load(fis, passwordFactory == null ? null : passwordFactory.get()); } return keyStore; } catch (GeneralSecurityException | IOException e) { throw xmlLog.xmlFailedToLoadKeyStoreData(location, e); } }
public KeyStore get() throws ConfigXMLParseException { return new WrappingPasswordKeyStore(delegateFactory.get()); } }
@Override public <R, E extends Exception> Optional<R> execute(ExceptionSupplier<R, E> executeTask) throws E { long stamp = this.lock.tryReadLock(); if (stamp != 0L) { try { return Optional.of(executeTask.get()); } finally { this.lock.unlock(stamp); } } return Optional.empty(); }
private void createConnectionDefinition() throws IllegalStateException { ExceptionSupplier<ModifiableConnDef, Exception> connDefSupplier = connectionDefinitionSupplier.getValue(); try { if (connDefSupplier != null) value.inject(connDefSupplier.get()); } catch (Exception e) { throw new IllegalStateException(e); } }
public Transaction getTransaction() throws SystemException, IllegalStateException { if (finalTransactionSupplier == null) { return null; } if (txnCmd != 0) { throw new IllegalStateException(); } final ImportResult<?> importResult = finalTransactionSupplier.get(); if (importResult.isNew()) { txnCmd = 1; } else { txnCmd = 2; } return importResult.getTransaction(); }
default ExceptionSupplier<R, E> compose(ExceptionSupplier<? extends T, ? extends E> before) { Assert.checkNotNullParam("before", before); return () -> apply(before.get()); } }
private DirContext obtainDirContext() { try { DirContext context = dirContextSupplier.get(); binaryAttributesBackup = context.getEnvironment().get(ENV_BINARY_ATTRIBUTES); context.addToEnvironment(ENV_BINARY_ATTRIBUTES, String.join(" ", certificateAttribute, certificateChainAttribute, keyAttribute)); return context; } catch (NamingException e) { throw log.failedToObtainDirContext(e); } }
default <R> ExceptionSupplier<R, E> andThen(ExceptionFunction<? super T, ? extends R, ? extends E> after) { Assert.checkNotNullParam("after", after); return () -> after.apply(get()); } }
default ExceptionRunnable<E> compose(ExceptionSupplier<? extends T, ? extends E> before) { Assert.checkNotNullParam("before", before); return () -> accept(before.get()); } }
default ExceptionRunnable<E> andThen(ExceptionConsumer<? super T, ? extends E> after) { Assert.checkNotNullParam("after", after); return () -> after.accept(get()); }
public final String getPassword() { if (credentialSourceSupplier != null) { try { return new String( credentialSourceSupplier.get().getCredential(PasswordCredential.class).getPassword(ClearPassword.class).getPassword()); } catch (Exception e) { throw ConnectorLogger.DEPLOYMENT_CONNECTOR_LOGGER.invalidCredentialSourceSupplier(e); } } return this.password; }
static ExceptionUnaryOperator<RuleNode<SecurityFactory<SSLContext>>, ConfigXMLParseException> parseSslContextRuleType(final ConfigurationXMLStreamReader reader, final Version xmlVersion, final Map<String, ExceptionSupplier<SecurityFactory<SSLContext>, ConfigXMLParseException>> sslContextsMap) throws ConfigXMLParseException { final String attributeName = "use-ssl-context"; final String name = requireSingleAttribute(reader, attributeName); final XMLLocation location = reader.getLocation(); final MatchRule rule = parseAbstractMatchRuleType(reader, xmlVersion); return next -> { final ExceptionSupplier<SecurityFactory<SSLContext>, ConfigXMLParseException> factory = sslContextsMap.get(name); if (factory == null) throw xmlLog.xmlUnknownSslContextSpecified(location, name); return new RuleNode<>(next, rule, factory.get()); }; }
static ExceptionUnaryOperator<RuleNode<AuthenticationConfiguration>, ConfigXMLParseException> parseAuthenticationRuleType(final ConfigurationXMLStreamReader reader, final Version xmlVersion, final Map<String, ExceptionSupplier<AuthenticationConfiguration, ConfigXMLParseException>> authenticationConfigurationsMap) throws ConfigXMLParseException { final String attributeName = "use-configuration"; final String name = requireSingleAttribute(reader, attributeName); final XMLLocation location = reader.getLocation(); final MatchRule rule = parseAbstractMatchRuleType(reader, xmlVersion); return next -> { final ExceptionSupplier<AuthenticationConfiguration, ConfigXMLParseException> factory = authenticationConfigurationsMap.get(name); if (factory == null) throw xmlLog.xmlUnknownAuthenticationConfigurationSpecified(location, name); return new RuleNode<>(next, rule, factory.get()); }; }
public X509CertificateChainPrivateCredential get() throws ConfigXMLParseException { final KeyStore.Entry entry = entrySupplier.get(); if (entry == null) { throw xmlLog.keyStoreEntryMissing(location, "unknown"); } if (entry instanceof KeyStore.PrivateKeyEntry) { final KeyStore.PrivateKeyEntry privateKeyEntry = (KeyStore.PrivateKeyEntry) entry; final X509Certificate[] certificateChain = X500.asX509CertificateArray(privateKeyEntry.getCertificateChain()); return new X509CertificateChainPrivateCredential(privateKeyEntry.getPrivateKey(), certificateChain); } throw xmlLog.xmlInvalidKeyStoreEntryType(location, "unknown", KeyStore.PrivateKeyEntry.class, entry.getClass()); } }
private static <A> A requireSingleAttribute(final ConfigurationXMLStreamReader reader, final String attributeName, ExceptionSupplier<A, ConfigXMLParseException> attributeFunction) throws ConfigXMLParseException { final int attributeCount = reader.getAttributeCount(); if (attributeCount < 1) { throw reader.missingRequiredAttribute("", attributeName); } checkAttributeNamespace(reader, 0); if (! reader.getAttributeLocalName(0).equals(attributeName)) { throw reader.unexpectedAttribute(0); } if (attributeCount > 1) { throw reader.unexpectedAttribute(1); } return attributeFunction.get(); }