Cached version of {@link ProxiedFileSystemUtils#createProxiedFileSystemUsingToken(String, Token, URI, Configuration)}.
329678
@Builder(builderClassName = "ProxiedFileSystemFromToken", builderMethodName = "fromToken")
  private static FileSystem getProxiedFileSystemUsingToken(@NonNull String userNameToProxyAs, Token<?> userNameToken,
      URI fsURI, Configuration conf, FileSystem referenceFS) throws IOException, ExecutionException {
    Preconditions.checkNotNull(userNameToProxyAs, "Must provide a user name to proxy as.");
    Preconditions.checkNotNull(userNameToken, "Must provide token for user to proxy.");
    URI actualURI = resolveUri(fsURI, conf, referenceFS);
    Configuration actualConfiguration = resolveConfiguration(conf, referenceFS);

    return USER_NAME_TO_FILESYSTEM_CACHE.get(getFileSystemKey(actualURI, userNameToProxyAs, referenceFS),
        new CreateProxiedFileSystemFromToken(userNameToProxyAs, userNameToken, actualURI, actualConfiguration,
            referenceFS));
  }
1293283
public void addProxy(String protocol, String host, int port, String username, String password) {
    Proxy proxy = new Proxy(protocol, host, port, username, password);
    proxies.add(proxy);
  }
1147907
@Override
    public Token createToken(Map<String, Object> tokenData) throws TokenCreationFailedException {
        TokenFactory tokenFactory = ltpaConfig.getTokenFactory();
        return tokenFactory.createToken(tokenData);
    }
939434
protected synchronized void cacheToken(final Token token) {

		log.debug("OAuthTokenManager.cacheToken");

		// Parse token expires in seconds.
		int tokenExpiresInSecs;
		try {
			tokenExpiresInSecs = Integer.parseInt(token.getExpires_in());
		} catch (NumberFormatException exception) {
			tokenExpiresInSecs = 0;
		}

		// Parse token expiration time
		long tokenExpirationTime;
		try {
			tokenExpirationTime = Long.parseLong(token.getExpiration());
		} catch (NumberFormatException exception) {
			tokenExpirationTime = 0;
		}

		// Calculate token refresh time based on lifespan percentage offset.
		long refreshBeforeExpirySecs = (long) (tokenExpiresInSecs * this.iamRefreshOffset);
		long tokenRefreshTime = tokenExpirationTime - refreshBeforeExpirySecs;

		token.setRefreshTime(tokenRefreshTime);
		token.setExpirationTime(tokenExpirationTime);

		setTokenCache(token);
	}
265947
public static ClassLoader resolveClassLoaderForBeanProxy(String contextId, Class<?> proxiedType, TypeInfo typeInfo, ProxyServices proxyServices) {
        Class<?> superClass = typeInfo.getSuperClass();
        if (superClass.getName().startsWith(JAVA)) {
            ClassLoader cl = proxyServices.getClassLoader(proxiedType);
            if (cl == null) {
                cl = Thread.currentThread().getContextClassLoader();
            }
            return cl;
        }
        return Container.instance(contextId).services().get(ProxyServices.class).getClassLoader(superClass);
    }
1173175
public synchronized AsynchConsumerProxyQueue createOrderedProxyQueue(OrderingContext context)
      throws SIResourceException, SIIncorrectCallException
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createOrderedProxyQueue", context);
      
      short id = nextId();
         
      AsynchConsumerProxyQueue proxyQueue = createOrderedProxyQueue(context, id, (short) 0); // D249096
      
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createOrderedProxyQueue", proxyQueue);
      return proxyQueue;
   }
531234
private static FaxClientSpiProxy createFaxClientSpiProxy(FaxClientSpi faxClientSpi)
    {
        //create fax client SPI interceptors
        FaxClientSpiInterceptor[] interceptors=FaxClientSpiFactory.createFaxClientSpiInterceptors(faxClientSpi);
        
        //get class name
        String className=faxClientSpi.getConfigurationValue(FaxClientSpiFactory.SPI_PROXY_CLASS_NAME_PROPERTY_KEY);
        if(className==null)
        {
            className=FaxClientSpiProxyImpl.class.getName();
        }

        //create new instance
        FaxClientSpiProxy faxClientSpiProxy=(FaxClientSpiProxy)ReflectionHelper.createInstance(className);
        
        //initialize
        faxClientSpiProxy.initialize(faxClientSpi,interceptors);
        
        return faxClientSpiProxy;
    }
81217
@Override
	public void createCacheFileAsync(final String fileNamePrefix, final InputStream is,
			final CreateCompletionCallback callback) {

		_aggregator.getExecutors().getFileCreateExecutor().submit(new Runnable() {
			public void run() {
				File file = null;
				try {
					file = File.createTempFile(fileNamePrefix, ".cache", _directory); //$NON-NLS-1$
					OutputStream os = new FileOutputStream(file);
					CopyUtil.copy(is, os);
					if (callback != null) {
						callback.completed(file.getName(), null);
					}
				} catch (IOException e) {
					if (log.isLoggable(Level.WARNING))
						log.log(Level.WARNING, MessageFormat.format(
								Messages.CacheManagerImpl_4, new Object[]{file.getPath()}), e);
					if (callback != null) {
						callback.completed(file.getName(), e);
					}
				}
			}
		});
	}
1286414
public static Proxy asProxy(org.apache.maven.settings.Proxy proxy) {
        final Authentication authentication;
        if (proxy.getUsername() != null || proxy.getPassword() != null) {
            authentication = new AuthenticationBuilder().addUsername(proxy.getUsername())
                    .addPassword(proxy.getPassword()).build();
        } else {
            authentication = null;
        }
        return new Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authentication);
    }
858039
protected GitHubClient createClient(String host, String userName,
			String password, String oauth2Token, String serverId,
			Settings settings, MavenSession session)
			throws MojoExecutionException {
		GitHubClient client;
		if (!StringUtils.isEmpty(host)) {
			if (isDebug())
				debug("Using custom host: " + host);
			client = createClient(host);
		} else
			client = createClient();

		{
			Proxy proxy = getProxy( settings, serverId, host );
			if ( null != proxy )
			{
				try
				{
					SettingsDecrypter settingsDecrypter = container.lookup( SettingsDecrypter.class );
					SettingsDecryptionResult result =
						settingsDecrypter.decrypt( new DefaultSettingsDecryptionRequest( proxy ) );
					proxy = result.getProxy();
				}
				catch ( ComponentLookupException cle )
				{
					throw new MojoExecutionException( "Unable to lookup SettingsDecrypter: " + cle.getMessage(), cle );
				}
			}

			if ( null != proxy ){
				java.net.Proxy javaProxy = new java.net.Proxy(java.net.Proxy.Type.HTTP, new InetSocketAddress( proxy.getHost(), proxy.getPort()));
				if (isDebug())
					debug(MessageFormat.format("Found Proxy {0}:{1}",
							proxy.getHost(), proxy.getPort()));

				if ( client instanceof GitHubClientEgit )
				{
					GitHubClientEgit clientEgit = (GitHubClientEgit)client;
					if (isDebug())
						debug(MessageFormat.format("Use Proxy for Egit {0}",
								javaProxy));
					clientEgit.setProxy( javaProxy );
				}
			}
		}

		if (configureUsernamePassword(client, userName, password)
				|| configureOAuth2Token(client, oauth2Token)
				|| configureServerCredentials(client, serverId, settings,
						session))
			return client;
		else
			throw new MojoExecutionException(
					"No authentication credentials configured");
	}
911507
@SuppressWarnings({ "unchecked", "rawtypes" })
    public <T> T createProxy(ClassLoader classLoader) {

        LettuceAssert.notNull(classLoader, "ClassLoader must not be null");

        Class<?>[] interfaces = this.interfaces.toArray(new Class[0]);

        return (T) Proxy.newProxyInstance(classLoader, interfaces, new InterceptorChainInvocationHandler(interceptors));
    }
310406
public SecurityTokenServiceClient buildClientForRelyingPartyTokenResponses(final SecurityToken securityToken,
                                                                               final WSFederationRegisteredService service) {
        val cxfBus = BusFactory.getDefaultBus();
        val sts = new SecurityTokenServiceClient(cxfBus);
        sts.setAddressingNamespace(StringUtils.defaultIfBlank(service.getAddressingNamespace(), WSFederationConstants.HTTP_WWW_W3_ORG_2005_08_ADDRESSING));
        sts.setWsdlLocation(prepareWsdlLocation(service));
        val namespace = StringUtils.defaultIfBlank(service.getNamespace(), WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512);
        sts.setServiceQName(new QName(namespace, service.getWsdlService()));
        sts.setEndpointQName(new QName(namespace, service.getWsdlEndpoint()));
        sts.setEnableAppliesTo(StringUtils.isNotBlank(service.getAppliesTo()));
        sts.setOnBehalfOf(securityToken.getToken());
        sts.setKeyType(WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512_BEARER);
        sts.setTokenType(StringUtils.defaultIfBlank(service.getTokenType(), WSConstants.WSS_SAML2_TOKEN_TYPE));

        if (StringUtils.isNotBlank(service.getPolicyNamespace())) {
            sts.setWspNamespace(service.getPolicyNamespace());
        }

        return sts;
    }
708545
public Node createProxyNode(Object sourceNodeId, Object targetNodeId, GraphDatabaseService graphDb,
            EntityMetadata sourceEntityMetadata, EntityMetadata targetEntityMetadata)
    {

        String sourceNodeIdColumnName = ((AbstractAttribute) sourceEntityMetadata.getIdAttribute()).getJPAColumnName();
        String targetNodeIdColumnName = ((AbstractAttribute) targetEntityMetadata.getIdAttribute()).getJPAColumnName();

        Node node = graphDb.createNode();
        node.setProperty(PROXY_NODE_TYPE_KEY, PROXY_NODE_VALUE);
        node.setProperty(sourceNodeIdColumnName, sourceNodeId);
        node.setProperty(targetNodeIdColumnName, targetNodeId);
        return node;
    }
1007972
public URI proxy(URI uri) {
        Proxy conf;
        String scheme;

        scheme = uri.getScheme();
        conf = proxies.get(scheme);
        if (conf == null || conf.excludes(uri)) {
            return null;
        }
        try {
            return new URI(scheme, null, conf.host, conf.port, null, null, null);
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException(e);
        }
    }
567822
@Nonnull
    private Proxy getProxy(String apiUrl) {
        Jenkins jenkins = GitHubWebHook.getJenkinsInstance();

        if (jenkins.proxy == null) {
            return Proxy.NO_PROXY;
        } else {
            try {
                return jenkins.proxy.createProxy(new URL(apiUrl).getHost());
            } catch (MalformedURLException e) {
                return jenkins.proxy.createProxy(apiUrl);
            }
        }
    }
1093227
@SuppressWarnings("deprecation")
	ProxyConfig buildProxyConfig() {
		validateProxy();
		return new ProxyConfig(getProxyHost(), getProxyPort(), getProxyUsername(), getProxyPassword(), getProxyBridgePort());
	}
868051
static <K, V> SerializationProxy<K, V> makeSerializationProxy(
      BoundedLocalCache<?, ?> cache, boolean isWeighted) {
    SerializationProxy<K, V> proxy = new SerializationProxy<>();
    proxy.weakKeys = cache.collectKeys();
    proxy.weakValues = cache.nodeFactory.weakValues();
    proxy.softValues = cache.nodeFactory.softValues();
    proxy.isRecordingStats = cache.isRecordingStats();
    proxy.removalListener = cache.removalListener();
    proxy.ticker = cache.expirationTicker();
    proxy.writer = cache.writer;
    if (cache.expiresAfterAccess()) {
      proxy.expiresAfterAccessNanos = cache.expiresAfterAccessNanos();
    }
    if (cache.expiresAfterWrite()) {
      proxy.expiresAfterWriteNanos = cache.expiresAfterWriteNanos();
    }
    if (cache.expiresVariable()) {
      proxy.expiry = cache.expiry();
    }
    if (cache.evicts()) {
      if (isWeighted) {
        proxy.weigher = cache.weigher;
        proxy.maximumWeight = cache.maximum();
      } else {
        proxy.maximumSize = cache.maximum();
      }
    }
    return proxy;
  }