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); } }
private DirContext obtainContext() throws RealmUnavailableException { try { DirContext ctx = dirContextSupplier.get(); synchronized (this.listenersPendingRegistration) { // we got ctx, this means connection is up // add & remove in case we are ok, take into account network failure. final Iterator<Consumer<Principal>> it = this.listenersPendingRegistration.iterator(); while(it.hasNext()) { registerIdentityChangeListener(ctx, it.next()); it.remove(); } return ctx; } } catch (NamingException e) { throw log.ldapRealmFailedToObtainContext(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()); } }
public Transaction getTransaction() throws SystemException, IllegalStateException { final ExceptionSupplier<ImportResult<?>, SystemException> transactionSupplier = this.transactionSupplier; if (transactionSupplier == null) { return null; } if (txnCmd != 0) { throw new IllegalStateException(); } final ImportResult<?> importResult = transactionSupplier.get(); if (importResult.isNew()) { txnCmd = 1; } else { txnCmd = 2; } return importResult.getTransaction(); }
X509ExtendedKeyManager build() throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, ConfigXMLParseException { final String algorithm = this.algorithm != null ? this.algorithm : KeyManagerFactory.getDefaultAlgorithm(); Provider provider = findProvider(providers, providerName, KeyManagerFactory.class, algorithm); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(xmlLocation, providerName, "KeyManagerFactory", algorithm); } KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(algorithm, provider); keyManagerFactory.init(keyStoreSupplier != null ? keyStoreSupplier.get() : null, null); for (KeyManager keyManager : keyManagerFactory.getKeyManagers()) { if (keyManager instanceof X509ExtendedKeyManager) { return (X509ExtendedKeyManager) keyManager; } } throw ElytronMessages.log.noDefaultKeyManager(); } }
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()); }; }